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.

278 lines
6.6 KiB

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