continue;
/* If the sensor is continuously firing, leave it alone */
- if ( sensor_info[s].selected_trigger !=
- sensor_info[s].motion_trigger_name)
+ if (sensor_info[s].selected_trigger !=
+ sensor_info[s].motion_trigger_name)
continue;
/* If we haven't seen a sample, there's nothing to duplicate */
int64_t period;
/*
- * Check if have have to deal with "terse" drivers that only send events
- * when there is motion, despite the fact that the associated Android
- * sensor type is continuous rather than on-change. In that case we have
- * to duplicate events. Check deadline for the nearest upcoming event.
+ * Check if we're dealing with a driver that only send events when
+ * there is motion, despite the fact that the associated Android sensor
+ * type is continuous rather than on-change. In that case we have to
+ * duplicate events. Check deadline for the nearest upcoming event.
*/
for (s=0; s<sensor_count; s++)
if (sensor_info[s].enable_count &&
}
+static void tentative_switch_trigger (int s)
+{
+ /*
+ * Under certain situations it may be beneficial to use an alternate
+ * trigger:
+ *
+ * - for applications using the accelerometer with high sampling rates,
+ * prefer the continuous trigger over the any-motion one, to avoid
+ * jumps related to motion thresholds
+ */
+
+ if (is_fast_accelerometer(s) &&
+ !(sensor_info[s].quirks & QUIRK_TERSE_DRIVER) &&
+ sensor_info[s].selected_trigger ==
+ sensor_info[s].motion_trigger_name)
+ setup_trigger(s, sensor_info[s].init_trigger_name);
+}
+
+
int sensor_set_delay(int s, int64_t ns)
{
/* Set the rate at which a specific sensor should report events */
}
}
-
if (max_supported_rate &&
new_sampling_rate > max_supported_rate) {
new_sampling_rate = max_supported_rate;
}
-
/* If the desired rate is already active we're all set */
if (new_sampling_rate == cur_sampling_rate)
return 0;
sysfs_write_float(sysfs_path, new_sampling_rate);
- /* Switch back to continuous sampling for accelerometer based games */
- if (is_fast_accelerometer(s) && sensor_info[s].selected_trigger !=
- sensor_info[s].init_trigger_name)
- setup_trigger(s, sensor_info[s].init_trigger_name);
+ /* Check if it makes sense to use an alternate trigger */
+ tentative_switch_trigger(s);
if (trig_sensors_per_dev[dev_num])
enable_buffer(dev_num, 1);