--- - 2005-11-01 13:03:48.066749000 -0700 +++ xc/programs/Xserver/hw/xfree86/input/evdev/evdev.c 2005-11-01 13:03:25.804062800 -0700 @@ -79,10 +79,51 @@ #define MODEFLAG 8 #define COMPOSEFLAG 16 +typedef void (*EvdevCommonOptProc)(InputInfoPtr pInfo); + typedef struct { int kernel24; + EvdevCommonOptProc CommonOptions; + int negativeZ; + int positiveZ; + int negativeH; + int positiveH; + int negativeW; + int positiveW; } EvdevRec, *EvdevPtr; +#ifdef XFree86LOADER +static const OptionInfoRec *EvdevAvailableOptions(void *unused); +#endif + +typedef enum { + OPTION_ALWAYS_CORE, + OPTION_SEND_CORE_EVENTS, + OPTION_CORE_POINTER, + OPTION_Z_AXIS_MAPPING, + OPTION_H_AXIS_MAPPING, + OPTION_W_AXIS_MAPPING +} MouseOpts; + +#ifdef XFree86LOADER +static const OptionInfoRec EvdevOptions[] = { + { OPTION_ALWAYS_CORE, "AlwaysCore", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SEND_CORE_EVENTS, "SendCoreEvents", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CORE_POINTER, "CorePointer", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_Z_AXIS_MAPPING, "ZAxisMapping", OPTV_STRING, {0}, FALSE }, + { OPTION_W_AXIS_MAPPING, "HAxisMapping", OPTV_STRING, {0}, FALSE }, + { OPTION_H_AXIS_MAPPING, "WAxisMapping", OPTV_STRING, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +static const OptionInfoRec * +EvdevAvailableOptions(void *unused) +{ + return (EvdevOptions); +} +#endif + + static int wheel_up_button = 4; static int wheel_down_button = 5; static int wheel_left_button = 6; @@ -121,6 +162,8 @@ EvdevReadInput(InputInfoPtr pInfo) struct input_event ev; int len, value; int dx, dy; + EvdevPtr pEvdev; + pEvdev = pInfo->private; dx = 0; dy = 0; @@ -150,16 +193,23 @@ EvdevReadInput(InputInfoPtr pInfo) case REL_WHEEL: if (value > 0) - PostButtonClicks(pInfo, wheel_up_button, value); + PostButtonClicks(pInfo, pEvdev->positiveW, value); if (value < 0) - PostButtonClicks(pInfo, wheel_down_button, -value); + PostButtonClicks(pInfo, pEvdev->negativeW, -value); + break; + + case REL_Z: + if (value > 0) + PostButtonClicks(pInfo, pEvdev->positiveZ, value); + if (value < 0) + PostButtonClicks(pInfo, pEvdev->negativeZ, -value); break; case REL_HWHEEL: if (value > 0) - PostButtonClicks(pInfo, wheel_right_button, value); + PostButtonClicks(pInfo, pEvdev->positiveH, value); if (value < 0) - PostButtonClicks(pInfo, wheel_left_button, -value); + PostButtonClicks(pInfo, pEvdev->negativeH, -value); break; } break; @@ -176,7 +226,7 @@ EvdevReadInput(InputInfoPtr pInfo) value, 0, 0); break; - case BTN_SIDE: + case BTN_SIDE: case BTN_EXTRA: case BTN_FORWARD: case BTN_BACK: @@ -640,6 +690,60 @@ EvdevProbe(InputInfoPtr pInfo) return 0; } +static void +evdevCommonOptions(InputInfoPtr pInfo) +{ + EvdevPtr pEvdev; + pEvdev = pInfo->private; + char * s; + + s = xf86SetStrOption(pInfo->options, "HAxisMapping", "6 7"); + if (s) { + int b1, b2; + char * msg = NULL; + if (sscanf(s, "%d %d", &b1, &b2) == 2 && + b1 > 0 && b1 < 8 && + b2 > 0 && b2 < 8 ) + { + sprintf(msg, "%d %d", b1, b2); + } + pEvdev->positiveH = b1; + pEvdev->negativeH = b2; + xf86Msg(X_CONFIG, "HZAxisMapping: %s\n", msg); + } + s = xf86SetStrOption(pInfo->options, "WAxisMapping", "4 5"); + if (s) { + int b1, b2; + char * msg = NULL; + if (sscanf(s, "%d %d", &b1, &b2) == 2 && + b1 > 0 && b1 < 8 && + b2 > 0 && b2 < 8 ) + { + sprintf(msg, "%d %d", b1, b2); + } + pEvdev->positiveW = b1; + pEvdev->negativeW = b2; + xf86Msg(X_CONFIG, "WAxisMapping: %s\n", msg); + } + s = xf86SetStrOption(pInfo->options, "ZAxisMapping", "6 7"); + if (s) { + int b1, b2; + char * msg = NULL; + if (sscanf(s, "%d %d", &b1, &b2) == 2 && + b1 > 0 && b1 < 8 && + b2 > 0 && b2 < 8 ) + { + sprintf(msg, "ZAxisMapping %d %d", b1, b2); + } + pEvdev->positiveZ = b1; + pEvdev->negativeZ = b2; + xf86Msg(X_CONFIG, "ZAxisMapping: %s\n", msg); + } + + + +} + static InputInfoPtr EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) { @@ -672,9 +776,11 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr if (!(pEvdev = xcalloc(sizeof(*pEvdev), 1))) return pInfo; pInfo->private = pEvdev; + pEvdev->CommonOptions = evdevCommonOptions; xf86CollectInputOptions(pInfo, NULL, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options); + pEvdev->CommonOptions(pInfo); device = xf86CheckStrOption(dev->commonOptions, "Device", NULL); if (!device) { @@ -691,7 +797,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr if (pInfo->fd < 0) { xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n", device); - xfree(pEvdev); + /* xfree(pEvdev); */ return pInfo; }