From d0b1084fb1fdba4357b60a78f392cf60a357054b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Thu, 17 Nov 2022 11:58:54 +0200 Subject: [PATCH 1/4] haptic: Define haptic effect modifiers. Define new haptic.repeat modifier, which changes how haptic effect's looping is handled. Already used keys haptic.duration and haptic.sequence were not previously defined in haptic.h so add those as well now. [haptic] Define haptic effect modifiers. JB#59349 --- src/include/ngf/haptic.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/include/ngf/haptic.h b/src/include/ngf/haptic.h index 2f601f0..bfd7b83 100644 --- a/src/include/ngf/haptic.h +++ b/src/include/ngf/haptic.h @@ -53,6 +53,27 @@ #define N_HAPTIC_EFFECT_DEFAULT "default" +/** + * haptic.repeat is generic catch-all boolean that when defined and set + * as false all repeats in haptic sequences are changed to play out only + * once, even if the sequence would be defined with unlimited repeats. + * + * In case of non-repeating sequence with the key defined as true will + * change the sequence to have unlimited repeats. + */ +#define N_HAPTIC_REPEAT_KEY "haptic.repeat" + +/** + * haptic.duration defines the maximum time an effect is played, in + * milliseconds. + */ +#define N_HAPTIC_DURATION_KEY "haptic.duration" + +/** Sequence for the haptic effect, overriding possible system-wide + * definitions for an event. + */ +#define N_HAPTIC_SEQUENCE_KEY "haptic.sequence" + /* System-defined haptic effects. Preferably all plugins implementing * haptic functionality should be able to handle all the effects * listed here. Strictly speaking only mandatory one is "default". From 67c9f3a33643b6898d5282b06629189514146b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Thu, 17 Nov 2022 12:00:18 +0200 Subject: [PATCH 2/4] ffmemless: Implement modifier haptic.repeat. If haptic.repeat key is not found revert to old behaviour of using sound.repeat for determining effect looping. [ffmemless] Implement modifier haptic.repeat. JB#59349 --- data/plugins.d/50-ffmemless.ini | 2 +- src/plugins/ffmemless/plugin.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/data/plugins.d/50-ffmemless.ini b/data/plugins.d/50-ffmemless.ini index 1e4b1e5..65f990c 100644 --- a/data/plugins.d/50-ffmemless.ini +++ b/data/plugins.d/50-ffmemless.ini @@ -34,7 +34,7 @@ supported_effects = touch;touch_weak;touch_strong;release;release_weak;release_s # _DELAY = [0,65535], milliseconds before starting playback, defaults to 0 # # _REPEAT = [1,4294967295], how many times to repeat effect, defaults to 1 -# Please note that if the event has "sound.repeat" enabled, +# Please note that if the event has "haptic.repeat" enabled, # the effect is repeated until stop signal regardless of _REPEAT # value. # diff --git a/src/plugins/ffmemless/plugin.c b/src/plugins/ffmemless/plugin.c index bc9b70a..ad5d929 100644 --- a/src/plugins/ffmemless/plugin.c +++ b/src/plugins/ffmemless/plugin.c @@ -659,7 +659,7 @@ static int ffm_sink_prepare(NSinkInterface *iface, NRequest *request) const NProplist *props = n_request_get_properties (request); const struct ffm_effect_data *data; struct ffm_effect_data *copy; - gboolean repeat; + gint repeat = -1; /* -1 not set, 1 TRUE, 0 FALSE */ guint playback_time; const gchar *key; @@ -679,9 +679,21 @@ static int ffm_sink_prepare(NSinkInterface *iface, NRequest *request) copy->request = request; copy->iface = iface; - repeat = n_proplist_get_bool (props, FFM_SOUND_REPEAT_KEY); + /* If new haptic.repeat key is defined use that, otherwise revert to + * following sound.repeat to determine looping. */ + if (n_proplist_has_key (props, N_HAPTIC_REPEAT_KEY)) + repeat = n_proplist_get_bool (props, N_HAPTIC_REPEAT_KEY) ? 1 : 0; + else + repeat = n_proplist_get_bool (props, FFM_SOUND_REPEAT_KEY) ? 1 : 0; + playback_time = n_proplist_get_uint (props, FFM_HAPTIC_DURATION_KEY); - if (repeat || playback_time) { + + /* If haptic.repeat is explicitly set to false then, if + * repeats were infinite -> set repeat to 2 (effectively repeats once) + * repeats was defined -> repeat the original repeat count */ + if (repeat == 0) { + copy->repeat = data->repeat == INT32_MAX ? 2 : data->repeat; + } else if (repeat == 1 || playback_time > 0) { /* * If duration was not defined, it's zero and we don't report playback * done. Otherwise, as effects are already stored by the kernel we just From 93b1e7c450acc182c42df5ce5527ddc4258bad62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Thu, 17 Nov 2022 12:01:22 +0200 Subject: [PATCH 3/4] haptic: Fix indentation. --- src/include/ngf/haptic.h | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/include/ngf/haptic.h b/src/include/ngf/haptic.h index bfd7b83..c4d9abe 100644 --- a/src/include/ngf/haptic.h +++ b/src/include/ngf/haptic.h @@ -44,14 +44,14 @@ * The haptic event type is used to filter out playback in case user has * disabled the setting for certain type of haptic feedback. */ -#define N_HAPTIC_TYPE_KEY "haptic.type" +#define N_HAPTIC_TYPE_KEY "haptic.type" -#define N_HAPTIC_TYPE_TOUCH "touch" -#define N_HAPTIC_TYPE_EVENT "event" +#define N_HAPTIC_TYPE_TOUCH "touch" +#define N_HAPTIC_TYPE_EVENT "event" -#define N_HAPTIC_EFFECT_KEY "haptic.effect" +#define N_HAPTIC_EFFECT_KEY "haptic.effect" -#define N_HAPTIC_EFFECT_DEFAULT "default" +#define N_HAPTIC_EFFECT_DEFAULT "default" /** * haptic.repeat is generic catch-all boolean that when defined and set @@ -83,29 +83,29 @@ * * alarm and ringtone effects should repeat indefinitely. */ -#define N_HAPTIC_EFFECT_DRAG_START "drag_start" -#define N_HAPTIC_EFFECT_RELEASE_WEAK "release_weak" -#define N_HAPTIC_EFFECT_DRAG_FAIL "drag_fail" -#define N_HAPTIC_EFFECT_DRAG_BOUNDARY "drag_boundary" -#define N_HAPTIC_EFFECT_TOUCH_WEAK "touch_weak" -#define N_HAPTIC_EFFECT_DRAG_END "drag_end" -#define N_HAPTIC_EFFECT_RELEASE "release" -#define N_HAPTIC_EFFECT_TOUCH "touch" -#define N_HAPTIC_EFFECT_RELEASE_STRONG "release_strong" -#define N_HAPTIC_EFFECT_TOUCH_STRONG "touch_strong" -#define N_HAPTIC_EFFECT_SHORT "short" -#define N_HAPTIC_EFFECT_STRONG "strong" -#define N_HAPTIC_EFFECT_LONG "long" -#define N_HAPTIC_EFFECT_NOTICE "notice" -#define N_HAPTIC_EFFECT_MESSAGE "message" -#define N_HAPTIC_EFFECT_ATTENTION "attention" -#define N_HAPTIC_EFFECT_ALARM "alarm" -#define N_HAPTIC_EFFECT_RINGTONE "ringtone" +#define N_HAPTIC_EFFECT_DRAG_START "drag_start" +#define N_HAPTIC_EFFECT_RELEASE_WEAK "release_weak" +#define N_HAPTIC_EFFECT_DRAG_FAIL "drag_fail" +#define N_HAPTIC_EFFECT_DRAG_BOUNDARY "drag_boundary" +#define N_HAPTIC_EFFECT_TOUCH_WEAK "touch_weak" +#define N_HAPTIC_EFFECT_DRAG_END "drag_end" +#define N_HAPTIC_EFFECT_RELEASE "release" +#define N_HAPTIC_EFFECT_TOUCH "touch" +#define N_HAPTIC_EFFECT_RELEASE_STRONG "release_strong" +#define N_HAPTIC_EFFECT_TOUCH_STRONG "touch_strong" +#define N_HAPTIC_EFFECT_SHORT "short" +#define N_HAPTIC_EFFECT_STRONG "strong" +#define N_HAPTIC_EFFECT_LONG "long" +#define N_HAPTIC_EFFECT_NOTICE "notice" +#define N_HAPTIC_EFFECT_MESSAGE "message" +#define N_HAPTIC_EFFECT_ATTENTION "attention" +#define N_HAPTIC_EFFECT_ALARM "alarm" +#define N_HAPTIC_EFFECT_RINGTONE "ringtone" /* Supported haptic classes */ -#define N_HAPTIC_CLASS_UNDEFINED (0) -#define N_HAPTIC_CLASS_TOUCH (1) -#define N_HAPTIC_CLASS_EVENT (2) +#define N_HAPTIC_CLASS_UNDEFINED (0) +#define N_HAPTIC_CLASS_TOUCH (1) +#define N_HAPTIC_CLASS_EVENT (2) /** * Convenience function to filter haptic depending on settings and call state From 7fcd7713e5f63f356b2cc292f87d51e240ae7963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Fri, 18 Nov 2022 11:47:55 +0200 Subject: [PATCH 4/4] Bump version. --- configure.ac | 2 +- rpm/ngfd.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 44820cf..d0e6cc6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.61) -AC_INIT(ngfd, 1.4.0) +AC_INIT(ngfd, 1.5.0) AM_INIT_AUTOMAKE([subdir-objects]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/rpm/ngfd.spec b/rpm/ngfd.spec index 21fbda0..c3a865b 100644 --- a/rpm/ngfd.spec +++ b/rpm/ngfd.spec @@ -1,7 +1,7 @@ Name: ngfd Summary: Non-graphic feedback service for sounds and other events -Version: 1.4.0 +Version: 1.5.0 Release: 1 License: LGPLv2+ URL: https://github.com/sailfishos/ngfd