Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.2 KiB

  1. #ifndef HAPTIC_UTILS_H
  2. #define HAPTIC_UTILS_H
  3. #ifdef CLIENT_DLL
  4. #include "haptics/ihaptics.h"
  5. // forward decl.
  6. class C_BaseEntity;
  7. class C_BaseCombatCharacter;
  8. class C_BasePlayer;
  9. class bf_read;
  10. // use client side versions.
  11. #ifndef CBasePlayer
  12. #define CBasePlayer C_BasePlayer;
  13. #endif
  14. #ifndef CBaseCombatWeapon
  15. #define CBaseCombatWeapon C_BaseCombatWeapon
  16. #endif
  17. // stubbed version of haptics interface. Used when haptics is not available.
  18. class CHapticsStubbed : public IHaptics
  19. {
  20. public:
  21. public: // Initialization.
  22. virtual bool Initialize(IVEngineClient* newengine,
  23. IViewRender *newview,
  24. vgui::IInputInternal* newinput,
  25. CGlobalVarsBase* newgpGlobals,
  26. CreateInterfaceFn newengineFactory,
  27. void *IMEWindow,
  28. IFileSystem* filesystem,
  29. IEngineVGui* newvgui,
  30. ActivityList_IndexForName_t actIndexForName,
  31. ActivityList_NameForIndex_t actNameForIndex)
  32. {return false;};
  33. public: // Device methods
  34. virtual bool HasDevice(){return false;};
  35. virtual void ShutdownHaptics(){};
  36. public: // Game input handling
  37. virtual void CalculateMove(float &forward_move, float &side_move, float delta){};
  38. virtual void OnPlayerChanged(){}
  39. virtual void SetNavigationClass(const char *defaultNavigationName){};
  40. virtual const char *GetNavigationClass(){ return 0; };
  41. virtual void GameProcess(){}
  42. virtual void MenuProcess(){}
  43. public: // Effect methods
  44. virtual void ProcessHapticEvent(int numArgs, ...){}
  45. virtual void ProcessHapticWeaponActivity(const char *weapon, int activity){}
  46. virtual void HapticsPunch(float strength, const QAngle &angle){}
  47. virtual void ApplyDamageEffect(float damage, int damagetype, const Vector &angle){}
  48. virtual void UpdateAvatarVelocity(const Vector &vel){}
  49. virtual void RemoveAvatarEffect(){}
  50. virtual void SetConstantForce(const Vector &force){}
  51. virtual Vector GetConstantForce(){return Vector(0,0,0);}
  52. virtual void SetDrag(float amount){}
  53. virtual void SetShake(float scalar, float currentamount){}
  54. virtual void SetHeld(float amount){}
  55. virtual void SetMoveSurface(HapticSurfaceType_t surface){}
  56. virtual HapticSurfaceType_t GetMoveSurface(){ return HST_NONE; }
  57. virtual void SetDangling(float amount){};
  58. public: // Notify methods
  59. virtual void LocalPlayerReset(){};
  60. virtual void UpdatePlayerFOV(float fov){};
  61. virtual void WorldPrecache() {};
  62. };
  63. #else
  64. // forward decl.
  65. class CBasePlayer;
  66. class CBaseCombatWeapon;
  67. class CTakeDamageInfo;
  68. #endif // CLIENT_DLL
  69. void HapticSendWeaponAnim(class CBaseCombatWeapon* weapon, int iActivity);
  70. void HapticSetConstantForce(class CBasePlayer* pPlayer,Vector force);
  71. void HapticSetDrag(class CBasePlayer* pPlayer, float drag);
  72. // note: does nothing on server.
  73. void HapticProcessSound(const char* soundname, int entIndex);
  74. #ifdef CLIENT_DLL
  75. void ConnectHaptics(CreateInterfaceFn appFactory);
  76. void DisconnectHaptics();
  77. void UpdateAvatarEffect(void);
  78. void HapticsExitedVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger );
  79. void HapticsEnteredVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger );
  80. //bool value true if user is using a haptic device.
  81. extern ConVar hap_HasDevice;
  82. #else
  83. void HapticsDamage(CBasePlayer* pPlayer, const CTakeDamageInfo &info);
  84. void HapticPunch(CBasePlayer* pPlayer, float amount, float x, float y);
  85. void HapticMeleeContact(CBasePlayer* pPlayer);
  86. #endif
  87. #endif