SDL_gamecontroller.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #ifndef _SDL_gamecontroller_h
  2. #define _SDL_gamecontroller_h
  3. #include "SDL_stdinc.h"
  4. #include "SDL_error.h"
  5. #include "SDL_joystick.h"
  6. #include "begin_code.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. struct _SDL_GameController;
  11. typedef struct _SDL_GameController SDL_GameController;
  12. typedef enum
  13. {
  14. SDL_CONTROLLER_BINDTYPE_NONE = 0,
  15. SDL_CONTROLLER_BINDTYPE_BUTTON,
  16. SDL_CONTROLLER_BINDTYPE_AXIS,
  17. SDL_CONTROLLER_BINDTYPE_HAT
  18. } SDL_GameControllerBindType;
  19. typedef struct SDL_GameControllerButtonBind
  20. {
  21. SDL_GameControllerBindType bindType;
  22. union
  23. {
  24. int button;
  25. int axis;
  26. struct {
  27. int hat;
  28. int hat_mask;
  29. } hat;
  30. } value;
  31. } SDL_GameControllerButtonBind;
  32. typedef int SDLCALL tSDL_GameControllerAddMapping( const char* mappingString );
  33. typedef char * SDLCALL tSDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
  34. typedef char * SDLCALL tSDL_GameControllerMapping( SDL_GameController * gamecontroller );
  35. typedef SDL_bool SDLCALL tSDL_IsGameController(int joystick_index);
  36. typedef const char * SDLCALL tSDL_GameControllerNameForIndex(int joystick_index);
  37. typedef SDL_GameController * SDLCALL tSDL_GameControllerOpen(int joystick_index);
  38. typedef const char * SDLCALL tSDL_GameControllerName(SDL_GameController *gamecontroller);
  39. typedef SDL_bool SDLCALL tSDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
  40. typedef SDL_Joystick * SDLCALL tSDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
  41. typedef int SDLCALL tSDL_GameControllerEventState(int state);
  42. typedef void SDLCALL tSDL_GameControllerUpdate(void);
  43. typedef enum
  44. {
  45. SDL_CONTROLLER_AXIS_INVALID = -1,
  46. SDL_CONTROLLER_AXIS_LEFTX,
  47. SDL_CONTROLLER_AXIS_LEFTY,
  48. SDL_CONTROLLER_AXIS_RIGHTX,
  49. SDL_CONTROLLER_AXIS_RIGHTY,
  50. SDL_CONTROLLER_AXIS_TRIGGERLEFT,
  51. SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
  52. SDL_CONTROLLER_AXIS_MAX
  53. } SDL_GameControllerAxis;
  54. typedef SDL_GameControllerAxis SDLCALL tSDL_GameControllerGetAxisFromString(const char *pchString);
  55. extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
  56. extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
  57. SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
  58. SDL_GameControllerAxis axis);
  59. extern DECLSPEC Sint16 SDLCALL
  60. SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
  61. SDL_GameControllerAxis axis);
  62. typedef enum
  63. {
  64. SDL_CONTROLLER_BUTTON_INVALID = -1,
  65. SDL_CONTROLLER_BUTTON_A,
  66. SDL_CONTROLLER_BUTTON_B,
  67. SDL_CONTROLLER_BUTTON_X,
  68. SDL_CONTROLLER_BUTTON_Y,
  69. SDL_CONTROLLER_BUTTON_BACK,
  70. SDL_CONTROLLER_BUTTON_GUIDE,
  71. SDL_CONTROLLER_BUTTON_START,
  72. SDL_CONTROLLER_BUTTON_LEFTSTICK,
  73. SDL_CONTROLLER_BUTTON_RIGHTSTICK,
  74. SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
  75. SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
  76. SDL_CONTROLLER_BUTTON_DPAD_UP,
  77. SDL_CONTROLLER_BUTTON_DPAD_DOWN,
  78. SDL_CONTROLLER_BUTTON_DPAD_LEFT,
  79. SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
  80. SDL_CONTROLLER_BUTTON_MAX
  81. } SDL_GameControllerButton;
  82. typedef SDL_GameControllerButton SDLCALL tSDL_GameControllerGetButtonFromString(const char *pchString);
  83. extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
  84. extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
  85. SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
  86. SDL_GameControllerButton button);
  87. typedef Uint8 SDLCALL tSDL_GameControllerGetButton(SDL_GameController *gamecontroller,
  88. SDL_GameControllerButton button);
  89. typedef void SDLCALL tSDL_GameControllerClose(SDL_GameController *gamecontroller);
  90. extern tSDL_GameControllerAddMapping *SDL_GameControllerAddMapping;
  91. extern tSDL_GameControllerMappingForGUID *SDL_GameControllerMappingForGUID;
  92. extern tSDL_GameControllerMapping *SDL_GameControllerMapping;
  93. extern tSDL_IsGameController *SDL_IsGameController;
  94. extern tSDL_GameControllerNameForIndex *SDL_GameControllerNameForIndex;
  95. extern tSDL_GameControllerOpen *SDL_GameControllerOpen;
  96. extern tSDL_GameControllerName *SDL_GameControllerName;
  97. extern tSDL_GameControllerGetAttached *SDL_GameControllerGetAttached;
  98. extern tSDL_GameControllerGetJoystick *SDL_GameControllerGetJoystick;
  99. extern tSDL_GameControllerEventState *SDL_GameControllerEventState;
  100. extern tSDL_GameControllerUpdate *SDL_GameControllerUpdate;
  101. extern tSDL_GameControllerGetAxisFromString *SDL_GameControllerGetAxisFromString;
  102. extern tSDL_GameControllerGetButtonFromString *SDL_GameControllerGetButtonFromString;
  103. extern tSDL_GameControllerGetButton *SDL_GameControllerGetButton;
  104. extern tSDL_GameControllerClose *SDL_GameControllerClose;
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #include "close_code.h"
  109. #endif