forked from mirrors/0ad
Cleanup after SDL1 removal.
Remove the "sdl1" option from premake4.lua (thanks historic_bruno). Improve isUnprintableChar indentation, resolve two defines, change SDL* to SDL2 in premake (thanks leper). This was SVN commit r17479.
This commit is contained in:
@@ -611,9 +611,9 @@ void CConsole::SaveHistory()
|
||||
|
||||
static bool isUnprintableChar(SDL_Keysym key)
|
||||
{
|
||||
switch (key.sym)
|
||||
{
|
||||
// We want to allow some, which are handled specially
|
||||
switch (key.sym)
|
||||
{
|
||||
// We want to allow some, which are handled specially
|
||||
case SDLK_RETURN: case SDLK_TAB:
|
||||
case SDLK_BACKSPACE: case SDLK_DELETE:
|
||||
case SDLK_HOME: case SDLK_END:
|
||||
@@ -622,10 +622,10 @@ static bool isUnprintableChar(SDL_Keysym key)
|
||||
case SDLK_PAGEUP: case SDLK_PAGEDOWN:
|
||||
return false;
|
||||
|
||||
// Ignore the others
|
||||
// Ignore the others
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InReaction conInputHandler(const SDL_Event_* ev)
|
||||
|
||||
+8
-10
@@ -30,11 +30,9 @@
|
||||
|
||||
static bool unified[UNIFIED_LAST - UNIFIED_SHIFT];
|
||||
|
||||
#define SDLKEY SDL_Keycode
|
||||
|
||||
struct SKey
|
||||
{
|
||||
SDLKEY code; // keycode or MOUSE_ or UNIFIED_ value
|
||||
SDL_Keycode code; // keycode or MOUSE_ or UNIFIED_ value
|
||||
bool negated; // whether the key must be pressed (false) or unpressed (true)
|
||||
};
|
||||
|
||||
@@ -81,7 +79,7 @@ static void LoadConfigBindings()
|
||||
continue;
|
||||
}
|
||||
|
||||
SKey key = { (SDLKEY)mapping, false };
|
||||
SKey key = { (SDL_Keycode)mapping, false };
|
||||
keyCombination.push_back(key);
|
||||
}
|
||||
|
||||
@@ -144,7 +142,7 @@ bool isNegated(const SKey& key)
|
||||
else if ((int)key.code > UNIFIED_LAST && g_mouse_buttons[key.code - UNIFIED_LAST] == key.negated)
|
||||
return false;
|
||||
// Modifier keycodes are between the normal keys and the mouse 'keys'
|
||||
else if ((int)key.code < UNIFIED_LAST && (int)key.code > CUSTOM_SDL_KEYCODE && unified[key.code - UNIFIED_SHIFT] == key.negated)
|
||||
else if ((int)key.code < UNIFIED_LAST && (int)key.code > SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES) && unified[key.code - UNIFIED_SHIFT] == key.negated)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@@ -214,25 +212,25 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
phantom.ev.type = ((ev->ev.type == SDL_KEYDOWN) || (ev->ev.type == SDL_MOUSEBUTTONDOWN)) ? SDL_KEYDOWN : SDL_KEYUP;
|
||||
if ((keycode == SDLK_LSHIFT) || (keycode == SDLK_RSHIFT))
|
||||
{
|
||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SHIFT;
|
||||
phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_SHIFT;
|
||||
unified[0] = (phantom.ev.type == SDL_KEYDOWN);
|
||||
HotkeyInputHandler(&phantom);
|
||||
}
|
||||
else if ((keycode == SDLK_LCTRL) || (keycode == SDLK_RCTRL))
|
||||
{
|
||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_CTRL;
|
||||
phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_CTRL;
|
||||
unified[1] = (phantom.ev.type == SDL_KEYDOWN);
|
||||
HotkeyInputHandler(&phantom);
|
||||
}
|
||||
else if ((keycode == SDLK_LALT) || (keycode == SDLK_RALT))
|
||||
{
|
||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_ALT;
|
||||
phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_ALT;
|
||||
unified[2] = (phantom.ev.type == SDL_KEYDOWN);
|
||||
HotkeyInputHandler(&phantom);
|
||||
}
|
||||
else if ((keycode == SDLK_LGUI) || (keycode == SDLK_RGUI))
|
||||
{
|
||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SUPER;
|
||||
phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_SUPER;
|
||||
unified[3] = (phantom.ev.type == SDL_KEYDOWN);
|
||||
HotkeyInputHandler(&phantom);
|
||||
}
|
||||
@@ -246,7 +244,7 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||
|
||||
bool consoleCapture = false;
|
||||
|
||||
if (g_Console->IsActive() && keycode < CUSTOM_SDL_KEYCODE)
|
||||
if (g_Console->IsActive() && keycode < SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES))
|
||||
consoleCapture = true;
|
||||
|
||||
// Here's an interesting bit:
|
||||
|
||||
+2
-4
@@ -27,12 +27,10 @@ extern void InitKeyNameMap();
|
||||
extern CStr8 FindKeyName(int keycode);
|
||||
extern int FindKeyCode(const CStr8& keyname);
|
||||
|
||||
// Pick a code which is greater than any keycodes used by SDL itself
|
||||
# define CUSTOM_SDL_KEYCODE SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES)
|
||||
|
||||
enum {
|
||||
// Start sequential IDs in the right place
|
||||
EXTRA_KEYS_BASE = CUSTOM_SDL_KEYCODE,
|
||||
// Pick a code which is greater than any keycodes used by SDL itself
|
||||
EXTRA_KEYS_BASE = SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES),
|
||||
// 'Keycodes' for the unified modifier keys
|
||||
UNIFIED_SHIFT,
|
||||
UNIFIED_CTRL,
|
||||
|
||||
Reference in New Issue
Block a user