From 32cf0758d20396fc9264a66bd5f772ac728c605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 6 May 2025 11:37:00 +0200 Subject: [PATCH 1/2] vibra: Some style and comment fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- src/fbd-feedback-vibra-pattern.c | 2 +- src/fbd-feedback-vibra.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fbd-feedback-vibra-pattern.c b/src/fbd-feedback-vibra-pattern.c index ff84644..144961e 100644 --- a/src/fbd-feedback-vibra-pattern.c +++ b/src/fbd-feedback-vibra-pattern.c @@ -196,7 +196,7 @@ do_pattern_step (FbdFeedbackVibraPattern *self) *magnitude, *duration); - /* Removing any pending effect */ + /* Remove any pending effect */ fbd_dev_vibra_remove_effect (dev); if (*magnitude != 0.0) { diff --git a/src/fbd-feedback-vibra.c b/src/fbd-feedback-vibra.c index c2dc9d2..6973d80 100644 --- a/src/fbd-feedback-vibra.c +++ b/src/fbd-feedback-vibra.c @@ -1,6 +1,9 @@ /* * Copyright (C) 2020 Purism SPC + * 2024-2025 The Phosh Developers + * * SPDX-License-Identifier: GPL-3.0+ + * * Author: Guido Günther */ @@ -94,15 +97,15 @@ fbd_feedback_vibra_end (FbdFeedbackBase *base) g_return_if_fail (klass->end_vibra); klass->end_vibra (self); g_clear_handle_id (&priv->timer_id, g_source_remove); - fbd_feedback_base_done (FBD_FEEDBACK_BASE(self)); + fbd_feedback_base_done (FBD_FEEDBACK_BASE (self)); } static void fbd_feedback_vibra_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { FbdFeedbackVibra *self = FBD_FEEDBACK_VIBRA (object); FbdFeedbackVibraPrivate *priv = fbd_feedback_vibra_get_instance_private (self); 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 2/2] 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");