summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-06-16 16:38:11 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-06-18 14:41:47 +1000
commita30fef9956b296f59ea18a9ee38d0abafeb15a4e (patch)
treeea0fc578946cf668ef0f1f7b8196c915f0e93b19 /hw
parent17f9723f488d0470e3879c6b0dfdba61544cdd7b (diff)
input: Add labels to buttons and valuators - ABI_XINPUT_VERSION 7
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'hw')
-rw-r--r--hw/kdrive/src/kinput.c45
-rw-r--r--hw/vfb/InitInput.c24
-rw-r--r--hw/xfree86/common/xf86Module.h2
-rw-r--r--hw/xfree86/common/xf86Xinput.c4
-rw-r--r--hw/xfree86/common/xf86Xinput.h2
-rw-r--r--hw/xnest/Pointer.c20
-rw-r--r--hw/xquartz/darwin.c67
-rw-r--r--hw/xwin/winmouse.c20
8 files changed, 157 insertions, 27 deletions
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 740852ee0..5e7ff5376 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -46,6 +46,7 @@
#include "exevents.h"
#include "extinit.h"
#include "exglobals.h"
+#include "xserver-properties.h"
#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
@@ -382,6 +383,8 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
DevicePtr pDev = (DevicePtr)pDevice;
KdPointerInfo *pi;
Atom xiclass;
+ Atom *btn_labels;
+ Atom *axes_labels;
if (!pDev)
return BadImplementation;
@@ -429,9 +432,47 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return !Success;
}
- InitPointerDeviceStruct(pDev, pi->map, pi->nButtons,
+ btn_labels = xcalloc(pi->nButtons, sizeof(Atom));
+ if (!btn_labels)
+ return BadAlloc;
+ axes_labels = xcalloc(pi->nAxes, sizeof(Atom));
+ if (!axes_labels) {
+ xfree(btn_labels);
+ return BadAlloc;
+ }
+
+ switch(pi->nAxes)
+ {
+ default:
+ case 7:
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ case 6:
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ case 5:
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ case 4:
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ case 3:
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ case 2:
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ case 1:
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ case 0:
+ break;
+ }
+
+ if (pi->nAxes >= 2) {
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ }
+
+ InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
(PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), pi->nAxes);
+ GetMotionHistorySize(), pi->nAxes, axes_labels);
+
+ xfree(btn_labels);
+ xfree(axes_labels);
if (pi->inputClass == KD_TOUCHSCREEN) {
InitAbsoluteClassDeviceStruct(pDevice);
diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index 4c8c99653..7f2d56fa8 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -41,6 +41,8 @@ from The Open Group.
#include "lk201kbd.h"
#include "xkbsrv.h"
#include <X11/keysym.h>
+#include "xserver-properties.h"
+#include "exevents.h"
Bool
LegalModifier(unsigned int key, DeviceIntPtr pDev)
@@ -87,8 +89,13 @@ vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
static int
vfbMouseProc(DeviceIntPtr pDevice, int onoff)
{
- BYTE map[4];
+#define NBUTTONS 3
+#define NAXES 2
+
+ BYTE map[NBUTTONS + 1];
DevicePtr pDev = (DevicePtr)pDevice;
+ Atom btn_labels[NBUTTONS] = {0};
+ Atom axes_labels[NAXES] = {0};
switch (onoff)
{
@@ -96,8 +103,16 @@ vfbMouseProc(DeviceIntPtr pDevice, int onoff)
map[1] = 1;
map[2] = 2;
map[3] = 3;
- InitPointerDeviceStruct(pDev, map, 3,
- (PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2);
+
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+ InitPointerDeviceStruct(pDev, map, NBUTTONS, btn_labels,
+ (PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), NAXES, axes_labels);
break;
case DEVICE_ON:
@@ -112,6 +127,9 @@ vfbMouseProc(DeviceIntPtr pDevice, int onoff)
break;
}
return Success;
+
+#undef NBUTTONS
+#undef NAXES
}
void
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 5d36cecff..ded52162e 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(5, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(6, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(7, 0)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(2, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 39186ac9f..cb1e92090 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1010,13 +1010,13 @@ xf86XInputSetScreen(LocalDevicePtr local,
void
-xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
+xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
int resolution, int min_res, int max_res)
{
if (!dev || !dev->valuator)
return;
- InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution, min_res,
+ InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
max_res);
}
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 04c663faa..0ad56649b 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -171,7 +171,7 @@ extern _X_EXPORT LocalDevicePtr xf86FirstLocalDevice(void);
extern _X_EXPORT int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
extern _X_EXPORT void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);
extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, pointer options);
-extern _X_EXPORT void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval,
+extern _X_EXPORT void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
int maxval, int resolution, int min_res,
int max_res);
extern _X_EXPORT void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c
index 8f764a624..c5d361c63 100644
--- a/hw/xnest/Pointer.c
+++ b/hw/xnest/Pointer.c
@@ -33,6 +33,8 @@ is" without express or implied warranty.
#include "Pointer.h"
#include "Args.h"
+#include "xserver-properties.h"
+
DeviceIntPtr xnestPointerDevice = NULL;
void
@@ -46,6 +48,8 @@ int
xnestPointerProc(DeviceIntPtr pDev, int onoff)
{
CARD8 map[MAXBUTTONS];
+ Atom btn_labels[MAXBUTTONS] = {0};
+ Atom axes_labels[2] = {0};
int nmap;
int i;
@@ -55,9 +59,21 @@ xnestPointerProc(DeviceIntPtr pDev, int onoff)
nmap = XGetPointerMapping(xnestDisplay, map, MAXBUTTONS);
for (i = 0; i <= nmap; i++)
map[i] = i; /* buttons are already mapped */
- InitPointerDeviceStruct(&pDev->public, map, nmap,
+
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ 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);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+ InitPointerDeviceStruct(&pDev->public, map, nmap, btn_labels,
xnestChangePointerControl,
- GetMotionHistorySize(), 2);
+ GetMotionHistorySize(), 2, axes_labels);
break;
case DEVICE_ON:
xnestEventMask |= XNEST_POINTER_EVENT_MASK;
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index f01668201..fdbdfe48c 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -51,6 +51,8 @@
#include "exevents.h"
#include "extinit.h"
+#include "xserver-properties.h"
+
#include <sys/types.h>
#include <sys/time.h>
#include <sys/syslimits.h>
@@ -336,17 +338,35 @@ static Bool DarwinAddScreen(int index, ScreenPtr pScreen, int argc, char **argv)
* DarwinMouseProc: Handle the initialization, etc. of a mouse
*/
static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
+#define NBUTTONS 7
+#define NAXES 2
// 7 buttons: left, right, middle, then four scroll wheel "buttons"
- CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
-
+ CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3, 4, 5, 6, 7};
+ Atom btn_labels[NAXES] = {0};
+ Atom axes_labels[NBUTTONS] = {0};
+
switch (what) {
case DEVICE_INIT:
pPointer->public.on = FALSE;
-
+
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ 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);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+
// Set button map.
- InitPointerDeviceStruct((DevicePtr)pPointer, map, 7,
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
+ btn_labels,
(PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), 2);
+ GetMotionHistorySize(), NAXES,
+ axes_labels);
pPointer->valuator->mode = Absolute; // Relative
InitAbsoluteClassDeviceStruct(pPointer);
// InitValuatorAxisStruct(pPointer, 0, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
@@ -364,28 +384,43 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
}
return Success;
+#undef NBUTTONS
+#undef NAXES
}
static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
- CARD8 map[4] = {0, 1, 2, 3};
-
+#define NBUTTONS 3
+#define NAXES 5
+ CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3};
+ Atom axes_labels[NAXES] = {0};
+ Atom btn_labels[NBUTTONS] = {0};
+
switch (what) {
case DEVICE_INIT:
pPointer->public.on = FALSE;
-
+
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
+
// Set button map.
- InitPointerDeviceStruct((DevicePtr)pPointer, map, 3,
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
+ btn_labels,
(PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), 5);
+ GetMotionHistorySize(), NAXES,
+ axes_labels);
pPointer->valuator->mode = Absolute; // Relative
InitProximityClassDeviceStruct(pPointer);
InitAbsoluteClassDeviceStruct(pPointer);
- InitValuatorAxisStruct(pPointer, 0, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
- InitValuatorAxisStruct(pPointer, 1, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
- InitValuatorAxisStruct(pPointer, 2, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
- InitValuatorAxisStruct(pPointer, 3, -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
- InitValuatorAxisStruct(pPointer, 4, -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+ InitValuatorAxisStruct(pPointer, 0, axes_labels[0], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+ InitValuatorAxisStruct(pPointer, 1, axes_labels[1], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+ InitValuatorAxisStruct(pPointer, 2, axes_labels[2], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+ InitValuatorAxisStruct(pPointer, 3, axes_labels[3], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+ InitValuatorAxisStruct(pPointer, 4, axes_labels[4], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
// pPointer->use = IsXExtensionDevice;
break;
case DEVICE_ON:
@@ -399,6 +434,8 @@ static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
return Success;
}
return Success;
+#undef NBUTTONS
+#undef NAXES
}
/*
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 9cfc945f8..e6d891397 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -38,6 +38,8 @@
#if defined(XFree86Server)
#include "inputstr.h"
+#include "exevents.h" /* for button/axes labels */
+#include "xserver-properties.h"
/* Peek the internal button mapping */
static CARD8 const *g_winMouseButtonMap = NULL;
@@ -70,6 +72,8 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState)
int lngWheelEvents = 2;
CARD8 *map;
DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ Atom *btn_labels;
+ Atom axes_labels[2];
switch (iState)
{
@@ -97,13 +101,27 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState)
map[0] = 0;
for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
map[i] = i;
+
+ btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
InitPointerDeviceStruct (pDevice,
+ btn_labels,
map,
lngMouseButtons + lngWheelEvents,
winMouseCtrl,
GetMotionHistorySize(),
- 2);
+ 2,
+ axes_labels);
free(map);
+ free(btn_labels);
#if defined(XFree86Server)
g_winMouseButtonMap = pDeviceInt->button->map;