diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2008-08-07 17:34:54 +0930 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2008-08-08 16:04:23 +0930 |
commit | 134829d911c698704595014ba402516ae9a2f36c (patch) | |
tree | e1251750fa92bfd21a5e6c88acccc401bb75d00d /src/evdev.c | |
parent | Add EVDEV_MAXBUTTONS instead of checking against 32. (diff) | |
download | xf86-input-evdev-134829d911c698704595014ba402516ae9a2f36c.tar.gz xf86-input-evdev-134829d911c698704595014ba402516ae9a2f36c.tar.bz2 xf86-input-evdev-134829d911c698704595014ba402516ae9a2f36c.zip |
Simplify the property handler registration.
Instead of having separate handlers for each property, just handle all of them
in one handler for emuMB, and one handler for emuWheel.
Diffstat (limited to 'src/evdev.c')
-rw-r--r-- | src/evdev.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/evdev.c b/src/evdev.c index a383d7b..a80a433 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -96,22 +96,16 @@ static const char *evdevDefaults[] = { }; #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 -typedef struct _PropTable { - Atom prop; - char *prop_name; - Atom (*init)(DeviceIntPtr dev, char* name); - BOOL (*handler)(DeviceIntPtr dev, Atom prop, XIPropertyValuePtr val); -} PropTable, *PropTableEntryPtr; - -static PropTable evdevPropTable[] = { - { 0, "Middle Button Emulation", EvdevMBEmuInitProperty, EvdevMBEmuSetProperty }, - { 0, "Middle Button Timeout", EvdevMBEmuInitPropertyTimeout, EvdevMBEmuSetProperty}, - { 0, "Wheel Emulation", EvdevWheelEmuInitProperty, EvdevWheelEmuSetProperty}, - { 0, "Wheel Emulation X Axis", EvdevWheelEmuInitPropertyXMap, EvdevWheelEmuSetProperty}, - { 0, "Wheel Emulation Y Axis", EvdevWheelEmuInitPropertyYMap, EvdevWheelEmuSetProperty}, - { 0, "Wheel Emulation Inertia", EvdevWheelEmuInitPropertyInertia, EvdevWheelEmuSetProperty}, - { 0, "Wheel Emulation Button", EvdevWheelEmuInitPropertyButton, EvdevWheelEmuSetProperty}, - { 0, NULL, NULL, NULL } +typedef struct _PropHandler { + void (*init)(DeviceIntPtr dev); + BOOL (*handle)(DeviceIntPtr dev, Atom prop, XIPropertyValuePtr val); +} PropHandler; + +static PropHandler evdevPropHandlers[] = +{ + {EvdevMBEmuInitProperty, EvdevMBEmuSetProperty}, + {EvdevWheelEmuInitProperty, EvdevWheelEmuSetProperty}, + {NULL, NULL} }; #endif @@ -178,13 +172,13 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) static Bool EvdevSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr val) { - PropTableEntryPtr entry = evdevPropTable; + PropHandler *handler = evdevPropHandlers; - while (entry && entry->prop_name) + while (handler->init || handler->handle) { - if (entry->prop == property) - return entry->handler(dev, property, val); - entry++; + if (handler->handle && !handler->handle(dev, property, val)) + return FALSE; + handler++; } /* property not handled, report success */ @@ -882,13 +876,12 @@ EvdevInitButtonMapping(InputInfoPtr pInfo) static void EvdevInitProperties(DeviceIntPtr device) { - PropTableEntryPtr entry; - - entry = evdevPropTable; - while(entry && entry->prop_name) + PropHandler *handler = evdevPropHandlers; + while(handler->init || handler->handle) { - entry->prop = (*entry->init)(device, entry->prop_name); - entry++; + if (handler->init) + (*handler->init)(device); + handler++; } } |