Counter Strike : Global Offensive Source Code
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.

277 lines
6.5 KiB

  1. #ifndef IN_SIXENSE_H
  2. #define IN_SIXENSE_H
  3. #include "mathlib/vector.h"
  4. #include "vgui_controls/Frame.h"
  5. #include "vgui_controls/label.h"
  6. #include "vgui_video.h"
  7. #include "convar.h"
  8. #include "usercmd.h"
  9. #include "tier1/utlstring.h"
  10. #include "GameEventListener.h"
  11. #include "in_sixense_gesture_bindings.h"
  12. #if defined( CLIENT_DLL )
  13. class C_Portal_Player;
  14. #define CPortal_Player C_Portal_Player
  15. #else
  16. class CPortal_Player;
  17. #endif
  18. // forward declarations
  19. namespace sixenseUtils {
  20. class IFPSViewAngles;
  21. class IFPSPlayerMovement;
  22. class IFPSEvents;
  23. class IFPSMeleeWeapon;
  24. class IDerivatives;
  25. class IButtonStates;
  26. class ILaserPointer;
  27. class IControllerManager;
  28. };
  29. class SixenseInput : public CGameEventListener
  30. {
  31. public:
  32. bool LoadModules();
  33. bool UnloadModules();
  34. SixenseInput();
  35. ~SixenseInput();
  36. void Init();
  37. void PostInit();
  38. void Shutdown();
  39. #ifdef PORTAL2
  40. bool IsBaseWarningUp();
  41. void PlayerPortalled( const VMatrix &PortalMatrix );
  42. void SetOneToOneMode( bool bOnOrOff );
  43. inline QAngle GetAnglesToRightHand() { return m_AnglesToRightHand; }
  44. inline QAngle GetAnglesToLeftHand() { return m_AnglesToLeftHand; }
  45. // If the right trigger is held and a melee weapon is selected, go to 1-to-1 melee mode
  46. bool IsInOneToOneMode();
  47. bool IsInAlwaysOneToOneMode();
  48. void FixPortalView();
  49. void SetPortalTweakingParameters( bool bIsTweaking );
  50. bool IsHoldingObject();
  51. C_BaseEntity *GetHeldObject();
  52. #endif
  53. bool IsEnabled();
  54. bool IsLeftHanded();
  55. // SixenseFrame computes the view parameters from the controllers. Should be called once per frame
  56. bool SixenseFrame( float flFrametime, CUserCmd *pCmd );
  57. void SixenseUpdateKeys( float flFrametime, CUserCmd *pCmd );
  58. bool SendKeyToActiveWindow(ButtonCode_t key);
  59. void SixenseUpdateMouseCursor();
  60. void SixenseUpdateControllerManager();
  61. void controllerManagerCallback( int );
  62. inline void ResetFrameTime( float flTime ) { m_fRemainingFrameTime = flTime; }
  63. // Set the engine's view angles
  64. void SetView( float flInputSampleFrametime, CUserCmd *pCmd );
  65. void SetMode( int nMode );
  66. void ResetView( QAngle SpawnAngles );
  67. void SetEnabled( bool bEnabled );
  68. void LoadDefaultSettings( int nLevel );
  69. bool InMenuMode();
  70. QAngle GetViewAngles();
  71. QAngle GetViewAngleOffset();
  72. void ForceViewAngles( QAngle angles );
  73. bool IsSixenseMap();
  74. void CreateGUI( vgui::VPANEL parent );
  75. void SwitchViewModes( CUserCmd *pCmd );
  76. // playerIndex = (0 to 3), handIndex = (left = 0 or right = 1)
  77. void Rumble( unsigned char nIndex, unsigned char nRumbleData, unsigned char nRumbleFlags );
  78. void Rumble( unsigned char nPlayerIndex, unsigned char nHandIndex, unsigned char nRumbleData, unsigned char nRumbleFlags );
  79. void SetFilter( float f );
  80. void GetFOV( float *pHfov, float *pVfov );
  81. #ifdef SIXENSE_PLAYER_DATA
  82. void SetPlayerHandPositions( CUserCmd *pCmd, float flFrametime );
  83. #endif
  84. void SetBaseOffset();
  85. void SetFilterLevel( float flNearRange, float flNearVal, float flFarRange, float flFarVal );
  86. static class SixenseGUIFrame *m_SixenseFrame;
  87. bool IsAimingForwards();
  88. virtual void FireGameEvent( IGameEvent *pEvent );
  89. void BlendView();
  90. void DisableFreeAimSpin( int nDisable );
  91. void DisableGestures( int nDisable );
  92. void PlayerSpawn();
  93. bool AreBindingsDisabled();
  94. void LeftPointGesture( bool start );
  95. void RightPointGesture( bool start );
  96. void StartRatchet();
  97. void StopRatchet();
  98. void CheckWeaponForScope();
  99. SixenseGestureBindings *GetGestureBindings();
  100. void InstallConvarCallbacks();
  101. void UpdateValuesFromConvars();
  102. void ConvarChanged();
  103. private:
  104. bool m_bIsEnabled; // sixense.dll loaded
  105. bool m_bIsActive; // controllers not docked
  106. bool m_bModulesLoaded;
  107. bool m_bWasInMenuMode;
  108. #ifdef PORTAL2
  109. bool m_bJustPortalled;
  110. bool m_bIsLeftTriggerDown;
  111. bool m_bIsRightTriggerDown;
  112. bool m_bIsIn1to1Mode;
  113. bool m_bIs1to1ModeLocked;
  114. bool m_bIs1to1ModeScaling;
  115. bool m_bIs1to1ModeRatcheting;
  116. bool m_bExitOneWhenAimingForwards;
  117. bool m_bScalingLockedOneToOne;
  118. bool m_bIsTweaking;
  119. float m_fDisableJumpUntil;
  120. int m_nGlowIndex;
  121. float m_fLastHorizSpeedMult;
  122. float m_fLastVertSpeedMult;
  123. QAngle m_AnglesToRightHand, m_AnglesToLeftHand;
  124. float m_fTweakSixenseAimFreeaimAccelBandExponent;
  125. float m_fTweakSixenseAimFreeaimAutoLevelRate;
  126. float m_fTweakSixenseAimFreeaimAccelBandSize;
  127. float m_fTweakSixenseAimFreeaimMaxSpeed;
  128. float m_fTweakSixenseAimFreeaimDeadZoneRadius;
  129. float m_fTweakSixenseAimFreeaimHeadingMultiplier;
  130. float m_fTweakSixenseAimFreeaimPitchMultiplier;
  131. float m_fTweakSixenseAim1to1HeadingMultiplier;
  132. float m_fTweakSixenseAim1to1PitchMultiplier;
  133. Vector3 m_GrabPos;
  134. #endif
  135. bool m_bConvarChanged;
  136. bool m_bPlayerValid;
  137. float m_fRemainingFrameTime;
  138. bool m_bScopeSwitchedMode;
  139. sixenseUtils::IFPSViewAngles::fps_mode m_nScopeSwitchedPrevMode;
  140. int m_nScopeSwitchedPrevSpringViewEnabled;
  141. float m_fTeleportWaitToBlendTime;
  142. class ISixenseAPI *m_pSixenseAPI;
  143. struct _sixenseAllControllerData *m_pACD;
  144. class sixenseUtils::IFPSViewAngles *m_pFPSViewAngles;
  145. class sixenseUtils::IFPSPlayerMovement *m_pFPSPlayerMovement;
  146. class sixenseUtils::IFPSEvents *m_pFPSEvents;
  147. class sixenseUtils::IDerivatives *m_pLeftDeriv, *m_pRightDeriv;
  148. class sixenseUtils::IButtonStates *m_pLeftButtonStates, *m_pRightButtonStates;
  149. class sixenseUtils::ILaserPointer *m_pLaserPointer;
  150. class sixenseUtils::IControllerManager *m_pControllerManager;
  151. int m_LastViewMode;
  152. int m_nLeftIndex, m_nRightIndex;
  153. void PlayerDroppedEntity( int entityID );
  154. void PlayerUsedEntity( int entityID );
  155. bool m_bMoveMouseToCenter;
  156. int m_nFilterLevel;
  157. unsigned char m_nLastLeftSequence, m_nLastRightSequence;
  158. bool m_bShouldSetBaseOffset;
  159. bool m_bJustSpawned;
  160. #ifdef WATERMARK
  161. class SixenseWatermarkFrame *m_WatermarkFrame;
  162. #endif
  163. int m_nFreeaimSpinDisabled;
  164. int m_nGesturesDisabled;
  165. bool m_nShouldUnduck;
  166. SixenseGestureBindings *m_pGestureBindings;
  167. };
  168. extern SixenseInput *g_pSixenseInput;
  169. class SixenseGUIFrame : public vgui::Frame
  170. {
  171. DECLARE_CLASS_SIMPLE( SixenseGUIFrame, vgui::Frame );
  172. public:
  173. // Construction
  174. SixenseGUIFrame( vgui::VPANEL parent, char const *pPanelName );
  175. virtual ~SixenseGUIFrame();
  176. void setImage( CUtlString img_name );
  177. virtual void SetVisible( bool bState );
  178. private:
  179. vgui::ImagePanel *m_ImagePanel;
  180. };
  181. #ifdef PORTAL2
  182. class SixenseBaseWarning : public vgui::Frame
  183. {
  184. DECLARE_CLASS_SIMPLE( SixenseBaseWarning, vgui::Frame );
  185. public:
  186. SixenseBaseWarning( vgui::Panel *parent, char const *name );
  187. //virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  188. protected:
  189. //virtual void PaintBackground();
  190. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  191. vgui::Label *_label;
  192. };
  193. #endif
  194. #endif