2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

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