From 7a326060eaf7fee38b91dd9dfb6bf10bcad7e108 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 28 Nov 2005 05:54:20 +0000 Subject: [PATCH] made K_MOUSE4/5 keys separate from K_MWHEELUP/DOWN keys git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5846 d7cf8633-e32d-0410-b094-e92efae38249 --- keys.h | 4 +- vid_glx.c | 114 ++++++++++++++---------------------------------------- vid_sdl.c | 34 +++++++++++----- vid_wgl.c | 28 ++++++++++++-- 4 files changed, 80 insertions(+), 100 deletions(-) diff --git a/keys.h b/keys.h index 343b3112..51d0691b 100644 --- a/keys.h +++ b/keys.h @@ -109,10 +109,10 @@ extern enum keynum_e K_MOUSE1 = 512, K_MOUSE2, K_MOUSE3, + K_MWHEELUP, + K_MWHEELDOWN, K_MOUSE4, - K_MWHEELUP = K_MOUSE4, K_MOUSE5, - K_MWHEELDOWN = K_MOUSE5, K_MOUSE6, K_MOUSE7, K_MOUSE8, diff --git a/vid_glx.c b/vid_glx.c index 80fa95ab..cc503fda 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -316,6 +316,28 @@ static void IN_Activate (qboolean grab) } } +static keynum_t buttonremap[18] = +{ + K_MOUSE1, + K_MOUSE3, + K_MOUSE2, + K_MWHEELUP, + K_MWHEELDOWN, + K_MOUSE4, + K_MOUSE5, + K_MOUSE6, + K_MOUSE7, + K_MOUSE8, + K_MOUSE9, + K_MOUSE10, + K_MOUSE11, + K_MOUSE12, + K_MOUSE13, + K_MOUSE14, + K_MOUSE15, + K_MOUSE16, +}; + static void HandleEvents(void) { XEvent event; @@ -375,94 +397,18 @@ static void HandleEvents(void) case ButtonPress: // mouse button pressed - switch(event.xbutton.button) - { - case 1: - Key_Event(K_MOUSE1, 0, true); - break; - case 2: - Key_Event(K_MOUSE3, 0, true); - break; - case 3: - Key_Event(K_MOUSE2, 0, true); - break; - case 4: - Key_Event(K_MWHEELUP, 0, true); - break; - case 5: - Key_Event(K_MWHEELDOWN, 0, true); - break; - case 6: - Key_Event(K_MOUSE4, 0, true); - break; - case 7: - Key_Event(K_MOUSE5, 0, true); - break; - case 8: - Key_Event(K_MOUSE6, 0, true); - break; - case 9: - Key_Event(K_MOUSE7, 0, true); - break; - case 10: - Key_Event(K_MOUSE8, 0, true); - break; - case 11: - Key_Event(K_MOUSE9, 0, true); - break; - case 12: - Key_Event(K_MOUSE10, 0, true); - break; - default: - Con_Printf("HandleEvents: ButtonPress gave value %d, 1-12 expected\n", event.xbutton.button); - break; - } + if (event.xbutton.button <= 18) + Key_Event(buttonremap[event.xbutton.button - 1], 0, true); + else + Con_Printf("HandleEvents: ButtonPress gave value %d, 1-18 expected\n", event.xbutton.button); break; case ButtonRelease: // mouse button released - switch(event.xbutton.button) - { - case 1: - Key_Event(K_MOUSE1, 0, false); - break; - case 2: - Key_Event(K_MOUSE3, 0, false); - break; - case 3: - Key_Event(K_MOUSE2, 0, false); - break; - case 4: - Key_Event(K_MWHEELUP, 0, false); - break; - case 5: - Key_Event(K_MWHEELDOWN, 0, false); - break; - case 6: - Key_Event(K_MOUSE4, 0, false); - break; - case 7: - Key_Event(K_MOUSE5, 0, false); - break; - case 8: - Key_Event(K_MOUSE6, 0, false); - break; - case 9: - Key_Event(K_MOUSE7, 0, false); - break; - case 10: - Key_Event(K_MOUSE8, 0, false); - break; - case 11: - Key_Event(K_MOUSE9, 0, false); - break; - case 12: - Key_Event(K_MOUSE10, 0, false); - break; - default: - Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-12 expected\n", event.xbutton.button); - break; - } + if (event.xbutton.button <= 18) + Key_Event(buttonremap[event.xbutton.button - 1], 0, false); + else + Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-18 expected\n", event.xbutton.button); break; case CreateNotify: diff --git a/vid_sdl.c b/vid_sdl.c index 4906819b..2580104f 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -251,6 +251,26 @@ static int Sys_EventFilter( SDL_Event *event ) #endif } +static keynum_t buttonremap[16] = +{ + K_MOUSE1, + K_MOUSE3, + K_MOUSE2, + K_MOUSE4, + K_MOUSE5, + K_MOUSE6, + K_MOUSE7, + K_MOUSE8, + K_MOUSE9, + K_MOUSE10, + K_MOUSE11, + K_MOUSE12, + K_MOUSE13, + K_MOUSE14, + K_MOUSE15, + K_MOUSE16, +}; + void Sys_SendKeyEvents( void ) { SDL_Event event; @@ -274,18 +294,12 @@ void Sys_SendKeyEvents( void ) } break; case SDL_MOUSEBUTTONDOWN: - if( event.button.button == SDL_BUTTON_MIDDLE ) - event.button.button = SDL_BUTTON_RIGHT; - else if( event.button.button == SDL_BUTTON_RIGHT ) - event.button.button = SDL_BUTTON_MIDDLE; - Key_Event( K_MOUSE1 + event.button.button - 1, 0, true ); + if (event.button.button <= 16) + Key_Event( buttonremap[event.button.button - 1], 0, true ); break; case SDL_MOUSEBUTTONUP: - if( event.button.button == SDL_BUTTON_MIDDLE ) - event.button.button = SDL_BUTTON_RIGHT; - else if( event.button.button == SDL_BUTTON_RIGHT ) - event.button.button = SDL_BUTTON_MIDDLE; - Key_Event( K_MOUSE1 + event.button.button - 1, 0, false ); + if (event.button.button <= 16) + Key_Event( buttonremap[event.button.button - 1], 0, false ); break; } } diff --git a/vid_wgl.c b/vid_wgl.c index ab04857b..8c118008 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -469,6 +469,26 @@ void Sys_SendKeyEvents (void) LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static keynum_t buttonremap[16] = +{ + K_MOUSE1, + K_MOUSE2, + K_MOUSE3, + K_MOUSE4, + K_MOUSE5, + K_MOUSE6, + K_MOUSE7, + K_MOUSE8, + K_MOUSE9, + K_MOUSE10, + K_MOUSE11, + K_MOUSE12, + K_MOUSE13, + K_MOUSE14, + K_MOUSE15, + K_MOUSE16, +}; + /* main window procedure */ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -567,9 +587,9 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // perform button actions int i; - for (i=0 ; i