mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Use new property API (no ConfigureDP, less args to ChangeDP)
Return appropriate status codes from property handlers. Make properties non-deletable.
This commit is contained in:
@@ -228,7 +228,7 @@ EvdevDragLockInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
|
||||
PropModeReplace, 1, &pEvdev->dragLock.meta,
|
||||
FALSE, FALSE, FALSE);
|
||||
FALSE);
|
||||
} else {
|
||||
int highest = 0;
|
||||
int i;
|
||||
@@ -242,9 +242,11 @@ EvdevDragLockInitProperty(DeviceIntPtr dev)
|
||||
}
|
||||
|
||||
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
|
||||
highest + 1, pair, FALSE, FALSE, FALSE);
|
||||
highest + 1, pair, FALSE);
|
||||
}
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_dlock, FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -255,7 +257,7 @@ EvdevDragLockInitProperty(DeviceIntPtr dev)
|
||||
* for the pair. 0 disables a pair.
|
||||
* i.e. to set bt 3 to draglock button 1, supply 0,0,1
|
||||
*/
|
||||
BOOL
|
||||
int
|
||||
EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
@@ -264,27 +266,27 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
if (atom == prop_dlock)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (val->format != 8 || val->type != XA_INTEGER)
|
||||
return FALSE;
|
||||
|
||||
/* Don't allow changes while a lock is active */
|
||||
/* FIXME: Need more meaningful method of returning Busy. */
|
||||
if (pEvdev->dragLock.meta)
|
||||
{
|
||||
if (pEvdev->dragLock.meta_state)
|
||||
return FALSE;
|
||||
return BadAccess;
|
||||
} else
|
||||
{
|
||||
for (i = 0; i < EVDEV_MAXBUTTONS; i++)
|
||||
if (pEvdev->dragLock.lock_state[i])
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if (val->size == 1)
|
||||
{
|
||||
int meta = *((CARD8*)val->data);
|
||||
if (meta > EVDEV_MAXBUTTONS)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
|
||||
pEvdev->dragLock.meta = meta;
|
||||
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
||||
@@ -294,7 +296,7 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
|
||||
for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++)
|
||||
if (vals[i] > EVDEV_MAXBUTTONS)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
|
||||
pEvdev->dragLock.meta = 0;
|
||||
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
||||
@@ -304,6 +306,6 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return Success;
|
||||
}
|
||||
#endif
|
||||
|
||||
21
src/emuMB.c
21
src/emuMB.c
@@ -327,10 +327,10 @@ EvdevMBEmuPreInit(InputInfoPtr pInfo)
|
||||
#ifdef HAVE_PROPERTIES
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_mbemu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1, &pEvdev->emulateMB.enabled,
|
||||
TRUE, FALSE, FALSE);
|
||||
TRUE);
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_mbtimeout, XA_INTEGER, 16,
|
||||
PropModeReplace, 1, &pEvdev->emulateMB.timeout,
|
||||
TRUE, FALSE, FALSE);
|
||||
TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -363,7 +363,6 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int rc = TRUE;
|
||||
INT32 valid_vals[] = { MBEMU_DISABLED, MBEMU_ENABLED, MBEMU_AUTO };
|
||||
|
||||
if (!dev->button) /* don't init prop for keyboards */
|
||||
return;
|
||||
@@ -372,27 +371,23 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbemu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateMB.enabled,
|
||||
FALSE, FALSE, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_mbemu, FALSE, FALSE, FALSE, 3, valid_vals);
|
||||
|
||||
FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_mbemu, FALSE);
|
||||
|
||||
prop_mbtimeout = MakeAtom((char*)propname_mbtimeout,
|
||||
strlen(propname_mbtimeout),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 16, PropModeReplace, 1,
|
||||
&pEvdev->emulateMB.timeout, FALSE, FALSE,
|
||||
FALSE);
|
||||
&pEvdev->emulateMB.timeout, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_mbtimeout, FALSE);
|
||||
}
|
||||
|
||||
BOOL
|
||||
int
|
||||
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
@@ -403,6 +398,6 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
else if (atom == prop_mbtimeout)
|
||||
pEvdev->emulateMB.timeout = *((INT16*)val->data);
|
||||
|
||||
return TRUE;
|
||||
return Success;
|
||||
}
|
||||
#endif
|
||||
|
||||
102
src/emuWheel.c
102
src/emuWheel.c
@@ -318,32 +318,23 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_wheel_emu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1, &pEvdev->emulateWheel.enabled,
|
||||
TRUE, FALSE, FALSE);
|
||||
PropModeReplace, 1, &pEvdev->emulateWheel.enabled, TRUE);
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_wheel_button, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.button,
|
||||
TRUE, FALSE, FALSE);
|
||||
PropModeReplace, 1, &pEvdev->emulateWheel.button, TRUE);
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_wheel_inertia, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.inertia,
|
||||
TRUE, FALSE, FALSE);
|
||||
PropModeReplace, 1, &pEvdev->emulateWheel.inertia, TRUE);
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_wheel_timeout, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.timeout,
|
||||
TRUE, FALSE, FALSE);
|
||||
PropModeReplace, 1, &pEvdev->emulateWheel.timeout, TRUE);
|
||||
|
||||
val[0] = pEvdev->emulateWheel.X.up_button;
|
||||
val[1] = pEvdev->emulateWheel.X.down_button;
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_wheel_xmap, XA_INTEGER, 8,
|
||||
PropModeReplace, 2, val,
|
||||
TRUE, FALSE, FALSE);
|
||||
PropModeReplace, 2, val, TRUE);
|
||||
|
||||
val[0] = pEvdev->emulateWheel.Y.up_button;
|
||||
val[1] = pEvdev->emulateWheel.Y.down_button;
|
||||
XIChangeDeviceProperty(pInfo->dev, prop_wheel_ymap, XA_INTEGER, 8,
|
||||
PropModeReplace, 2, val,
|
||||
TRUE, FALSE, FALSE);
|
||||
PropModeReplace, 2, val, TRUE);
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -363,92 +354,64 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev)
|
||||
prop_wheel_emu = MakeAtom((char*)propname_wheel_emu, strlen(propname_wheel_emu), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.enabled,
|
||||
FALSE, FALSE, FALSE);
|
||||
&pEvdev->emulateWheel.enabled, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_wheel_emu, FALSE, FALSE,
|
||||
FALSE, 2, valid_vals);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_emu, FALSE);
|
||||
|
||||
valid_vals[0] = pEvdev->emulateWheel.X.up_button;
|
||||
valid_vals[1] = pEvdev->emulateWheel.X.down_button;
|
||||
|
||||
prop_wheel_xmap = MakeAtom((char*)propname_wheel_xmap, strlen(propname_wheel_xmap), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_xmap, XA_INTEGER, 8,
|
||||
PropModeReplace, 2, valid_vals,
|
||||
FALSE, FALSE, FALSE);
|
||||
PropModeReplace, 2, valid_vals, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_wheel_xmap, FALSE, FALSE,
|
||||
FALSE, 0, NULL);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_xmap, FALSE);
|
||||
|
||||
valid_vals[0] = pEvdev->emulateWheel.Y.up_button;
|
||||
valid_vals[1] = pEvdev->emulateWheel.Y.down_button;
|
||||
|
||||
prop_wheel_ymap = MakeAtom((char*)propname_wheel_ymap, strlen(propname_wheel_ymap), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_ymap, XA_INTEGER, 8,
|
||||
PropModeReplace, 2, valid_vals,
|
||||
FALSE, FALSE, FALSE);
|
||||
PropModeReplace, 2, valid_vals, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_wheel_ymap, FALSE, FALSE,
|
||||
FALSE, 0, NULL);
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_ymap, FALSE);
|
||||
|
||||
prop_wheel_inertia = MakeAtom((char*)propname_wheel_inertia, strlen(propname_wheel_inertia), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.inertia,
|
||||
FALSE, FALSE, FALSE);
|
||||
&pEvdev->emulateWheel.inertia, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_wheel_inertia, FALSE, FALSE,
|
||||
FALSE, 0, NULL);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE);
|
||||
|
||||
prop_wheel_timeout = MakeAtom((char*)propname_wheel_timeout, strlen(propname_wheel_timeout), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.timeout,
|
||||
FALSE, FALSE, FALSE);
|
||||
&pEvdev->emulateWheel.timeout, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_wheel_timeout, FALSE, FALSE,
|
||||
FALSE, 0, NULL);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE);
|
||||
|
||||
prop_wheel_button = MakeAtom((char*)propname_wheel_button, strlen(propname_wheel_button), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.button,
|
||||
FALSE, FALSE, FALSE);
|
||||
&pEvdev->emulateWheel.button, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
rc = XIConfigureDeviceProperty(dev, prop_wheel_button, FALSE, FALSE,
|
||||
FALSE, 0, NULL);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_wheel_button, FALSE);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
int
|
||||
EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
@@ -462,10 +425,11 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
if (pEvdev->emulateWheel.inertia <= 0)
|
||||
{
|
||||
pEvdev->emulateWheel.inertia = 10;
|
||||
XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.inertia,
|
||||
TRUE, FALSE, FALSE);
|
||||
/* We may get here before the property is actually enabled */
|
||||
if (prop_wheel_inertia)
|
||||
XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER,
|
||||
16, PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.inertia, TRUE);
|
||||
}
|
||||
|
||||
/* Don't enable with negative timeout */
|
||||
@@ -474,46 +438,48 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
pEvdev->emulateWheel.timeout = 200;
|
||||
XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
|
||||
PropModeReplace, 1,
|
||||
&pEvdev->emulateWheel.timeout,
|
||||
TRUE, FALSE, FALSE);
|
||||
&pEvdev->emulateWheel.timeout, TRUE);
|
||||
}
|
||||
}
|
||||
else if (atom == prop_wheel_button)
|
||||
{
|
||||
int bt = *((CARD8*)val->data);
|
||||
|
||||
if (bt < 0 || bt >= EVDEV_MAXBUTTONS)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
pEvdev->emulateWheel.button = bt;
|
||||
} else if (atom == prop_wheel_xmap)
|
||||
{
|
||||
if (val->size != 2)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
|
||||
pEvdev->emulateWheel.X.up_button = *((CARD8*)val->data);
|
||||
pEvdev->emulateWheel.X.down_button = *(((CARD8*)val->data) + 1);
|
||||
} else if (atom == prop_wheel_ymap)
|
||||
{
|
||||
if (val->size != 2)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
|
||||
pEvdev->emulateWheel.Y.up_button = *((CARD8*)val->data);
|
||||
pEvdev->emulateWheel.Y.down_button = *(((CARD8*)val->data) + 1);
|
||||
} else if (atom == prop_wheel_inertia)
|
||||
{
|
||||
int inertia = *((CARD16*)val->data);
|
||||
|
||||
if (inertia < 0)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
|
||||
pEvdev->emulateWheel.inertia = inertia;
|
||||
} else if (atom == prop_wheel_timeout)
|
||||
{
|
||||
int timeout = *((CARD16*)val->data);
|
||||
|
||||
if (timeout < 0)
|
||||
return FALSE;
|
||||
return BadValue;
|
||||
|
||||
pEvdev->emulateWheel.timeout = timeout;
|
||||
}
|
||||
return TRUE;
|
||||
return Success;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
23
src/evdev.c
23
src/evdev.c
@@ -100,7 +100,7 @@ static const char *evdevDefaults[] = {
|
||||
#ifdef HAVE_PROPERTIES
|
||||
typedef struct _PropHandler {
|
||||
void (*init)(DeviceIntPtr dev);
|
||||
BOOL (*handle)(DeviceIntPtr dev, Atom prop, XIPropertyValuePtr val);
|
||||
int (*handle)(DeviceIntPtr dev, Atom prop, XIPropertyValuePtr val);
|
||||
} PropHandler;
|
||||
|
||||
static PropHandler evdevPropHandlers[] =
|
||||
@@ -175,28 +175,27 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static Bool
|
||||
static int
|
||||
EvdevSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr val)
|
||||
{
|
||||
PropHandler *handler = evdevPropHandlers;
|
||||
int rc;
|
||||
|
||||
while (handler->init || handler->handle)
|
||||
{
|
||||
if (handler->handle && !handler->handle(dev, property, val))
|
||||
return FALSE;
|
||||
if (handler->handle)
|
||||
{
|
||||
rc = handler->handle(dev, property, val);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
}
|
||||
handler++;
|
||||
}
|
||||
|
||||
/* property not handled, report success */
|
||||
return TRUE;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static Bool EvdevGetProperty(DeviceIntPtr dev,
|
||||
Atom property)
|
||||
{
|
||||
/* XXX */
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -986,7 +985,7 @@ EvdevInit(DeviceIntPtr device)
|
||||
/* We drop the return value, the only time we ever want the handlers to
|
||||
* unregister is when the device dies. In which case we don't have to
|
||||
* unregister anyway */
|
||||
XIRegisterPropertyHandler(device, EvdevSetProperty, EvdevGetProperty);
|
||||
XIRegisterPropertyHandler(device, EvdevSetProperty, NULL, NULL);
|
||||
EvdevInitProperties(device);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -131,13 +131,13 @@ unsigned int EvdevUtilButtonEventToButtonNumber(int code);
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
void EvdevMBEmuInitProperty(DeviceIntPtr);
|
||||
BOOL EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
|
||||
int EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
|
||||
|
||||
void EvdevWheelEmuInitProperty(DeviceIntPtr);
|
||||
BOOL EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
|
||||
int EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
|
||||
|
||||
void EvdevDragLockInitProperty(DeviceIntPtr);
|
||||
BOOL EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
|
||||
int EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr);
|
||||
#endif
|
||||
|
||||
/* Mouse Wheel emulation */
|
||||
|
||||
Reference in New Issue
Block a user