--- xf86-input-evdev-2.1.0/src/evdev.c 2008-11-18 19:35:18.000000000 -0500 +++ src/evdev.c 2008-11-29 19:36:03.000000000 -0500 @@ -317,13 +317,17 @@ { struct input_event ev; int len, value; - int dx, dy, tmp; + int dx, dy, dz, drx, dry, drz, tmp; unsigned int abs; unsigned int button; EvdevPtr pEvdev = pInfo->private; dx = 0; dy = 0; + dz = 0; + drx = 0; + dry = 0; + drz = 0; tmp = 0; abs = 0; @@ -364,6 +368,22 @@ dy += value; break; + case REL_Z: + dz += value; + break; + + case REL_RX: + drx += value; + break; + + case REL_RY: + dry += value; + break; + + case REL_RZ: + drz += value; + break; + case REL_WHEEL: if (value > 0) PostButtonClicks(pInfo, wheel_up_button, value); @@ -459,7 +479,7 @@ } } - if (dx != 0 || dy != 0) { + if (pInfo->type_name!=XI_SPACEBALL && (dx != 0 || dy != 0)) { if (pEvdev->swap_axes) { tmp = dx; dx = dy; @@ -469,7 +489,16 @@ dx *= -1; if (pEvdev->invert_y) dy *= -1; - xf86PostMotionEvent(pInfo->dev, FALSE, 0, 2, dx, dy); + xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, dx, dy); + } + + if (pInfo->type_name==XI_SPACEBALL) + { + if (pEvdev->invert_x) + dx *= -1; + if (pEvdev->invert_y) + dy *= -1; + xf86PostMotionEvent(pInfo->dev, TRUE, 0, 6, dx, dy, dz, drx, dry, drz); } /* @@ -940,26 +969,59 @@ pInfo = device->public.devicePrivate; - if (!InitValuatorClassDeviceStruct(device, 2, -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 - GetMotionHistory, -#endif - GetMotionHistorySize(), Relative)) - return !Success; + if(pInfo->type_name==XI_SPACEBALL) + { + if (!InitValuatorClassDeviceStruct(device, 6, + #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 + GetMotionHistory, + #endif + GetMotionHistorySize(), Absolute)) + return !Success; + } - /* X valuator */ - xf86InitValuatorAxisStruct(device, 0, -1, -1, 1, 0, 1); - xf86InitValuatorDefaults(device, 0); + else if (!InitValuatorClassDeviceStruct(device, 2, + #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 + GetMotionHistory, + #endif + GetMotionHistorySize(), Relative)) + return !Success; - /* Y valuator */ - xf86InitValuatorAxisStruct(device, 1, -1, -1, 1, 0, 1); - xf86InitValuatorDefaults(device, 1); + if(pInfo->type_name==XI_SPACEBALL) + { + /* X valuator */ + xf86InitValuatorAxisStruct(device, 0, -1800, 1800, 200, 0, 200); + + /* Y valuator */ + xf86InitValuatorAxisStruct(device, 1, -1800, 1800, 200, 0, 200); + + /* Z valuator */ + xf86InitValuatorAxisStruct(device, 2, -1800, 1800, 200, 0, 200); + + /* RX valuator */ + xf86InitValuatorAxisStruct(device, 3, -1800, 1800, 200, 0, 200); + + /* RY valuator */ + xf86InitValuatorAxisStruct(device, 4, -1800, 1800, 200, 0, 200); + + /* RZ valuator */ + xf86InitValuatorAxisStruct(device, 5, -1800, 1800, 200, 0, 200); + } + else + { + /* X valuator */ + xf86InitValuatorAxisStruct(device, 0, -1, -1, 1, 0, 1); + xf86InitValuatorDefaults(device, 0); + + /* Y valuator */ + xf86InitValuatorAxisStruct(device, 1, -1, -1, 1, 0, 1); + xf86InitValuatorDefaults(device, 1); + } xf86MotionHistoryAllocate(pInfo); if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc)) return !Success; - pInfo->flags |= XI86_POINTER_CAPABLE; + if(pInfo->type_name!=XI_SPACEBALL) pInfo->flags |= XI86_POINTER_CAPABLE; xf86MotionHistoryAllocate(pInfo); @@ -1303,7 +1365,7 @@ long key_bitmask[NBITS(KEY_MAX)] = {0}; long rel_bitmask[NBITS(REL_MAX)] = {0}; long abs_bitmask[NBITS(ABS_MAX)] = {0}; - int i, has_axes, has_keys, num_buttons; + int i, num_axes, has_keys, num_buttons; int kernel24 = 0; EvdevPtr pEvdev = pInfo->private; @@ -1338,7 +1400,7 @@ return 1; } - has_axes = FALSE; + num_axes = 0; has_keys = FALSE; num_buttons = 0; @@ -1353,14 +1415,21 @@ { pEvdev->flags |= EVDEV_BUTTON_EVENTS; pEvdev->buttons = num_buttons; - xf86Msg(X_INFO, "%s: Found %d mouse buttons\n", pInfo->name, + xf86Msg(X_INFO, "%s: Found %d buttons\n", pInfo->name, num_buttons); } - if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) { + if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask) && TestBit(REL_Z, rel_bitmask) && + TestBit(REL_RX, rel_bitmask) && TestBit(REL_RY, rel_bitmask) && TestBit(REL_RZ, rel_bitmask)) { + xf86Msg(X_INFO, "%s: Found x, y, z, rx, ry, and rz relative axes\n", pInfo->name); + pEvdev->flags |= EVDEV_RELATIVE_EVENTS; + num_axes = 6; + } + + else if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) { xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name); pEvdev->flags |= EVDEV_RELATIVE_EVENTS; - has_axes = TRUE; + num_axes = 2; } if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) { @@ -1377,7 +1446,7 @@ pEvdev->flags |= EVDEV_BUTTON_EVENTS; } } - has_axes = TRUE; + num_axes = 2; } for (i = 0; i < BTN_MISC; i++) @@ -1390,7 +1459,7 @@ has_keys = TRUE; } - if (has_axes && num_buttons) { + if (num_axes==2 && num_buttons) { xf86Msg(X_INFO, "%s: Configuring as mouse\n", pInfo->name); pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS | XI86_CONFIGURED; @@ -1415,6 +1484,12 @@ } } + if (num_axes==6 && num_buttons) { + xf86Msg(X_INFO, "%s: Configuring as 6DOF device\n", pInfo->name); + pInfo->flags |= XI86_CONFIGURED; + pInfo->type_name = XI_SPACEBALL; + } + if ((pInfo->flags & XI86_CONFIGURED) == 0) { xf86Msg(X_WARNING, "%s: Don't know how to use device\n", pInfo->name);