case SDLK_KP_PLUS: return K_KP_PLUS;
case SDLK_KP_ENTER: return K_KP_ENTER;
#if SDL_MAJOR_VERSION == 1
- case SDLK_KP_1: return K_KP_1;
- case SDLK_KP_2: return K_KP_2;
- case SDLK_KP_3: return K_KP_3;
- case SDLK_KP_4: return K_KP_4;
+ case SDLK_KP_1: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_1 : K_END);
+ case SDLK_KP_2: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_2 : K_DOWNARROW);
+ case SDLK_KP_3: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_3 : K_PGDN);
+ case SDLK_KP_4: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_4 : K_LEFTARROW);
case SDLK_KP_5: return K_KP_5;
- case SDLK_KP_6: return K_KP_6;
- case SDLK_KP_7: return K_KP_7;
- case SDLK_KP_8: return K_KP_8;
- case SDLK_KP_9: return K_KP_9;
- case SDLK_KP_0: return K_KP_0;
+ case SDLK_KP_6: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_6 : K_RIGHTARROW);
+ case SDLK_KP_7: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_7 : K_HOME);
+ case SDLK_KP_8: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_8 : K_UPARROW);
+ case SDLK_KP_9: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_9 : K_PGUP);
+ case SDLK_KP_0: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_0 : K_INS);
#endif
- case SDLK_KP_PERIOD: return K_KP_PERIOD;
+ case SDLK_KP_PERIOD: return ((SDL_GetModState() & KMOD_NUM) ? K_KP_PERIOD : K_DEL);
// case SDLK_APPLICATION: return K_APPLICATION;
// case SDLK_POWER: return K_POWER;
case SDLK_KP_EQUALS: return K_KP_EQUALS;
case SDL_KEYUP:
keycode = MapKey(event.key.keysym.sym);
if (!VID_JoyBlockEmulatedKeys(keycode))
+ {
+ if(keycode == K_NUMLOCK || keycode == K_CAPSLOCK)
+ {
+ // simulate down followed by up
+ Key_Event(keycode, event.key.keysym.unicode, true);
+ Key_Event(keycode, event.key.keysym.unicode, false);
+ break;
+ }
Key_Event(keycode, event.key.keysym.unicode, (event.key.state == SDL_PRESSED));
+ }
break;
case SDL_ACTIVEEVENT:
if( event.active.state & SDL_APPACTIVE )
//void VID_MenuDraw (void);
//void VID_MenuKey (int key);
-//LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-//void AppActivate(BOOL fActive, BOOL minimize);
-//void ClearAllStates (void);
-//void VID_UpdateWindowStatus (void);
+LONG WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+void AppActivate(BOOL fActive, BOOL minimize);
+static void ClearAllStates(void);
+qboolean VID_InitModeGL(viddef_mode_t *mode);
+qboolean VID_InitModeSOFT(viddef_mode_t *mode);
//====================================
//==========================================================================
-
-
static unsigned char scantokey[128] =
{
-// 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 0 ,27 ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,K_BACKSPACE,9 ,//0
- 'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,'o' ,'p' ,'[' ,']' ,13 ,K_CTRL ,'a' ,'s' ,//1
- 'd' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,'\'' ,'`' ,K_SHIFT ,'\\' ,'z' ,'x' ,'c' ,'v' ,//2
- 'b' ,'n' ,'m' ,',' ,'.' ,'/' ,K_SHIFT,'*' ,K_ALT ,' ' ,0 ,K_F1 ,K_F2 ,K_F3 ,K_F4 ,K_F5 ,//3
- K_F6 ,K_F7 ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0 ,K_HOME,K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5,K_RIGHTARROW,K_KP_PLUS ,K_END,//4
- K_DOWNARROW,K_PGDN,K_INS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return result;
+
switch ( result )
{
case K_HOME:
}
else
{
+ if(virtualkey == VK_NUMLOCK)
+ return K_NUMLOCK;
+
switch ( result )
{
case 0x0D:
LONG lRet = 1;
int fActive, fMinimized, temp;
unsigned char state[256];
- unsigned char asciichar[4];
+ const unsigned int UNICODE_BUFFER_LENGTH = 4;
+ WCHAR unicode[UNICODE_BUFFER_LENGTH];
int vkey;
int charlength;
qboolean down = false;
GetKeyboardState (state);
// alt/ctrl/shift tend to produce funky ToAscii values,
// and if it's not a single character we don't know care about it
- charlength = ToAscii (wParam, lParam >> 16, state, (LPWORD)asciichar, 0);
- if (vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || charlength == 0)
- asciichar[0] = 0;
- else if( charlength == 2 ) {
- asciichar[0] = asciichar[1];
- }
+ charlength = ToUnicode(wParam, lParam >> 16, state, unicode, UNICODE_BUFFER_LENGTH, 0);
+ if(vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || charlength == 0)
+ unicode[0] = 0;
+ else if(charlength == 2)
+ unicode[0] = unicode[1];
if (!VID_JoyBlockEmulatedKeys(vkey))
- Key_Event (vkey, asciichar[0], down);
+ Key_Event(vkey, unicode[0], down);
break;
case WM_SYSCHAR: