# apple magicmouse... libinput? evdev? how?

## rburcham

I have been a happy gen-1 magic mouse user for a couple years now.  All of a sudden I am not.

I recently moved from a 2012 MBP to a 2018 Dell Precision 7730.  My magic mouse had "just worked" with Xorg on the MBP, everything including left/right/middle "buttons," touch-horizontal and touch-vertical scrolling, the whole deal.  So I took it with me to the Dell.

I am working with a fresh Gentoo install, and for some reason Xorg now wants to drive the magicmouse as though it were a stock 2-button mouse.  Only left/right buttons work, no middle or touch-scrolling.  I know I never had any unique config for the magicmouse on the MBP, so I don't know why it doesn't "just work" any longer.  Googling suggests other recently have had similar issues, but many have at least manually (through xinput manipulation) been able to restore the expected behavior.  I cannot.

This is a bummer.  I have configured both libinput and evdev drivers in xorg.conf.d, and in each case I can see properties with xinput (evdev example below).

```
$ xinput list

⎡ Virtual core pointer                          id=2    [master pointer  (3)]

⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]

⎜   ↳ DELL0832:00 044E:1220 Touchpad            id=13   [slave  pointer  (2)]

⎜   ↳ rburcham’s Mouse                          id=19   [slave  pointer  (2)]

⎣ Virtual core keyboard                         id=3    [master keyboard (2)]

    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]

    ↳ Power Button                              id=6    [slave  keyboard (3)]

    ↳ Video Bus                                 id=7    [slave  keyboard (3)]

    ↳ Power Button                              id=8    [slave  keyboard (3)]

    ↳ Sleep Button                              id=9    [slave  keyboard (3)]

    ↳ Apple Inc. Apple Keyboard                 id=10   [slave  keyboard (3)]

    ↳ Apple Inc. Apple Keyboard                 id=11   [slave  keyboard (3)]

    ↳ Integrated_Webcam_HD: Integrate           id=12   [slave  keyboard (3)]

    ↳ DELL0832:00 044E:1220 UNKNOWN             id=14   [slave  keyboard (3)]

    ↳ Intel HID events                          id=15   [slave  keyboard (3)]

    ↳ Intel HID 5 button array                  id=16   [slave  keyboard (3)]

    ↳ Dell WMI hotkeys                          id=17   [slave  keyboard (3)]

    ↳ AT Translated Set 2 keyboard              id=18   [slave  keyboard (3)]
```

Indeed it seems upon initialization the values for interesting properties would suggest they are not enabled, e.g "Middle Button," "Wheel" and "Third Button" Emulation:

```
$ xinput list-props 19    

Device 'rburcham’s Mouse':

        Device Enabled (155):   1

        Coordinate Transformation Matrix (157): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

        Device Accel Profile (286):     0

        Device Accel Constant Deceleration (287):       1.000000

        Device Accel Adaptive Deceleration (288):       1.000000

        Device Accel Velocity Scaling (289):    10.000000

        Device Product ID (279):        1452, 781

        Device Node (278):      "/dev/input/event21"

        Evdev Axis Inversion (314):     0, 0

        Evdev Axes Swap (316):  0

        Axis Labels (317):      "Rel X" (165), "Rel Y" (166), "Rel Horiz Wheel" (312), "Rel Vert Wheel" (313)

        Button Labels (318):    "Button Left" (158), "Button Middle" (159), "Button Right" (160), "Button Wheel Up" (161), "Button Wheel Down" (162), "Button Horiz Wheel Left" (163), "Button Horiz Wheel Right" (164)

        Evdev Scrolling Distance (319): 1, 1, 1

        Evdev Middle Button Emulation (320):    0

        Evdev Middle Button Timeout (321):      50

        Evdev Middle Button Button (322):       2

        Evdev Third Button Emulation (323):     0

        Evdev Third Button Emulation Timeout (324):     1000

        Evdev Third Button Emulation Button (325):      3

        Evdev Third Button Emulation Threshold (326):   20

        Evdev Wheel Emulation (327):    0

        Evdev Wheel Emulation Axes (328):       0, 0, 4, 5

        Evdev Wheel Emulation Inertia (329):    10

        Evdev Wheel Emulation Timeout (330):    200

        Evdev Wheel Emulation Button (331):     4

        Evdev Drag Lock Buttons (332):  0
```

I can toggle these, for example 

```
$ xinput set-prop 19 327 1
```

... such that they appear changed on a followup 'xinput list-props 19' however this doesn't have any effect on the behavior of the device or Xorg.  When using libinput instead of evdev the results are the same, although the prop ids and descriptions for the middle/wheel/third button props are trivially different.

So the magicmouse continues to act like a 2-button mouse.  This seems to contradict similar accounts on the web e.g.

https://bbs.archlinux.org/viewtopic.php?id=132548

https://ubuntuforums.org/showthread.php?t=2390267

Perhaps most telling is that when I 'evtest /dev/input/event21' on the device, evtest completely ignores any middle-click or touch-scroll activity.  It does happily register movement and left/right clicks.  So I suppose Xorg simply sees a 2-button mouse, despite what evdev or libinput pretend to report.

Does anyone know what the new secret is to getting a gen-1 magic mouse to "just work" again?

----------

## rburcham

FWIW hid_magicmouse is definitely driving the device:

```
[Tue Nov 13 08:40:35 2018] magicmouse 0005:05AC:030D.0005: unknown main item tag 0x0

[Tue Nov 13 08:40:35 2018] input: rburcham’s Mouse as /devices/virtual/misc/uhid/0005:05AC:030D.0005/input/input25

[Tue Nov 13 08:40:35 2018] magicmouse 0005:05AC:030D.0005: input,hidraw4: BLUETOOTH HID v3.06 Mouse [rburcham’s Mouse] on [redacted]
```

and

```
# uname -a

Linux roblt4 4.18.12-gentoo #1 SMP Wed Oct 31 13:37:37 -00 2018 x86_64 Intel(R) Xeon(R) E-2176M CPU @ 2.70GHz GenuineIntel GNU/Linux

roblt4 /usr/src/linux # emerge xorg -s

  

[ Results for search key : xorg ]

Searching...

*  x11-base/xorg-drivers

      Latest version available: 1.20

      Latest version installed: 1.20

      Size of files: 0 KiB

      Homepage:      https://www.gentoo.org/

      Description:   Meta package containing deps on all xorg drivers

      License:       metapackage

*  x11-base/xorg-proto

      Latest version available: 2018.4

      Latest version installed: 2018.4

      Size of files: 483 KiB

      Homepage:      https://cgit.freedesktop.org/xorg/proto/xorgproto/

      Description:   X.Org combined protocol headers

      License:       MIT

*  x11-base/xorg-server

      Latest version available: 1.20.3

      Latest version installed: 1.20.3

      Size of files: 6,060 KiB

      Homepage:      https://www.x.org/wiki/ https://cgit.freedesktop.org/

      Description:   X.Org X servers

      License:       MIT

*  x11-base/xorg-x11

      Latest version available: 7.4-r3

      Latest version installed: 7.4-r3

      Size of files: 0 KiB

      Homepage:      https://www.x.org/wiki/

      Description:   An X11 implementation maintained by the X.Org Foundation (meta package)

      License:       metapackage

*  x11-misc/xorg-cf-files

      Latest version available: 1.0.6-r1

      Latest version installed: 1.0.6-r1

      Size of files: 335 KiB

      Homepage:      https://www.x.org/wiki/ https://cgit.freedesktop.org/

      Description:   Old Imake-related build files

      License:       MIT

[ Applications found : 5 ]
```

Last edited by rburcham on Fri Nov 30, 2018 2:32 am; edited 2 times in total

----------

## rburcham

In researching libinput I noticed in the file /usr/share/libinput/50-system-apple.quirks

```
# The Apple MagicMouse has a touchpad built-in but the kernel still

# emulates a full 2/3 button mouse for us. Ignore anything from the

# ABS interface

[Apple MagicMouse]

MatchUdevType=mouse

MatchBus=bluetooth

MatchVendor=0x05AC

MatchProduct=0x030D

AttrEventCodeDisable=EV_ABS
```

I don't know how to interpret the comment... Does anyone know what ABS means?

----------

## 1clue

I'm interested in the discussion. Posting to subscribe.

----------

## rburcham

It's nice to know that I'm not alone :)

I found this:

https://www.kernel.org/doc/Documentation/input/event-codes.txt

So now I know what EV_ABS is sort of.  Still don't really know if it's relevant.  I tried loading hid_magicmouse with that part commented out of the quirk file, and there was no difference in the driver/device behavior.

----------

## rburcham

hid_magicmouse is reporting the params:

```
# grep "" /sys/module/hid_magicmouse/parameters/*

/sys/module/hid_magicmouse/parameters/emulate_3button:Y

/sys/module/hid_magicmouse/parameters/emulate_scroll_wheel:Y

/sys/module/hid_magicmouse/parameters/report_undeciphered:N

/sys/module/hid_magicmouse/parameters/scroll_acceleration:N

/sys/module/hid_magicmouse/parameters/scroll_speed:32

```

These look right.  I have to think I'm looking at the impact of some kind of change in libinput. Perhaps a quirk change or a wholesale change in behavior. I admit I don't know what version I was running on my original gentoo'd MBP 2012 where the magic mouse behaved flawlessly.

Since gentooing this Dell Precision 7330 I can see from emerge.log that within the past two weeks I have updated from dev-libs/libinput-1.12.1-r1 to dev-libs/libinput-1.12.2 to dev-libs/libinput-1.12.3, and the magic mouse has always behaved like a 2-button mouse across the board.

```
# emerge libinput -s

  

[ Results for search key : libinput ]

Searching...

*  dev-libs/libinput

      Latest version available: 1.12.3

      Latest version installed: 1.12.3

      Size of files: 508 KiB

      Homepage:      https://www.freedesktop.org/wiki/Software/libinput/

      Description:   Library to handle input devices in Wayland

      License:       MIT

... 

*  x11-drivers/xf86-input-libinput

      Latest version available: 0.28.1

      Latest version installed: 0.28.1

      Size of files: 368 KiB

      Homepage:      https://www.x.org/wiki/ https://cgit.freedesktop.org/

      Description:   X.org input driver based on libinput

      License:       MIT

*  x11-misc/libinput-gestures

      Latest version available: 2.39

      Latest version installed: [ Not Installed ]

      Size of files: 18 KiB

      Homepage:      https://github.com/bulletmark/libinput-gestures

      Description:   Actions gestures on your touchpad using libinput

      License:       GPL-3+

```

I'll see if I can roll back the libinput.

----------

## rburcham

Rolling back to libinput 1.11.3 and 1.10.7 didn't change anything.  So now I'm thinking kernel?  I'll try an earlier kernel.

----------

## rburcham

I've tried a few kernels.  I don't know what's going on, but my BT magicmouse, which up until a couple weeks ago worked perfectly (left/right/middle clicks, v-scroll and h-scroll) on a MBP running 4.18.7, now will only drive like a stock 2-button mouse on my new Dell on that same kernel (or any other earlier or later kernel I try).  

Bummer.  Judging from Google this seems not to be an isolated incident... I'm wondering now if anyone is able to get their magic mouse to work properly.  And if so what xorg, libinput and kernel is being used?

Can anyone get their gen-1 magicmouse to work properly?

----------

## rburcham

Still no joy, with latest everything.  Kernel 4.19.1, libinput-1.12.3, xf86-input-libinput-0.28.1

After BT connecting the device, dmesg:

```
[Fri Nov 16 15:30:27 2018] magicmouse 0005:05AC:030D.0005: unknown main item tag 0x0

[Fri Nov 16 15:30:27 2018] input: rburcham’s Mouse as /devices/virtual/misc/uhid/0005:05AC:030D.0005/input/input24

[Fri Nov 16 15:30:27 2018] magicmouse 0005:05AC:030D.0005: input,hidraw4: BLUETOOTH HID v3.06 Mouse [rburcham’s Mouse] on [redacted]

```

Xorg.0.log:

```

...

[   366.242] (II) config/udev: Adding input device rburcham’s Mouse (/dev/input/mouse2)

[   366.242] (II) No input driver specified, ignoring this device.

[   366.242] (II) This device may have been added with another device file.

[   366.321] (II) config/udev: Adding input device rburcham’s Mouse (/dev/input/event21)

[   366.321] (**) rburcham’s Mouse: Applying InputClass "Apple magicmouse (BT)"

[   366.321] (II) LoadModule: "evdev"

[   366.321] (II) Loading /usr/lib64/xorg/modules/input/evdev_drv.so

[   366.354] (II) Module evdev: vendor="X.Org Foundation"

[   366.355]    compiled for 1.20.3, module version = 2.10.6

[   366.355]    Module class: X.Org XInput Driver

[   366.355]    ABI class: X.Org XInput driver, version 24.1

[   366.355] (II) Using input driver 'evdev' for 'rburcham’s Mouse'

[   366.355] (**) rburcham’s Mouse: always reports core events

[   366.355] (**) evdev: rburcham’s Mouse: Device: "/dev/input/event21"

[   366.355] (**) evdev: rburcham’s Mouse: ButtonMapping '1 2 3 4 5 6 7 8'

[   366.355] (--) evdev: rburcham’s Mouse: Vendor 0x5ac Product 0x30d

[   366.355] (--) evdev: rburcham’s Mouse: Found 3 mouse buttons

[   366.355] (--) evdev: rburcham’s Mouse: Found scroll wheel(s)

[   366.355] (--) evdev: rburcham’s Mouse: Found relative axes

[   366.355] (--) evdev: rburcham’s Mouse: Found x and y relative axes

[   366.355] (--) evdev: rburcham’s Mouse: Found absolute axes

[   366.355] (--) evdev: rburcham’s Mouse: Found absolute multitouch axes

[   366.355] (II) evdev: rburcham’s Mouse: Configuring as mouse

[   366.355] (II) evdev: rburcham’s Mouse: Adding scrollwheel support

[   366.355] (**) Option "Emulate3Buttons" "yes"

[   366.355] (**) evdev: rburcham’s Mouse: YAxisMapping: buttons 4 and 5

[   366.355] (**) evdev: rburcham’s Mouse: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200

[   366.355] (**) Option "config_info" "udev:/sys/devices/virtual/misc/uhid/0005:05AC:030D.0005/input/input24/event21"

[   366.355] (II) XINPUT: Adding extended input device "rburcham’s Mouse" (type: MOUSE, id 19)

[   366.355] (II) evdev: rburcham’s Mouse: initialized for relative axes.

[   366.355] (WW) evdev: rburcham’s Mouse: ignoring absolute axes.

[   366.355] (**) rburcham’s Mouse: (accel) keeping acceleration scheme 1

[   366.355] (**) rburcham’s Mouse: (accel) acceleration profile 0

[   366.355] (**) rburcham’s Mouse: (accel) acceleration factor: 2.000

[   366.355] (**) rburcham’s Mouse: (accel) acceleration threshold: 4
```

and

```
$ xinput list-props 19

Device 'rburcham’s Mouse':

        Device Enabled (155):   1

        Coordinate Transformation Matrix (157): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

        Device Accel Profile (286):     0

        Device Accel Constant Deceleration (287):       1.000000

        Device Accel Adaptive Deceleration (288):       1.000000

        Device Accel Velocity Scaling (289):    10.000000

        Device Product ID (279):        1452, 781

        Device Node (278):      "/dev/input/event21"

        Evdev Axis Inversion (595):     0, 0

        Evdev Axes Swap (597):  0

        Axis Labels (598):      "Rel X" (165), "Rel Y" (166), "Rel Horiz Wheel" (435), "Rel Vert Wheel" (436)

        Button Labels (599):    "Button Left" (158), "Button Middle" (159), "Button Right" (160), "Button Wheel Up" (161), "Button Wheel Down" (162), "Button Horiz Wheel Left" (163), "Button Horiz Wheel Right" (164)

        Evdev Scrolling Distance (600): 1, 1, 1

        Evdev Middle Button Emulation (601):    1

        Evdev Middle Button Timeout (602):      50

        Evdev Middle Button Button (603):       2

        Evdev Third Button Emulation (604):     0

        Evdev Third Button Emulation Timeout (605):     1000

        Evdev Third Button Emulation Button (606):      3

        Evdev Third Button Emulation Threshold (607):   20

        Evdev Wheel Emulation (608):    1

        Evdev Wheel Emulation Axes (609):       4, 5, 6, 7

        Evdev Wheel Emulation Inertia (610):    10

        Evdev Wheel Emulation Timeout (611):    200

        Evdev Wheel Emulation Button (612):     4

        Evdev Drag Lock Buttons (613):  0

$ xinput get-button-map 19

1 2 3 4 5 6 7
```

And this right here is the problem, but I know not what to do:

```
# /usr/libexec/libinput/libinput-measure-touchpad-pressure /dev/input/event21

Using rburcham’s Mouse: /dev/input/event21

Error: device does not have ABS_PRESSURE/ABS_MT_PRESSURE

$ /usr/libexec/libinput/libinput-measure-touch-size /dev/input/event21

Using rburcham’s Mouse: /dev/input/event21

Ready for recording data.

Touch sizes used: 0:0

Palm size used: 0

Thumb size used: 0

Place a single finger on the device to measure touch size.

Ctrl+C to exit

***nothing happens when I touch the mouse***

^C

$ /usr/libexec/libinput/libinput-measure-touchpad-tap /dev/input/event21

Using rburcham’s Mouse: /dev/input/event21

Error: device does not have BTN_TOUCH
```

So there simply is no touch capability from the libinput perspective.  Halp.

----------

## zmo

hi @rburcham

so you know I'm having the exact same issue, it happened to me as I recently updated my arch install from 5.0.3 to 5.1. I've tried many things but it had no effects. Did you successfully restore scroll and middle click to the mouse?

I'm doing my own research and updates on the other forums, but I thought I should share about it here as well:

https://bbs.archlinux.org/viewtopic.php?pid=1850232#p1850232

Cheers

----------

## mobian

@rburcham, @zmo,

Did either of you figure this out? I just hit the same issue and haven't been able to find a resolution...

Thanks.

----------

## zmo

Sadly, nope.

With the last update, it did solve the bluetooth disconnection issue, but I still haven't got my middle button and scroll back.

----------

## zmo

As a little update, updated to 5.2.4 kernel, and the regression is still there.

I have done some further testing, I tried switching back and forth between libinput and evdev, and setting different options to see if it changed anything and no luck at all.

I tried to listen directly to the 

```
/dev/input/eventXX
```

 chardev (using 

```
od -x
```

), and there's not a single touch event reported.

So my conclusion is that it's not the libinput/evdev's fault, but it's on the kernel side. So I did another sweep of the web (focusing on the kernel lists) and found out those threads (I missed the last time):

https://www.spinics.net/lists/linux-input/msg59094.html

who reported the same bug.

A bug report has been submitted to freedesktop, but discarded as "not our fault":

https://gitlab.freedesktop.org/libinput/libinput/issues/200

but since that thread (back in december!!!) there was no updates.

The OP of that thread suggested that this commit might have introduced the issue:

https://lkml.org/lkml/2017/4/7/109

What I find surprising is that we're like 3 people on the interwebs caring about that bug… ¯\_(ツ)_/¯

I'm going to try recompiling that module locally without that patch (or make a bisect search of the regression on the module) to find out what caused the regression.

----------

## zmo

I have made a report there, and looks like the OP did one as well:

https://github.com/robotrovsky/Linux-Magic-Trackpad-2-Driver/issues/44

it's possible that the merge with Linux Magic Trackpad 2 Driver is not responsible for the regression.

I've tried a bisect process on the kernel module by copy pasting former versions of the file within my 5.2.4 kernel tree, to see if I could get back to a version that worked, but had no luck. I went up to a 2018 version that made a major HID API change so I could not go further back without hacking the module's code.

I tried to add log outputs to the kernel module in several places, and I found out that the method `magicmouse_raw_event` does never get called on touch events, whereas it's supposed to be so.

So I thought it's the setup that's wrong, so I did a bisect on that part of the code, getting back up to a 2013 version of the module, still no luck. `magicmouse_raw_event` still does not gets called.

I'm considering two possibilities for the regression:

- either some change happened outside of the module that changes what shall be setup to start reporting those events ;

- or the mouse firmware or internal settings changed as it connected to macOS (which would be very evil).

I'll try some tests another day, but I already lost like 4/5 hours of work trying to understand this. And I'd appreciate some help/insights, as I'm quite stuck ☺

N.B.: if the owner of the repo is ok with that, I'll keep updating progress on the issue on the github issue, than stay spread between here and the arch forums. This issue is kernel related, not distribution related.

----------

