From dc88668839f4613d60526aa78aed3e74eebe64ad Mon Sep 17 00:00:00 2001 From: "Zephaniah E. Hull" Date: Thu, 13 Jul 2006 11:59:25 -0400 Subject: Split the New functions so that structs can be allocated and buttons detected, and then stuff that depends on _other_ areas. (Specificly, axes and btn have a circular dependency on which one has to run first, this solves that.) Add button names, and a way to get a button number from a name. Add a function for checking to see if a button exists, takes the number from the previous function. Change the (unused) state array of pointers in the button struct to an array of pointers to functions for callback. Implemented the 'touch' feature, on by default if BTN_DIGI_TOUCH exists, won't, in rel mode, process x/y data unless it's down, and is used to try and make 'pick up stencil, move to other side of digitizer, set back down' not jump to the other side of the screen in rel mode. (This doesn't work as well as it could, but I'm fairly sure that it's due to the quality of the absolute input device I'm using, but feedback would be really nice.) FIXME: Update the manpage for this. --- src/evdev_btn.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 4 deletions(-) (limited to 'src/evdev_btn.c') diff --git a/src/evdev_btn.c b/src/evdev_btn.c index 35edee1..9a9b65e 100644 --- a/src/evdev_btn.c +++ b/src/evdev_btn.c @@ -51,6 +51,91 @@ #include +static char *button_names[] = { + "MISC_0", + "MISC_1", + "MISC_2", + "MISC_3", + "MISC_4", + "MISC_5", + "MISC_6", + "MISC_7", + "MISC_8", + "MISC_9", + "MISC_10", + "MISC_11", + "MISC_12", + "MISC_13", + "MISC_14", + "MISC_15", + "MOUSE_LEFT", + "MOUSE_RIGHT", + "MOUSE_MIDDLE", + "MOUSE_SIDE", + "MOUSE_EXTRA", + "MOUSE_FORWARD", + "MOUSE_BACK", + "MOUSE_TASK", + "MOUSE_8", + "MOUSE_9", + "MOUSE_10", + "MOUSE_12", + "MOUSE_13", + "MOUSE_14", + "MOUSE_15", + "JOY_TRIGGER", + "JOY_THUMB", + "JOY_THUMB2", + "JOY_TOP", + "JOY_TOP2", + "JOY_PINKIE", + "JOY_BASE", + "JOY_BASE2", + "JOY_BASE3", + "JOY_BASE4", + "JOY_BASE5", + "JOY_BASE6", + "JOY_12", + "JOY_13", + "JOY_14", + "JOY_DEAD", + "GAME_A", + "GAME_B", + "GAME_C", + "GAME_X", + "GAME_Y", + "GAME_Z", + "GAME_TL", + "GAME_TR", + "GAME_TL2", + "GAME_TR2", + "GAME_SELECT", + "GAME_START", + "GAME_MODE", + "GAME_THUMBL", + "GAME_THUMBR", + "GAME_15", + "DIGI_TOOL_PEN", + "DIGI_TOOL_RUBBER", + "DIGI_TOOL_BRUSH", + "DIGI_TOOL_PENCIL", + "DIGI_TOOL_AIRBRUSH", + "DIGI_TOOL_FINGER", + "DIGI_TOOL_MOUSE", + "DIGI_TOOL_LENS", + "DIGI_8", + "DIGI_9", + "DIGI_TOUCH", + "DIGI_STYLUS", + "DIGI_STYLUS2", + "DIGI_TOOL_DOUBLETAP", + "DIGI_TOOL_TRIPLETAP", + "DIGI_15", + "WHEEL_GEAR_UP", + "WHEEL_GEAR_DOWN", + NULL +}; + void EvdevBtnPostFakeClicks(InputInfoPtr pInfo, int button, int count) { @@ -168,7 +253,7 @@ EvdevBtnCalcRemap (InputInfoPtr pInfo) int -EvdevBtnNew(InputInfoPtr pInfo) +EvdevBtnNew0(InputInfoPtr pInfo) { evdevDevicePtr pEvdev = pInfo->private; evdevStatePtr state = &pEvdev->state; @@ -191,6 +276,18 @@ EvdevBtnNew(InputInfoPtr pInfo) if (state->btn->real_buttons) xf86Msg(X_INFO, "%s: Found %d mouse buttons\n", pInfo->name, state->btn->real_buttons); + return Success; +} + +int +EvdevBtnNew1(InputInfoPtr pInfo) +{ + evdevDevicePtr pEvdev = pInfo->private; + evdevStatePtr state = &pEvdev->state; + + if (!state->btn) + return !Success; + EvdevBtnCalcRemap (pInfo); if (state->btn->buttons) @@ -221,7 +318,7 @@ EvdevBtnProcess (InputInfoPtr pInfo, struct input_event *ev) if (!state->btn) return; - button = ev->code - BTN_MISC; + button = ev->code; if ((ev->code >= BTN_MOUSE) && (ev->code < BTN_JOYSTICK)) { button -= BTN_MOUSE - BTN_MISC; @@ -229,9 +326,42 @@ EvdevBtnProcess (InputInfoPtr pInfo, struct input_event *ev) button += BTN_MOUSE - BTN_MISC; } - if (state->btn->state[button]) - *state->btn->state[button] = ev->value; + button -= BTN_MISC; + + if (state->btn->callback[button]) + state->btn->callback[button](pInfo, button, ev->value); button = state->btn->map[button]; xf86PostButtonEvent (pInfo->dev, 0, button, ev->value, 0, 0); } + +int +EvdevBtnFind (InputInfoPtr pInfo, const char *button) +{ + int i; + + for (i = 0; button_names[i]; i++) + if (!strcasecmp(button, button_names[i])) + return i + 1; + + return -1; +} + +int +EvdevBtnExists (InputInfoPtr pInfo, int button) +{ + evdevDevicePtr pEvdev = pInfo->private; + + button += BTN_MISC; + + xf86Msg(X_INFO, "%s: Checking button %s (%d)\n", pInfo->name, button_names[button - BTN_MISC], button); + + if ((button >= BTN_MOUSE) && (button < BTN_JOYSTICK)) { + button -= BTN_MOUSE - BTN_MISC; + } else if ((button >= BTN_MISC) && (button < BTN_MOUSE)) { + button += BTN_MOUSE - BTN_MISC; + } + + xf86Msg(X_INFO, "%s: Checking bit %d\n", pInfo->name, button); + return test_bit(button, pEvdev->bits.key); +} -- cgit v1.2.3