hw/xwin: Map extra mouse buttons 1 and 2 to X buttons 8 and 9
Map extra mouse buttons 1 and 2 to X buttons 8 and 9, as conventional, leaving X buttons 6 and 7 for tilt wheel. Also add button labels for buttons 6, 7, 8 and 9 and change btn_labels in from a dynamic allocation to a fixed one of the required size for all the labels we use. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
c9d7b9516f
commit
cf9c777ee0
|
@ -65,10 +65,10 @@ int
|
||||||
winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||||
{
|
{
|
||||||
int lngMouseButtons, i;
|
int lngMouseButtons, i;
|
||||||
int lngWheelEvents = 2;
|
int lngWheelEvents = 4;
|
||||||
CARD8 *map;
|
CARD8 *map;
|
||||||
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
DevicePtr pDevice = (DevicePtr) pDeviceInt;
|
||||||
Atom *btn_labels;
|
Atom btn_labels[9];
|
||||||
Atom axes_labels[2];
|
Atom axes_labels[2];
|
||||||
|
|
||||||
switch (iState) {
|
switch (iState) {
|
||||||
|
@ -80,15 +80,23 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||||
/* Mapping of windows events to X events:
|
/* Mapping of windows events to X events:
|
||||||
* LEFT:1 MIDDLE:2 RIGHT:3
|
* LEFT:1 MIDDLE:2 RIGHT:3
|
||||||
* SCROLL_UP:4 SCROLL_DOWN:5
|
* SCROLL_UP:4 SCROLL_DOWN:5
|
||||||
* XBUTTON 1:6 XBUTTON 2:7 ...
|
* TILT_LEFT:6 TILT_RIGHT:7
|
||||||
|
* XBUTTON 1:8 XBUTTON 2:9 (most commonly 'back' and 'forward')
|
||||||
|
* ...
|
||||||
*
|
*
|
||||||
|
* The current Windows API only defines 2 extra buttons, so we don't
|
||||||
|
* expect more than 5 buttons to be reported, but more than that
|
||||||
|
* should be handled correctly
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* To map scroll wheel correctly we need at least the 3 normal buttons
|
* To map scroll wheel correctly we need at least the 3 normal buttons
|
||||||
*/
|
*/
|
||||||
if (lngMouseButtons < 3)
|
if (lngMouseButtons < 3)
|
||||||
lngMouseButtons = 3;
|
lngMouseButtons = 3;
|
||||||
|
|
||||||
/* allocate memory:
|
/* allocate memory:
|
||||||
* number of buttons + 2x mouse wheel event + 1 extra (offset for map)
|
* number of buttons + 4 x mouse wheel event + 1 extra (offset for map)
|
||||||
*/
|
*/
|
||||||
map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
|
map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
|
||||||
|
|
||||||
|
@ -97,12 +105,15 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||||
for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++)
|
for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++)
|
||||||
map[i] = i;
|
map[i] = i;
|
||||||
|
|
||||||
btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
|
|
||||||
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
||||||
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
||||||
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
||||||
btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
|
btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
|
||||||
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
|
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
|
||||||
|
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
|
||||||
|
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
|
||||||
|
btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK);
|
||||||
|
btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD);
|
||||||
|
|
||||||
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
||||||
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
||||||
|
@ -114,7 +125,6 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState)
|
||||||
winMouseCtrl,
|
winMouseCtrl,
|
||||||
GetMotionHistorySize(), 2, axes_labels);
|
GetMotionHistorySize(), 2, axes_labels);
|
||||||
free(map);
|
free(map);
|
||||||
free(btn_labels);
|
|
||||||
|
|
||||||
g_winMouseButtonMap = pDeviceInt->button->map;
|
g_winMouseButtonMap = pDeviceInt->button->map;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -661,7 +661,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
|
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
|
||||||
break;
|
break;
|
||||||
SetCapture(hwnd);
|
SetCapture(hwnd);
|
||||||
return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 5,
|
return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 7,
|
||||||
wParam);
|
wParam);
|
||||||
|
|
||||||
case WM_XBUTTONUP:
|
case WM_XBUTTONUP:
|
||||||
|
@ -670,7 +670,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
winStartMousePolling(s_pScreenPriv);
|
winStartMousePolling(s_pScreenPriv);
|
||||||
return winMouseButtonsHandle(s_pScreen, ButtonRelease,
|
return winMouseButtonsHandle(s_pScreen, ButtonRelease,
|
||||||
HIWORD(wParam) + 5, wParam);
|
HIWORD(wParam) + 7, wParam);
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
if (SendMessage
|
if (SendMessage
|
||||||
|
|
|
@ -649,13 +649,13 @@ winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
|
if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
|
||||||
break;
|
break;
|
||||||
SetCapture(hwnd);
|
SetCapture(hwnd);
|
||||||
return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 5,
|
return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 7,
|
||||||
wParam);
|
wParam);
|
||||||
case WM_XBUTTONUP:
|
case WM_XBUTTONUP:
|
||||||
if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
|
if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
|
||||||
break;
|
break;
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 5,
|
return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 7,
|
||||||
wParam);
|
wParam);
|
||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
|
|
|
@ -894,7 +894,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
SetCapture(hwnd);
|
SetCapture(hwnd);
|
||||||
return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 5,
|
return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 7,
|
||||||
wParam);
|
wParam);
|
||||||
case WM_XBUTTONUP:
|
case WM_XBUTTONUP:
|
||||||
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
|
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
|
||||||
|
@ -906,7 +906,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
)
|
)
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
return winMouseButtonsHandle(s_pScreen, ButtonRelease,
|
return winMouseButtonsHandle(s_pScreen, ButtonRelease,
|
||||||
HIWORD(wParam) + 5, wParam);
|
HIWORD(wParam) + 7, wParam);
|
||||||
|
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
|
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user