summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/draglock.c79
-rw-r--r--src/emuMB.c52
-rw-r--r--src/emuWheel.c128
-rw-r--r--src/evdev.h21
4 files changed, 137 insertions, 143 deletions
diff --git a/src/draglock.c b/src/draglock.c
index e1f037a..631da17 100644
--- a/src/draglock.c
+++ b/src/draglock.c
@@ -211,45 +211,6 @@ EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value)
#ifdef HAVE_PROPERTIES
/**
- * Initialise property for drag lock buttons setting.
- */
-void
-EvdevDragLockInitProperty(DeviceIntPtr dev)
-{
- InputInfoPtr pInfo = dev->public.devicePrivate;
- EvdevPtr pEvdev = pInfo->private;
-
- if (!dev->button) /* don't init prop for keyboards */
- return;
-
- prop_dlock = MakeAtom(EVDEV_PROP_DRAGLOCK, strlen(EVDEV_PROP_DRAGLOCK), TRUE);
- if (pEvdev->dragLock.meta)
- {
- XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
- PropModeReplace, 1, &pEvdev->dragLock.meta,
- FALSE);
- } else {
- int highest = 0;
- int i;
- CARD8 pair[EVDEV_MAXBUTTONS] = {0};
-
- for (i = 0; i < EVDEV_MAXBUTTONS; i++)
- {
- if (pEvdev->dragLock.lock_pair[i])
- highest = i;
- pair[i] = pEvdev->dragLock.lock_pair[i];
- }
-
- XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
- highest + 1, pair, FALSE);
- }
-
- XISetDevicePropertyDeletable(dev, prop_dlock, FALSE);
-
- XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
-}
-
-/**
* Set the drag lock property.
* If only one value is supplied, then this is used as the meta button.
* If more than one value is supplied, then each value is the drag lock button
@@ -314,4 +275,44 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
return Success;
}
+
+/**
+ * Initialise property for drag lock buttons setting.
+ */
+void
+EvdevDragLockInitProperty(DeviceIntPtr dev)
+{
+ InputInfoPtr pInfo = dev->public.devicePrivate;
+ EvdevPtr pEvdev = pInfo->private;
+
+ if (!dev->button) /* don't init prop for keyboards */
+ return;
+
+ prop_dlock = MakeAtom(EVDEV_PROP_DRAGLOCK, strlen(EVDEV_PROP_DRAGLOCK), TRUE);
+ if (pEvdev->dragLock.meta)
+ {
+ XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
+ PropModeReplace, 1, &pEvdev->dragLock.meta,
+ FALSE);
+ } else {
+ int highest = 0;
+ int i;
+ CARD8 pair[EVDEV_MAXBUTTONS] = {0};
+
+ for (i = 0; i < EVDEV_MAXBUTTONS; i++)
+ {
+ if (pEvdev->dragLock.lock_pair[i])
+ highest = i;
+ pair[i] = pEvdev->dragLock.lock_pair[i];
+ }
+
+ XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
+ highest + 1, pair, FALSE);
+ }
+
+ XISetDevicePropertyDeletable(dev, prop_dlock, FALSE);
+
+ XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
+}
+
#endif
diff --git a/src/emuMB.c b/src/emuMB.c
index 8e8e2ac..ab6dae9 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -342,6 +342,32 @@ EvdevMBEmuEnable(InputInfoPtr pInfo, BOOL enable)
#ifdef HAVE_PROPERTIES
+int
+EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
+ BOOL checkonly)
+{
+ InputInfoPtr pInfo = dev->public.devicePrivate;
+ EvdevPtr pEvdev = pInfo->private;
+
+ if (atom == prop_mbemu)
+ {
+ if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
+ return BadMatch;
+
+ if (!checkonly)
+ pEvdev->emulateMB.enabled = *((BOOL*)val->data);
+ } else if (atom == prop_mbtimeout)
+ {
+ if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
+ return BadMatch;
+
+ if (!checkonly)
+ pEvdev->emulateMB.timeout = *((INT16*)val->data);
+ }
+
+ return Success;
+}
+
/**
* Initialise property for MB emulation on/off.
*/
@@ -376,30 +402,4 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
}
-
-int
-EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
- BOOL checkonly)
-{
- InputInfoPtr pInfo = dev->public.devicePrivate;
- EvdevPtr pEvdev = pInfo->private;
-
- if (atom == prop_mbemu)
- {
- if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
- return BadMatch;
-
- if (!checkonly)
- pEvdev->emulateMB.enabled = *((BOOL*)val->data);
- } else if (atom == prop_mbtimeout)
- {
- if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
- return BadMatch;
-
- if (!checkonly)
- pEvdev->emulateMB.timeout = *((INT16*)val->data);
- }
-
- return Success;
-}
#endif
diff --git a/src/emuWheel.c b/src/emuWheel.c
index b9c9e13..6504b8d 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -311,71 +311,6 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
}
#ifdef HAVE_PROPERTIES
-void
-EvdevWheelEmuInitProperty(DeviceIntPtr dev)
-{
- InputInfoPtr pInfo = dev->public.devicePrivate;
- EvdevPtr pEvdev = pInfo->private;
- int rc = TRUE;
- INT32 vals[4] = { TRUE, FALSE};
-
- if (!dev->button) /* don't init prop for keyboards */
- return;
-
- prop_wheel_emu = MakeAtom(EVDEV_PROP_WHEEL, strlen(EVDEV_PROP_WHEEL), TRUE);
- rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8,
- PropModeReplace, 1,
- &pEvdev->emulateWheel.enabled, FALSE);
- if (rc != Success)
- return;
-
- XISetDevicePropertyDeletable(dev, prop_wheel_emu, FALSE);
-
- vals[0] = pEvdev->emulateWheel.X.up_button;
- vals[1] = pEvdev->emulateWheel.X.down_button;
- vals[2] = pEvdev->emulateWheel.Y.up_button;
- vals[3] = pEvdev->emulateWheel.Y.down_button;
-
- prop_wheel_axismap = MakeAtom(EVDEV_PROP_WHEEL_AXES, strlen(EVDEV_PROP_WHEEL_AXES), TRUE);
- rc = XIChangeDeviceProperty(dev, prop_wheel_axismap, XA_INTEGER, 8,
- PropModeReplace, 4, vals, FALSE);
-
- if (rc != Success)
- return;
-
- XISetDevicePropertyDeletable(dev, prop_wheel_axismap, FALSE);
-
- prop_wheel_inertia = MakeAtom(EVDEV_PROP_WHEEL_INERTIA, strlen(EVDEV_PROP_WHEEL_INERTIA), TRUE);
- rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
- PropModeReplace, 1,
- &pEvdev->emulateWheel.inertia, FALSE);
- if (rc != Success)
- return;
-
- XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE);
-
- prop_wheel_timeout = MakeAtom(EVDEV_PROP_WHEEL_TIMEOUT, strlen(EVDEV_PROP_WHEEL_TIMEOUT), TRUE);
- rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
- PropModeReplace, 1,
- &pEvdev->emulateWheel.timeout, FALSE);
- if (rc != Success)
- return;
-
- XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE);
-
- prop_wheel_button = MakeAtom(EVDEV_PROP_WHEEL_BUTTON, strlen(EVDEV_PROP_WHEEL_BUTTON), TRUE);
- rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8,
- PropModeReplace, 1,
- &pEvdev->emulateWheel.button, FALSE);
- if (rc != Success)
- return;
-
- XISetDevicePropertyDeletable(dev, prop_wheel_button, FALSE);
-
- XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
-}
-
-
int
EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
@@ -465,4 +400,67 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
return Success;
}
+void
+EvdevWheelEmuInitProperty(DeviceIntPtr dev)
+{
+ InputInfoPtr pInfo = dev->public.devicePrivate;
+ EvdevPtr pEvdev = pInfo->private;
+ int rc = TRUE;
+ INT32 vals[4] = { TRUE, FALSE};
+
+ if (!dev->button) /* don't init prop for keyboards */
+ return;
+
+ prop_wheel_emu = MakeAtom(EVDEV_PROP_WHEEL, strlen(EVDEV_PROP_WHEEL), TRUE);
+ rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8,
+ PropModeReplace, 1,
+ &pEvdev->emulateWheel.enabled, FALSE);
+ if (rc != Success)
+ return;
+
+ XISetDevicePropertyDeletable(dev, prop_wheel_emu, FALSE);
+
+ vals[0] = pEvdev->emulateWheel.X.up_button;
+ vals[1] = pEvdev->emulateWheel.X.down_button;
+ vals[2] = pEvdev->emulateWheel.Y.up_button;
+ vals[3] = pEvdev->emulateWheel.Y.down_button;
+
+ prop_wheel_axismap = MakeAtom(EVDEV_PROP_WHEEL_AXES, strlen(EVDEV_PROP_WHEEL_AXES), TRUE);
+ rc = XIChangeDeviceProperty(dev, prop_wheel_axismap, XA_INTEGER, 8,
+ PropModeReplace, 4, vals, FALSE);
+
+ if (rc != Success)
+ return;
+
+ XISetDevicePropertyDeletable(dev, prop_wheel_axismap, FALSE);
+
+ prop_wheel_inertia = MakeAtom(EVDEV_PROP_WHEEL_INERTIA, strlen(EVDEV_PROP_WHEEL_INERTIA), TRUE);
+ rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
+ PropModeReplace, 1,
+ &pEvdev->emulateWheel.inertia, FALSE);
+ if (rc != Success)
+ return;
+
+ XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE);
+
+ prop_wheel_timeout = MakeAtom(EVDEV_PROP_WHEEL_TIMEOUT, strlen(EVDEV_PROP_WHEEL_TIMEOUT), TRUE);
+ rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
+ PropModeReplace, 1,
+ &pEvdev->emulateWheel.timeout, FALSE);
+ if (rc != Success)
+ return;
+
+ XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE);
+
+ prop_wheel_button = MakeAtom(EVDEV_PROP_WHEEL_BUTTON, strlen(EVDEV_PROP_WHEEL_BUTTON), TRUE);
+ rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8,
+ PropModeReplace, 1,
+ &pEvdev->emulateWheel.button, FALSE);
+ if (rc != Success)
+ return;
+
+ XISetDevicePropertyDeletable(dev, prop_wheel_button, FALSE);
+
+ XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
+}
#endif
diff --git a/src/evdev.h b/src/evdev.h
index c071971..ea4cbc1 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -120,6 +120,8 @@ typedef struct {
struct input_absinfo absinfo[ABS_MAX];
} EvdevRec, *EvdevPtr;
+unsigned int EvdevUtilButtonEventToButtonNumber(int code);
+
/* Middle Button emulation */
int EvdevMBEmuTimer(InputInfoPtr);
BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL);
@@ -129,19 +131,6 @@ void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr);
void EvdevMBEmuEnable(InputInfoPtr, BOOL);
-unsigned int EvdevUtilButtonEventToButtonNumber(int code);
-
-#ifdef HAVE_PROPERTIES
-void EvdevMBEmuInitProperty(DeviceIntPtr);
-int EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
-
-void EvdevWheelEmuInitProperty(DeviceIntPtr);
-int EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
-
-void EvdevDragLockInitProperty(DeviceIntPtr);
-int EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
-#endif
-
/* Mouse Wheel emulation */
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
@@ -150,4 +139,10 @@ BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
/* Draglock code */
void EvdevDragLockPreInit(InputInfoPtr pInfo);
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
+
+#ifdef HAVE_PROPERTIES
+void EvdevMBEmuInitProperty(DeviceIntPtr);
+void EvdevWheelEmuInitProperty(DeviceIntPtr);
+void EvdevDragLockInitProperty(DeviceIntPtr);
+#endif
#endif