Commit Graph
213 Commits
Author SHA1 Message Date
Guido Günther a108dda1be led-multicolor: Scale to RGB colors to LEDs max brightness
Otherwise we might exceed max brightness and get -EINVAL.

Tested-by: Chris Vogel <chris@ween.de>
Reported-by: Chris Vogel <chris@ween.de>
Closes: https://gitlab.freedesktop.org/agx/feedbackd/-/issues/95
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-12-29 17:33:53 +00:00
Guido Günther 704f93ef15 feedback-led: Document rgb color strings
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-12-29 17:33:53 +00:00
Guido Günther 8d00274e02 alert-slider: Minor cleanups
Fix help string and move event into the block it is used in

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-12-24 15:18:47 +01:00
Guido Günther 8090ccb0a9 dev-sound: Only set media role when role based routing is enabled
This allows to already update the theme without breaking existing installations.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-10-24 13:43:39 +02:00
Guido Günther 96b00b6c61 dev-sound: Fix format
Gbp-Dch: Ignore
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-10-24 13:43:39 +02:00
Guido Günther ef1e299047 feedback-manager: Let app level cap important level
As per DBus spec the `important` hint is meant to override
the global feedback level not any per app level the user
might have configured as otherwise there's no way to override
this.

Closes: https://gitlab.freedesktop.org/agx/feedbackd/-/issues/93
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-08-24 09:28:17 +00:00
Guido Günther 546fb205ea treewide: Fix feedack typo
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-08-24 09:28:17 +00:00
Sicelo A. Mhlongo 8aa7213327 fbd-dev-led: Support LEDs with legacy naming
As noted in include/dt-bindings/leds/common.h in the Linux kernel, the Nokia
N900 has leds that use legacy naming. Until this naming scheme is removed from
the kernel, support it through the use of an additional FEEDBACKD_LED_COLOR
udev property, which must be set to the color corresponding to the LED.

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
2025-06-30 19:11:41 +02:00
Guido Günther ee8a9dd553 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>
2025-05-09 19:37:41 +00:00
Guido Günther 32cf0758d2 vibra: Some style and comment fixes
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-05-09 19:37:41 +00:00
Guido Günther f9f248ef23 fbd-dev-led: Sort leds by priority
This makes sure we e.g. prefer multicolor leds over single color ones
and those that can be on insuspend (qcom) over those that can't.

We can extend this to allow to set the priority via udev/hwdb in the
future.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-05-06 14:54:52 +00:00
Guido Günther 651c4f9fac fbd-dev-led: Ignore leds that can't handle patterns
While in theory we could have themes with only freq = 0 values we
currently assume there can be patterns.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-05-06 14:54:52 +00:00
Guido Günther e23c3401f9 fbd-dev-sound: Set special media role when present
We default to "event".

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-04-30 10:52:57 +02:00
Guido Günther 9054862071 feedback-sound: Allow to set media role
This will allow us to specify the role when playing the sound.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-04-30 10:52:57 +02:00
Guido Günther 0f031521e7 feedback-sound: Modernize prop definitions
Gbp-Dch: Ignore
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-04-30 10:52:57 +02:00
Guido Günther a3fdc4852b fbd-dev-led-multicolor: Ignore LEDs that don't have three values
We assume that multicolor LEDs are RGB so reject those that don't
have three components.

E.g. the Framework Laptop exposes a power button LED as multicolor
that only has a white component. This way it gets treated as single color LED.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-04-30 08:50:14 +00:00
knoppix knoppix 0e88863a3d Allow constant lighting of notification LED through the setting of frequency in theme.json to zero. 2025-04-23 20:02:12 +00:00
Guido Günther c37bfecbe0 vibra-periodic: Add a fallback for the previous [0, 0xFFFF] range
This keeps old themes working

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-21 12:15:57 +01:00
Guido Günther da93a16cda vibra-periodic: Deserialize magnitude and fade-in-level manually
This allows us to add proper fallbacks

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-21 12:15:56 +01:00
Guido Günther 91c34f4099 vibra-periodic: Use better defaults for fade-in-*
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 <agx@sigxcpu.org>
2025-03-21 12:14:55 +01:00
Guido Günther 89b33dcbab vibra-periodic: Use same range as in rumble and periodic
We use [0.0, 1.0] in the other haptic feedbacks so let's make periodic
do the same.

We adjust dev-vibra to match that.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/86
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-21 12:14:55 +01:00
Guido Günther f94de01a85 vibra-periodic: Modernize doc comment and property definitions
Also untabify. No functional change.

Gpb-Dch: Ignore
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-21 12:14:55 +01:00
Guido Günther 7b026b40cc dev-vibra: Allow full magnitude in rumble
Lets not artificially cap the magnitude in the device specific
implementation.

Since the default magnitude for the common rumble feedback was set to
0.5 in the previous commit the effective magnitude in existing themes
remains unchanged for that event.

The pattern feedbacks didn't make it into a release yet so there's
nothing that could get broken.

The change doubles the effective when using the Vibra DBus API but as it
seems that libmanette didn't land support yet lets just ignore that
here.

Periodic feedback is unaffected as it uses a different internal API.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-20 07:48:42 +00:00
Guido Günther f089ad2fd0 vibra-rumble: Add magnitude property
We add a magnitude property and set it to 0.5 by default. This ensure
the relative magnitude stays the same when switching from 0xFFFF to
0x7FFF in dev-vibra.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-20 07:48:42 +00:00
Evangelos Ribeiro Tzaras d5ad81cac5 tests: Depend on daemon for integration test
The carefree developer might try running meson test
before meson compile, leaving them with a failing integration test:

Start of lfb-integration tests
dbus-daemon[326641]: [session uid=1000 pid=326641 pidfd=8] Activating service name='org.sigxcpu.Feedback' requested by ':1.0' (uid=1000 pid=326640 comm="$(pwd)/_build/tests/te")
+ exec $(pwd)/_build/src/feedbackd
$(pwd)/_build/run: 18: exec: $(pwd)/_build/src/feedbackd: not found

Signed-off-by: Evangelos Ribeiro Tzaras <devrtz@fortysixandtwo.eu>
2025-03-16 09:33:45 +01:00
Guido Günther 41c1521790 vibra-periodic: Honor max strength
Since we scale down the magnitude we also scale down the fade in level
to keep the ratio between the two the same.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/84

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-09 12:28:08 +01:00
Guido Günther 6d6cd905fc vibra-rumble: Honor max haptic strength
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-09 12:28:08 +01:00
Guido Günther cc02a4d48a vibra-pattern: Honor max haptic strength
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-09 12:28:08 +01:00
Guido Günther bb1b5d0e1f feedback-vibra: Add and track max-haptic-strength gsetting
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-09 12:28:08 +01:00
Guido Günther 7b19feb25f fbd-feedback-vibra-pattern: Deserialize properties
This allows us to use them in feedback themes

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-06 11:00:04 +01:00
Guido Günther 54060b4e38 vibra-pattern: End pending vibra when a new one is triggered
This wasn't much of an issue for the DBus API but when using
it as event feedback it matters as we might start the new
feedback just before the old one ended due to timers being
slighlty late.
2025-03-06 10:57:37 +01:00
Guido Günther e92df04e80 vibra-pattern: Check for NULL dev
When running e.g. in the theme validator we might not have a vibra dev.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-06 10:57:37 +01:00
Guido Günther 88dd60413e vibra-pattern: Reset pos when done
This allows to reuse the feedback.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-06 10:57:37 +01:00
Guido Günther 836fbe0920 treewide: Fix typos
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-06 10:57:37 +01:00
Guido Günther 99cc84c646 build: Format meson files
This will make adding future files less noisy.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-05 11:30:50 +00:00
Sam Day 21f9176e5e feedback-led: Ensure flash LED is stopped when prefer-flash gets disabled
Fixes: #82

Signed-off-by: Sam Day <me@samcday.com>
2025-02-07 22:51:09 +01:00
Guido Günther c9c69304e6 feedback-manager: Add sound feedback for custom sound file
If a custom sound is provided for the event, use that instead of the one
from the theme. We always add the sound event, even when the theme
doesn't have sound feedback for that event honoring the users choice.

Closes: https://source.puri.sm/Librem5/feedbackd/-/merge_requests/150

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 16:12:46 +01:00
Guido Günther 24ed50226e feedback-manager: Parse sound file hint
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 16:12:13 +01:00
Guido Günther e105a21a1d fbd-dev-sound: Play custom sound file if specified
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 16:12:13 +01:00
Guido Günther bff82ef14b fbd-feedback-sound: Allow to set file name
This will be preferred over "effect" when set.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 16:12:13 +01:00
Guido Günther d0f1c3bb28 feedback-manager: Drop fb_found boolean
Just check the elements on the event list. This makes it easier to
extend as we can't forget to toggle the variable.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 16:11:23 +01:00
Guido Günther 9fd06731ae feedback-manager: Improve readability of add_event_feedbacks()
Save one indent level and add the feedback at the very end. This
makes extending easier.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 16:04:11 +01:00
Guido Günther 9bb2a528c6 feedback-manager: Split out event feedback preparation
It's becoming gradually more complex so move it to a separate function.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-01-26 14:38:52 +01:00
Guido Günther f639f7d103 feedback-manager: Instantiate .Haptic DBus interface
Make the haptic interface available on the Bus when a haptic
motor is found at daemon startup.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/80

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:54:40 +01:00
Guido Günther 31c7bf7d6b haptic-manager: New object to handle the Haptic DBus interface
To trigger a 200ms rumble at 100%, a 50ms pause and a 300ms rumble at 50%:

   busctl call --user org.sigxcpu.Feedback /org/sigxcpu/Feedback org.sigxcpu.Feedback.Haptic Vibrate 'sa(du)' org.foo.app 3 1.0 200  0.0 50  0.5 300

To cancel an ongoing pattern:

   busctl call --user org.sigxcpu.Feedback /org/sigxcpu/Feedback org.sigxcpu.Feedback.Haptic Vibrate 'sa(du)' org.foo.app 0

The API has lower priority than the event based API to e.g.  not miss
incoming phone calls or cell broadast messages.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:54:40 +01:00
Guido Günther 9cebb2c081 feedback-vibra: Add support for patterns
Add a new class that takes an array of durations and magnitudes.
A magnitude of 0 indicates a pause.

We can consider dropping the VibraRumble class at some point as that
is a special case of VibraPeriodic now however as the feedbacks are
encoded in the themes let's make sure VibraPattern is good API before
deprecating VibraRumble.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:58 +01:00
Guido Günther 386c98c381 dev-vibra: Allow to set magnitude
Allows for more subtle feedback

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:44 +01:00
Guido Günther 58221c7416 feedback-vibra: Allow derived classes to override duration
This allows the derived classes to perform the length duration
calculation.  The parent class can thus still keep track of the total
feedback length.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:25 +01:00
Guido Günther 18f2c88746 feedback-vibra: Clear timer id
Make sure we clear the timer id when vibra ended.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:21 +01:00
Guido Günther 24736b9490 feedback-vibra: Use g_timeout_add_once
Fix some indent while at that

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:17 +01:00