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.
 
 
 
 
 
 

72 lines
1.5 KiB

  1. #ifndef IZ_KEYBOARD_H
  2. #define IZ_KEYBOARD_H
  3. #include <SDL_stdinc.h>
  4. #include <SDL_keyboard.h>
  5. #include <SDL_events.h>
  6. #include <minIni.h>
  7. #include "IZ_action.h"
  8. typedef struct {
  9. SDL_KeyCode control_mapping[CONTROLS];
  10. } IZ_KeyboardConfig;
  11. typedef struct {
  12. IZ_KeyboardConfig config;
  13. } IZ_KeyboardState;
  14. static const IZ_KeyboardState IZ_KEYBOARD_DEFAULT_STATE[IZ_PLAYERS] = {
  15. {
  16. .config = {
  17. .control_mapping = {
  18. SDLK_UP,
  19. SDLK_RIGHT,
  20. SDLK_DOWN,
  21. SDLK_LEFT,
  22. SDLK_RETURN, // yes
  23. SDLK_BACKSPACE, // no
  24. SDLK_a, // action0
  25. SDLK_s, // action1
  26. SDLK_d, // action2
  27. SDLK_f, // action3
  28. SDLK_z, // action4
  29. SDLK_x, // action5
  30. SDLK_c, // action6
  31. SDLK_v, // action7
  32. SDLK_w, // action8
  33. SDLK_e, // action9
  34. },
  35. },
  36. },
  37. {
  38. .config = {
  39. .control_mapping = {
  40. SDLK_KP_8,
  41. SDLK_KP_6,
  42. SDLK_KP_5,
  43. SDLK_KP_4,
  44. SDLK_KP_ENTER, // yes
  45. SDLK_KP_MINUS, // no
  46. SDLK_j, // action0
  47. SDLK_k, // action1
  48. SDLK_l, // action2
  49. SDLK_SEMICOLON, // action3
  50. SDLK_m, // action4
  51. SDLK_COMMA, // action5
  52. SDLK_PERIOD, // action6
  53. SDLK_SLASH, // action7
  54. SDLK_i, // action8
  55. SDLK_o, // action9
  56. },
  57. },
  58. },
  59. };
  60. IZ_ProcedureResult IZ_KeyboardSaveConfig(IZ_KeyboardState(*)[IZ_PLAYERS], const char*);
  61. void IZ_KeyboardHandleEvents(IZ_KeyboardState(*)[IZ_PLAYERS], IZ_Action(*)[IZ_PLAYERS], SDL_Event);
  62. IZ_ProcedureResult IZ_KeyboardInitialize(IZ_KeyboardState(*)[IZ_PLAYERS], const char*, u8, const char**);
  63. #endif