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.

73 lines
2.5 KiB

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