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.

143 lines
3.9 KiB

  1. #ifndef HAPTICS_INTERFACE_H
  2. #define HAPTICS_INTERFACE_H
  3. #ifdef GAME_DLL
  4. #pragma warning("IHaptics.h is only for client ussage");
  5. #endif
  6. #include "tier0/platform.h"
  7. #include "appframework/IAppSystem.h"
  8. #define HAPTICS_INTERFACE_VERSION "HapticsInterface001"
  9. #define HAPTICS_DLL_NAME "haptics"
  10. // systems forward decl.
  11. class IVEngineClient;
  12. class IViewRender;
  13. class IInputInternal;
  14. class CGlobalVarsBase;
  15. class IFileSystem;
  16. class IEngineVGui;
  17. // vgui forward decl
  18. namespace vgui{
  19. class IInputInternal;
  20. }
  21. // math types forward decl
  22. class QAngle;
  23. class Vector;
  24. typedef enum {
  25. HST_NONE = 0,
  26. HST_ROPE,
  27. } HapticSurfaceType_t;
  28. typedef int (*ActivityList_IndexForName_t)( const char *pszActivityName );
  29. typedef const char *(*ActivityList_NameForIndex_t)( int iActivityIndex );
  30. // NVNT haptic system interface declaration
  31. abstract_class IHaptics
  32. {
  33. public: // Initialization.
  34. virtual bool Initialize(IVEngineClient* newengine,
  35. IViewRender *newview,
  36. vgui::IInputInternal* newinput,
  37. CGlobalVarsBase* newgpGlobals,
  38. CreateInterfaceFn newengineFactory,
  39. void *IMEWindow,
  40. IFileSystem* filesystem,
  41. IEngineVGui* newvgui,
  42. ActivityList_IndexForName_t actIndexForName,
  43. ActivityList_NameForIndex_t actNameForIndex) = 0;
  44. public: // Device methods
  45. // returns true if there is at least one device connected.
  46. virtual bool HasDevice() = 0;
  47. // closes all haptic devices and effect processing
  48. virtual void ShutdownHaptics() = 0;
  49. public: // Game input handling
  50. // computes view angles and adjusts forward_move and side_move
  51. virtual void CalculateMove(float &forward_move, float &side_move, float delta) = 0;
  52. virtual void OnPlayerChanged()=0;
  53. // Sets the internal navigation class.
  54. virtual void SetNavigationClass(const char *defaultNavigationName) = 0;
  55. // Turns the internal navigation off. ( clears navigation class )
  56. inline void ClearNavigationClass();
  57. // Returns the active navigation class ( if none returns NULL )
  58. virtual const char *GetNavigationClass() = 0;
  59. // Should be called by the game input class after CalculateMove (when not in menu)
  60. virtual void GameProcess() = 0;
  61. // Should be called by the game input class when in a menu
  62. virtual void MenuProcess() = 0;
  63. public: // Effect methods
  64. // process a haptic event.
  65. virtual void ProcessHapticEvent(int numArgs, ...) = 0;
  66. virtual void ProcessHapticWeaponActivity(const char *weapon, int activity) = 0;
  67. // send a haptic punch effect
  68. virtual void HapticsPunch(float strength, const QAngle &angle) = 0;
  69. // trigger a damage effect
  70. virtual void ApplyDamageEffect(float damage, int damagetype, const Vector &angle) = 0;
  71. // update the avatar ( acceleration ) effect by a velocity sample
  72. virtual void UpdateAvatarVelocity(const Vector &velocity) = 0;
  73. // stop processing any running avatar effects
  74. virtual void RemoveAvatarEffect() = 0;
  75. // sets the device's constant force effect to force vector
  76. virtual void SetConstantForce(const Vector &force) = 0;
  77. // returns the last sent constant force
  78. virtual Vector GetConstantForce() = 0;
  79. // set the amount of drag (viscosity) on the haptic devices
  80. virtual void SetDrag(float amount) = 0;
  81. // set the values to the screen shake effect
  82. virtual void SetShake(float scalar, float currentamount) = 0;
  83. // enable/disable device position lock.
  84. virtual void SetHeld(float amount) = 0;
  85. // set anchor weight mass scaler.
  86. virtual void SetMoveSurface(HapticSurfaceType_t surface) = 0;
  87. virtual HapticSurfaceType_t GetMoveSurface() = 0;
  88. // set dangling ( being hung, holding onto ledges )
  89. virtual void SetDangling(float amount) = 0;
  90. public: // Notify methods
  91. // notify the haptics system that we have been respawned.
  92. virtual void LocalPlayerReset()=0;
  93. // notify the haptics system of the player's field of view angle
  94. virtual void UpdatePlayerFOV(float fov)=0;
  95. virtual void WorldPrecache() = 0;
  96. };
  97. inline void IHaptics::ClearNavigationClass( void )
  98. {
  99. SetNavigationClass(0);
  100. }
  101. extern IHaptics* haptics;
  102. #endif// HAPTICS_INTERFACE_H