|
|
@ -15,6 +15,7 @@ GNU General Public License for more details. |
|
|
|
|
|
|
|
|
|
|
|
#if defined( XASH_SDL ) && !defined( XASH_DEDICATED ) |
|
|
|
#if defined( XASH_SDL ) && !defined( XASH_DEDICATED ) |
|
|
|
#include <SDL.h> |
|
|
|
#include <SDL.h> |
|
|
|
|
|
|
|
#include <ctype.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "common.h" |
|
|
|
#include "common.h" |
|
|
|
#include "keydefs.h" |
|
|
|
#include "keydefs.h" |
|
|
@ -39,56 +40,57 @@ static int wheelbutton; |
|
|
|
#define SDL_SCANCODE_BACKSLASH SDLK_BACKSLASH |
|
|
|
#define SDL_SCANCODE_BACKSLASH SDLK_BACKSLASH |
|
|
|
#define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET |
|
|
|
#define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET |
|
|
|
#define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET |
|
|
|
#define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET |
|
|
|
#define SDL_SCANCODE_EQUALS: keynum = '='; break; |
|
|
|
#define SDL_SCANCODE_EQUALS SDLK_EQUALS |
|
|
|
#define SDL_SCANCODE_MINUS: keynum = '-'; break; |
|
|
|
#define SDL_SCANCODE_MINUS SDLK_MINUS |
|
|
|
#define SDL_SCANCODE_TAB: keynum = K_TAB; break; |
|
|
|
#define SDL_SCANCODE_TAB SDLK_TAB |
|
|
|
#define SDL_SCANCODE_RETURN: keynum = K_ENTER; break; |
|
|
|
#define SDL_SCANCODE_RETURN SDLK_RETURN |
|
|
|
#define SDL_SCANCODE_ESCAPE: keynum = K_ESCAPE; break; |
|
|
|
#define SDL_SCANCODE_ESCAPE SDLK_ESCAPE |
|
|
|
#define SDL_SCANCODE_SPACE: keynum = K_SPACE; break; |
|
|
|
#define SDL_SCANCODE_SPACE SDLK_SPACE |
|
|
|
#define SDL_SCANCODE_BACKSPACE: keynum = K_BACKSPACE; break; |
|
|
|
#define SDL_SCANCODE_BACKSPACE SDLK_BACKSPACE |
|
|
|
#define SDL_SCANCODE_UP: keynum = K_UPARROW; break; |
|
|
|
#define SDL_SCANCODE_UP SDLK_UP |
|
|
|
#define SDL_SCANCODE_LEFT: keynum = K_LEFTARROW; break; |
|
|
|
#define SDL_SCANCODE_LEFT SDLK_LEFT |
|
|
|
#define SDL_SCANCODE_DOWN: keynum = K_DOWNARROW; break; |
|
|
|
#define SDL_SCANCODE_DOWN SDLK_DOWN |
|
|
|
#define SDL_SCANCODE_RIGHT: keynum = K_RIGHTARROW; break; |
|
|
|
#define SDL_SCANCODE_RIGHT SDLK_RIGHT |
|
|
|
#define SDL_SCANCODE_LALT: |
|
|
|
#define SDL_SCANCODE_LALT SDLK_LALT |
|
|
|
#define SDL_SCANCODE_RALT: keynum = K_ALT; break; |
|
|
|
#define SDL_SCANCODE_RALT SDLK_RALT |
|
|
|
#define SDL_SCANCODE_LCTRL: |
|
|
|
#define SDL_SCANCODE_LCTRL SDLK_LCTRL |
|
|
|
#define SDL_SCANCODE_RCTRL: keynum = K_CTRL; break; |
|
|
|
#define SDL_SCANCODE_RCTRL SDLK_RCTRL |
|
|
|
#define SDL_SCANCODE_LSHIFT: |
|
|
|
#define SDL_SCANCODE_LSHIFT SDLK_LSHIFT |
|
|
|
#define SDL_SCANCODE_RSHIFT: keynum = K_SHIFT; break; |
|
|
|
#define SDL_SCANCODE_RSHIFT SDLK_RSHIFT |
|
|
|
#define SDL_SCANCODE_LGUI: |
|
|
|
#define SDL_SCANCODE_LGUI SDLK_LMETA |
|
|
|
#define SDL_SCANCODE_RGUI: keynum = K_WIN; break; |
|
|
|
#define SDL_SCANCODE_RGUI SDLK_RMETA |
|
|
|
#define SDL_SCANCODE_INSERT: keynum = K_INS; break; |
|
|
|
#define SDL_SCANCODE_INSERT SDLK_INSERT |
|
|
|
#define SDL_SCANCODE_DELETE: keynum = K_DEL; break; |
|
|
|
#define SDL_SCANCODE_DELETE SDLK_DELETE |
|
|
|
#define SDL_SCANCODE_PAGEDOWN: keynum = K_PGDN; break; |
|
|
|
#define SDL_SCANCODE_PAGEDOWN SDLK_PAGEDOWN |
|
|
|
#define SDL_SCANCODE_PAGEUP: keynum = K_PGUP; break; |
|
|
|
#define SDL_SCANCODE_PAGEUP SDLK_PAGEUP |
|
|
|
#define SDL_SCANCODE_HOME: keynum = K_HOME; break; |
|
|
|
#define SDL_SCANCODE_HOME SDLK_HOME |
|
|
|
#define SDL_SCANCODE_END: keynum = K_END; break; |
|
|
|
#define SDL_SCANCODE_END SDLK_END |
|
|
|
#define SDL_SCANCODE_KP_1: keynum = numLock ? '1' : K_KP_END; break; |
|
|
|
#define SDL_SCANCODE_KP_1 SDLK_KP1 |
|
|
|
#define SDL_SCANCODE_KP_2: keynum = numLock ? '2' : K_KP_DOWNARROW; break; |
|
|
|
#define SDL_SCANCODE_KP_2 SDLK_KP2 |
|
|
|
#define SDL_SCANCODE_KP_3: keynum = numLock ? '3' : K_KP_PGDN; break; |
|
|
|
#define SDL_SCANCODE_KP_3 SDLK_KP3 |
|
|
|
#define SDL_SCANCODE_KP_4: keynum = numLock ? '4' : K_KP_LEFTARROW; break; |
|
|
|
#define SDL_SCANCODE_KP_4 SDLK_KP4 |
|
|
|
#define SDL_SCANCODE_KP_5: keynum = numLock ? '5' : K_KP_5; break; |
|
|
|
#define SDL_SCANCODE_KP_5 SDLK_KP5 |
|
|
|
#define SDL_SCANCODE_KP_6: keynum = numLock ? '6' : K_KP_RIGHTARROW; break; |
|
|
|
#define SDL_SCANCODE_KP_6 SDLK_KP6 |
|
|
|
#define SDL_SCANCODE_KP_7: keynum = numLock ? '7' : K_KP_HOME; break; |
|
|
|
#define SDL_SCANCODE_KP_7 SDLK_KP7 |
|
|
|
#define SDL_SCANCODE_KP_8: keynum = numLock ? '8' : K_KP_UPARROW; break; |
|
|
|
#define SDL_SCANCODE_KP_8 SDLK_KP8 |
|
|
|
#define SDL_SCANCODE_KP_9: keynum = numLock ? '9' : K_KP_PGUP; break; |
|
|
|
#define SDL_SCANCODE_KP_9 SDLK_KP9 |
|
|
|
#define SDL_SCANCODE_KP_0: keynum = numLock ? '0' : K_KP_INS; break; |
|
|
|
#define SDL_SCANCODE_KP_0 SDLK_KP0 |
|
|
|
#define SDL_SCANCODE_KP_PERIOD: keynum = K_KP_DEL; break; |
|
|
|
#define SDL_SCANCODE_KP_PERIOD SDLK_KP_PERIOD |
|
|
|
#define SDL_SCANCODE_KP_ENTER: keynum = K_KP_ENTER; break; |
|
|
|
#define SDL_SCANCODE_KP_ENTER SDLK_KP_ENTER |
|
|
|
#define SDL_SCANCODE_KP_PLUS: keynum = K_KP_PLUS; break; |
|
|
|
#define SDL_SCANCODE_KP_PLUS SDLK_KP_PLUS |
|
|
|
#define SDL_SCANCODE_KP_MINUS: keynum = K_KP_MINUS; break; |
|
|
|
#define SDL_SCANCODE_KP_MINUS SDLK_KP_MINUS |
|
|
|
#define SDL_SCANCODE_KP_DIVIDE: keynum = K_KP_SLASH; break; |
|
|
|
#define SDL_SCANCODE_KP_DIVIDE SDLK_KP_DIVIDE |
|
|
|
#define SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break; |
|
|
|
#define SDL_SCANCODE_KP_MULTIPLY SDLK_KP_MULTIPLY |
|
|
|
#define SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break; |
|
|
|
#define SDL_SCANCODE_NUMLOCKCLEAR SDLK_NUMLOCK |
|
|
|
#define SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break; |
|
|
|
#define SDL_SCANCODE_CAPSLOCK SDLK_CAPSLOCK |
|
|
|
#define SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ???
|
|
|
|
#define SDL_SCANCODE_SLASH SDLK_SLASH |
|
|
|
#define SDL_SCANCODE_SLASH: keynum = '/'; break; |
|
|
|
#define SDL_SCANCODE_PERIOD SDLK_PERIOD |
|
|
|
#define SDL_SCANCODE_PERIOD: keynum = '.'; break; |
|
|
|
#define SDL_SCANCODE_SEMICOLON SDLK_SEMICOLON |
|
|
|
#define SDL_SCANCODE_SEMICOLON: keynum = ';'; break; |
|
|
|
#define SDL_SCANCODE_APOSTROPHE SDLK_QUOTE |
|
|
|
#define SDL_SCANCODE_APOSTROPHE: keynum = '\''; break; |
|
|
|
#define SDL_SCANCODE_COMMA SDLK_COMMA |
|
|
|
#define SDL_SCANCODE_COMMA: keynum = ','; break; |
|
|
|
#define SDL_SCANCODE_PRINTSCREEN SDLK_PRINT |
|
|
|
#define SDL_SCANCODE_PRINTSCREEN: |
|
|
|
#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN |
|
|
|
|
|
|
|
#define SDL_GetScancodeName( x ) "unknown" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -100,10 +102,13 @@ SDLash_KeyEvent |
|
|
|
static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int down = key.state != SDL_RELEASED; |
|
|
|
int down = key.state != SDL_RELEASED; |
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
int keynum = key.keysym.scancode; |
|
|
|
int keynum = key.keysym.scancode; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
int keynum = key.keysym.sym; |
|
|
|
|
|
|
|
#endif |
|
|
|
qboolean numLock = SDL_GetModState() & KMOD_NUM; |
|
|
|
qboolean numLock = SDL_GetModState() & KMOD_NUM; |
|
|
|
|
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
if( SDL_IsTextInputActive() && down ) |
|
|
|
if( SDL_IsTextInputActive() && down ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( SDL_GetModState() & KMOD_CTRL ) |
|
|
|
if( SDL_GetModState() & KMOD_CTRL ) |
|
|
@ -116,8 +121,23 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if !SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
if( keynum >= SDLK_KP0 && keynum <= SDLK_KP9 ) |
|
|
|
|
|
|
|
keynum -= SDLK_KP0 + '0'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( isprint( keynum ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( SDL_GetModState() & KMOD_SHIFT ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
keynum = Key_ToUpper( keynum ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CL_CharEvent( keynum ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DECLARE_KEY_RANGE( min, max, repl ) \ |
|
|
|
#define DECLARE_KEY_RANGE( min, max, repl ) \ |
|
|
|
if( keynum >= (min) && keynum <= (max) ) \ |
|
|
|
if( keynum >= (min) && keynum <= (max) ) \ |
|
|
@ -180,7 +200,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
case SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break; |
|
|
|
case SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break; |
|
|
|
case SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break; |
|
|
|
case SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break; |
|
|
|
case SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break; |
|
|
|
case SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break; |
|
|
|
case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ???
|
|
|
|
|
|
|
|
case SDL_SCANCODE_SLASH: keynum = '/'; break; |
|
|
|
case SDL_SCANCODE_SLASH: keynum = '/'; break; |
|
|
|
case SDL_SCANCODE_PERIOD: keynum = '.'; break; |
|
|
|
case SDL_SCANCODE_PERIOD: keynum = '.'; break; |
|
|
|
case SDL_SCANCODE_SEMICOLON: keynum = ';'; break; |
|
|
|
case SDL_SCANCODE_SEMICOLON: keynum = ';'; break; |
|
|
@ -193,6 +212,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ???
|
|
|
|
// don't console spam on known functional buttons, but not used in engine
|
|
|
|
// don't console spam on known functional buttons, but not used in engine
|
|
|
|
case SDL_SCANCODE_MUTE: |
|
|
|
case SDL_SCANCODE_MUTE: |
|
|
|
case SDL_SCANCODE_VOLUMEUP: |
|
|
|
case SDL_SCANCODE_VOLUMEUP: |
|
|
@ -200,7 +220,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
case SDL_SCANCODE_BRIGHTNESSDOWN: |
|
|
|
case SDL_SCANCODE_BRIGHTNESSDOWN: |
|
|
|
case SDL_SCANCODE_BRIGHTNESSUP: |
|
|
|
case SDL_SCANCODE_BRIGHTNESSUP: |
|
|
|
return; |
|
|
|
return; |
|
|
|
#endif |
|
|
|
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
|
|
|
case SDL_SCANCODE_UNKNOWN: |
|
|
|
case SDL_SCANCODE_UNKNOWN: |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); |
|
|
|
if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); |
|
|
@ -211,88 +231,22 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
|
|
|
|
DECLARE_KEY_RANGE( SDLK_a, SDLK_z, 'a' ) |
|
|
|
#undef DECLARE_KEY_RANGE |
|
|
|
else DECLARE_KEY_RANGE( SDLK_1, SDLK_9, '1' ) |
|
|
|
|
|
|
|
else DECLARE_KEY_RANGE( SDLK_F1, SDLK_F12, K_F1 ) |
|
|
|
Key_Event( keynum, down ); |
|
|
|
else |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
switch( keynum ) |
|
|
|
static void SDLash_MouseKey( int key, int down, int istouch ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case SDLK_BACKQUOTE: keynum = '`'; break; |
|
|
|
if( CVAR_TO_BOOL( touch_emulate ) ) |
|
|
|
case SDLK_0: keynum = '0'; break; |
|
|
|
|
|
|
|
case SDLK_BACKSLASH: keynum = '\\'; break; |
|
|
|
|
|
|
|
case SDLK_LEFTBRACKET: keynum = '['; break; |
|
|
|
|
|
|
|
case SDLK_RIGHTBRACKET: keynum = ']'; break; |
|
|
|
|
|
|
|
case SDLK_EQUALS: keynum = '='; break; |
|
|
|
|
|
|
|
case SDLK_MINUS: keynum = '-'; break; |
|
|
|
|
|
|
|
case SDLK_TAB: keynum = K_TAB; break; |
|
|
|
|
|
|
|
case SDLK_RETURN: keynum = K_ENTER; break; |
|
|
|
|
|
|
|
case SDLK_ESCAPE: keynum = K_ESCAPE; break; |
|
|
|
|
|
|
|
case SDLK_SPACE: keynum = K_SPACE; break; |
|
|
|
|
|
|
|
case SDLK_BACKSPACE: keynum = K_BACKSPACE; break; |
|
|
|
|
|
|
|
case SDLK_UP: keynum = K_UPARROW; break; |
|
|
|
|
|
|
|
case SDLK_LEFT: keynum = K_LEFTARROW; break; |
|
|
|
|
|
|
|
case SDLK_DOWN: keynum = K_DOWNARROW; break; |
|
|
|
|
|
|
|
case SDLK_RIGHT: keynum = K_RIGHTARROW; break; |
|
|
|
|
|
|
|
case SDLK_LALT: |
|
|
|
|
|
|
|
case SDLK_RALT: keynum = K_ALT; break; |
|
|
|
|
|
|
|
case SDLK_LCTRL: |
|
|
|
|
|
|
|
case SDLK_RCTRL: keynum = K_CTRL; break; |
|
|
|
|
|
|
|
case SDLK_LSHIFT: |
|
|
|
|
|
|
|
case SDLK_RSHIFT: keynum = K_SHIFT; break; |
|
|
|
|
|
|
|
case SDLK_LMETA: |
|
|
|
|
|
|
|
case SDLK_RMETA: keynum = K_WIN; break; |
|
|
|
|
|
|
|
case SDLK_INSERT: keynum = K_INS; break; |
|
|
|
|
|
|
|
case SDLK_DELETE: keynum = K_DEL; break; |
|
|
|
|
|
|
|
case SDLK_PAGEDOWN: keynum = K_PGDN; break; |
|
|
|
|
|
|
|
case SDLK_PAGEUP: keynum = K_PGUP; break; |
|
|
|
|
|
|
|
case SDLK_HOME: keynum = K_HOME; break; |
|
|
|
|
|
|
|
case SDLK_END: keynum = K_END; break; |
|
|
|
|
|
|
|
case SDLK_KP1: keynum = numLock ? '1' : K_KP_END; break; |
|
|
|
|
|
|
|
case SDLK_KP2: keynum = numLock ? '2' : K_KP_DOWNARROW; break; |
|
|
|
|
|
|
|
case SDLK_KP3: keynum = numLock ? '3' : K_KP_PGDN; break; |
|
|
|
|
|
|
|
case SDLK_KP4: keynum = numLock ? '4' : K_KP_LEFTARROW; break; |
|
|
|
|
|
|
|
case SDLK_KP5: keynum = numLock ? '5' : K_KP_5; break; |
|
|
|
|
|
|
|
case SDLK_KP6: keynum = numLock ? '6' : K_KP_RIGHTARROW; break; |
|
|
|
|
|
|
|
case SDLK_KP7: keynum = numLock ? '7' : K_KP_HOME; break; |
|
|
|
|
|
|
|
case SDLK_KP8: keynum = numLock ? '8' : K_KP_UPARROW; break; |
|
|
|
|
|
|
|
case SDLK_KP9: keynum = numLock ? '9' : K_KP_PGUP; break; |
|
|
|
|
|
|
|
case SDLK_KP0: keynum = numLock ? '0' : K_KP_INS; break; |
|
|
|
|
|
|
|
case SDLK_KP_PERIOD: keynum = K_KP_DEL; break; |
|
|
|
|
|
|
|
case SDLK_KP_ENTER: keynum = K_KP_ENTER; break; |
|
|
|
|
|
|
|
case SDLK_KP_PLUS: keynum = K_KP_PLUS; break; |
|
|
|
|
|
|
|
case SDLK_KP_MINUS: keynum = K_KP_MINUS; break; |
|
|
|
|
|
|
|
case SDLK_KP_DIVIDE: keynum = K_KP_SLASH; break; |
|
|
|
|
|
|
|
case SDLK_KP_MULTIPLY: keynum = '*'; break; |
|
|
|
|
|
|
|
case SDLK_NUMLOCK: keynum = K_KP_NUMLOCK; break; |
|
|
|
|
|
|
|
case SDLK_CAPSLOCK: keynum = K_CAPSLOCK; break; |
|
|
|
|
|
|
|
case SDLK_SLASH: keynum = '/'; break; |
|
|
|
|
|
|
|
case SDLK_PERIOD: keynum = '.'; break; |
|
|
|
|
|
|
|
case SDLK_SEMICOLON: keynum = ';'; break; |
|
|
|
|
|
|
|
case SDLK_QUOTE: keynum = '\''; break; |
|
|
|
|
|
|
|
case SDLK_COMMA: keynum = ','; break; |
|
|
|
|
|
|
|
case SDLK_PRINT: |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
host.force_draw_version = true; |
|
|
|
Touch_KeyEvent( key, down ); |
|
|
|
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
case SDLK_UNKNOWN: |
|
|
|
else if( in_mouseinitialized && !m_ignore->value && !istouch ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); |
|
|
|
Key_Event( key, down ); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown key: %s = %i\n", SDL_GetScancodeName( keynum ), keynum ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef DECLARE_KEY_RANGE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Key_Event( keynum, down ); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -304,14 +258,41 @@ SDLash_MouseEvent |
|
|
|
static void SDLash_MouseEvent( SDL_MouseButtonEvent button ) |
|
|
|
static void SDLash_MouseEvent( SDL_MouseButtonEvent button ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int down = button.state != SDL_RELEASED; |
|
|
|
int down = button.state != SDL_RELEASED; |
|
|
|
|
|
|
|
qboolean istouch; |
|
|
|
|
|
|
|
|
|
|
|
if( CVAR_TO_BOOL( touch_emulate ) ) |
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
{ |
|
|
|
istouch = button.which == SDL_TOUCH_MOUSEID; |
|
|
|
Touch_KeyEvent( K_MOUSE1 - 1 + button.button, down ); |
|
|
|
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
|
|
|
} |
|
|
|
istouch = false; |
|
|
|
else if( in_mouseinitialized && !m_ignore->value && button.which != SDL_TOUCH_MOUSEID ) |
|
|
|
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch( button.button ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Key_Event( K_MOUSE1 - 1 + button.button, down ); |
|
|
|
case SDL_BUTTON_LEFT: |
|
|
|
|
|
|
|
SDLash_MouseKey( K_MOUSE1, down, istouch ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SDL_BUTTON_RIGHT: |
|
|
|
|
|
|
|
SDLash_MouseKey( K_MOUSE2, down, istouch ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SDL_BUTTON_MIDDLE: |
|
|
|
|
|
|
|
SDLash_MouseKey( K_MOUSE3, down, istouch ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SDL_BUTTON_X1: |
|
|
|
|
|
|
|
SDLash_MouseKey( K_MOUSE4, down, istouch ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SDL_BUTTON_X2: |
|
|
|
|
|
|
|
SDLash_MouseKey( K_MOUSE5, down, istouch ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
case SDL_BUTTON_WHEELUP: |
|
|
|
|
|
|
|
Key_Event( K_MWHEELUP, down ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SDL_BUTTON_WHEELDOWN: |
|
|
|
|
|
|
|
Key_Event( K_MWHEELDOWN, down ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#endif // ! SDL_VERSION_ATLEAST( 2, 0, 0 )
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
Con_Printf( "Unknown mouse button ID: %d\n", button.button ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -321,6 +302,7 @@ SDLash_InputEvent |
|
|
|
|
|
|
|
|
|
|
|
============= |
|
|
|
============= |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
static void SDLash_InputEvent( SDL_TextInputEvent input ) |
|
|
|
static void SDLash_InputEvent( SDL_TextInputEvent input ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *text; |
|
|
|
char *text; |
|
|
@ -339,6 +321,43 @@ static void SDLash_InputEvent( SDL_TextInputEvent input ) |
|
|
|
CL_CharEvent( ch ); |
|
|
|
CL_CharEvent( ch ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // SDL_VERSION_AT_LEAST( 2, 0, 0 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void SDLash_ActiveEvent( int gain ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( gain ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
host.status = HOST_FRAME; |
|
|
|
|
|
|
|
IN_ActivateMouse(true); |
|
|
|
|
|
|
|
if( snd_mute_losefocus->value ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SNDDMA_Activate( true ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
host.force_draw_version = true; |
|
|
|
|
|
|
|
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; |
|
|
|
|
|
|
|
if( vid_fullscreen->value ) |
|
|
|
|
|
|
|
VID_SetMode(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#if TARGET_OS_IPHONE |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Keep running if ftp server enabled
|
|
|
|
|
|
|
|
void IOS_StartBackgroundTask( void ); |
|
|
|
|
|
|
|
IOS_StartBackgroundTask(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
host.status = HOST_NOFOCUS; |
|
|
|
|
|
|
|
IN_DeactivateMouse(); |
|
|
|
|
|
|
|
if( snd_mute_losefocus->value ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SNDDMA_Activate( false ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
host.force_draw_version = true; |
|
|
|
|
|
|
|
host.force_draw_version_time = host.realtime + 2; |
|
|
|
|
|
|
|
VID_RestoreScreenResolution(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
============= |
|
|
|
============= |
|
|
@ -360,27 +379,53 @@ static void SDLash_EventFilter( SDL_Event *event ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* Mouse events */ |
|
|
|
/* Mouse events */ |
|
|
|
case SDL_MOUSEMOTION: |
|
|
|
case SDL_MOUSEMOTION: |
|
|
|
if( !host.mouse_visible && event->motion.which != SDL_TOUCH_MOUSEID ) |
|
|
|
if( !host.mouse_visible |
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
&& event->motion.which != SDL_TOUCH_MOUSEID ) |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
#endif |
|
|
|
IN_MouseEvent(); |
|
|
|
IN_MouseEvent(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case SDL_MOUSEBUTTONUP: |
|
|
|
case SDL_MOUSEBUTTONUP: |
|
|
|
case SDL_MOUSEBUTTONDOWN: |
|
|
|
case SDL_MOUSEBUTTONDOWN: |
|
|
|
|
|
|
|
|
|
|
|
SDLash_MouseEvent( event->button ); |
|
|
|
SDLash_MouseEvent( event->button ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case SDL_MOUSEWHEEL: |
|
|
|
|
|
|
|
wheelbutton = event->wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP; |
|
|
|
|
|
|
|
Key_Event( wheelbutton, true ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Keyboard events */ |
|
|
|
/* Keyboard events */ |
|
|
|
case SDL_KEYDOWN: |
|
|
|
case SDL_KEYDOWN: |
|
|
|
case SDL_KEYUP: |
|
|
|
case SDL_KEYUP: |
|
|
|
SDLash_KeyEvent( event->key ); |
|
|
|
SDLash_KeyEvent( event->key ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Joystick events */ |
|
|
|
|
|
|
|
case SDL_JOYAXISMOTION: |
|
|
|
|
|
|
|
Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYBALLMOTION: |
|
|
|
|
|
|
|
Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYHATMOTION: |
|
|
|
|
|
|
|
Joy_HatMotionEvent( event->jhat.hat, event->jhat.value ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYBUTTONDOWN: |
|
|
|
|
|
|
|
case SDL_JOYBUTTONUP: |
|
|
|
|
|
|
|
Joy_ButtonEvent( event->jbutton.button, event->jbutton.state ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_QUIT: |
|
|
|
|
|
|
|
Sys_Quit(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
case SDL_MOUSEWHEEL: |
|
|
|
|
|
|
|
wheelbutton = event->wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP; |
|
|
|
|
|
|
|
Key_Event( wheelbutton, true ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
/* Touch events */ |
|
|
|
/* Touch events */ |
|
|
|
case SDL_FINGERDOWN: |
|
|
|
case SDL_FINGERDOWN: |
|
|
|
case SDL_FINGERUP: |
|
|
|
case SDL_FINGERUP: |
|
|
@ -435,30 +480,11 @@ static void SDLash_EventFilter( SDL_Event *event ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IME */ |
|
|
|
/* IME */ |
|
|
|
case SDL_TEXTINPUT: |
|
|
|
case SDL_TEXTINPUT: |
|
|
|
SDLash_InputEvent( event->text ); |
|
|
|
SDLash_InputEvent( event->text ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
/* Joystick events */ |
|
|
|
|
|
|
|
case SDL_JOYAXISMOTION: |
|
|
|
|
|
|
|
Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYBALLMOTION: |
|
|
|
|
|
|
|
Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYHATMOTION: |
|
|
|
|
|
|
|
Joy_HatMotionEvent( event->jhat.hat, event->jhat.value ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYBUTTONDOWN: |
|
|
|
|
|
|
|
case SDL_JOYBUTTONUP: |
|
|
|
|
|
|
|
Joy_ButtonEvent( event->jbutton.button, event->jbutton.state ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_JOYDEVICEADDED: |
|
|
|
case SDL_JOYDEVICEADDED: |
|
|
|
Joy_AddEvent(); |
|
|
|
Joy_AddEvent(); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -508,10 +534,6 @@ static void SDLash_EventFilter( SDL_Event *event ) |
|
|
|
Joy_RemoveEvent( ); |
|
|
|
Joy_RemoveEvent( ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case SDL_QUIT: |
|
|
|
|
|
|
|
Sys_Quit(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SDL_WINDOWEVENT: |
|
|
|
case SDL_WINDOWEVENT: |
|
|
|
if( event->window.windowID != SDL_GetWindowID( host.hWnd ) ) |
|
|
|
if( event->window.windowID != SDL_GetWindowID( host.hWnd ) ) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -540,47 +562,35 @@ static void SDLash_EventFilter( SDL_Event *event ) |
|
|
|
VID_SetMode(); |
|
|
|
VID_SetMode(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SDL_WINDOWEVENT_FOCUS_GAINED: |
|
|
|
case SDL_WINDOWEVENT_FOCUS_GAINED: |
|
|
|
host.status = HOST_FRAME; |
|
|
|
SDLash_ActiveEvent( true ); |
|
|
|
IN_ActivateMouse(true); |
|
|
|
|
|
|
|
if( snd_mute_losefocus->value ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SNDDMA_Activate( true ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
host.force_draw_version = true; |
|
|
|
|
|
|
|
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; |
|
|
|
|
|
|
|
if( vid_fullscreen->value ) |
|
|
|
|
|
|
|
VID_SetMode(); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case SDL_WINDOWEVENT_FOCUS_LOST: |
|
|
|
case SDL_WINDOWEVENT_FOCUS_LOST: |
|
|
|
#if TARGET_OS_IPHONE |
|
|
|
SDLash_ActiveEvent( false ); |
|
|
|
{ |
|
|
|
|
|
|
|
// Keep running if ftp server enabled
|
|
|
|
|
|
|
|
void IOS_StartBackgroundTask( void ); |
|
|
|
|
|
|
|
IOS_StartBackgroundTask(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
host.status = HOST_NOFOCUS; |
|
|
|
|
|
|
|
IN_DeactivateMouse(); |
|
|
|
|
|
|
|
if( snd_mute_losefocus->value ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SNDDMA_Activate( false ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
host.force_draw_version = true; |
|
|
|
|
|
|
|
host.force_draw_version_time = host.realtime + 2; |
|
|
|
|
|
|
|
VID_RestoreScreenResolution(); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case SDL_WINDOWEVENT_RESIZED: |
|
|
|
case SDL_WINDOWEVENT_RESIZED: |
|
|
|
|
|
|
|
case SDL_WINDOWEVENT_MAXIMIZED: |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT; |
|
|
|
if( vid_fullscreen->value ) |
|
|
|
if( vid_fullscreen->value ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
VID_SaveWindowSize( event->window.data1, event->window.data2 ); |
|
|
|
SDL_GL_GetDrawableSize( host.hWnd, &w, &h ); |
|
|
|
SCR_VidInit(); // tell the client.dll what vid_mode has changed
|
|
|
|
R_SaveVideoMode( w, h ); |
|
|
|
|
|
|
|
SCR_VidInit(); // tell the client.dll that vid_mode has changed
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
case SDL_VIDEORESIZE: |
|
|
|
|
|
|
|
R_SaveVideoMode( event->resize.w, event->resize.h ); |
|
|
|
|
|
|
|
SCR_VidInit(); |
|
|
|
|
|
|
|
break; // tell the client.dll that vid_mode has changed
|
|
|
|
|
|
|
|
case SDL_ACTIVEEVENT: |
|
|
|
|
|
|
|
SDLash_ActiveEvent( event->active.gain ); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|