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.

72 lines
2.4 KiB

  1. #ifndef IN_SIXENSE_GESTURES_H
  2. #define IN_SIXENSE_GESTURES_H
  3. #ifdef _WIN32
  4. #pragma once
  5. #endif
  6. #include <sixense_utils/interfaces.hpp>
  7. class SixenseGestureBindings {
  8. public:
  9. SixenseGestureBindings();
  10. // Add a new binding. release_command can be empty. If press_command starts with '+', a release_command is generated with '-'.
  11. void AddBinding( CUtlString hand, CUtlString action, CUtlString arg, CUtlString press_command, CUtlString release_command );
  12. // Print bindings to console
  13. void ListBindings();
  14. // Write the bindings to a cfg file that can be loaded from the console or at startup (defaults to sixense_bindings.cfg)
  15. void WriteBindings( CUtlString filename );
  16. // Clear all bindings
  17. void ClearBindings();
  18. // Delete the nth binding
  19. void DeleteBinding( int n );
  20. // Create a set of default bindings appropriate for this game
  21. void CreateDefaultBindings();
  22. // Check to see if any bindings need to be triggered. disable_activations allows the caller to prevent new bindings from being triggered, while
  23. // still allowing enabled gestures to disable.
  24. void UpdateBindings( sixenseUtils::IButtonStates *pLeftButtonStates, sixenseUtils::IButtonStates *pRightButtonStates, bool bIsMenuVisible );
  25. // How many bindings are there?
  26. int GetNumBindings();
  27. // Allow per-game authorization of commmands when the menu is up
  28. bool AllowMenuCommand( char * );
  29. // Allow per-game authorization of commmands in general
  30. bool AllowCommand( char * );
  31. protected:
  32. typedef struct {
  33. int m_Action;
  34. int m_iHand; // 0=left, 1=right
  35. int m_iArgument;
  36. char *m_pActivateCommand;
  37. char *m_pDeactivateCommand;
  38. bool m_bAutoMirrored;
  39. } GestureBinding;
  40. // some helpers for converting input strings
  41. bool HandFromString( CUtlString hand_str, int *hand );
  42. bool ActionFromString( CUtlString action_str, sixenseUtils::IButtonStates::ActionType *action );
  43. bool ButtonMaskFromString( CUtlString button, unsigned short *button_token );
  44. bool DirectionFromString( CUtlString dir_str, sixenseUtils::IButtonStates::Direction *dir );
  45. bool ActionTokenToStr( sixenseUtils::IButtonStates::ActionType action, char *buf, int buflen );
  46. bool DirectionTokenToStr( int arg, char *buf, int buflen );
  47. bool ButtonTokenToStr( int arg, char *buf, int buflen );
  48. bool HandTokenToStr( int hand, char *buf, int buflen );
  49. // Help deallocate a binding
  50. void FreeStrings( GestureBinding binding );
  51. private:
  52. CUtlLinkedList<GestureBinding> m_GestureBindingList;
  53. };
  54. #endif