From: havoc Date: Sun, 20 Apr 2003 05:48:03 +0000 (+0000) Subject: thanks to "backslash" for submitting a patch to support Intellimouse Explorer's two... X-Git-Tag: xonotic-v0.1.0preview~6656 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=c8b10ff42dfa1208346879250f655c3fd2909704 thanks to "backslash" for submitting a patch to support Intellimouse Explorer's two extra buttons (side buttons), I expanded the patch to support up to 10 mouse buttons (plus mwheelup/mwheeldown) in both GLX and WGL ports. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2970 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/keys.c b/keys.c index b49e2ac1..e89ff178 100644 --- a/keys.c +++ b/keys.c @@ -90,6 +90,17 @@ keyname_t keynames[] = {"MOUSE1", K_MOUSE1}, {"MOUSE2", K_MOUSE2}, {"MOUSE3", K_MOUSE3}, + // LordHavoc: thanks to backslash for this MOUSE4 and MOUSE5 code + /* backslash :: imouse explorer buttons */ + {"MOUSE4", K_MOUSE4}, + {"MOUSE5", K_MOUSE5}, + /* :: backslash */ + // LordHavoc: added more for completeness + {"MOUSE6", K_MOUSE6}, + {"MOUSE7", K_MOUSE7}, + {"MOUSE8", K_MOUSE8}, + {"MOUSE9", K_MOUSE9}, + {"MOUSE10", K_MOUSE10}, {"JOY1", K_JOY1}, {"JOY2", K_JOY2}, diff --git a/keys.h b/keys.h index 37141c0b..9e85a321 100644 --- a/keys.h +++ b/keys.h @@ -77,13 +77,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define K_PAUSE 255 -// -// mouse buttons generate virtual keys -// -#define K_MOUSE1 200 -#define K_MOUSE2 201 -#define K_MOUSE3 202 - // // joystick buttons // @@ -132,6 +125,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define K_MWHEELDOWN 239 #define K_MWHEELUP 240 +// +// mouse buttons generate virtual keys +// +#define K_MOUSE1 241 +#define K_MOUSE2 242 +#define K_MOUSE3 243 +// LordHavoc: thanks to backslash for this MOUSE4 and MOUSE5 code, +// LordHavoc: however I renumbered it differently and added MOUSE6 through MOUSE10 +/* backslash :: imouse explorer buttons */ +#define K_MOUSE4 244 +#define K_MOUSE5 245 +/* backslash :: renumber everything that follows so that the mouse4/5 buttons can be squeezed in */ +// LordHavoc: added these for completeness +#define K_MOUSE6 246 +#define K_MOUSE7 247 +#define K_MOUSE8 248 +#define K_MOUSE9 249 +#define K_MOUSE10 250 + + extern char *keybindings[256]; extern int key_repeats[256]; diff --git a/vid_glx.c b/vid_glx.c index 800b46c1..f6b67a64 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -381,8 +381,29 @@ static void HandleEvents(void) case 5: Key_Event(K_MWHEELDOWN, true); break; + case 6: + Key_Event(K_MOUSE4, true); + break; + case 7: + Key_Event(K_MOUSE5, true); + break; + case 8: + Key_Event(K_MOUSE6, true); + break; + case 9: + Key_Event(K_MOUSE7, true); + break; + case 10: + Key_Event(K_MOUSE8, true); + break; + case 11: + Key_Event(K_MOUSE9, true); + break; + case 12: + Key_Event(K_MOUSE10, true); + break; default: - Con_Printf("HandleEvents: ButtonPress gave value %d, 1-5 expected\n", event.xbutton.button); + Con_Printf("HandleEvents: ButtonPress gave value %d, 1-12 expected\n", event.xbutton.button); break; } break; @@ -406,8 +427,29 @@ static void HandleEvents(void) case 5: Key_Event(K_MWHEELDOWN, false); break; + case 6: + Key_Event(K_MOUSE4, false); + break; + case 7: + Key_Event(K_MOUSE5, false); + break; + case 8: + Key_Event(K_MOUSE6, false); + break; + case 9: + Key_Event(K_MOUSE7, false); + break; + case 10: + Key_Event(K_MOUSE8, false); + break; + case 11: + Key_Event(K_MOUSE9, false); + break; + case 12: + Key_Event(K_MOUSE10, false); + break; default: - Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-5 expected\n", event.xbutton.button); + Con_Printf("HandleEvents: ButtonRelease gave value %d, 1-12 expected\n", event.xbutton.button); break; } break; diff --git a/vid_wgl.c b/vid_wgl.c index 36787132..29091695 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -110,6 +110,26 @@ static qboolean dinput; HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter); +// LordHavoc: thanks to backslash for this support for mouse buttons 4 and 5 +/* backslash :: imouse explorer buttons */ +/* These are #ifdefed out for non-Win2K in the February 2001 version of + MS's platform SDK, but we need them for compilation. . . */ +#ifndef WM_XBUTTONDOWN + #define WM_XBUTTONDOWN 0x020B + #define WM_XBUTTONUP 0x020C +#endif +#ifndef MK_XBUTTON1 + #define MK_XBUTTON1 0x0020 + #define MK_XBUTTON2 0x0040 +// LordHavoc: lets hope this allows more buttons in the future... + #define MK_XBUTTON3 0x0080 + #define MK_XBUTTON4 0x0100 + #define MK_XBUTTON5 0x0200 + #define MK_XBUTTON6 0x0400 + #define MK_XBUTTON7 0x0800 +#endif +/* :: backslash */ + // mouse variables int mouse_buttons; int mouse_oldbuttonstate; @@ -536,6 +556,8 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: + case WM_XBUTTONDOWN: // backslash :: imouse explorer buttons + case WM_XBUTTONUP: // backslash :: imouse explorer buttons case WM_MOUSEMOVE: temp = 0; @@ -548,6 +570,26 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (wParam & MK_MBUTTON) temp |= 4; + /* backslash :: imouse explorer buttons */ + if (wParam & MK_XBUTTON1) + temp |= 8; + + if (wParam & MK_XBUTTON2) + temp |= 16; + /* :: backslash */ + + // LordHavoc: lets hope this allows more buttons in the future... + if (wParam & MK_XBUTTON3) + temp |= 32; + if (wParam & MK_XBUTTON4) + temp |= 64; + if (wParam & MK_XBUTTON5) + temp |= 128; + if (wParam & MK_XBUTTON6) + temp |= 256; + if (wParam & MK_XBUTTON7) + temp |= 512; + IN_MouseEvent (temp); break; @@ -1216,7 +1258,7 @@ void IN_StartupMouse (void) } } - mouse_buttons = 3; + mouse_buttons = 10; // if a fullscreen video mode was set before the mouse was initialized, // set the mouse state appropriately