diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/input/sdl/input.c | 7 | ||||
-rw-r--r-- | shell/menu/buttons.h | 31 | ||||
-rw-r--r-- | shell/menu/buttons_trimui.h | 25 | ||||
-rw-r--r-- | shell/menu/menu.c | 97 |
4 files changed, 109 insertions, 51 deletions
diff --git a/shell/input/sdl/input.c b/shell/input/sdl/input.c index a4ceba3..077d053 100644 --- a/shell/input/sdl/input.c +++ b/shell/input/sdl/input.c @@ -17,6 +17,7 @@ #include "menu.h" #include "config.h" +#include "buttons.h" uint8_t *keystate; uint8_t exit_snes = 0; @@ -62,8 +63,8 @@ uint32_t S9xReadJoypad(int32_t port) case SDL_KEYDOWN: switch(event.key.keysym.sym) { - case SDLK_ESCAPE: - case SDLK_END: + case BTN_MENU: + case BTN_L2: emulator_state = 1; break; } @@ -71,7 +72,7 @@ uint32_t S9xReadJoypad(int32_t port) case SDL_KEYUP: switch(event.key.keysym.sym) { - case SDLK_HOME: + case BTN_HOME: emulator_state = 1; break; } diff --git a/shell/menu/buttons.h b/shell/menu/buttons.h new file mode 100644 index 0000000..6be3f18 --- /dev/null +++ b/shell/menu/buttons.h @@ -0,0 +1,31 @@ +#ifndef BUTTONS_H +#define BUTTONS_H + +#ifdef TRIMUI +#include "buttons_trimui.h" +#else + +#include <SDL/SDL.h> + +#define BTN_UP SDLK_UP +#define BTN_RIGHT SDLK_RIGHT +#define BTN_DOWN SDLK_DOWN +#define BTN_LEFT SDLK_LEFT +#define BTN_A SDLK_LCTRL +#define BTN_B SDLK_LALT +#define BTN_X SDLK_LSHIFT +#define BTN_Y SDLK_SPACE +#define BTN_L SDLK_TAB +#define BTN_R SDLK_BACKSPACE +#define BTN_START SDLK_RETURN +#define BTN_SELECT SDLK_ESCAPE +#define BTN_MENU SDLK_RCTRL + +#define BTN_L2 SDLK_END +#define BTN_R2 SDLK_3 +#define BTN_VOLUMEUP SDLK_AMPERSAND +#define BTN_VOLUMEDOWN SDLK_WORLD_73 +#define BTN_HOME SDLK_HOME +#endif + +#endif // BUTTONS_H diff --git a/shell/menu/buttons_trimui.h b/shell/menu/buttons_trimui.h new file mode 100644 index 0000000..36b548d --- /dev/null +++ b/shell/menu/buttons_trimui.h @@ -0,0 +1,25 @@ +#ifndef BUTTONS_TRIMUI_H +#define BUTTONS_TRIMUI_H +#include <SDL/SDL.h> + +#define BTN_UP SDLK_UP +#define BTN_RIGHT SDLK_RIGHT +#define BTN_DOWN SDLK_DOWN +#define BTN_LEFT SDLK_LEFT +#define BTN_A SDLK_SPACE +#define BTN_B SDLK_LCTRL +#define BTN_X SDLK_LSHIFT +#define BTN_Y SDLK_LALT +#define BTN_L SDLK_TAB +#define BTN_R SDLK_BACKSPACE +#define BTN_START SDLK_RETURN +#define BTN_SELECT SDLK_RCTRL +#define BTN_MENU SDLK_ESCAPE + +#define BTN_L2 SDLK_END +#define BTN_R2 SDLK_3 +#define BTN_VOLUMEUP SDLK_AMPERSAND +#define BTN_VOLUMEDOWN SDLK_WORLD_73 +#define BTN_HOME SDLK_HOME + +#endif // BUTTONS_TRIMUI_H diff --git a/shell/menu/menu.c b/shell/menu/menu.c index 2ea1636..1de8a15 100644 --- a/shell/menu/menu.c +++ b/shell/menu/menu.c @@ -14,6 +14,7 @@ #include "video_blit.h" #include "config.h" #include "menu.h" +#include "buttons.h" t_config option; uint32_t emulator_state = 0; @@ -76,21 +77,21 @@ static void config_load() else { /* Default mapping for Horizontal */ - option.config_buttons[0][0] = SDLK_UP; // UP - option.config_buttons[0][1] = SDLK_RIGHT; // RIGHT - option.config_buttons[0][2] = SDLK_DOWN; // DOWN - option.config_buttons[0][3] = SDLK_LEFT; // LEFT + option.config_buttons[0][0] = BTN_UP; + option.config_buttons[0][1] = BTN_RIGHT; + option.config_buttons[0][2] = BTN_DOWN; + option.config_buttons[0][3] = BTN_LEFT; - option.config_buttons[0][4] = SDLK_SPACE; // A - option.config_buttons[0][5] = SDLK_LCTRL; // B - option.config_buttons[0][6] = SDLK_LSHIFT; // X - option.config_buttons[0][7] = SDLK_LALT; // Y + option.config_buttons[0][4] = BTN_A; + option.config_buttons[0][5] = BTN_B; + option.config_buttons[0][6] = BTN_X; + option.config_buttons[0][7] = BTN_Y; - option.config_buttons[0][8] = SDLK_TAB; // L - option.config_buttons[0][9] = SDLK_BACKSPACE; // R + option.config_buttons[0][8] = BTN_L; + option.config_buttons[0][9] = BTN_R; - option.config_buttons[0][10] = SDLK_RETURN; // START - option.config_buttons[0][11] = SDLK_RCTRL; // SELECT + option.config_buttons[0][10] = BTN_START; + option.config_buttons[0][11] = BTN_SELECT; option.fullscreen = 1; } @@ -115,67 +116,67 @@ static const char* Return_Text_Button(uint32_t button) switch(button) { /* UP button */ - case SDLK_UP: + case BTN_UP: return "DPAD UP"; break; /* DOWN button */ - case SDLK_DOWN: + case BTN_DOWN: return "DPAD DOWN"; break; /* LEFT button */ - case SDLK_LEFT: + case BTN_LEFT: return "DPAD LEFT"; break; /* RIGHT button */ - case SDLK_RIGHT: + case BTN_RIGHT: return "DPAD RIGHT"; break; /* A button */ - case SDLK_SPACE: + case BTN_A: return "A"; break; /* B button */ - case SDLK_LCTRL: + case BTN_B: return "B"; break; /* X button */ - case SDLK_LSHIFT: + case BTN_X: return "X"; break; /* Y button */ - case SDLK_LALT: + case BTN_Y: return "Y"; break; /* L button */ - case SDLK_TAB: + case BTN_L: return "L"; break; /* R button */ - case SDLK_BACKSPACE: + case BTN_R: return "R"; break; /* Power button */ - case SDLK_END: + case BTN_L2: return "L2"; break; /* Brightness */ - case SDLK_3: + case BTN_R2: return "R2"; break; /* Volume - */ - case SDLK_AMPERSAND: + case BTN_VOLUMEUP: return "Volume -"; break; /* Volume + */ - case SDLK_WORLD_73: + case BTN_VOLUMEDOWN: return "Volume +"; break; /* Start */ - case SDLK_RETURN: + case BTN_START: return "Start"; break; /* Select */ - case SDLK_RCTRL: + case BTN_SELECT: return "Select"; break; default: @@ -207,7 +208,7 @@ static void Input_Remapping() { switch(Event.key.keysym.sym) { - case SDLK_UP: + case BTN_UP: currentselection--; if (currentselection < 1) { @@ -215,33 +216,33 @@ static void Input_Remapping() else currentselection = 9; } break; - case SDLK_DOWN: + case BTN_DOWN: currentselection++; if (currentselection == 10) { currentselection = 1; } break; - case SDLK_SPACE: - case SDLK_RETURN: + case BTN_A: + case BTN_START: pressed = 1; break; - case SDLK_ESCAPE: + case BTN_MENU: option.config_buttons[controls_chosen][currentselection - 1] = 0; break; - case SDLK_LCTRL: + case BTN_B: exit_input = 1; break; - case SDLK_LEFT: + case BTN_LEFT: if (currentselection > 9) currentselection -= 9; break; - case SDLK_RIGHT: + case BTN_RIGHT: if (currentselection < 10) currentselection += 9; break; - case SDLK_BACKSPACE: + case BTN_R: controls_chosen = 1; break; - case SDLK_TAB: + case BTN_L: controls_chosen = 0; break; default: @@ -265,7 +266,7 @@ static void Input_Remapping() { if (Event.type == SDL_KEYDOWN) { - if (Event.key.keysym.sym != SDLK_ESCAPE) + if (Event.key.keysym.sym != BTN_MENU) { option.config_buttons[controls_chosen][currentselection - 1] = Event.key.keysym.sym; exit_map = 1; @@ -427,27 +428,27 @@ void Menu() { switch(Event.key.keysym.sym) { - case SDLK_UP: + case BTN_UP: currentselection--; if (currentselection == 0) currentselection = 6; break; - case SDLK_DOWN: + case BTN_DOWN: currentselection++; if (currentselection == 7) currentselection = 1; break; - case SDLK_END: - case SDLK_RCTRL: - case SDLK_LCTRL: + case BTN_L2: + case BTN_SELECT: + case BTN_B: pressed = 1; currentselection = 1; break; - case SDLK_SPACE: - case SDLK_RETURN: + case BTN_A: + case BTN_START: pressed = 1; break; - case SDLK_LEFT: + case BTN_LEFT: switch(currentselection) { case 2: @@ -461,7 +462,7 @@ void Menu() break; } break; - case SDLK_RIGHT: + case BTN_RIGHT: switch(currentselection) { case 2: |