diff --git a/Engine.c b/Engine.c index 0d371ee..b7bcbbb 100644 --- a/Engine.c +++ b/Engine.c @@ -6,7 +6,9 @@ #include "SDL/SDL_ttf.h" #include "SDL/SDL_mixer.h" +#include "config.h" #include "enum.h" + #include "Engine.h" #include "Timer.h" #include "Player.h" @@ -16,6 +18,7 @@ #include "Kaos.h" #include "HyperKaos.h" #include "Scene.h" + #include "extern.h" // @@ -89,25 +92,25 @@ void interact() case SDL_KEYDOWN: switch (event.key.keysym.sym) { - case SDLK_w: + case DPAD_UP: hero->bearing.y = -2; break; - case SDLK_a: + case DPAD_LEFT: hero->bearing.x = -2; break; - case SDLK_s: + case DPAD_DOWN: hero->bearing.y = 2; break; - case SDLK_d: + case DPAD_RIGHT: hero->bearing.x = 2; break; - case SDLK_j: + case A_BUTTON: actionbutton = 1; break; - case SDLK_q: + case PAUSE_BUTTON: pausemenu(); break; - case SDLK_f: + case FS_BUTTON: toggleFullscreen(); break; default: break; @@ -116,31 +119,31 @@ void interact() case SDL_KEYUP: switch( event.key.keysym.sym ) { - case SDLK_w: + case DPAD_UP: if (hero->bearing.y < 0) { hero->bearing.y = 0; } break; - case SDLK_a: + case DPAD_LEFT: if (hero->bearing.x < 0) { hero->bearing.x = 0 ; } break; - case SDLK_s: + case DPAD_DOWN: if (hero->bearing.y > 0) { hero->bearing.y = 0; } break; - case SDLK_d: + case DPAD_RIGHT: if (hero->bearing.x > 0) { hero->bearing.x = 0; } break; - case SDLK_j: + case A_BUTTON: actionbutton = 0; break; default: break; @@ -340,17 +343,17 @@ void mainmenu() case SDL_KEYDOWN: switch (event.key.keysym.sym) { - case SDLK_w: + case DPAD_UP: menucounter--; break; - case SDLK_s: + case DPAD_DOWN: menucounter++; break; - case SDLK_j: + case A_BUTTON: select = 1; break; - case SDLK_f: + case FS_BUTTON: toggleFullscreen(); break; default: break; @@ -451,19 +454,19 @@ void pausemenu() case SDL_KEYDOWN: switch (event.key.keysym.sym) { - case SDLK_w: + case DPAD_UP: menucounter--; break; - case SDLK_s: + case DPAD_DOWN: menucounter++; break; - case SDLK_j: + case A_BUTTON: select = 1; break; - case SDLK_q: + case PAUSE_BUTTON: paused = 0; break; - case SDLK_f: + case FS_BUTTON: toggleFullscreen(); break; default: break; diff --git a/Kaos.c b/Kaos.c index 8e091da..63fca66 100644 --- a/Kaos.c +++ b/Kaos.c @@ -3,6 +3,8 @@ #include "SDL/SDL_ttf.h" #include "SDL/SDL_mixer.h" +#include "config.h" + #include "enum.h" #include "Engine.h" #include "Timer.h" @@ -98,17 +100,17 @@ void runChoice(Kaos* self) case SDL_KEYDOWN: switch(event.key.keysym.sym) { - case SDLK_a: - case SDLK_d: + case DPAD_LEFT: + case DPAD_RIGHT: if (choice == 0) choice = 1; else choice = 0; break; - case SDLK_j: + case A_BUTTON: textIsRelevent = 0; if (choice == 0) run(kSelf->path1); else run(kSelf->path2); break; - case SDLK_f: + case FS_BUTTON: toggleFullscreen(); break; default: break; diff --git a/Scene.c b/Scene.c index e3f9fba..933f50b 100644 --- a/Scene.c +++ b/Scene.c @@ -5,6 +5,8 @@ #include #include +#include "config.h" + #include "Scene.h" #include "Timer.h" #include "Engine.h" @@ -77,10 +79,10 @@ void sceneInput(Scene* self, int* counter) case SDL_KEYDOWN: switch (event.key.keysym.sym) { - case SDLK_j: + case A_BUTTON: *counter = self->time - 1; break; - case SDLK_f: + case FS_BUTTON: toggleFullscreen(); break; default: break; diff --git a/TextBox.c b/TextBox.c index 96ed9be..3dc927c 100644 --- a/TextBox.c +++ b/TextBox.c @@ -2,6 +2,9 @@ #include "SDL/SDL_image.h" #include "SDL/SDL_ttf.h" #include "SDL/SDL_mixer.h" + +#include "config.h" + #include "Engine.h" #include "Timer.h" #include "Player.h" @@ -77,9 +80,12 @@ void textBoxInput(TextBox* self, int* textIsRelevent) case SDL_KEYDOWN: switch (event.key.keysym.sym) { - case SDLK_j: + case A_BUTTON: if (self->cursor < 15) self->cursor += 3; break; + case FS_BUTTON: + toggleFullscreen(); + break; default: break; } } @@ -103,7 +109,7 @@ void textBoxInput(TextBox* self, int* textIsRelevent) case SDL_KEYDOWN: switch (event.key.keysym.sym) { - case SDLK_j: + case A_BUTTON: if (self->scroll + 1 != self->lines) { self->cursor = 0; @@ -112,7 +118,7 @@ void textBoxInput(TextBox* self, int* textIsRelevent) } else *textIsRelevent = 0; break; - case SDLK_f: + case FS_BUTTON: toggleFullscreen(); break; diff --git a/config.h b/config.h new file mode 100644 index 0000000..e75ee24 --- /dev/null +++ b/config.h @@ -0,0 +1,9 @@ +/* see http://sdlk.beuc.net/sdl.wiki/SDLKey for keysyms */ + +#define DPAD_UP SDLK_w +#define DPAD_DOWN SDLK_s +#define DPAD_LEFT SDLK_a +#define DPAD_RIGHT SDLK_d +#define A_BUTTON SDLK_j +#define FS_BUTTON SDLK_f +#define PAUSE_BUTTON SDLK_q