2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
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.
 
 
 
 
 
 

94 lines
1.5 KiB

  1. #ifndef IZ_JOYSTICK_H
  2. #define IZ_JOYSTICK_H
  3. #include <SDL_stdinc.h>
  4. #include <SDL_joystick.h>
  5. #include <SDL_events.h>
  6. #include <minIni.h>
  7. #include "IZ_action.h"
  8. typedef u8 IZ_PadButton;
  9. static const u16 IZ_DEFAULT_AXIS_THRESHOLD = 8000;
  10. typedef enum {
  11. IZ_JOY_AXIS_DIRECTION_HORIZONTAL1 = 0,
  12. IZ_JOY_AXIS_DIRECTION_VERTICAL1 = 1,
  13. IZ_JOY_AXIS_DIRECTION_HORIZONTAL2 = 3,
  14. IZ_JOY_AXIS_DIRECTION_VERTICAL2 = 4,
  15. } IZ_JoyAxisDirection;
  16. typedef struct {
  17. u16 axis_threshold;
  18. SDL_JoystickID device_id;
  19. IZ_PadButton control_mapping[CONTROLS];
  20. } IZ_JoystickConfig;
  21. typedef struct {
  22. SDL_Joystick* device;
  23. IZ_JoystickConfig config;
  24. } IZ_JoystickState;
  25. static const IZ_JoystickState IZ_JOYSTICK_DEFAULT_STATE[IZ_PLAYERS] = {
  26. {
  27. .config = {
  28. .control_mapping = {
  29. 255,
  30. 255,
  31. 255,
  32. 255,
  33. 11,
  34. 10,
  35. 1,
  36. 0,
  37. 4,
  38. 3,
  39. 6,
  40. 7,
  41. 8,
  42. 9,
  43. 13,
  44. 14,
  45. },
  46. .axis_threshold = 8000u,
  47. .device_id = 0,
  48. },
  49. .device = NULL,
  50. },
  51. {
  52. .config = {
  53. .control_mapping = {
  54. 255,
  55. 255,
  56. 255,
  57. 255,
  58. 11,
  59. 10,
  60. 1,
  61. 0,
  62. 4,
  63. 3,
  64. 6,
  65. 7,
  66. 8,
  67. 9,
  68. 13,
  69. 14,
  70. },
  71. .axis_threshold = 8000u,
  72. .device_id = 1,
  73. },
  74. .device = NULL,
  75. },
  76. };
  77. IZ_ProcedureResult IZ_JoystickSaveConfig(IZ_JoystickState(*)[IZ_PLAYERS], const char*);
  78. void IZ_JoystickHandleEvents(IZ_JoystickState(*)[IZ_PLAYERS], IZ_Action(*)[IZ_PLAYERS], SDL_Event);
  79. IZ_ProcedureResult IZ_JoystickInitialize(IZ_JoystickState(*)[IZ_PLAYERS], const char*, u8, const char**);
  80. void IZ_JoystickTeardown(IZ_JoystickState(*)[IZ_PLAYERS]);
  81. #endif