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.
 
 
 
 
 
 

75 lines
1.5 KiB

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