From 6a45cd05e9a90a6059923b73194f412df0c3240c Mon Sep 17 00:00:00 2001 From: punkrockguy318 Date: Tue, 23 Feb 2010 01:31:54 +0000 Subject: [PATCH] SDL: fceuX ported to SDL 1.3; full compatibility maintained with 1.2 SDL: compile-time SDL version printed with "--help" --- src/drivers/sdl/input.cpp | 29 ++++++++++++++++++++++++----- src/drivers/sdl/keyscan.h | 3 +++ src/drivers/sdl/sdl.cpp | 2 ++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp index 5ec1764f..60fd4765 100644 --- a/src/drivers/sdl/input.cpp +++ b/src/drivers/sdl/input.cpp @@ -137,7 +137,13 @@ _keyonly(int a) // check for valid key if(a > SDLK_LAST+1 || a < 0) return(0); - if(g_keyState[a]) { + #if SDL_VERSION_ATLEAST(1, 3, 0) + if(g_keyState[SDL_GetScancodeFromKey((SDLKey)a)]) + #else + if(g_keyState[a]) + #endif + { + if(!keyonce[a]) { keyonce[a] = 1; return(1); @@ -393,9 +399,14 @@ static void KeyboardCommands() { int is_shift, is_alt; + char* movie_fname = ""; // get the keyboard input + #if SDL_VERSION_ATLEAST(1, 3, 0) + g_keyState = SDL_GetKeyboardState(NULL); + #else g_keyState = SDL_GetKeyState(NULL); + #endif // check if the family keyboard is enabled if(InputType[2] == SIFC_FKB) { @@ -410,8 +421,10 @@ KeyboardCommands() } } - is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT); - is_alt = KEY(LEFTALT) | KEY(RIGHTALT); + //is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT); + //is_alt = KEY(LEFTALT) | KEY(RIGHTALT); + is_shift = 0; + is_alt = 0; if(_keyonly(renderBgKey)) { if(is_shift) { @@ -638,8 +651,10 @@ KeyboardCommands() if(keyonly(H)) FCEUI_NTSCSELHUE(); if(keyonly(T)) FCEUI_NTSCSELTINT(); - if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC(); - if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC(); + + // TEMPORAILY DISABLED! DO NOT COMMIT! TODO! + // if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC(); + // if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC(); if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) { if(keyonly(F8)) { @@ -813,7 +828,11 @@ DTestButton(ButtConfig *bc) for(x = 0; x < bc->NumC; x++) { if(bc->ButtType[x] == BUTTC_KEYBOARD) { + #if SDL_VERSION_ATLEAST(1,3,0) + if(g_keyState[SDL_GetScancodeFromKey((SDLKey)bc->ButtonNum[x])]) { + #else if(g_keyState[bc->ButtonNum[x]]) { + #endif return(1); } } else if(bc->ButtType[x] == BUTTC_JOYSTICK) { diff --git a/src/drivers/sdl/keyscan.h b/src/drivers/sdl/keyscan.h index 1c1b80a0..ed4c3927 100644 --- a/src/drivers/sdl/keyscan.h +++ b/src/drivers/sdl/keyscan.h @@ -43,4 +43,7 @@ #define SDLK_SCROLLLOCK SDLK_SCROLLOCK /* I guess the SDL people don't like lots of Ls... */ #define SDLK_GRAVE SDLK_BACKQUOTE #define MKK(k) SDLK_##k +#if SDL_VERSION_ATLEAST(1, 3, 0) +#define SDLK_LAST SDL_NUM_SCANCODES +#endif #define MKK_COUNT (SDLK_LAST+1) diff --git a/src/drivers/sdl/sdl.cpp b/src/drivers/sdl/sdl.cpp index 7d3a7f7c..5a9a0e02 100644 --- a/src/drivers/sdl/sdl.cpp +++ b/src/drivers/sdl/sdl.cpp @@ -151,6 +151,8 @@ static void ShowUsage(char *prog) puts ("--mute {0|1} Mutes FCEUX while still passing the audio stream to\n mencoder."); #endif puts(""); + printf("Compiled with SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL ); + } /**