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.

87 lines
1.3 KiB

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