/** * 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 Atom InitTypedAtom(DeviceIntPtr dev, char *name, Atom type, int format, int nvalues, int *values) { int i; Atom atom; uint8_t val_8[9]; /* we never have more than 9 values in an atom */ uint16_t val_16[9]; uint32_t val_32[9]; pointer converted; for (i = 0; i < nvalues; i++) { switch(format) { case 8: val_8[i] = values[i]; break; case 16: val_16[i] = values[i]; break; case 32: val_32[i] = values[i]; break; } } switch(format) { case 8: converted = val_8; break; case 16: converted = val_16; break; case 32: converted = val_32; break; } atom = MakeAtom(name, strlen(name), TRUE); XIChangeDeviceProperty(dev, atom, type, format, PropModeReplace, nvalues, converted, FALSE); XISetDevicePropertyDeletable(dev, atom, FALSE); return atom; }
Atom atom_init_integer(DeviceIntPtr dev, char* name, int nvalues, int* values, int size) { Atom atom; int i; uint8_t uvals8[MAX_INT_VALUES]; uint16_t uvals16[MAX_INT_VALUES]; uint32_t uvals32[MAX_INT_VALUES]; pointer uvals; nvalues = MINVAL(MAX_INT_VALUES, nvalues); switch(size) { case 8: for (i = 0; i < nvalues; i++) { uvals8[i] = values[i]; } uvals = uvals8; break; case 16: for (i = 0; i < nvalues; i++) { uvals16[i] = values[i]; } uvals = uvals16; break; default: for (i = 0; i < nvalues; i++) { uvals32[i] = values[i]; } uvals = uvals32; break; } atom = MakeAtom(name, strlen(name), TRUE); XIChangeDeviceProperty(dev, atom, XA_INTEGER, size, PropModeReplace, nvalues, uvals, FALSE); XISetDevicePropertyDeletable(dev, atom, FALSE); return atom; }
static int init_properties(DeviceIntPtr dev) { static const char* const strMaxContacts = "Max Contacts"; static const char* const strAxesPerContact = "Axes Per Contact"; int rc; Atom labelMaxContacts; Atom labelAxesPerContact; int max_contacts = MT_NUM_FINGERS; int axes_per_contact = MT_AXIS_PER_FINGER; labelMaxContacts = MakeAtom(strMaxContacts, strlen(strMaxContacts), TRUE); labelAxesPerContact = MakeAtom(strAxesPerContact, strlen(strAxesPerContact), TRUE); rc = XIChangeDeviceProperty(dev, labelMaxContacts, XA_INTEGER, 8, PropModeReplace, 1, &max_contacts, TRUE); if (rc != Success) return rc; XISetDevicePropertyDeletable(dev, labelMaxContacts, FALSE); rc = XIChangeDeviceProperty(dev, labelAxesPerContact, XA_INTEGER, 8, PropModeReplace, 1, &axes_per_contact, TRUE); if (rc != Success) return rc; XISetDevicePropertyDeletable(dev, labelAxesPerContact, FALSE); return Success; }
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 Atom InitFloatAtom(DeviceIntPtr dev, char *name, int nvalues, float *values) { Atom atom; atom = MakeAtom(name, strlen(name), TRUE); XIChangeDeviceProperty(dev, atom, float_type, 32, PropModeReplace, nvalues, values, FALSE); XISetDevicePropertyDeletable(dev, atom, FALSE); return atom; }
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; }