restore SDL1-support in sdl_events.cpp

* add define for SDL_SCANCODE_GRAVE - seems like only SDL2
  has names for the values
* add some missing keys to SDL_KeyToDoom3Key
* add scancode to unmapped-key warning
* backspace needs to be handled the same for SDL1 as in SDL2
  (i.e. a new event must be created for it) to work in console
This commit is contained in:
Daniel Gibson 2012-12-22 02:54:31 +01:00
parent 26d3ef7e54
commit f0dfe7e499

View file

@ -53,6 +53,9 @@ If you have questions concerning this license or the applicable additional terms
#define SDLK_KP_9 SDLK_KP9
#define SDLK_NUMLOCKCLEAR SDLK_NUMLOCK
#define SDLK_PRINTSCREEN SDLK_PRINT
// DG: SDL1 doesn't seem to have defines for scancodes.. add the (only) one we need
#define SDL_SCANCODE_GRAVE 49 // in SDL2 this is 53.. but according to two different systems and keyboards this works for SDL1
// DG end
#endif
const char* kbdNames[] =
@ -161,6 +164,33 @@ static int SDL_KeyToDoom3Key( SDL_Keycode key, bool& isChar )
case SDLK_9:
return K_9;
// DG: add some missing keys..
case SDLK_UNDERSCORE:
return K_UNDERLINE;
case SDLK_MINUS:
return K_MINUS;
case SDLK_COMMA:
return K_COMMA;
case SDLK_COLON:
return K_COLON;
case SDLK_SEMICOLON:
return K_SEMICOLON;
case SDLK_PERIOD:
return K_PERIOD;
case SDLK_AT:
return K_AT;
case SDLK_EQUALS:
return K_EQUALS;
// DG end
/*
SDLK_COLON = 58,
SDLK_SEMICOLON = 59,
@ -768,7 +798,7 @@ sysEvent_t Sys_GetEvent()
else
{
if( ev.type == SDL_KEYDOWN )
common->Warning( "unmapped SDL key %d (0x%x)", ev.key.keysym.sym, ev.key.keysym.unicode );
common->Warning( "unmapped SDL key %d (0x%x) scancode %d", ev.key.keysym.sym, ev.key.keysym.unicode, ev.key.keysym.scancode );
return res_none;
}
}
@ -780,16 +810,15 @@ sysEvent_t Sys_GetEvent()
kbd_polls.Append( kbd_poll_t( key, ev.key.state == SDL_PRESSED ) );
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( key == K_BACKSPACE && ev.key.state == SDL_PRESSED )
c = key;
#else
#if ! SDL_VERSION_ATLEAST(2, 0, 0)
if( ev.key.state == SDL_PRESSED && isChar && ( ev.key.keysym.unicode & 0xff00 ) == 0 )
{
c = ev.key.keysym.unicode & 0xff;
}
#endif
return res;
}