]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
made K_MOUSE4/5 keys separate from K_MWHEELUP/DOWN keys
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Nov 2005 05:54:20 +0000 (05:54 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Nov 2005 05:54:20 +0000 (05:54 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5846 d7cf8633-e32d-0410-b094-e92efae38249

keys.h
vid_glx.c
vid_sdl.c
vid_wgl.c

diff --git a/keys.h b/keys.h
index 343b3112fabe00237267897314785df3b52a6aa6..51d0691b24e41ce82e2e3e14fc78868dda5194ea 100644 (file)
--- 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,
index 80fa95abbf7d3cf69df929a394ae6a04b5a1d447..cc503fda5e474a92d26b2b52e18a40d0c5fac42e 100644 (file)
--- 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:
index 4906819bc2b362b0fd5e03b530cf5d214700d42b..2580104f1b6e16f385bb37d3b550606c2d71fe76 100644 (file)
--- 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;
                }
 }
index ab04857b0274d7519a9e4fcbdd619660492c5736..8c1180084e5fe19ddcb4624e63459b50b8473bbe 100644 (file)
--- 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<mouse_buttons ; i++)
+                               for (i=0 ; i<mouse_buttons && i < 16 ; i++)
                                        if ((temp ^ mouse_oldbuttonstate) & (1<<i))
-                                               Key_Event (K_MOUSE1 + i, 0, (temp & (1<<i)) != 0);
+                                               Key_Event (buttonremap[i], 0, (temp & (1<<i)) != 0);
                                mouse_oldbuttonstate = temp;
                        }
 
@@ -1265,9 +1285,9 @@ static void IN_MouseMove (void)
                }
 
                // perform button actions
-               for (i=0 ; i<mouse_buttons ; i++)
+               for (i=0 ; i<mouse_buttons && i < 16 ; i++)
                        if ((mstate_di ^ mouse_oldbuttonstate) & (1<<i))
-                               Key_Event (K_MOUSE1 + i, 0, (mstate_di & (1<<i)) != 0);
+                               Key_Event (buttonremap[i], 0, (mstate_di & (1<<i)) != 0);
                mouse_oldbuttonstate = mstate_di;
 
                in_mouse_x = mx;