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.

46 lines
904 B

  1. #ifndef IZ_KEYBOARD_H
  2. #define IZ_KEYBOARD_H
  3. #include <SDL_keyboard.h>
  4. #include <SDL_events.h>
  5. #include <minIni.h>
  6. #include "../IZ_action.h"
  7. #include "../IZ_config.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 SDL_KeyCode IZ_DEFAULT_KEYBOARD_CONTROLS[PLAYERS][CONTROLS] = {
  15. {
  16. SDLK_UP,
  17. SDLK_RIGHT,
  18. SDLK_DOWN,
  19. SDLK_LEFT,
  20. SDLK_RETURN, // yes
  21. SDLK_BACKSPACE, // no
  22. SDLK_a, // action0
  23. SDLK_s, // action1
  24. SDLK_d, // action2
  25. SDLK_f, // action3
  26. SDLK_z, // action4
  27. SDLK_x, // action5
  28. SDLK_c, // action6
  29. SDLK_v, // action7
  30. SDLK_w, // action8
  31. SDLK_e, // action9
  32. },
  33. };
  34. void IZ_LoadKeyboardConfig(IZ_KeyboardConfig*, uint8_t);
  35. void IZ_SaveKeyboardConfig(IZ_KeyboardConfig*, uint8_t);
  36. void IZ_HandleKeyboardEvents(SDL_Event, IZ_KeyboardState*, IZ_Action*);
  37. #endif