configure.ac | 2 man/evdev.man | 30 - src/Makefile.am | 2 src/evdev.c | 458 +++++++++++++++------------ src/evdev.h | 241 ++++++-------- src/evdev_axes.c | 810 +++++++++++++++++++++++++++++++------------------ src/evdev_brain.c | 505 ------------------------------ src/evdev_btn.c | 326 +++++++++++++------ src/evdev_key.c | 221 +++++++++---- src/inotify-syscalls.h | 83 ----- src/inotify.h | 60 --- 11 files changed, 1286 insertions(+), 1452 deletions(-)
New commits: commit e2be2ffa473583b98b93a319163bb54eb5d83ed6 Author: Daniel Stone <[EMAIL PROTECTED]> Date: Wed Aug 1 00:02:33 2007 +0300 Options: Accept differently-named options Take some differently-named options for device and the XKB options. These should really be better-handled, but eh. diff --git a/src/evdev.c b/src/evdev.c index 94cb619..dc801d0 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -398,7 +398,9 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) pInfo->private = pEvdev; - pEvdev->device = xf86CheckStrOption(dev->commonOptions, "Device", NULL); + pEvdev->device = xf86CheckStrOption(dev->commonOptions, "path", NULL); + if (!pEvdev->device) + pEvdev->device = xf86CheckStrOption(dev->commonOptions, "Device", NULL); xf86CollectInputOptions(pInfo, NULL, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options); diff --git a/src/evdev_key.c b/src/evdev_key.c index d278988..eed6319 100644 --- a/src/evdev_key.c +++ b/src/evdev_key.c @@ -466,11 +466,22 @@ EvdevKeyNew (InputInfoPtr pInfo) pInfo->flags |= XI86_KEYBOARD_CAPABLE | XI86_CONFIGURED; - SetXkbOption (pInfo, "XkbRules", __XKBDEFRULES__, &state->key->xkb_rules); - SetXkbOption (pInfo, "XkbModel", "evdev", &state->key->xkb_model); - SetXkbOption (pInfo, "XkbLayout", "us", &state->key->xkb_layout); - SetXkbOption (pInfo, "XkbVariant", NULL, &state->key->xkb_variant); - SetXkbOption (pInfo, "XkbOptions", NULL, &state->key->xkb_options); + SetXkbOption (pInfo, "xkb_rules", NULL, &state->key->xkb_rules); + if (!state->key->xkb_rules) + SetXkbOption (pInfo, "XkbRules", __XKBDEFRULES__, + &state->key->xkb_rules); + SetXkbOption (pInfo, "xkb_model", NULL, &state->key->xkb_model); + if (!state->key->xkb_model) + SetXkbOption (pInfo, "XkbModel", "evdev", &state->key->xkb_model); + SetXkbOption (pInfo, "xkb_layout", NULL, &state->key->xkb_layout); + if (!state->key->xkb_layout) + SetXkbOption (pInfo, "XkbLayout", "us", &state->key->xkb_layout); + SetXkbOption (pInfo, "xkb_variant", NULL, &state->key->xkb_variant); + if (!state->key->xkb_variant) + SetXkbOption (pInfo, "XkbVariant", NULL, &state->key->xkb_variant); + SetXkbOption (pInfo, "xkb_options", NULL, &state->key->xkb_options); + if (!state->key->xkb_options) + SetXkbOption (pInfo, "XkbOptions", NULL, &state->key->xkb_options); return Success; } commit e86aab93c56ad72f3798169ea94dc6b91dab6ab6 Author: Brice Goglin <[EMAIL PROTECTED]> Date: Thu Jul 26 18:31:58 2007 +0200 Multiple typos in evdev.man Reported by "A. Costa" <[EMAIL PROTECTED]> in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=432063 diff --git a/man/evdev.man b/man/evdev.man index 8c6ed00..2395cd8 100644 --- a/man/evdev.man +++ b/man/evdev.man @@ -110,7 +110,7 @@ This option uses globbing. .BI "Option \*qPhys\*q \*q" string \*q Specifies the device phys string for the device you wish to use. .fi -The phys string is generally consistant to the USB port a device is plugged +The phys string is generally consistent to the USB port a device is plugged into. .fi A list of currently plugged in devices and associated device names can be @@ -127,7 +127,7 @@ Specifies device capability bits which must be set, possibly set, or unset. ff. .fi The bit specifier format is a string consisting of +<n>, -<n>, and ~<n> -space sepirated specifiers, where <n> is a positive integer or integer range. +space separated specifiers, where <n> is a positive integer or integer range. (The latter given in the format of 2-6.) .fi + specifies bits which must be set. @@ -195,9 +195,9 @@ device itself. Specifies the order in which evdev will scan for devices. .fi This is in the range of 0 to 3, and is used for the case -where more then one evdev inputsection matches the same device. +where more then one evdev input section matches the same device. .fi -An inputsection with a lower pass number will always beat out +An input section with a lower pass number will always beat out one with a higher pass number. Order when both sections are the same number is undefined. .fi @@ -206,14 +206,14 @@ The default is 0. .PP .SS RELATIVE AXIS CONFIGURATION -The relative axis portion of this driver handle all reported relative axies. +The relative axis portion of this driver handle all reported relative axes. .fi -The axies are named X, Y, Z, RX, RY, RZ, HWHEEL, DIAL, WHEEL, MISC, 10, 11, +The axes are named X, Y, Z, RX, RY, RZ, HWHEEL, DIAL, WHEEL, MISC, 10, 11, 12, 13, 14, and 15. .fi -The axies are reported to X as valuators, with the default mapping of axies -to valuators being the first axies found to the first valuator, the second -found to the second valuator, and so on, so that if you have axies X, Y, +The axes are reported to X as valuators, with the default mapping of axes +to valuators being the first axes found to the first valuator, the second +found to the second valuator, and so on, so that if you have axes X, Y, HWHEEL, and WHEEL, you would have X=0, Y=1, HWHEEL=2, WHEEL=3. .fi If the driver is reporting core events, valuators 0 and 1 are always mapped @@ -236,15 +236,15 @@ and map the Wheel axis to buttons 4 5, you get buttons 1 2 3 6 7, with buttons 6 and 7 being physical buttons 4 and 5. .PP .SS ABSOLUTE AXIS CONFIGURATION -The relative axis portion of this driver handle all reported relative axies. +The relative axis portion of this driver handle all reported relative axes. .fi -The axies are named X, Y, Z, RX, RY, RZ, THROTTLE, RUDDER, WHEEL, GAS, BREAK, +The axes are named X, Y, Z, RX, RY, RZ, THROTTLE, RUDDER, WHEEL, GAS, BREAK, <11-15>, HAT0X, HAT0Y, HAT1X, HAT1Y, HAT2X, HAT2Y, HAT3X, HAT3Y, PRESSURE, TILT_X, TILT_Y, TOOL_WIDTH, VOLUME, <29-39>, MISC, <41-62>. .fi -The axies are reported to X as valuators, with the default mapping of axies -to valuators being the first axies found to the first valuator, the second -found to the second valuator, and so on, so that if you have axies X, Y, +The axes are reported to X as valuators, with the default mapping of axes +to valuators being the first axes found to the first valuator, the second +found to the second valuator, and so on, so that if you have axes X, Y, TILT_X, and TILT_Y, you would have X=0, Y=1, TILT_X=2, TILT_Y=3. .fi If the driver is reporting core events, valuators 0 and 1 are always mapped @@ -279,7 +279,7 @@ This can be set at run time per actual device with the xinput utility. At the moment, the button portion of this driver only handles buttons reported as mouse buttons, that is from BTN_MOUSE to BTN_JOYSTICK - 1. .fi -At this time there are no configuration options for buttens. +At this time there are no configuration options for buttons. .SS KEYBOARD CONFIGURATION The keyboard portion of this driver handles all keys reported and requires XKB support. commit c69f4bd5707093a4f998c3fad508f466edbe8334 Author: Tiago Vignatti <[EMAIL PROTECTED]> Date: Fri Jun 15 01:35:29 2007 -0300 Clean up a little bit the code. diff --git a/src/evdev.c b/src/evdev.c index 42bc9df..94cb619 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -267,12 +267,6 @@ EvdevReadInput(InputInfoPtr pInfo) } } -static void -EvdevSigioReadInput (int fd, void *data) -{ - EvdevReadInput ((InputInfoPtr) data); -} - static int EvdevProc(DeviceIntPtr device, int what) { @@ -315,8 +309,8 @@ EvdevProc(DeviceIntPtr device, int what) xf86Msg(X_ERROR, "%s: Unable to grab device (%s).\n", pInfo->name, strerror(errno)); xf86FlushInput (pInfo->fd); - if (!xf86InstallSIGIOHandler (pInfo->fd, EvdevSigioReadInput, pInfo)) - AddEnabledDevice (pInfo->fd); + + xf86AddEnabledDevice(pInfo); device->public.on = TRUE; commit 64677ecc76d6eae530960b714712921e1bb9d4a7 Author: Tiago Vignatti <[EMAIL PROTECTED]> Date: Fri Jun 15 01:33:49 2007 -0300 Remove inotify things. diff --git a/src/Makefile.am b/src/Makefile.am index 5a68288..0fb7ffd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,4 +29,4 @@ @[EMAIL PROTECTED] = -Wall @[EMAIL PROTECTED] = @inputdir@ [EMAIL PROTECTED]@_drv_la_SOURCES = evdev.c evdev.h evdev_axes.c evdev_btn.c evdev_key.c inotify.h inotify-syscalls.h [EMAIL PROTECTED]@_drv_la_SOURCES = evdev.c evdev.h evdev_axes.c evdev_btn.c evdev_key.c diff --git a/src/inotify-syscalls.h b/src/inotify-syscalls.h deleted file mode 100644 index 296da90..0000000 --- a/src/inotify-syscalls.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _LINUX_INOTIFY_SYSCALLS_H -#define _LINUX_INOTIFY_SYSCALLS_H - -#include <sys/syscall.h> - -#if defined(__i386__) -# define __NR_inotify_init 291 -# define __NR_inotify_add_watch 292 -# define __NR_inotify_rm_watch 293 -#elif defined(__x86_64__) -# define __NR_inotify_init 253 -# define __NR_inotify_add_watch 254 -# define __NR_inotify_rm_watch 255 -#elif defined(__powerpc__) || defined(__powerpc64__) -# define __NR_inotify_init 275 -# define __NR_inotify_add_watch 276 -# define __NR_inotify_rm_watch 277 -#elif defined (__ia64__) -# define __NR_inotify_init 1277 -# define __NR_inotify_add_watch 1278 -# define __NR_inotify_rm_watch 1279 -#elif defined (__s390__) -# define __NR_inotify_init 284 -# define __NR_inotify_add_watch 285 -# define __NR_inotify_rm_watch 286 -#elif defined (__alpha__) -# define __NR_inotify_init 444 -# define __NR_inotify_add_watch 445 -# define __NR_inotify_rm_watch 446 -#elif defined (__sparc__) || defined (__sparc64__) -# define __NR_inotify_init 151 -# define __NR_inotify_add_watch 152 -# define __NR_inotify_rm_watch 156 -#elif defined (__arm__) -# define __NR_inotify_init 316 -# define __NR_inotify_add_watch 317 -# define __NR_inotify_rm_watch 318 -#elif defined (__sh__) -# define __NR_inotify_init 290 -# define __NR_inotify_add_watch 291 -# define __NR_inotify_rm_watch 292 -#elif defined (__hppa__) || defined (__hppa64__) -# define __NR_inotify_init 269 -# define __NR_inotify_add_watch 270 -# define __NR_inotify_rm_watch 271 -#elif defined (__mips__) -# if _MIPS_SIM == _MIPS_SIM_ABI32 -# define __NR_inotify_init 4284 -# define __NR_inotify_add_watch 4285 -# define __NR_inotify_rm_watch 4286 -# elif _MIPS_SIM == _MIPS_SIM_NABI32 -# define __NR_inotify_init 6247 -# define __NR_inotify_add_watch 6248 -# define __NR_inotify_rm_watch 6249 -# elif _MIPS_SIM == _MIPS_SIM_ABI64 -# define __NR_inotify_init 5243 -# define __NR_inotify_add_watch 5244 -# define __NR_inotify_rm_watch 5245 -# endif -#elif defined (__mc68000__) -# define __NR_inotify_init 284 -# define __NR_inotify_add_watch 285 -# define __NR_inotify_rm_watch 286 -#else -# error "Unsupported architecture!" -#endif - -static inline int inotify_init (void) -{ - return syscall (__NR_inotify_init); -} - -static inline int inotify_add_watch (int fd, const char *name, __u32 mask) -{ - return syscall (__NR_inotify_add_watch, fd, name, mask); -} - -static inline int inotify_rm_watch (int fd, __u32 wd) -{ - return syscall (__NR_inotify_rm_watch, fd, wd); -} - -#endif /* _LINUX_INOTIFY_SYSCALLS_H */ diff --git a/src/inotify.h b/src/inotify.h deleted file mode 100644 index 20d419a..0000000 --- a/src/inotify.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Inode based directory notification for Linux - * - * Copyright (C) 2005 John McCutchan - */ - -#ifndef _LINUX_INOTIFY_H -#define _LINUX_INOTIFY_H - -#include <linux/types.h> - -/* - * struct inotify_event - structure read from the inotify device for each event - * - * When you are watching a directory, you will receive the filename for events - * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd. - */ -struct inotify_event { - __s32 wd; /* watch descriptor */ - __u32 mask; /* watch mask */ - __u32 cookie; /* cookie to synchronize two events */ - __u32 len; /* length (including nulls) of name */ - char name[0]; /* stub for possible name */ -}; - -/* the following are legal, implemented events that user-space can watch for */ -#define IN_ACCESS 0x00000001 /* File was accessed */ -#define IN_MODIFY 0x00000002 /* File was modified */ -#define IN_ATTRIB 0x00000004 /* Metadata changed */ -#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */ -#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */ -#define IN_OPEN 0x00000020 /* File was opened */ -#define IN_MOVED_FROM 0x00000040 /* File was moved from X */ -#define IN_MOVED_TO 0x00000080 /* File was moved to Y */ -#define IN_CREATE 0x00000100 /* Subfile was created */ -#define IN_DELETE 0x00000200 /* Subfile was deleted */ -#define IN_DELETE_SELF 0x00000400 /* Self was deleted */ - -/* the following are legal events. they are sent as needed to any watch */ -#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */ -#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ -#define IN_IGNORED 0x00008000 /* File was ignored */ - -/* helper events */ -#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */ -#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */ - -/* special flags */ -#define IN_ISDIR 0x40000000 /* event occurred against dir */ -#define IN_ONESHOT 0x80000000 /* only send event once */ - -/* - * All of the events - we build the list by hand so that we can add flags in - * the future and not break backward compatibility. Apps will get only the - * events that they originally wanted. Be sure to add new events here! - */ -#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ - IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ - IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF) -#endif /* _LINUX_INOTIFY_H */ commit 08a09682f5b6d43181e98bc72782e2b2eec180e5 Author: Zephaniah E. Hull <[EMAIL PROTECTED]> Date: Wed Jun 13 11:05:07 2007 -0400 Update version using PACKAGE_VERSION_*. diff --git a/src/evdev.c b/src/evdev.c index 868bbff..42bc9df 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -562,7 +562,7 @@ static XF86ModuleVersionInfo EvdevVersionRec = MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, - 1, 1, 0, + PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL, ABI_CLASS_XINPUT, ABI_XINPUT_VERSION, MOD_CLASS_XINPUT, commit 9c9a47210a6c7146f29fd6d05b6f46955a3bee5a Author: Zephaniah E. Hull <[EMAIL PROTECTED]> Date: Tue Jun 12 11:59:16 2007 -0400 Move the mode option handling to the Init stage. (Sorta ugly placement wise, but the other segfaults.) diff --git a/src/evdev_axes.c b/src/evdev_axes.c index 60bfde7..e967c61 100644 --- a/src/evdev_axes.c +++ b/src/evdev_axes.c @@ -726,18 +726,6 @@ EvdevAxisAbsNew1(InputInfoPtr pInfo) } } - s = xf86SetStrOption(pInfo->options, "Mode", "Absolute"); - if (!strcasecmp(s, "Absolute")) { - pInfo->dev->valuator->mode = Absolute; - xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s); - } else if (!strcasecmp(s, "Relative")) { - pInfo->dev->valuator->mode = Relative; - xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s); - } else { - pInfo->dev->valuator->mode = Absolute; - xf86Msg(X_CONFIG, "%s: Unknown Mode: %s.\n", pInfo->name, s); - } - return Success; } @@ -861,6 +849,7 @@ EvdevAxesInit (DeviceIntPtr device) evdevAxesRec *axes = state->axes; AbsoluteClassRec *dev_abs; int i; + const char *s; if (!axes || !axes->axes) return Success; @@ -874,6 +863,23 @@ EvdevAxesInit (DeviceIntPtr device) 0)) return !Success; + + /* + * This has to go in Init, because until now there is no valuator struct + * allocated. + */ + s = xf86SetStrOption(pInfo->options, "Mode", "Absolute"); + if (!strcasecmp(s, "Absolute")) { + pInfo->dev->valuator->mode = Absolute; + xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s); + } else if (!strcasecmp(s, "Relative")) { + pInfo->dev->valuator->mode = Relative; + xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s); + } else { + pInfo->dev->valuator->mode = Absolute; + xf86Msg(X_CONFIG, "%s: Unknown Mode: %s.\n", pInfo->name, s); + } + /* * Yes, we want to do this for relative devices too. * Some of the settings are useful for both. commit 2d2c4804f925505e737c2c812687f47840218c93 Author: Zephaniah E. Hull <[EMAIL PROTECTED]> Date: Mon Jun 11 09:08:24 2007 -0400 evdev.c: Set and use the X mode control, letting XInput see it properly. Kill some cruft. evdev.h: Set and use the X mode control, letting XInput see it properly. evdev_axes.c: Set and use the X mode control, letting XInput see it properly. evdev_key.c: Remove some cruft, the bell func can be NULL now, so do so. Don't bother looking for keys above 0xF7 until we can actually do something with them. diff --git a/src/evdev.c b/src/evdev.c index 881f079..868bbff 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -367,9 +367,7 @@ EvdevSwitchMode (ClientPtr client, DeviceIntPtr device, int mode) case Absolute: case Relative: xf86Msg(X_INFO, "%s: Switching mode to %d.\n", pInfo->name, mode); - if (state->abs) - state->mode = mode; - else + if (!state->abs) return !Success; break; default: @@ -379,11 +377,6 @@ EvdevSwitchMode (ClientPtr client, DeviceIntPtr device, int mode) return Success; } -/* -static Bool -EvdevNew(evdevDriverPtr driver, evdevDevicePtr device) -*/ - InputInfoPtr EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) { @@ -407,9 +400,6 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) pInfo->device_control = EvdevProc; pInfo->read_input = EvdevReadInput; pInfo->switch_mode = EvdevSwitchMode; -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0 - pInfo->motion_history_proc = xf86GetMotionEvents; -#endif pInfo->conf_idev = dev; pInfo->private = pEvdev; diff --git a/src/evdev.h b/src/evdev.h index d14bba3..9d84843 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -181,7 +181,6 @@ typedef struct { typedef struct _evdevState { Bool can_grab; Bool sync; - int mode; /* Either Absolute or Relative. */ evdevBtnPtr btn; evdevAbsPtr abs; diff --git a/src/evdev_axes.c b/src/evdev_axes.c index 4abab46..60bfde7 100644 --- a/src/evdev_axes.c +++ b/src/evdev_axes.c @@ -581,7 +581,7 @@ EvdevAxesAbsProcess (InputInfoPtr pInfo, struct input_event *ev) if (v_flags & EV_ABS_V_M_REL) is_rel = 1; - else if ((v_flags & EV_ABS_V_M_AUTO) && state->mode == Relative) + else if ((v_flags & EV_ABS_V_M_AUTO) && pInfo->dev->valuator->mode == Relative) is_rel = 1; else is_rel = 0; @@ -728,13 +728,13 @@ EvdevAxisAbsNew1(InputInfoPtr pInfo) s = xf86SetStrOption(pInfo->options, "Mode", "Absolute"); if (!strcasecmp(s, "Absolute")) { - state->mode = Absolute; + pInfo->dev->valuator->mode = Absolute; xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s); } else if (!strcasecmp(s, "Relative")) { - state->mode = Relative; + pInfo->dev->valuator->mode = Relative; xf86Msg(X_CONFIG, "%s: Configuring in %s mode.\n", pInfo->name, s); } else { - state->mode = Absolute; + pInfo->dev->valuator->mode = Absolute; xf86Msg(X_CONFIG, "%s: Unknown Mode: %s.\n", pInfo->name, s); } diff --git a/src/evdev_key.c b/src/evdev_key.c index b0864a3..d278988 100644 --- a/src/evdev_key.c +++ b/src/evdev_key.c @@ -331,22 +331,6 @@ static KeySym map[] = { /* 0xf7 */ NoSymbol, NoSymbol, }; -/* - * FIXME: We have no way of ringing the bell ourselves. - * - * And recent versions of X don't have the system call. - * Who cares. - */ -static void -EvdevKbdBell (int percent, DeviceIntPtr device, pointer arg, int unused) -{ -#if 0 - KeybdCtrl *ctrl = arg; - - xf86OSRingBell(percent, ctrl->bell_pitch, ctrl->bell_duration); -#endif -} - static void EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl) { @@ -440,7 +424,7 @@ EvdevKeyInit (DeviceIntPtr device) state->key->xkb_options); XkbInitKeyboardDeviceStruct (device, &state->key->xkbnames, &keySyms, modMap, - EvdevKbdBell, EvdevKbdCtrl); + NULL, EvdevKbdCtrl); return Success; } @@ -467,17 +451,11 @@ EvdevKeyNew (InputInfoPtr pInfo) evdevStatePtr state = &pEvdev->state; int i, keys = 0; - for (i = 0; i <= KEY_UNKNOWN; i++) + for (i = 0; i <= 0xF7; i++) if (test_bit (i, pEvdev->bits.key)) { keys = 1; break; } - if (!keys) - for (i = KEY_OK; i <= KEY_MAX; i++) - if (test_bit (i, pEvdev->bits.key)) { - keys = 1; - break; - } if (!keys) return !Success; commit 6b97bf7a4eaa34ebde4ac7250f660da5bab8164d Author: Zephaniah E. Hull <[EMAIL PROTECTED]> Date: Wed Jun 6 05:00:29 2007 -0400 Handle default remapping around existing button targets better. diff --git a/src/evdev_btn.c b/src/evdev_btn.c index 90f33b4..c03f879 100644 --- a/src/evdev_btn.c +++ b/src/evdev_btn.c @@ -362,7 +362,7 @@ EvdevBtnNew1(InputInfoRec *pInfo) evdevStateRec *state = &pEvdev->state; evdevBtnRec *btn = state->btn; char option[128], value[128]; - int i, b, j; + int i, b, j, target; if (!btn) return !Success; @@ -375,24 +375,32 @@ EvdevBtnNew1(InputInfoRec *pInfo) btn->real_buttons++; snprintf(option, sizeof(option), "Button%sMapTo", button_names[i]); + if (b >= BTN_DIGI && b < BTN_WHEEL) - snprintf (value, sizeof (value), "null"); + target = -1; else if (b == BTN_RIGHT) - snprintf (value, sizeof (value), "Button 3"); + target = 3; else if (b == BTN_MIDDLE) - snprintf (value, sizeof (value), "Button 2"); + target = 2; else if (b >= BTN_MOUSE && b < BTN_JOYSTICK) - snprintf (value, sizeof (value), "Button %d", 1 + i - (BTN_MOUSE - BTN_MISC)); + target = 1 + i - (BTN_MOUSE - BTN_MISC); else if (b >= BTN_MISC && b < BTN_MOUSE) - snprintf (value, sizeof (value), "Button %d", 1 + i + (BTN_MOUSE - BTN_MISC)); - else if (btn->b_flags[i] & EV_BTN_B_PRESENT) { - for (j = i; j < BTN_MAX; j++) + target = 1 + i + (BTN_MOUSE - BTN_MISC); + else + target = 1 + i; + + if (btn->b_flags[target] & EV_BTN_B_PRESENT) { + for (j = target; j < BTN_MAX; j++) if (!(btn->b_flags[j] & EV_BTN_B_PRESENT)) { - snprintf (value, sizeof (value), "Button %d", j + 1); + target = j; break; } - } else - snprintf (value, sizeof (value), "Button %d", i + 1); + } + + if (target > 0) + snprintf (value, sizeof (value), "Button %d", target); + else + snprintf (value, sizeof (value), "null"); EvdevParseMapOption (pInfo, option, value, &btn->b_map_data[i], &btn->b_map[i]); } commit 5c6b3dd86feef58ccf43a710624404031df72f2c Author: Zephaniah E. Hull <[EMAIL PROTECTED]> Date: Wed Jun 6 04:42:51 2007 -0400 Move MapButtons_t closer to where it's used. diff --git a/src/evdev_btn.c b/src/evdev_btn.c index 63a6abf..90f33b4 100644 --- a/src/evdev_btn.c +++ b/src/evdev_btn.c @@ -161,13 +161,6 @@ EvdevBtnPostFakeClicks(InputInfoRec *pInfo, int button, int count) } } -typedef struct { - int button_plus; - int button_minus; - int step; - int count; -} MapButtons_t; - static void EvdevMapButton (InputInfoRec *pInfo, int value, int mode, void *map_data) { @@ -209,6 +202,13 @@ EvdevParseMapToButton (InputInfoRec *pInfo, return 1; } +typedef struct { + int button_plus; + int button_minus; + int step; + int count; +} MapButtons_t; + static void EvdevMapButtons (InputInfoRec *pInfo, int value, int mode, void *map_data) { commit f15636ac529481a9d83e0250ff89690296f96a3d Author: Zephaniah E. Hull <[EMAIL PROTECTED]> Date: Wed Jun 6 04:41:54 2007 -0400 Wheel mice work again! (Old configs don't.) evdev.c: Add EvdevParseMapToButton and EvdevParseMapToButtons to evdev_map_parsers. Add EvdevParseMapOption to search through evdev_map_parsers. Fix up EvdevTokenize to handle the evdev_option_token_t changes. EvdevAxesNew0 after BtnNew0 instead of before now. (This isn't the right fix.) evdev.h: EVDEV_MAXBUTTONS -> BTN_MAX. Redid evdevBtnRec with the new mapping goodness. Removed v_min and v_max from evdevAbsRec. Reworked evdev_option_token_t, no union, no is_chain. If it's a chain, it still has a string, but the chain pointer is set. EvdevParseMapToButton, EvdevParseMapToButtons, and EvdevParseMapOption. evdev_axes.c: Kill off EvdevAxesMapButton, a variant lives in evdev_btn.c now. Changes for the evdev_option_token_t changes. Use EvdevParseMapOption instead of repeating the contents twice. Disable EV_ABS_V_INVERT for the moment. (Better fix maybe needed.) evdev_btn.c: s/Ptr /Rec */g EvdevMapButton and parser. EvdevMapButtons and parser. Nuke EvdevBtnCalcRemap as a whole. Move everything but the alloc to New1 from New0. New mapping code, same guts os the axes mapping code even. diff --git a/src/evdev.c b/src/evdev.c index f2debd2..881f079 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -99,22 +99,59 @@ evdev_map_parsers_t evdev_map_parsers[] = { .func = EvdevParseMapToAbsAxis, }, { + .name = "Button", + .func = EvdevParseMapToButton, + }, + { + .name = "Buttons", + .func = EvdevParseMapToButtons, + }, + { .name = NULL, .func = NULL, } }; +Bool +EvdevParseMapOption (InputInfoRec *pInfo, char *option, char *def, void **map_data, evdev_map_func_f *map_func) +{ + evdev_option_token_t *tokens; + const char *s; + int i; + + s = xf86SetStrOption(pInfo->options, option, def); + tokens = EvdevTokenize (s, " ="); + if (tokens->next) { + for (i = 0; evdev_map_parsers[i].name; i++) { + if (!strcasecmp (tokens->str, evdev_map_parsers[i].name)) { + if (!evdev_map_parsers[i].func (pInfo, option, tokens->next, map_data, map_func)) { + xf86Msg (X_ERROR, "%s: Unable to parse '%s' as a map specifier.\n", pInfo->name, s); + EvdevFreeTokens (tokens); + return 0; + } + return 1; + } + } + + if (!evdev_map_parsers[i].name) + xf86Msg (X_ERROR, "%s: Unable to find parser for '%s' as a map specifier.\n", pInfo->name, s); + } else { + xf86Msg (X_ERROR, "%s: Unable to parse '%s' as a map specifier string.\n", pInfo->name, s); + } + EvdevFreeTokens (tokens); + return 0; +} + evdev_option_token_t * -EvdevTokenize (const char *option, const char *tokens, const char *first) +EvdevTokenize (const char *option, const char *tokens) { evdev_option_token_t *head = NULL, *token = NULL, *prev = NULL; const char *ctmp; + const char *first; char *tmp = NULL; int len; - if (!first) { - first = strchr (option, tokens[0]); - } + first = strchr (option, tokens[0]); while (1) { if (first) @@ -145,12 +182,11 @@ EvdevTokenize (const char *option, const char *tokens, const char *first) if (tokens[1]) { ctmp = strchr (tmp, tokens[1]); if (ctmp) { - token->is_chain = 1; - token->u.chain = EvdevTokenize (tmp, tokens + 1, ctmp); + token->chain = EvdevTokenize (ctmp+1, tokens + 1); } else - token->u.str = tmp; + token->str = tmp; } else - token->u.str = tmp; + token->str = tmp; if (!first) break; @@ -168,10 +204,9 @@ EvdevFreeTokens (evdev_option_token_t *token) evdev_option_token_t *next; while (token) { - if (token->is_chain) - EvdevFreeTokens (token->u.chain); - else - free (token->u.str); + if (token->chain) + EvdevFreeTokens (token->chain); + free (token->str); next = token->next; free (token); token = next; @@ -191,7 +226,7 @@ EvdevReadInput(InputInfoPtr pInfo) if (len != sizeof(ev)) { /* The kernel promises that we always only read a complete * event, so len != sizeof ev is an error. */ - xf86Msg(X_ERROR, "Read error: %s (%d, %d != %ld)\n", + xf86Msg(X_ERROR, "Read error: %s (%d, %d != %zd)\n", strerror(errno), errno, len, sizeof (ev)); if (len < 0) { @@ -412,8 +447,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) /* XXX: Note, the order of these is (maybe) still important. */ - EvdevAxesNew0 (pInfo); EvdevBtnNew0 (pInfo); + EvdevAxesNew0 (pInfo); EvdevAxesNew1 (pInfo); EvdevBtnNew1 (pInfo); diff --git a/src/evdev.h b/src/evdev.h index cfce03b..d14bba3 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -80,7 +80,7 @@ #define AXES_MAX ABS_MAX -#define EVDEV_MAXBUTTONS 96 +#define BTN_MAX 96 struct _evdevDevice; @@ -104,16 +104,15 @@ typedef struct { unsigned long ff[NBITS(FF_MAX)]; } evdevBitsRec, *evdevBitsPtr; -#define EV_BTN_IGNORE_X 1 -#define EV_BTN_IGNORE_EVDEV 2 -#define EV_BTN_IGNORE_MAP (EV_BTN_IGNORE_X | EV_BTN_IGNORE_EVDEV) +#define EV_BTN_B_PRESENT (1<<0) typedef struct { int real_buttons; int buttons; - CARD8 ignore[EVDEV_MAXBUTTONS]; - CARD8 map[EVDEV_MAXBUTTONS]; - void (*callback[EVDEV_MAXBUTTONS])(InputInfoPtr pInfo, int button, int value); + int b_flags[BTN_MAX]; + void *b_map_data[ABS_MAX]; + evdev_map_func_f b_map[BTN_MAX]; + void (*callback[BTN_MAX])(InputInfoPtr pInfo, int button, int value); } evdevBtnRec, *evdevBtnPtr; #define EV_ABS_V_PRESENT (1<<0) @@ -132,8 +131,6 @@ typedef struct { int axes; int v[ABS_MAX]; int v_flags[ABS_MAX]; - int v_min[ABS_MAX]; - int v_max[ABS_MAX]; void *v_map_data[ABS_MAX]; evdev_map_func_f v_map[ABS_MAX]; } evdevAbsRec, *evdevAbsPtr; @@ -233,11 +230,8 @@ void EvdevKeyProcess (InputInfoPtr pInfo, struct input_event *ev); */ typedef struct evdev_option_token_s { - int is_chain; - union { - const char *str; - struct evdev_option_token_s *chain; - } u; + const char *str; + struct evdev_option_token_s *chain; struct evdev_option_token_s *next; } evdev_option_token_t; @@ -247,7 +241,7 @@ typedef Bool (*evdev_parse_map_func_f)(InputInfoPtr pInfo, evdev_option_token_t *option, void **map_data, evdev_map_func_f *map_func); -evdev_option_token_t *EvdevTokenize (const char *option, const char *tokens, const char *first); +evdev_option_token_t *EvdevTokenize (const char *option, const char *tokens); void EvdevFreeTokens (evdev_option_token_t *token); Bool EvdevParseMapToRelAxis (InputInfoPtr pInfo, const char *name, @@ -257,6 +251,16 @@ Bool EvdevParseMapToAbsAxis (InputInfoPtr pInfo, const char *name, evdev_option_token_t *option, void **map_data, evdev_map_func_f *map_func); +Bool +EvdevParseMapToButton (InputInfoRec *pInfo, + const char *name, + evdev_option_token_t *option, + void **map_data, evdev_map_func_f *map_func); +Bool +EvdevParseMapToButtons (InputInfoRec *pInfo, + const char *name, + evdev_option_token_t *option, + void **map_data, evdev_map_func_f *map_func); typedef struct { char *name; @@ -264,5 +268,6 @@ typedef struct { } evdev_map_parsers_t; extern evdev_map_parsers_t evdev_map_parsers[]; +Bool EvdevParseMapOption (InputInfoRec *pInfo, char *option, char *def, void **map_data, evdev_map_func_f *map_func); #endif /* __EVDEV_H */ diff --git a/src/evdev_axes.c b/src/evdev_axes.c index 1443495..4abab46 100644 --- a/src/evdev_axes.c +++ b/src/evdev_axes.c @@ -163,36 +163,6 @@ EvdevAxesMapAxis (InputInfoPtr pInfo, int value, int mode, void *map_data) axes->flags |= EV_AXES_UPDATED; } -#if 0 -typedef struct { - int button_plus; - int button_minus; - int step; - int count; -} AxisMapButton_t; - -void -EvdevAxesMapButton (InputInfoPtr pInfo, int value, void *map_data) -{ - AxisMapButton_t *map = map_data; -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]