From 91c34f409928e77f7e482467cb36228993d16fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Mar 2025 14:55:41 +0100 Subject: [PATCH] vibra-periodic: Use better defaults for fade-in-* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lets start at zero when not specified otherwise and also set an arbitrary fade-in-time as setting it to the duration isn't very helpful. While at that move the defaults to the feedback rather than the device so we ensure consistency over different device implementations. Signed-off-by: Guido Günther --- src/fbd-dev-vibra.c | 9 --------- src/fbd-feedback-vibra-periodic.c | 13 ++++++++----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/fbd-dev-vibra.c b/src/fbd-dev-vibra.c index 62dc824..f764a6c 100644 --- a/src/fbd-dev-vibra.c +++ b/src/fbd-dev-vibra.c @@ -283,15 +283,6 @@ fbd_dev_vibra_periodic (FbdDevVibra *self, g_return_val_if_fail (FBD_IS_DEV_VIBRA (self), FALSE); - if (!magnitude) - magnitude = 0.5; - - if (!fade_in_level) - fade_in_level = magnitude; - - if (!fade_in_time) - fade_in_time = duration; - effect.type = FF_PERIODIC; effect.id = -1; effect.u.periodic.waveform = FF_SINE; diff --git a/src/fbd-feedback-vibra-periodic.c b/src/fbd-feedback-vibra-periodic.c index 733c219..2af95fd 100644 --- a/src/fbd-feedback-vibra-periodic.c +++ b/src/fbd-feedback-vibra-periodic.c @@ -35,9 +35,9 @@ static GParamSpec *props[PROP_LAST_PROP]; typedef struct _FbdFeedbackVibraPeriodic { FbdFeedbackVibra parent; - double magnitude; - double fade_in_level; - guint fade_in_time; + double magnitude; + double fade_in_level; + guint fade_in_time; } FbdFeedbackVibraPeriodic; G_DEFINE_TYPE (FbdFeedbackVibraPeriodic, fbd_feedback_vibra_periodic, FBD_TYPE_FEEDBACK_VIBRA); @@ -151,12 +151,12 @@ fbd_feedback_vibra_periodic_class_init (FbdFeedbackVibraPeriodicClass *klass) props[PROP_FADE_IN_TIME] = g_param_spec_uint ("fade-in-time", "", "", - 0, G_MAXINT, 0, + 0, G_MAXINT, 500, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); props[PROP_FADE_IN_LEVEL] = g_param_spec_double ("fade-in-level", "", "", - 0.0, 1.0, 0.5, + 0.0, 1.0, 0.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, PROP_LAST_PROP, props); @@ -165,4 +165,7 @@ fbd_feedback_vibra_periodic_class_init (FbdFeedbackVibraPeriodicClass *klass) static void fbd_feedback_vibra_periodic_init (FbdFeedbackVibraPeriodic *self) { + self->magnitude = 0.5; + self->fade_in_level = 0.0; + self->fade_in_time = 500; }