/** * choose profile */ static int AccelSetProfileProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, BOOL checkOnly) { DeviceVelocityPtr vel; int profile, *ptr = &profile; int rc; int nelem = 1; if (atom != XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER)) return Success; vel = GetDevicePredictableAccelData(dev); if (!vel) return BadValue; rc = XIPropToInt(val, &nelem, &ptr); if (checkOnly) { if (rc) return rc; if (GetAccelerationProfile(vel, profile) == NULL) return BadValue; } else SetAccelerationProfile(vel, profile); return Success; }
static DeviceIntPtr createDevice(int ctrl_num, int ctrl_den, int ctrl_threshold, int scheme, int predictableProfile, float corr_mul, float const_acceleration, float min_acceleration) { DeviceIntPtr dev = new DeviceIntRec ; dev->valuator = new ValuatorClassRec ; dev->valuator->accelScheme.number = PtrAccelNoOp ; dev->valuator->accelScheme.AccelSchemeProc = NULL ; dev->valuator->accelScheme.accelData = NULL ; dev->valuator->accelScheme.AccelCleanupProc = NULL ; dev->ptrfeed = new PtrFeedbackClassRec ; dev->ptrfeed->ctrl.num = ctrl_num ; dev->ptrfeed->ctrl.den = ctrl_den ; dev->ptrfeed->ctrl.threshold = ctrl_threshold ; for (unsigned int i=0; i<MAX_VALUATORS; ++i) dev->last.remainder[i] = 0 ; if (InitPointerAccelerationScheme(dev, scheme)) { DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev) ; if (vel) { SetAccelerationProfile(vel, predictableProfile) ; vel->corr_mul = corr_mul ; vel->const_acceleration = const_acceleration ; vel->min_acceleration = min_acceleration ; } } else std::cerr << "XorgFunction: InitPointerAccelerationScheme failed" << std::endl ; return dev ; }
/** * Init struct so it should match the average case */ void InitVelocityData(DeviceVelocityPtr s) { memset(s, 0, sizeof(DeviceVelocityRec)); s->corr_mul = 10.0; /* dots per 10 milisecond should be usable */ s->const_acceleration = 1.0; /* no acceleration/deceleration */ s->reset_time = 300; s->use_softening = 1; s->min_acceleration = 1.0; /* don't decelerate */ s->coupling = 0.25; s->average_accel = TRUE; SetAccelerationProfile(s, AccelProfileClassic); InitFilterChain(s, (float)1.0/20.0, 1, 1, 40); }
/** * Init DeviceVelocity struct so it should match the average case */ void InitVelocityData(DeviceVelocityPtr vel) { memset(vel, 0, sizeof(DeviceVelocityRec)); vel->corr_mul = 10.0; /* dots per 10 milisecond should be usable */ vel->const_acceleration = 1.0; /* no acceleration/deceleration */ vel->reset_time = 300; vel->use_softening = 1; vel->min_acceleration = 1.0; /* don't decelerate */ vel->max_rel_diff = 0.2; vel->max_diff = 1.0; vel->initial_range = 2; vel->average_accel = TRUE; SetAccelerationProfile(vel, AccelProfileClassic); InitTrackers(vel, 16); }
/** * Clean up DeviceVelocityRec */ void FreeVelocityData(DeviceVelocityPtr vel) { free(vel->tracker); SetAccelerationProfile(vel, PROFILE_UNINITIALIZE); }
/** * Clean up */ static void FreeVelocityData(DeviceVelocityPtr s){ CleanupFilterChain(s); SetAccelerationProfile(s, -1); }