diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-21 09:56:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-21 09:56:43 +0400 |
commit | ad7fab49d4346315cdb3db4bd087714ae45ffc89 (patch) | |
tree | 7b8fef32d77516f4873fd51915d1783bb1aa8016 /intern | |
parent | e7abdd7d56256b57d9e33326af253188ed9d96dc (diff) |
5 button mouse support from b333rt in IRC with some edits for X11.
Tested in X11 where its fairly confusing.
buttons 4 and 5 are used for the wheel which is well known, but it seems 6 and 7 are used for horizontal scrolling, my mouse assigns the extra 2 buttons to events 8 & 9.
So the X11 events used for buttons called 4&5 in blender are 8&9 in X11.
The mouse buttons can be re-ordered like this once xorg starts (swaps 6,7 with 8,9)
xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"
Couldn't test Win32, Apple not supported.
If someone wants to add horizontal scrolling its quite easy.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/GHOST_Types.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 34 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 7 |
3 files changed, 41 insertions, 2 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 73ed0bdd1fa..31819f341a0 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -132,6 +132,8 @@ typedef enum { GHOST_kButtonMaskLeft = 0, GHOST_kButtonMaskMiddle, GHOST_kButtonMaskRight, + GHOST_kButtonMaskButton4, + GHOST_kButtonMaskButton5, GHOST_kButtonNumMasks } GHOST_TButtonMask; diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 8513d056795..2e89be40bcb 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -39,7 +39,6 @@ #endif #include "GHOST_SystemWin32.h" -//#include <stdio.h> //for printf() // win64 doesn't define GWL_USERDATA #ifdef WIN32 @@ -61,6 +60,23 @@ #define WHEEL_DELTA 120 /* Value for rolling one detent, (old convention! MS changed it) */ #endif // WHEEL_DELTA +/* + * Defines for mouse buttons 4 and 5 aka xbutton1 and xbutton2. + * MSDN: Declared in Winuser.h, include Windows.h + * This does not seem to work with MinGW so we define our own here. + */ +#ifndef XBUTTON1 +#define XBUTTON1 0x0001 +#endif // XBUTTON1 +#ifndef XBUTTON2 +#define XBUTTON2 0x0002 +#endif // XBUTTON2 +#ifndef WM_XBUTTONUP +#define WM_XBUTTONUP 524 +#endif // WM_XBUTTONUP +#ifndef WM_XBUTTONDOWN +#define WM_XBUTTONDOWN 523 +#endif // WM_XBUTTONDOWN #include "GHOST_Debug.h" #include "GHOST_DisplayManagerWin32.h" @@ -672,6 +688,14 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, window->registerMouseClickEvent(true); event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskRight); break; + case WM_XBUTTONDOWN: + window->registerMouseClickEvent(true); + if ((short) HIWORD(wParam) == XBUTTON1){ + event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton4); + }else if((short) HIWORD(wParam) == XBUTTON2){ + event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskButton5); + } + break; case WM_LBUTTONUP: window->registerMouseClickEvent(false); event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft); @@ -684,6 +708,14 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, window->registerMouseClickEvent(false); event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskRight); break; + case WM_XBUTTONUP: + window->registerMouseClickEvent(false); + if ((short) HIWORD(wParam) == XBUTTON1){ + event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton4); + }else if((short) HIWORD(wParam) == XBUTTON2){ + event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskButton5); + } + break; case WM_MOUSEMOVE: event = processCursorEvent(GHOST_kEventCursorMove, window); break; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 9f6f3b4d5b0..cdbdce9c2ca 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -444,10 +444,15 @@ GHOST_SystemX11::processEvent(XEvent *xe) XButtonEvent & xbe = xe->xbutton; GHOST_TButtonMask gbmask = GHOST_kButtonMaskLeft; - switch (xbe.button) { case Button1 : gbmask = GHOST_kButtonMaskLeft; break; case Button3 : gbmask = GHOST_kButtonMaskRight; break; + /* It seems events 6 and 7 are for horizontal scrolling. + * you can re-order button mapping like this... (swaps 6,7 with 8,9) + * xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7" + */ + case 8 : gbmask = GHOST_kButtonMaskButton4; break; /* Button4 is the wheel */ + case 9 : gbmask = GHOST_kButtonMaskButton5; break; /* Button5 is a wheel too */ default: case Button2 : gbmask = GHOST_kButtonMaskMiddle; break; } |