Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterychuang/5cf9bf527bc26adef47d714c758a5509 to your computer and use it in GitHub Desktop.
Save peterychuang/5cf9bf527bc26adef47d714c758a5509 to your computer and use it in GitHub Desktop.
Enable touch-size-based palm rejection and disable touchpad while typing for Apple SPI Keyboard and Touchpad under libinput
From a3febd1a49f259049d0d9650e297590b56d71ae4 Mon Sep 17 00:00:00 2001
From: "Peter Y. Chuang" <peteryuchuang@gmail.com>
Date: Fri, 4 Aug 2017 00:24:36 +0200
Subject: [PATCH libinput] udev: Add Apple SPI Keyboard and Touchpad
This enables touch-size-based palm rejection and disable-while-typing
touchpad feature for the SPI keyboards and touchpads inside the 12-inch
MacBooks and 2016 or later MacBook Pros.
---
udev/90-libinput-model-quirks.hwdb | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb
index 2754c5d5..936cb67f 100644
--- a/udev/90-libinput-model-quirks.hwdb
+++ b/udev/90-libinput-model-quirks.hwdb
@@ -56,6 +56,14 @@ libinput:touchpad:input:b0005v05ACp*
libinput:name:*Apple Inc. Apple Internal Keyboard*:dmi:*
LIBINPUT_ATTR_KEYBOARD_INTEGRATION=internal
+libinput:name:*Apple SPI Touchpad*:dmi:*
+ LIBINPUT_MODEL_APPLE_TOUCHPAD=1
+ LIBINPUT_ATTR_TOUCH_SIZE_RANGE=50:30
+ LIBINPUT_ATTR_PALM_SIZE_THRESHOLD=800
+
+libinput:name:*Apple SPI Keyboard*:dmi:*
+ LIBINPUT_ATTR_KEYBOARD_INTEGRATION=internal
+
libinput:mouse:input:b0005v05ACp030D*
LIBINPUT_MODEL_APPLE_MAGICMOUSE=1
--
2.13.4
@lilyinstarlight
Copy link

lilyinstarlight commented Sep 16, 2018

I think I've ported this to libinput 1.12.0 but I'm unsure if I did it correctly. Here it is anyway for anyone who wants to try it.

diff --git a/quirks/50-system-apple.quirks b/quirks/50-system-apple.quirks
--- a/quirks/50-system-apple.quirks
+++ b/quirks/50-system-apple.quirks
@@ -19,6 +19,16 @@ ModelAppleTouchpad=1
 MatchName=*Apple Inc. Apple Internal Keyboard*
 AttrKeyboardIntegration=internal
 
+[Apple SPI Touchpad]
+MatchName=*Apple SPI Touchpad*
+ModelAppleTouchpad=1
+AttrTouchSizeRange=50:30
+AttrPalmSizeThreshold=800
+
+[Apple SPI Keyboard]
+MatchName=*Apple SPI Keyboard*
+AttrKeyboardIntegration=internal
+
 [Apple MagicMouse]
 MatchUdevType=mouse
 MatchBus=bluetooth

@dar5hak
Copy link

dar5hak commented Aug 17, 2019

@fkmclane I tried it with git apply and it said corrupt patch at line 21. But when I manually pasted your additions into the quirks file, it worked! Thank you so much! 🙏

@TE4-David-Sundqvist
Copy link

TE4-David-Sundqvist commented Dec 4, 2020

I cloned the repo, made the changes to quirks/50-system-apple.quirks that @lilyinstarlight suggested and then built it according to this tutorial. I don't notice any change on my MBP14,1. Am I doing something wrong or are there any other changes i need to make?

@dar5hak how did you do it?

@dar5hak
Copy link

dar5hak commented Dec 4, 2020

If I remember correctly, all I did was copy the green lines and paste them without the + signs. It was over a year ago though, so don't trust me.

@TE4-David-Sundqvist
Copy link

Sounds like you did the same then and it just worked for you. Maybe it doesn't work with newer versions of libinput?

@dar5hak
Copy link

dar5hak commented Dec 5, 2020

Possible. Also, what kernel version are you on? I heard they implemented support for SPI in mainline kernel 5.x.

@TE4-David-Sundqvist
Copy link

uname -r returns 5.4.70-amd64-desktop

@dar5hak
Copy link

dar5hak commented Dec 5, 2020

Hmm, I did it on 4.15. Things likely changed from the kernel side.

@lilyinstarlight
Copy link

It looks like you don't need to recompile libinput to add a few custom hardware quirks (see https://wayland.freedesktop.org/libinput/doc/latest/device-quirks.html#installing-temporary-local-device-quirks and the next section for debugging quirks).

There's a newer local-overrides.quirks file at https://gist.github.com/roadrunner2/1289542a748d9a104e7baec6a92f9cd7#file-local-overrides-quirks for the Apple SPI driver (and touch bar driver which isn't in the mainline kernel) that it seems can just be copied to /etc/libinput/local-overrides.quirks and use your distribution's libinput.

I hope that helps! I don't run Linux bare metal on my Macbook any more for a variety of reasons or I would let you know if copying that file worked for me.

@jaxjexjox
Copy link

jaxjexjox commented Dec 24, 2020

I apologise for having someone so low skilled reply here, but I don't suppose what I need to do, to get this working? Simply write a file to a path, that the OS will parse on boot?

I'm running Ubuntu 20.10, I'd give myself about a 3.5/10 to a 4 on the linux competency scale at best.
Macbook 13,1 (A1708)

NOTE: specifically the disabling of the touchpad on typing, I've not got a touchbar, but using this is a bit fiddly when the touchpad picks up my thumbs here and there!

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