Jump to content

Haptics

From postmarketOS Wiki
Revision as of 03:02, 4 March 2021 by Caleb (talk | contribs) (Add page for documenting device haptics support)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Haptics

Haptics are usually taken for granted on devices, they make it easier to tell if your finger has hit the keyboard when typing, and generally add a new dimension of UX.

Device Support

The following SoCs support haptics:

TODO TODO: Add haptics to the support list and make this list automatic
  • MSM8916 (and newer related SoCs?) (drivers/input/misc/pm8xxx-vibrator.c)
  • MSM8996 - SDM845 (pmi8998_haptics.c) drivers/input/misc/pmi8998-haptics.c <- the driver is not yet upstream, a version can be found here.

If your device uses one of MSM8996, MSM8998, SDM845, you can use this WIP haptics driver (and associated dts node). You will have to find the correct play-rate for your device and fill it out like this.

Currently only the buffer play mode and LRA (Linear Resonant Actuator) are supported, contributions welcome! For more detailed information on how the haptics hardware works, see the bottom of this page.

You can test the haptics device using fftest which is part of the linuxconsoletools package.

Software Support

feedbackd

Once your hardware is up and running, copy the /usr/share/feedbackd/themes/pine,pinephone.json file and adjust it to match the DTS compatible line for your device (e.g. oneplus,enchilada.json).

In order for feedbackd to detect your haptics hardware, you need to add a new udev rule, below is the rule for pmi8998_haptics.

/usr/lib/udev/rules.d/90-feedbackd.rules
SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT}=="1", SUBSYSTEMS=="input", ATTRS{name}=="pmi8998_haptics", TAG+="uaccess", ENV{FEEDBACKD_TYPE}="vibra"

This will find the haptics input device and add the ENV{FEEDBACKD_TYPE}="vibra" property for feedbackd.

With the above changes, you should now feel ForceFeedback in Phosh!

hfd-service

hfd-service is used by Lomiri (previously known as Unity8). Whilst it is not yet supported by postmarketOS, it's worth documenting here. Support for forcefeedback vibrators is added by this PR. The Manjaro ARM unstable branch also currently has these patches.

hfd-service automatically detects the first input device that supports forcefeedback and uses it for haptics.

See also