summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2007-12-20 08:22:52 +0000
committerAndrey Nazarov <skuller@skuller.net>2007-12-20 08:22:52 +0000
commit0817feeab90886b7c4379bc9fa54f67154c40172 (patch)
treee2e70640031471364e754b73d3e5f8cfc06e3e9d
parentd79575b7dee3903b73316b4e2bf1cceb693b983b (diff)
Added support for left/right SHIFT, CTRL, ALT modifiers on Windows.
ALT key now works as expected on Windows (do not pass WM_SYSKEYDOW to DefWindowProc). Updated revision to 168.
-rwxr-xr-xconfigure2
-rw-r--r--source/cl_keys.c2
-rw-r--r--source/cl_null.c2
-rw-r--r--source/com_local.h2
-rw-r--r--source/vid_win.c42
5 files changed, 35 insertions, 15 deletions
diff --git a/configure b/configure
index 7d9a9ba..7a32283 100755
--- a/configure
+++ b/configure
@@ -54,7 +54,7 @@ histfile=".conhistory"
democache=".democache"
screenshots="screenshots"
scoreshots="scoreshots"
-revision="167"
+revision="168"
tmpc="/tmp/q2pro-${RANDOM}.c"
tmpo="/tmp/q2pro-${RANDOM}.o"
diff --git a/source/cl_keys.c b/source/cl_keys.c
index 9354be3..ed1ca00 100644
--- a/source/cl_keys.c
+++ b/source/cl_keys.c
@@ -639,7 +639,7 @@ Called by the system between frames for both key up and key down events
Should NOT be called during an interrupt!
===================
*/
-void Key_Event( uint32 key, qboolean down, uint32 time ) {
+void Key_Event( unsigned key, qboolean down, unsigned time ) {
char *kb;
char cmd[MAX_STRING_CHARS];
diff --git a/source/cl_null.c b/source/cl_null.c
index 62df58a..278b857 100644
--- a/source/cl_null.c
+++ b/source/cl_null.c
@@ -98,7 +98,7 @@ void CL_AppActivate( qboolean active ) {
void Key_WriteBindings( fileHandle_t f ) {
}
-void Key_Event( uint32 key, qboolean down, uint32 time ) {
+void Key_Event( unsigned key, qboolean down, unsigned time ) {
}
void Key_CharEvent( int key ) {
diff --git a/source/com_local.h b/source/com_local.h
index 60466ef..e52f391 100644
--- a/source/com_local.h
+++ b/source/com_local.h
@@ -1059,7 +1059,7 @@ void CL_AppActivate( qboolean active );
void CL_UpdateUserinfo( cvar_t *var, cvarSetSource_t source );
void Key_Init( void );
-void Key_Event( uint32 key, qboolean down, uint32 time );
+void Key_Event( unsigned key, qboolean down, unsigned time );
void Key_CharEvent( int key );
void Key_WriteBindings( fileHandle_t f );
diff --git a/source/vid_win.c b/source/vid_win.c
index 901e485..38f6abe 100644
--- a/source/vid_win.c
+++ b/source/vid_win.c
@@ -375,8 +375,8 @@ static byte scantokey[128] = {
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
'o', 'p', '[', ']', K_ENTER, 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_LSHIFT, '\\', 'z', 'x', 'c', 'v', // 2
+ 'b', 'n', 'm', ',', '.', '/', K_RSHIFT, '*',
K_ALT, K_SPACE, K_CAPSLOCK, K_F1, K_F2, K_F3, K_F4, K_F5, // 3
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE, K_SCROLLOCK, K_HOME,
K_UPARROW, K_PGUP, K_KP_MINUS, K_LEFTARROW, K_KP_5, K_RIGHTARROW, K_KP_PLUS, K_END, // 4
@@ -396,18 +396,14 @@ Map from windows to quake keynums
=======
*/
static void Win_KeyEvent( WPARAM wParam, LPARAM lParam, qboolean down ) {
- uint32 result;
- uint32 scancode = ( lParam >> 16 ) & 255;
- qboolean is_extended = qfalse;
+ unsigned result;
+ unsigned scancode = ( lParam >> 16 ) & 255;
+ unsigned is_extended = ( lParam >> 24 ) & 1;
if( scancode > 127 ) {
return;
}
- if( lParam & ( 1 << 24 ) ) {
- is_extended = qtrue;
- }
-
result = scantokey[scancode];
if( !result ) {
Com_DPrintf( "Win_KeyEvent: unknown scancode %u\n", scancode );
@@ -446,6 +442,22 @@ static void Win_KeyEvent( WPARAM wParam, LPARAM lParam, qboolean down ) {
case K_DEL:
result = K_KP_DEL;
break;
+ case K_LSHIFT:
+ Key_Event( K_SHIFT, down, win.lastMsgTime );
+ Key_Event( K_LSHIFT, down, win.lastMsgTime );
+ return;
+ case K_RSHIFT:
+ Key_Event( K_SHIFT, down, win.lastMsgTime );
+ Key_Event( K_RSHIFT, down, win.lastMsgTime );
+ return;
+ case K_ALT:
+ Key_Event( K_ALT, down, win.lastMsgTime );
+ Key_Event( K_LALT, down, win.lastMsgTime );
+ return;
+ case K_CTRL:
+ Key_Event( K_CTRL, down, win.lastMsgTime );
+ Key_Event( K_LCTRL, down, win.lastMsgTime );
+ return;
}
} else {
switch( result ) {
@@ -458,6 +470,14 @@ static void Win_KeyEvent( WPARAM wParam, LPARAM lParam, qboolean down ) {
case 0xAF:
result = K_KP_PLUS;
break;
+ case K_ALT:
+ Key_Event( K_ALT, down, win.lastMsgTime );
+ Key_Event( K_RALT, down, win.lastMsgTime );
+ return;
+ case K_CTRL:
+ Key_Event( K_CTRL, down, win.lastMsgTime );
+ Key_Event( K_RCTRL, down, win.lastMsgTime );
+ return;
}
}
@@ -650,7 +670,7 @@ LONG WINAPI Win_MainWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
Win_KeyEvent( wParam, lParam, qtrue );
- break;
+ return FALSE;
#ifdef USE_CHAR_EVENTS
case WM_CHAR:
@@ -661,7 +681,7 @@ LONG WINAPI Win_MainWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WM_SYSKEYUP:
case WM_KEYUP:
Win_KeyEvent( wParam, lParam, qfalse );
- break;
+ return FALSE;
default:
break;