touchpad driver


You might prefer to use Stelian Pop's driver ( over mine, it emulates a synaptics touchpad to userspace and thus allows using the synaptics X driver with all its advantages.

I have written a small in-kernel driver/userspace daemon combination for the touchpad that simply creates a new device which can be used by userspace to read the touchpad data and uses that in userspace.

The driver works as follows: Every time a userspace program attempts to read data from the /dev/apple_touchpad0 device (udev, or /dev/usb/apple_touchpad0 under devfs) it gets either 17 or 64 bytes as detailed on the parent page of this. The driver does not support short reads, so you must always supply a buffer long enough to hold 64 bytes. If the userspace program is not reading data fast enough (one packet arrives per millisecond) then data is discarded, there is no queue.

The driver is also able to inject input layer events for button click and relative mouse movements, to do this the application has to write either 4 or 8 bytes into the device. If writing 4 bytes then this controls the button (interpreted as integer: zero - down, nonzero - up). If 8 bytes, these are two integers controlling the relative movement.

The code is available from my tla archive at To check it out, try

tla register-archive
tla get

(or equivalent with baz).

To use this driver, check out the code and run make in the directory. You'll then get, in the =build directory, the two relevant files

driver userspace driver binary

appletrackpad.ko kernel driver

The kernel driver was developed against and probably has a number of bugs and/or security problems. I'd appreciate if someone would take a look at the code, also the code of the userspace driver.

To use this:

# insmod =build/appletrackpad.ko
# ./=build/driver

From that point on, your trackpad should start working. It'll be a bit touchy and you can't tap (only the button works). I did this with a kernel-driver and a userspace daemon so it is easier for you to hack on the actual finger recognition etc.

Have fun!

ToDo list

  • investigate suspend/resume support (is it necessary?)
  • rewrite userspace driver to do much more:
    • palm detection
    • generating button4/5 for scrolling with 2 fingers
    • ...