Skip to content

Add haptic-control functionality to Apple M2's MTP touchpad - #573

Open
hex-64 wants to merge 4 commits into
AsahiLinux:asahi-wipfrom
hex-64:asahi-haptic-touchpad
Open

hex-64 wants to merge 4 commits into
AsahiLinux:asahi-wipfrom
hex-64:asahi-haptic-touchpad

Conversation

@hex-64

@hex-64 hex-64 commented Aug 20, 2026 •

Copy link
Copy Markdown

This merge request adds a new driver into the kernel to allow for the userspace to custom control the haptic effects of the apple MTP trackpad and follows the convention for haptic touchpad functionality as specified in [1].

Set the INPUT_PROP_PRESSUREPAD property within the MTP trackpad device indicating that this device is a haptic touchpad, and set the FF_HAPTIC capability to indicate that force feedback haptic effects can be uploaded to the trackpad [2]. Userspace can thus choose to upload force feedback effects to the touchpad, which would trigger it to switch into "Host controlled" mode, where the touchpad will no longer click unless signalled to do so by userspace.

This patch uses an unconventional means of doing so, by writing a separate loadable module for the haptic actuator. This is because the haptic actuator is considered a separate device on MTP trackpads, whereas haptics for HUTRR63 (And the other kernel drivers) considers the haptic actuator and the touchpad to be the very same device. Therefore, to conform to the standardized interface in [1] this patch creates a separate driver for the separate HID device, and is designed such that commands to the actuator are sent through the touchpad.

This changeset is relevant because allowing userspace control of the haptics allows for user control of:
1. Click feedback intensity
2. Sensitivity of when clicks trigger
3. Configuring "Force Touch"-like deep click functionality

The specific hardware commands and their fields have been reverse engineered on my own machine (Macbook Pro 2023 M2 Max) using the m1n1 hypervisor. The changes have not been tested on any other machine.

See also [3] where discussions were previously had on some of the specifics of the hardware

[1] https://lore.kernel.org/all/20250818-support-forcepads-v3-0-e4f9ab0add84@google.com/T/#m12f9be6691015fb9b2e834248c368e5f90
[2] https://docs.kernel.org/input/event-codes.html#input-prop-pressurepad
[3] https://gitlab.freedesktop.org/libinput/libinput/-/work_items/1027

@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch 2 times, most recently from 87b7a9a to 3e34e34 Compare August 20, 2026 14:48
@hex-64

hex-64 commented Aug 20, 2026

Copy link
Copy Markdown
Author

See https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1508 for an example of a userspace program that uses this functionality

@chadmed chadmed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also follow kernel commit message convention, it makes our life easier when upstreaming. This should be split into multiple commits, at least one adding the new driver and another integrating it into hid-magicmouse.

Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/Kconfig Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread include/linux/soc/apple/actuator.h Resolved
Comment thread include/linux/soc/apple/actuator.h Resolved
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 3e34e34 to 94951f1 Compare August 21, 2026 18:53
@hex-64

hex-64 commented Aug 21, 2026

Copy link
Copy Markdown
Author

Please also follow kernel commit message convention, it makes our life easier when upstreaming. This should be split into multiple commits, at least one adding the new driver and another integrating it into hid-magicmouse.

Hi! Thanks for the feedback, how's this now?

@hex-64
hex-64 requested a review from chadmed August 21, 2026 18:55
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch 3 times, most recently from 89e4a79 to 807128b Compare August 21, 2026 19:40
Comment thread drivers/hid/Kconfig Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-apple-mtp-haptic.c Resolved
Comment thread drivers/hid/Kconfig Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
Comment thread drivers/hid/hid-magicmouse.c Resolved
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch 3 times, most recently from d2be5bd to 152cea7 Compare October 24, 2026 16:43
@hex-64
hex-64 requested a review from sofus13 October 24, 2026 16:43

@sofus13 sofus13 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The driver seems close to "finished" to me. I found mostly minor style things, feel free to ignore :).

Are you planning on trying to upstream?

Btw. i have been using your driver on my m3. Thanks a lot for the time you spent on this and the libinput things

Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread include/linux/soc/apple/actuator.h Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 152cea7 to 9b260ab Compare October 25, 2026 21:22
@hex-64

hex-64 commented Oct 25, 2026

Copy link
Copy Markdown
Author

Thank you!!! I'm really glad that people are finding my work (Including the libinput stuff!) beneficial, that's all I want really!! :D

And also it's good to note that my driver works exactly as intended without modification on M3, wider range of devices to test is good also!

Yep, I really would like my changes to be upstreamed to mainline Linux, but our tree is quite different from the mainline tree for magicmouse and dockchannel, so I'm not really sure how one would go around upstreaming that 😅

But hopefully at this point, that's everything! I'm pretty happy with where the driver is at this point

@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch 2 times, most recently from 15b55d3 to 7039e98 Compare October 25, 2026 21:45
@hex-64
hex-64 requested a review from sofus13 October 31, 2026 02:39
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
Comment thread drivers/hid/hid-apple-haptic.c Resolved
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 7039e98 to 8cbfcf2 Compare November 1, 2026 04:46
@hex-64
hex-64 requested a review from sofus13 November 1, 2026 04:49
@hex-64

hex-64 commented Nov 1, 2026

Copy link
Copy Markdown
Author

Oops sorry didn't mean to request a review!

@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 8cbfcf2 to b81e8e0 Compare November 1, 2026 23:36
@hex-64

hex-64 commented Nov 1, 2026

Copy link
Copy Markdown
Author

As a final touch I went through and renamed the variables to make it clearer - in previous versions haptic_dev could have been taken to mean a struct device or a struct hid_haptic_device, where hdev could've been hid_dev or haptic_dev etc, so I went through to make it so that instead of haptic, we use actuator to refer to the device, and use haptic to refer to the effects/subsystem/struct, and hid_dev vs haptic_dev to indicator the difference between hid_haptic_device and hid_device variables. Alongside this I renamed the files so that they would be more consistent - all named actuator rather than one being apple_haptic.c whilst the other is actuator.h. Same thing with module names etc, made it all actuator for consistency's sake, and to show that it's a driver for the actuator hardware specifically.

At this point I am happy to see this get merged, can't think of anything else that this MR needs.

dchid_set_report() always sends HID_OUTPUT_REPORT regardless of the
report type requested by the caller. Inline it into its sole caller
and forward rtype directly, so SET_REPORT works correctly for feature
reports too, not just output reports, and to simplify function calls.

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
Adds a driver to control the actuator of the MTP touchpad for M2 and
later devices. This driver provides apple_actuator_init_haptics as an
entrypoint, which upon being called, will create a force feedback device
and attach it to the trackpad's input device, as well as installing all
the relevant callback functions. It also sets the FF_HAPTIC capability
to indicate that force feedback haptic effects can be uploaded to
the trackpad [1]. Through upload functions, userspace may control the
intensity or effect played when clicking.

This patch implements press, release and deep click waveforms, as well
as the softness module parameter, which sets the softness of all the
actuator's click effects.

Upon effect upload to the trackpad, the actuator will autonomously
switch from device-controlled to host-controlled mode, where it will
only click when signalled to do so by userspace. It will return to its
autonomous device-controlled mode upon erasure of the last haptic
effect, destruction of the force feedback device, or removal of the
actuator driver.

This patch is unconventional for a haptic driver, as it implements the
haptic driver as a separate loadable module from the trackpad driver.
This is because the haptic actuator is considered a separate device
on MTP trackpads, whereas haptics for HUTRR63 (and the other kernel
drivers) consider the haptic actuator and the touchpad to be the very
same device. Therefore, to conform to the standardized interface in
[2] this patch creates a separate driver for the separate HID device,
and is designed such that userspace controls the actuator through the
trackpad's input device.

The specific hardware commands and their fields have been reverse
engineered on my own machine (MacBook Pro 2023 M2 Max) using the m1n1
hypervisor.

[1] https://docs.kernel.org/input/event-codes.html#input-prop-pressurepad
[2] https://lore.kernel.org/all/20250818-support-forcepads-v3-0-e4f9ab0add84@google.com/T/#m12f9be6691015fb9b2e834248c368e5f90

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
Apple MTP trackpads already report real pressure with ABS_MT_PRESSURE. Set
the INPUT_PROP_PRESSUREPAD property as specified in commit ae8966b
("Input: rename INPUT_PROP_HAPTIC_TOUCHPAD to INPUT_PROP_PRESSUREPAD")
to indicate it as a haptic touchpad that correctly reports 5 fingers and
force in grams, rather than a traditional trackpad using pressure on a
unitless scale as a proxy for contact size.

Also set the INPUT_MT_TOTAL_FORCE bit to allow reporting of the total
force across all contacts.

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
Integrate the MTP actuator driver with the MTP trackpad driver to
expose new functionality that allows userspace to control the haptic
effects of the touchpad actuator as a force feedback device, following
the convention for haptic touchpad functionality as specified in [1].

At probe, the trackpad driver calls apple_actuator_init_haptics(), which
looks for the actuator device alongside the trackpad. Devices without an
actuator are left unchanged. If setting up haptics fails, an error is
logged and the trackpad keeps working without haptics.

This changeset will allow modification and triggering of the haptics
such that userspace may control:
    1. Click feedback intensity
    2. Sensitivity of when clicks trigger
    3. Configuring "Force Touch"-like deep click functionality

[1] https://lore.kernel.org/all/20250818-support-forcepads-v3-0-e4f9ab0add84@google.com/T/#m12f9be6691015fb9b2e834248c368e5f90

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 01d3742 to 168e216 Compare November 18, 2026 01:07
@hex-64

hex-64 commented Nov 18, 2026

Copy link
Copy Markdown
Author

Hi, what's the status of this MR now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants