From ee8a9dd55307d5fa9b682485d8281e2ca6b87bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 6 May 2025 16:40:31 +0200 Subject: [PATCH] vibra-pattern: Don't overwrite magnitudes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/fbd-feedback-vibra-pattern.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fbd-feedback-vibra-pattern.c b/src/fbd-feedback-vibra-pattern.c index 144961e..db5bea8 100644 --- a/src/fbd-feedback-vibra-pattern.c +++ b/src/fbd-feedback-vibra-pattern.c @@ -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");