Starter project for SDL2.
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.

51 lines
776 B

  1. #ifndef IZ_JOYSTICK_H
  2. #define IZ_JOYSTICK_H
  3. #include <SDL_joystick.h>
  4. #include <SDL_events.h>
  5. #include <minIni.h>
  6. #include "../IZ_action.h"
  7. #include "../IZ_config.h"
  8. typedef uint8_t IZ_PadButton;
  9. typedef struct {
  10. uint16_t axis_threshold;
  11. IZ_PadButton control_mapping[CONTROLS];
  12. } IZ_JoystickConfig;
  13. typedef struct {
  14. SDL_Joystick* joystick_instance;
  15. IZ_JoystickConfig config;
  16. } IZ_JoystickState;
  17. static IZ_PadButton IZ_DEFAULT_JOYSTICK_CONTROLS[PLAYERS][CONTROLS] = {
  18. {
  19. 255,
  20. 255,
  21. 255,
  22. 255,
  23. 11,
  24. 10,
  25. 1,
  26. 0,
  27. 4,
  28. 3,
  29. 6,
  30. 7,
  31. 8,
  32. 9,
  33. 13,
  34. 14,
  35. },
  36. };
  37. void IZ_LoadJoystickConfig(IZ_JoystickConfig*, uint8_t);
  38. void IZ_SaveJoystickConfig(IZ_JoystickConfig*, uint8_t);
  39. void IZ_HandleJoystickEvents(SDL_Event, IZ_JoystickState*, IZ_Action*);
  40. #endif