/** * Allocate a device pair that is initialised as a slave * device with properties that identify the devices as belonging * to XTest subsystem. * This only creates the pair, Activate/Enable Device * still need to be called. */ int AllocXTestDevice (ClientPtr client, char* name, DeviceIntPtr* ptr, DeviceIntPtr* keybd, DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) { int retval; int len = strlen(name); char *xtestname = calloc(len + 7, 1 ); char dummy = 1; strncpy( xtestname, name, len); strncat( xtestname, " XTEST", 6 ); retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); if ( retval == Success ){ (*ptr)->xtest_master_id = master_ptr->id; (*keybd)->xtest_master_id = master_keybd->id; XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); } free( xtestname ); return retval; }
static long AccelInitProfileProperty(DeviceIntPtr dev, DeviceVelocityPtr vel) { int profile = vel->statistics.profile_number; Atom prop_profile_number = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER); XIChangeDeviceProperty(dev, prop_profile_number, XA_INTEGER, 32, PropModeReplace, 1, &profile, FALSE); XISetDevicePropertyDeletable(dev, prop_profile_number, FALSE); return XIRegisterPropertyHandler(dev, AccelSetProfileProperty, NULL, NULL); }
static long AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel) { float fval = vel->corr_mul; Atom prop_velo_scale = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING); XIChangeDeviceProperty(dev, prop_velo_scale, XIGetKnownProperty(XATOM_FLOAT), 32, PropModeReplace, 1, &fval, FALSE); XISetDevicePropertyDeletable(dev, prop_velo_scale, FALSE); return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL); }
static long AccelInitAdaptDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel) { float fval = 1.0/vel->min_acceleration; Atom prop_adapt_decel = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION); XIChangeDeviceProperty(dev, prop_adapt_decel, XIGetKnownProperty(XATOM_FLOAT), 32, PropModeReplace, 1, &fval, FALSE); XISetDevicePropertyDeletable(dev, prop_adapt_decel, FALSE); return XIRegisterPropertyHandler(dev, AccelSetAdaptDecelProperty, NULL, NULL); }
static void AccelInitDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel) { float fval = 1.0/vel->const_acceleration; Atom prop_const_decel = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION); XIChangeDeviceProperty(dev, prop_const_decel, XIGetKnownProperty(XATOM_FLOAT), 32, PropModeReplace, 1, &fval, FALSE); XISetDevicePropertyDeletable(dev, prop_const_decel, FALSE); XIRegisterPropertyHandler(dev, AccelSetDecelProperty, NULL, NULL); }
/** * Allocate a device pair that is initialised as a slave * device with properties that identify the devices as belonging * to XTest subsystem. * This only creates the pair, Activate/Enable Device * still need to be called. */ int AllocXTestDevice(ClientPtr client, const char *name, DeviceIntPtr *ptr, DeviceIntPtr *keybd, DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) { int retval; char *xtestname; char dummy = 1; if (asprintf(&xtestname, "%s XTEST", name) == -1) return BadAlloc; retval = AllocDevicePair(client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); if (retval == Success) { (*ptr)->xtest_master_id = master_ptr->id; (*keybd)->xtest_master_id = master_keybd->id; XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); } free(xtestname); return retval; }
static int device_init(DeviceIntPtr dev, InputInfoPtr local) { struct mtev_mtouch *mt = local->private; Atom atom; int i; int j; unsigned char map[MT_NUM_BUTTONS + 1]; Atom btn_labels[MT_NUM_BUTTONS] = { 0 }; Atom axes_labels[MT_NUM_VALUATORS] = { 0, }; int r; if (MT_NUM_VALUATORS > MAX_VALUATORS) { xf86Msg(X_ERROR, "MT_NUM_VALUATORS(%d) > MAX_VALUATORS(%d)\n", MT_NUM_VALUATORS, MAX_VALUATORS); return BadValue; } for (i = 0; i < MT_NUM_BUTTONS; i++) btn_labels[i] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN); atom = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); btn_labels[0] = atom; init_axes_labels(axes_labels, MT_NUM_VALUATORS); r = init_properties(dev); if (r != Success) return r; local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { xf86Msg(X_ERROR, "mtev: cannot open device\n"); return !Success; } if (mtouch_configure(mt, local->fd)) { xf86Msg(X_ERROR, "mtev: cannot configure device\n"); return !Success; } xf86CloseSerial(local->fd); for (i = 0; i < MT_NUM_BUTTONS+1; i++) map[i] = i; InitPointerDeviceStruct((DevicePtr)dev, map, MT_NUM_BUTTONS, btn_labels, pointer_control, GetMotionHistorySize(), MT_NUM_VALUATORS, axes_labels); for (i = 0; i < MT_NUM_FINGERS; i++) { for (j = 0; j < MT_AXIS_PER_FINGER; j++) { const int val = (i * MT_AXIS_PER_FINGER) + j; int min; int max; switch (j) { case 0: min = mt->caps.abs_position_x.minimum; max = mt->caps.abs_position_x.maximum; if (mt->swap_xy) { mt->min_y = min; mt->max_y = max; } else { mt->min_x = min; mt->max_x = max; } break; case 1: min = mt->caps.abs_position_y.minimum; max = mt->caps.abs_position_y.maximum; if (mt->swap_xy) { mt->min_x = min; mt->max_x = max; } else { mt->min_y = min; mt->max_y = max; } break; case 2: min = mt->caps.abs_touch_major.minimum; max = mt->caps.abs_touch_major.maximum; break; case 3: if (mt->caps.has_touch_minor) { min = mt->caps.abs_touch_minor.minimum; max = mt->caps.abs_touch_minor.maximum; } else { min = mt->caps.abs_touch_major.minimum; max = mt->caps.abs_touch_major.maximum; } break; case 4: // Tracking id min = mt->caps.abs_tracking_id.minimum; max = mt->caps.abs_tracking_id.maximum > (MT_NUM_FINGERS-1) ? (MT_NUM_FINGERS-1) : mt->caps.abs_tracking_id.maximum; break; default: return BadValue; } xf86InitValuatorAxisStruct(dev, val, axes_labels[val], min, max, 1, 0, 1, Absolute); xf86InitValuatorDefaults(dev, val); } } XIRegisterPropertyHandler(dev, pointer_property, NULL, NULL); return Success; }
static int device_init(DeviceIntPtr dev, LocalDevicePtr local) { struct MTouch *mt = local->private; unsigned char btmap[DIM_BUTTON + 1] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 Atom axes_labels[2], btn_labels[DIM_BUTTON]; initAxesLabels(axes_labels); initButtonLabels(btn_labels); #endif local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { xf86Msg(X_ERROR, "mtrack: cannot open device\n"); return !Success; } if (mtouch_configure(mt, local->fd)) { xf86Msg(X_ERROR, "mtrack: cannot configure device\n"); return !Success; } xf86CloseSerial(local->fd); #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 InitPointerDeviceStruct((DevicePtr)dev, btmap, DIM_BUTTON, GetMotionHistory, pointer_control, GetMotionHistorySize(), 2); #elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 7 InitPointerDeviceStruct((DevicePtr)dev, btmap, DIM_BUTTON, pointer_control, GetMotionHistorySize(), 2); #elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 InitPointerDeviceStruct((DevicePtr)dev, btmap, DIM_BUTTON, btn_labels, pointer_control, GetMotionHistorySize(), 2, axes_labels); #else #error "Unsupported ABI_XINPUT_VERSION" #endif xf86InitValuatorAxisStruct(dev, 0, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 axes_labels[0], #endif mt->caps.abs[MTDEV_POSITION_X].minimum, mt->caps.abs[MTDEV_POSITION_X].maximum, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 1, 0, 1, Absolute); #else 1, 0, 1); #endif xf86InitValuatorDefaults(dev, 0); xf86InitValuatorAxisStruct(dev, 1, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 axes_labels[1], #endif mt->caps.abs[MTDEV_POSITION_Y].minimum, mt->caps.abs[MTDEV_POSITION_Y].maximum, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 1, 0, 1, Absolute); #else 1, 0, 1); #endif xf86InitValuatorDefaults(dev, 1); mprops_init(&mt->cfg, local); XIRegisterPropertyHandler(dev, mprops_set_property, NULL, NULL); return Success; }