Skip to content

Commit

Permalink
SDLVideo: update for SDL2 api change
Browse files Browse the repository at this point in the history
the unicode field is removed from the keysym struct
  • Loading branch information
bradallred committed Jul 4, 2013
1 parent 8267f31 commit 82a2d59
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gemrb/plugins/SDLVideo/SDLVideo.cpp
Expand Up @@ -46,6 +46,8 @@ using namespace GemRB;
#define SDLK_KP4 SDLK_KP_4 #define SDLK_KP4 SDLK_KP_4
#define SDLK_KP6 SDLK_KP_6 #define SDLK_KP6 SDLK_KP_6
#define SDLK_KP8 SDLK_KP_8 #define SDLK_KP8 SDLK_KP_8
#else
typedef Sint32 SDL_Keycode;
#endif #endif


SDLVideoDriver::SDLVideoDriver(void) SDLVideoDriver::SDLVideoDriver(void)
Expand Down Expand Up @@ -164,7 +166,7 @@ int SDLVideoDriver::ProcessEvent(const SDL_Event & event)
if (!EvntManager) if (!EvntManager)
return GEM_ERROR; return GEM_ERROR;


unsigned char key = 0; SDL_Keycode key = SDLK_UNKNOWN;
int modstate = GetModState(event.key.keysym.mod); int modstate = GetModState(event.key.keysym.mod);


/* Loop until there are no events left on the queue */ /* Loop until there are no events left on the queue */
Expand Down Expand Up @@ -195,7 +197,7 @@ int SDLVideoDriver::ProcessEvent(const SDL_Event & event)
// fallthrough // fallthrough
default: default:
if (event.key.keysym.sym<256) { if (event.key.keysym.sym<256) {
key=(unsigned char) event.key.keysym.sym; key = event.key.keysym.sym;
} }
break; break;
} }
Expand All @@ -207,7 +209,11 @@ int SDLVideoDriver::ProcessEvent(const SDL_Event & event)
core->PopupConsole(); core->PopupConsole();
break; break;
} }
key = (unsigned char) event.key.keysym.unicode; #if SDL_VERSION_ATLEAST(1,3,0)
key = SDL_GetKeyFromScancode(event.key.keysym.scancode);
#else
key = event.key.keysym.unicode;
#endif
if (key < 32 || key == 127) { if (key < 32 || key == 127) {
switch (event.key.keysym.sym) { switch (event.key.keysym.sym) {
case SDLK_ESCAPE: case SDLK_ESCAPE:
Expand Down

0 comments on commit 82a2d59

Please sign in to comment.