Commit Graph
189 Commits
Author SHA1 Message Date
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
Guido Günther 5ed445a81d feedback-manager: Don't trigger haptic feedbacks when vibra is busy
This just gives odd vibration. Later on we should use priorities to
allow for higher priority events like phone calls to override lower
priority events like e.g. button presses. This is similar to how we want
to handle LED patterns.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:04 +01:00
Guido Günther cdf5fb2b2d feedback-manager: Split out feedback level calculation
This allows to use it from other places too and while at that
documents it.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:35 +01:00
Guido Günther 8a11565cc1 dev-vibra: Allow to check if the device is busy
We accept `NULL` to make the case of no haptic easy to handle.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:28 +01:00
Guido Günther 5238d46968 feedback-rumble: Fix indent
There were some tabs from day 0

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:25 +01:00
Guido Günther b724789ab1 dev-vibra: Untabify
Gbp-Dch: Ignore
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:16 +01:00
Dang Huynh f2e59a4ee0 fbd-ledctrl: Add null pointer check for groups
The set_perms function does not check if getgrnam returns a null
pointer.

This causes the fbd-ledctrl to crash when a non-existent group is
passed.
2024-11-16 21:35:40 +01:00
Guido Günther 0a2392db3f fbd-alert-slider: Small service to track alert sliders
This tracks the alert slider on OnePlus 6/6T devices
and adjusts the profile level accordingly.

This is based on a script by "isyourbrain foss" in the Phosh matrix
channel.
2024-09-27 07:27:08 +00:00
Guido Günther 929d41b7db feedback-manager: End too noisy feedbacks on profile level change
When the profile gets lowered from e.g. quiet to silent we want to end
all ongoing feedbacks that belong to the quiet level.

This allows to e.g. silence an incoming phone call by switching the
feedback level via phosh's quick setting.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/13
Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/55
2024-06-21 19:57:29 +00:00
Guido Günther 3c02259156 event: Allow to end events by level
The level here is an abstract value but in fact matches the profile
level. Well make this a property when fixing #35.
2024-06-21 19:57:29 +00:00
Guido Günther 0a16ebe4af event: Make removing feedbacks more self contained
If the feedback is in our list of feedbacks disconnect signals
and drop the reference we hold.

As we have removed the signal handler that would invoke `check_ended()`
we invoke this manually when the list becomes empty.
2024-06-21 19:57:29 +00:00
Guido Günther 924320bbf9 fbd-event: Fix some indent
Gbp-Dch: Ignore
2024-06-21 19:57:29 +00:00
Guido Günther 2b6a9508a0 feedback-theme: Fix indent
Gbp-Dch: Ignore
2024-06-21 19:57:29 +00:00
Guido Günther 8f67dbd120 feedback-led: Allow to prefer flash LEDs over notification LEDs 2024-06-15 11:14:40 +02:00
Guido Günther ffd939c536 leds: Probe flash LED 2024-06-15 11:14:40 +02:00
Guido Günther e47ce8e09e led: Add flash LED type
Camera flashes are also exported via the LED subsystem. We use a
separate LED type so they're not picked by default.

We don't use them as fallbacks either.
2024-06-15 11:14:40 +02:00
Guido Günther e16dc3cdab feedback-led: Check if at least one LED is available
So far we didn't create any FbdDevLeds if there wasn't at least one
usable LED. Once we introduce flash LEDs we might probe the LED but the
LED might not be usable as the user hasn't enabled using it. Prepare for
that scenario.
2024-06-15 11:14:40 +02:00
Guido Günther 417b34be89 led: Drop FBD_FEEDBACK_LED_COLOR_LAST
With new led types we might not loop over all of them. This makes
it a bit more obvious.
2024-06-15 11:14:40 +02:00
Guido Günther a71fd7d470 manager: Move schema name to header
This makes it available to other compilation units
2024-06-15 11:14:40 +02:00
Guido Günther a4c35a8e61 led: Parse color values and pass them down the chain
We parse RGB color values as HEX ('#RRGGBB') and use those when a RGB
LED is available. Single color LEDs won't see a change.
2024-06-13 15:19:03 +02:00
Guido Günther efd088daa8 feedback-led: Document hw LED types 2024-06-13 15:17:52 +02:00
Guido Günther 4afc8398e2 feedbackd: Pass GMOBILE_USE_UNSTABLE_API to all files
No need to ack that individually
2024-06-13 15:17:52 +02:00
Guido Günther 5bd398ed18 feedback-led: Support colors as strings
The FbdDevLedColor enum defines the hardware color of the LED. We used
it for the feedbacks color value as long as the kernel mostly had
single color LEDs. As multicolor LEDs are common nowadays switch the
color to a string which will allow us to use RGB values later on.
2024-06-13 15:17:51 +02:00
Guido Günther 4551b1c939 fbd-feedback-led: Modernize property definitions
Adapt current phosh coding style before making other changes
2024-06-13 07:44:42 +02:00
Guido Günther 6e9e5700c0 dev-led-multicolor: Use correct format specifier
The values are unsigned int
2024-06-13 07:44:34 +02:00