robbi5 / magictrackpad2-dkms

A DKMS module to support the Apple Magic Trackpad 2
GNU General Public License v2.0
104 stars 11 forks source link

please get it merged into the Linux kernel #1

Open ec1oud opened 7 years ago

ec1oud commented 7 years ago

https://bugzilla.kernel.org/show_bug.cgi?id=112481 is a bug about this (which I wrote). I just today found your driver here.

robbi5 commented 7 years ago

The driver itself comes from @robotrovsky - see https://github.com/tiziano88/magic-trackpad-2-linux/issues/4

As you can read in the comment https://github.com/tiziano88/magic-trackpad-2-linux/issues/4#issuecomment-256772251 the driver is currently working - but only for usb. A better way that also supports bluetooth would be to implement it in the other touchpad driver that exists already in the kernel.

I just tried a few hours to package it into an ubuntu-compatible dkms package and don't know much about real kernel driver development, so I think that would be a better task for someone like @robotrovsky or other people who can hack on kernel drivers :)

johnyf commented 7 years ago

May I ask, just to make sure, if implemented in the other touchpad driver that already exists in the kernel, the driver would support both usb and bluetooth (not only bluetooth), right? I am asking because I'm interested in the usb mode of operation.

mwyborski commented 7 years ago

Yes, in the Magic Mouse/Magic Trackpad Driver, both USB and Bluetooth should work. It shouldn't be that difficult to port it over. USB is working with the existing driver already.

seefood commented 7 years ago

Any news about this? Alternatively, can this package be upgraded for kernel 4.10? It won't install nicely on Ubuntu Zesty without manual intervention:

❯ sudo dpkg -i magictrackpad2-dkms_1.0.0_all.deb 
Selecting previously unselected package magictrackpad2-dkms.
(Reading database ... 466158 files and directories currently installed.)
Preparing to unpack magictrackpad2-dkms_1.0.0_all.deb ...
Unpacking magictrackpad2-dkms (1.0.0) ...
Setting up magictrackpad2-dkms (1.0.0) ...

Creating symlink /var/lib/dkms/bcm5974/4.4+magictrackpad2/source ->
                 /usr/src/bcm5974-4.4+magictrackpad2

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j4 KERNELRELEASE=4.10.0-21-generic KERNEL_VERSION=4.10.0-21-generic all...
cleaning build area...

DKMS: build completed.

bcm5974:
Running module version sanity check.
Error! Module version 61D1CCA2F62F3B0BF9FEA62 for bcm5974.ko
is not newer than what is already found in kernel 4.10.0-21-generic (9918D260A34AD1472D292E2).
You may override by specifying --force.

depmod...

Backing up initrd.img-4.10.0-21-generic to /boot/initrd.img-4.10.0-21-generic.old-dkms
Making new initrd.img-4.10.0-21-generic
(If next boot fails, revert to initrd.img-4.10.0-21-generic.old-dkms image)
update-initramfs.......

DKMS: install completed.

Creating symlink /var/lib/dkms/hid/4.4+magictrackpad2/source ->
                 /usr/src/hid-4.4+magictrackpad2

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j4 KERNELRELEASE=4.10.0-21-generic -C /lib/modules/4.10.0-21-generic/build SUBDIRS=/var/lib/dkms/hid/4.4+magictrackpad2/build modules...
cleaning build area...

DKMS: build completed.

hid:
Running module version sanity check.
Error! Module version 05EF5100D1109BB0B3D672B for hid.ko
is not newer than what is already found in kernel 4.10.0-21-generic (E63C31BEC30B5CFB034E4B4).
You may override by specifying --force.

hid-apple.ko:
Running module version sanity check.
Error! Module version 2AA2E40696F597EF7D7FBF8 for hid-apple.ko
is not newer than what is already found in kernel 4.10.0-21-generic (F8F097919D0FCE0DF2EE660).
You may override by specifying --force.

depmod...

Backing up initrd.img-4.10.0-21-generic to /boot/initrd.img-4.10.0-21-generic.old-dkms
Making new initrd.img-4.10.0-21-generic
(If next boot fails, revert to initrd.img-4.10.0-21-generic.old-dkms image)
update-initramfs......

DKMS: install completed.
mwyborski commented 7 years ago

During the summer i should find time, to rewrite the driver with Bluetooth support. Afterwards i will try to get it merged into the kernel.

ira-lb commented 7 years ago

In the meantime, what can I do to get it to compile and install on Ubuntu 17.04? does it need to be ported to 4.10?

anton-johansson commented 7 years ago

Great work! I'm wondering, just like @ira-lb, if there's any way to get it working on Ubuntu 17.04. I'm getting this:

hid:
Running module version sanity check.
Error! Module version 05EF5100D1109BB0B3D672B for hid.ko
is not newer than what is already found in kernel 4.10.0-28-generic (E63C31BEC30B5CFB034E4B4).
You may override by specifying --force.

hid-apple.ko:
Running module version sanity check.
Error! Module version 2AA2E40696F597EF7D7FBF8 for hid-apple.ko
is not newer than what is already found in kernel 4.10.0-28-generic (F8F097919D0FCE0DF2EE660).
You may override by specifying --force.
mwyborski commented 7 years ago

Thanks! Please look for the updated official patch i send to linux-input: http://www.spinics.net/lists/kernel/msg2551703.html

I will post updates about the patch here: https://github.com/robotrovsky/Linux-Magic-Trackpad-2-Driver

ponyfleisch commented 7 years ago

Hey guys! I made a driver (based in part on this and the old magicmouse driver) that uses the HID layer so it works with bluetooth. Theoretically it should work with USB as well, however, there are some issues with USB at the moment. I also reverse engineered the protocol to be able to use host-based clicks which means we can do force touch now and adjust click parameters (sensitivity, intensity).

It's ALPHA quality at best and needs a lot of cleanup and polish before it's even remotely ready, but i thought it's best to share it early:

https://github.com/ponyfleisch/hid-magictrackpad2

I did not yet include modifications to the hid modules (like this driver does), so you might have to manually run rmmod hid-generic; modprobe hid-magictrackpad2.

Let me know if this one works for you. It may or may not be a basis on which to build a proper driver.

D12EA177E12 commented 7 years ago

@ponyfleisch

but I thought it's best to share it early

Yep, and it's the moment that everyone's been waiting for.

Before your driver came along, the Apple Magic Trackpad2 (hereafter referred to as the amtp2) is only capable of cursor movement, left mouse button and basic drag-and-drop in Linux. So, with the additional bluetooth, two-finger scroll and two-finger right-click support, which your driver provides, I thought we finally have ourselves a usable amtp2 on Linux. To my surprise, the basic drag-and-drop doesn't work. Can you verify with me whether you have drag-and-drop on your system.

Here is the output of sudo xinput --list-props 10:

Device 'Apple Magic Trackpad 2':
    Device Enabled (152):   1
    Coordinate Transformation Matrix (154): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    Device Accel Profile (280): 1
    Device Accel Constant Deceleration (281):   2.500000
    Device Accel Adaptive Deceleration (282):   1.000000
    Device Accel Velocity Scaling (283):    12.500000
    Synaptics Edges (547):  -3374, 3630, -2206, 2313
    Synaptics Finger (548): 25, 30, 0
    Synaptics Tap Time (549):   180
    Synaptics Tap Move (550):   402
    Synaptics Tap Durations (551):  180, 100, 100
    Synaptics ClickPad (552):   1
    Synaptics Middle Button Timeout (553):  0
    Synaptics Two-Finger Pressure (554):    283
    Synaptics Two-Finger Width (555):   7
    Synaptics Scrolling Distance (556): -182, -182
    Synaptics Edge Scrolling (492): 0, 0, 0
    Synaptics Two-Finger Scrolling (493):   1, 1
    Synaptics Move Speed (557): 1.000000, 1.750000, 0.021875, 0.000000
    Synaptics Button Scrolling (558):   1, 1
    Synaptics Button Scrolling Repeat (559):    1, 1
    Synaptics Button Scrolling Time (560):  100
    Synaptics Off (490):    2
    Synaptics Locked Drags (561):   0
    Synaptics Locked Drags Timeout (562):   5000
    Synaptics Tap Action (491): 2, 3, 0, 0, 1, 3, 0
    Synaptics Click Action (563):   1, 3, 0
    Synaptics Circular Scrolling (564): 0
    Synaptics Circular Scrolling Distance (565):    0.100000
    Synaptics Circular Scrolling Trigger (566): 0
    Synaptics Circular Pad (567):   0
    Synaptics Palm Detection (568): 0
    Synaptics Palm Dimensions (569):    10, 200
    Synaptics Coasting Speed (570): 20.000000, 50.000000
    Synaptics Pressure Motion (571):    30, 160
    Synaptics Pressure Motion Factor (572): 1.000000, 1.000000
    Synaptics Resolution Detect (573):  1
    Synaptics Grab Event Device (574):  0
    Synaptics Gestures (575):   1
    Synaptics Capabilities (576):   1, 0, 0, 1, 1, 1, 1
    Synaptics Pad Resolution (577): 1, 1
    Synaptics Area (578):   0, 0, 0, 0
    Synaptics Soft Button Areas (579):  0, 0, 0, 0, 0, 0, 0, 0
    Synaptics Noise Cancellation (580): 4, 4
    Device Product ID (269):    76, 613
    Device Node (270):  "/dev/input/event16"

and here's the output of sudo xinput --list --long 10:

Apple Magic Trackpad 2                      id=10   [slave  pointer  (2)]
    Reporting 11 classes:
        Class originated from: 10. Type: XIButtonClass
        Buttons supported: 12
        Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" None None None None None
        Button state:
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 0:
          Label: Rel X
          Range: -3678.000000 - 3934.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 1:
          Label: Rel Y
          Range: -2479.000000 - 2586.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 2:
          Label: Rel Horiz Scroll
          Range: 0.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 3:
          Label: Rel Vert Scroll
          Range: 0.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 4:
          Label: Abs MT Touch Major
          Range: 0.000000 - 2048.000000
          Resolution: 0 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 5:
          Label: Abs MT Touch Minor
          Range: 0.000000 - 2048.000000
          Resolution: 0 units/m
          Mode: absolute
          Current value: 0.000000
        Class originated from: 10. Type: XIValuatorClass
        Detail for Valuator 6:
          Label: Abs MT Orientation
          Range: -16384.000000 - 16384.000000
          Resolution: 0 units/m
          Mode: absolute
          Current value: 6144.000000
        Class originated from: 10. Type: XIScrollClass
        Scroll info for Valuator 2
          type: 2 (horizontal)
          increment: -182.000000
          flags: 0x0
        Class originated from: 10. Type: XIScrollClass
        Scroll info for Valuator 3
          type: 1 (vertical)
          increment: -182.000000
          flags: 0x0
        Class originated from: 10. Type: XITouchClass
        Touch mode: dependent
        Max number of touches: 16

Can anyone spot something wrong with the above settings? Any help will be greatly appreciated.

So close, ever so close...

@robbi5 sorry robbi5, I know my issue is not exactly about your dkms package, but we're all in this together, right? :-)

nsklaus commented 6 years ago

@ponyfleisch your dkms module works great ! thanks to @robbi5 and all involved too :)

chaddjohnson commented 6 years ago

@ponyfleisch @nsklaus I installed the dkms module, ran rmmod hid-generic; modprobe hid-magictrackpad, and connected my Apple Magic Trackpad 2. I am able to click, but the mouse cursor now will not move using the trackpad :(

Did I miss a step, or did you have to do something extra to make the cursor work?

I'm on Ubuntu 17.10 and kernel 4.13.0-25-generic.

markmcd commented 6 years ago

Ditto. Tried it on a Debian system with kernel 4.9.0-5-amd64, did the module dance & the cursor does not move. Clicks work fine though.

attila-lendvai commented 4 years ago

i can't even connect mine through bluetooth settings (Debian 10, kernel 5.5)... :/