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.

81 lines
1.2 KiB

  1. #ifndef IZ_CONFIG_H
  2. #define IZ_CONFIG_H
  3. #include "SDL_keycode.h"
  4. #include "../IZ_common.h"
  5. typedef struct {
  6. uint16_t width;
  7. uint16_t height;
  8. uint8_t max_fps;
  9. } IZ_VideoConfig;
  10. typedef struct {
  11. uint16_t gamepad_axis_threshold;
  12. } IZ_InputConfig;
  13. typedef SDL_KeyCode IZ_KeyCode;
  14. typedef int IZ_PadButton;
  15. typedef struct {
  16. IZ_KeyCode keyboard[CONTROLS];
  17. IZ_PadButton gamepad[CONTROLS];
  18. } IZ_ControlsConfig;
  19. typedef struct {
  20. IZ_VideoConfig video;
  21. IZ_InputConfig input;
  22. IZ_ControlsConfig controls[PLAYERS];
  23. } IZ_Config;
  24. static const IZ_KeyCode IZ_DEFAULT_KEYBOARD_CONTROLS[PLAYERS][CONTROLS] = {
  25. {
  26. SDLK_UP,
  27. SDLK_RIGHT,
  28. SDLK_DOWN,
  29. SDLK_LEFT,
  30. SDLK_RETURN, // yes
  31. SDLK_BACKSPACE, // no
  32. SDLK_a, // action0
  33. SDLK_s, // action1
  34. SDLK_d, // action2
  35. SDLK_f, // action3
  36. SDLK_z, // action4
  37. SDLK_x, // action5
  38. SDLK_c, // action6
  39. SDLK_v, // action7
  40. SDLK_w, // action8
  41. SDLK_e, // action9
  42. },
  43. };
  44. static const uint8_t IZ_DEFAULT_JOYSTICK_CONTROLS[PLAYERS][CONTROLS] = {
  45. {
  46. 255,
  47. 255,
  48. 255,
  49. 255,
  50. 11,
  51. 10,
  52. 1,
  53. 0,
  54. 4,
  55. 3,
  56. 6,
  57. 7,
  58. 8,
  59. 9,
  60. 13,
  61. 14,
  62. },
  63. };
  64. void IZ_GetConfigPath(char* config_path);
  65. void IZ_SaveConfig(IZ_Config* config);
  66. void IZ_LoadConfig(IZ_Config* config);
  67. #endif