vibra-pattern: Don't overwrite magnitudes
When determining the value for the rumble we assigned the result to the
value in the array thus potentially overwriting the value from the theme.
This goes unnoticed as long as we don't lower the global `max_strength`
below the magnitude. But when we e.g. set the `max_strength` to
zero the device will fail to rumble when we increase `max_strength`
later on again.
Steps to reproduce:
- Use an event that used `VibraRumble`, e.g. `button-press`
in the oneplus,fajita device theme
- `fbcli -E button-pressed` -> works
- set haptic feedback to 0%:
`gsettings set org.sigxcpu.feedbackd max-haptic-strength 0.0`
- set it back to 100%:
`gsettings set org.sigxcpu.feedbackd max-haptic-strength 1.0`
- `fbcli -E button-pressed` -> no feedback
Signed-off-by: Guido Günther <agx@sigxcpu.org>
This commit is contained in:
@@ -184,29 +184,29 @@ do_pattern_step (FbdFeedbackVibraPattern *self)
|
||||
{
|
||||
FbdFeedbackManager *manager = fbd_feedback_manager_get_default ();
|
||||
FbdDevVibra *dev = fbd_feedback_manager_get_dev_vibra (manager);
|
||||
double *magnitude;
|
||||
guint *duration;
|
||||
double magnitude;
|
||||
guint duration;
|
||||
|
||||
magnitude = &g_array_index (self->magnitudes, double, self->pos);
|
||||
duration = &g_array_index (self->durations, guint, self->pos);
|
||||
magnitude = g_array_index (self->magnitudes, double, self->pos);
|
||||
duration = g_array_index (self->durations, guint, self->pos);
|
||||
|
||||
g_debug ("step: pos: %d/%d, magn: %f, timeout %u",
|
||||
self->pos,
|
||||
self->durations->len,
|
||||
*magnitude,
|
||||
*duration);
|
||||
magnitude,
|
||||
duration);
|
||||
|
||||
/* Remove any pending effect */
|
||||
fbd_dev_vibra_remove_effect (dev);
|
||||
|
||||
if (*magnitude != 0.0) {
|
||||
if (magnitude != 0.0) {
|
||||
double max_strength = fbd_feedback_vibra_get_max_strength (FBD_FEEDBACK_VIBRA (self));
|
||||
|
||||
*magnitude = MIN (*magnitude, max_strength);
|
||||
fbd_dev_vibra_rumble (dev, *magnitude, *duration, TRUE);
|
||||
magnitude = MIN (magnitude, max_strength);
|
||||
fbd_dev_vibra_rumble (dev, magnitude, duration, TRUE);
|
||||
}
|
||||
|
||||
self->timer_id = g_timeout_add_once (*duration,
|
||||
self->timer_id = g_timeout_add_once (duration,
|
||||
on_timer_expired,
|
||||
self);
|
||||
g_source_set_name_by_id (self->timer_id, "feedback-vibra-pattern-timer");
|
||||
|
||||
Reference in New Issue
Block a user