mm2
mm2 copied to clipboard
3rd button and scroll support?
Hi,
I'm wondering if you have researched what's the effort to support 3rd button and scroll?
Thanks
Hi Rafael,
thanks for your interest, enabling the driver to recognize the MagicMouse 2 and operate as a 2-button mouse was quite straight forward. The Apple Magic Mouse/Touchpad devices emulate a 2-button mouse by default and the touch features are enabled by "poking" the device with a sequence of commands.
The first step was to enable the hod-magicmouse driver to recognize the MM2. (Done!) Second step is to get "touch mode" enabled on the mouse by decoding the device init sequence. (Some progress in decoding the commands) Third step will be to make sense of the received touch data and issue the relevant button3 and scroll commands back to the HID subsystem.
The original driver was developed by capturing and decoding the Bluetooth traffic to the mouse on the protocol. The command sequence for the MM2 is, of course, different and more complex. I captured the exchange on an MS Windows system with a working MM2 driver (I don't have access to the OS X Bluetooth debugger) but have yet to get that working in my updated hid-magicmouse driver. I have also obtained an MM1 for comparison but have not had time to do the capture for comparison as I rarely have an MS Windows system to hand.
Between the demands of work and family I have not been able to make any progress for some time. If you have access to an Apple developer account for the OS X Bluetooth debugger (an XCode add-on), packet captures for the Magic Mouse and Magic Trackpad init sequences would be a great help.
I would also like to improve the existing MM1 driver by restricting the "scroll sensitive" area to a band down the middle of the mouse surface. This would probably be a backport of new code for the MM2.
The code that is worth sharing is already on Github. I do have some test code for "poking" the mouse and attempting to enable touch but it is not in a fit state for sharing beyond some snippets.
regards,
Drew
On 21/07/16, Rafael Xavier de Souza [email protected] wrote:
Hi,
I'm wondering if you have researched what's the effort to support 3rd button and scroll?
Thanks
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub(https://github.com/biggreenogre/mm2/issues/1), or mute the thread(https://github.com/notifications/unsubscribe-auth/ADzaY2VVdwsif4_IrY5hDPPc24iHuveOks5qX71bgaJpZM4JSGEd).
Thanks for the details.
I've collected some packages using MacbookPro 2015, El Capitan (more info in the gist). Please, let me know if it helps and what else can I provide?
https://gist.github.com/rxaviers/3cfa809d03c799390ac3edbb697c7b30
Thanks
Hi Drew,
Were you able to check the packages I provided above? Are they what you were looking for please? :)
Thanks
Thanks rxaviers, sorry for the delay.
Yes, that's the right stuff!
Of particular interest is "pair.txt". We need to sort out the sequence of commands used to enable reporting of touch events by the mouse. Starting at line 390 - Jul 24 23:07:15.249, the GET/SET_FEATURE_REPORT" commands are where the touch capabilities are initialised. I see the Apple tool has a much better decode, I've never seen a "MULTI-TOUCH PASS THROUGH" description before though the hex pattern looks familiar. (Should I be concerned that I can read raw hex? :-} ) Since we seem to attracting some attention, I will do my best to reconcile this with my existing Linux and MS Windows packet dumps in the next few days.
regards,
Drew
Yay! Awesome, Crossing my fingers and I'm looking forward to it. Please, let me know if you need extra data.
On first pass: RID = Report ID = a report type "new" means I have not seen them with the MM1 or TP1
- A new command:
- SET_PROTOCOL - to "71". (line 352)
- New SET_FEATURE_REPORT IDs:
- F1 - MULTI_TOUCH pass-through
- FF - KEY-HOLED RID. Sets the RID for the next GET_ key-holed RID
- New GET_FEATURE_REPORT IDs:
- 4E - RECONNECT COUNT report
- F0 - DEVICE_MANAGER report pass-through set by previous SET_ key-holed RID
- F1 - MULTI_TOUCH pass-through
I guess key-holing is a method of extending the number of Feature Report IDs available.
The linux hid-magicmouse driver for the MM1 and TouchPad 1 makes
- one GET_FEATURE_REPORT (actually one GET_ multiple times)
- one SET_FEATURE_REPORT to enable the touch features.
The OSX MM2 has
- one SET_PROTOCOL,
- five GET_FEATURE_REPORT - DEVICE MANAGER PASS THROUGH,
- a GET_ on the RECONNECT COUNT report
- multiple GET_/SET_ commands on the MULTI_TOUCH pass through
I will see if I can brute-force the MM2 into touch mode with some of the SET_REPORT commands from your Macbook. Somehow, I think it will take a little more than that.
Attached is "pair_HID.txt" containing the relevant commands filtered out from "pair.txt" pair_HID.txt
regards,
Drew
Hi guys, how can I enable scrolling function for Magic Mouse 2 on Elementary OS? I ran ./magicmouse2_build with no success.
eduardo@ef:~/Downloads/mm2-master/mm2$ ./magicmouse2_build.sh Reading package lists... Done E: Unable to find a source package for linux cp: cannot stat 'dist_src/linux-3.13.0/drivers/hid': No such file or directory ./magicmouse2_build.sh: line 23: cd: hid: No such file or directory ./magicmouse2_build.sh: line 26: ../hid-ids.diff: No such file or directory ./magicmouse2_build.sh: line 27: ../hid-core.diff: No such file or directory ./magicmouse2_build.sh: line 28: ../hid-magicmouse.diff: No such file or directory make: Entering directory '/usr/src/linux-headers-4.4.0-36-generic' scripts/Makefile.build:44: /home/eduardo/Downloads/mm2-master/mm2/Makefile: No such file or directory make[1]: *** No rule to make target '/home/eduardo/Downloads/mm2-master/mm2/Makefile'. Stop. Makefile:1403: recipe for target 'module/home/eduardo/Downloads/mm2-master/mm2' failed make: *** [module/home/eduardo/Downloads/mm2-master/mm2] Error 2 make: Leaving directory '/usr/src/linux-headers-4.4.0-36-generic' [sudo] password for eduardo: make: Entering directory '/usr/src/linux-headers-4.4.0-36-generic' DEPMOD 4.4.0-36-generic make: Leaving directory '/usr/src/linux-headers-4.4.0-36-generic' modprobe: ERROR: ../libkmod/libkmod-module.c:192 kmod_module_parse_depline() ctx=0x56239f5a4010 path=/lib/modules/4.4.0-36-generic/kernel/drivers/hid/hid.ko error=No such file or directory modprobe: ERROR: ../libkmod/libkmod-module.c:192 kmod_module_parse_depline() ctx=0x56239f5a4010 path=/lib/modules/4.4.0-36-generic/kernel/drivers/hid/hid.ko error=No such file or directory modprobe: ERROR: could not insert 'hid_magicmouse': Unknown symbol in module, or unknown parameter (see dmesg)
Magicmouse module failed to load. Time to debug? sudo: lsinput: command not found
Magicmouse module loaded but no MM2 input device detected. Check udev hwdb for MM2 exists in /etc/udev/hwdb.d/
ps: Using Macbook Pro 15, Late 2011.
Hi Eduardopfreire, these tools will NOT provide scroll support for the Magic Mouse 2. Currently we are only able to recognise the device as a Magic Mouse and load the hid_magicmouse kernel module for testing. The mouse will continue to function as a simple 2-button mouse.
The script was created and tested for Ubuntu Trusty (14.04). It is left as an exercise for the user to customise it for the distro they are using. Elementary OS may not have a "linux" meta package for the kernel source. You could try "linux-generic" instead but I am not familiar with this distro
Elementary os is based on Ububtu. The magic mouse scrolling is still not supported but it looks like there was a commit on it which hasn't been released yet
Thanks Antonie,
is this the patch? https://lists.freedesktop.org/archives/wayland-devel/2016-June/029484.html
Looks like it does add multitouch to the magimouse but I think it is only for the original Magic Mouse (judging by the vendor code 0x05ac, device id 0x030d where the MM2 has vendor code 0x004c, device id 0x0269 )
That's still good news, I will have to try it out when I can. Hopefully it will be useful if I ever get multitouch mode enabled on the MM2.
regards,
Drew
On 08/02/17, Antonie Potgieter [email protected] wrote:
Elementary os is based on Ububtu. The magic mouse scrolling is still not supported but it looks like there was a commit on it which hasn't been released yet
— You are receiving this because you commented. Reply to this email directly, view it on GitHub(https://github.com/biggreenogre/mm2/issues/1#issuecomment-278389533), or mute the thread(https://github.com/notifications/unsubscribe-auth/ADzaY6SA6TXZGMtmxe_H56YGhqS4tN3Yks5rafSGgaJpZM4JSGEd).
Yes, that's the patch I saw, I'm not sure why it hasn't been applied to the hid. In all honesty, I'm a developer but I know nothing about drivers and my Linux knowledge doesn't go as far as this.
I can't remember the specifics right now, I can get it if needed but I tried to install the mm2 and it gave an error that the magic mouse wasn't detected so I tried to edit one of the hid files to add the vendor ID to it to make it recognize and or continue but couldn't get it to work.
UPDATE: The file I tried to edit was /etc/udev/hwdb.d/
. I firmly believe that if the Magic Mouse 2 vendor ID could be correctly added there, your script should work. The internals, hardware and firmware of the mouse should be the same but it could be different.
The github project files add the (new) Apple vendor code and MM2 device id into modprobe.d and the udev hardware database so that udev will load the magicmouse kernel module. It also patches the hid subsystem and magicmouse kernel module to recognise the MM2. This enables the Magic Mouse 2 with basic 2-button functionality. However, I have not yet succeeded in enabling "touch mode" on the mouse that will allow the 3-button + gestures that make this mouse useful.
The build script was written for Ubuntu 14.04 trusty so it may need some updating. It is commented, so you should be able to figure out what is going on.
I'm currently working with other Bluetooth LE devices (BLE is not supported in the bluez v4 stack that ships with Trusty). Perhaps I will learn enough about the BT stack to get the MM2 working properly.
regards,
Drew
On 13/02/17, Antonie Potgieter [email protected] wrote:
Yes, that's the patch I saw, I'm not sure why it hasn't been applied to the hid. In all honesty, I'm a developer but I know nothing about drivers and my Linux knowledge doesn't go as far as this.
I can't remember the specifics right now, I can get it if needed but I tried to install the mm2 and it gave an error that the magic mouse wasn't detected so I tried to edit one of the hid files to add the vendor ID to it to make it recognize and or continue but couldn't get it to work.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub(https://github.com/biggreenogre/mm2/issues/1#issuecomment-279522208), or mute the thread(https://github.com/notifications/unsubscribe-auth/ADzaY2keXtt7Lx4Q6PSOGc_9G0wazwRuks5rcMXHgaJpZM4JSGEd).
Hi, Drew and everyone.
Arch user here. Have been trying anything to get my MM2 multitouch to work and still nothing. It's really annoying me to be using this "fancy" 2-button mouse. I'm also a senior sysadmin and developer (though no experience with drivers), so please tell me if I am of any help.
Regards,
@biggreenogre FYI - it appears the Bluetooth Packet Logger is available free of charge now from https://developer.apple.com/download/more/ in the "Additional Tools for Xcode". I don't have a paid developer account and was able to collect info nearly identical to what @rxaviers captured on macOS 10.12.5 for MM2.
Thanks chrstphrchvz, I downloaded it a couple of days ago and the decode descriptions are definitely useful. I'm going to try to find time in the next week to compare OSX vs Linux and with my old notes.
@biggreenogre you can count me as a beta-tester, if there will be any luck for all of us, owners of the "magic 2-button fancy mouse" :) Unfortunately, I don't have a OSx installed, only Arch, but if you will need smth, I'll be glad to help
I have access to both, OSX (various versions) and Linux (Arch). You can count on me to beta-test and anything else I can help you with. I'm really tired of having this "magic 2-button fancy mouse"...hehe
Regards,
I have access to both OSX and Linux (Ubuntu) and I can (still) help too... :)
@diegomachadosoares have you ever got a chance to build the module?
sudo modprobe hid_magicmouse
modprobe: ERROR: ctx=0x1d72010 path=/lib/modules/4.12.8-2-ARCH/kernel/drivers/hid/hid.ko.gz error=No such file or directory
modprobe: ERROR: ctx=0x1d72010 path=/lib/modules/4.12.8-2-ARCH/kernel/drivers/hid/hid.ko.gz error=No such file or directory
modprobe: ERROR: could not insert 'hid_magicmouse': Unknown symbol in module, or unknown parameter (see dmesg)
And actually I have nothing in /lib/modules/4.12.8-2-ARCH/kernel/drivers/hid/
EDIT: and yes, I'm using Arch as well.
HI, @khrt.
Nop. Since it doesn't offer anything other than what the "hid_magicmouse" already provides (and my mm2 does work as a two button mouse with hid_magicmouse out of the box on Arch LInux), I never had to compile it. About the hid_magicmouse I have it on my Arch out of the box. Are you using any custom kernel?
@diegomachadosoares
No, for me it's using hid-generic.
[ 2106.734224] hid-generic 0005:004C:0269.0006: unknown main item tag 0x0
[ 2106.734318] input: Magic Mouse 2 as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:256/0005:004C:0269.0006/input/input21
[ 2106.734526] hid-generic 0005:004C:0269.0006: input,hidraw0: BLUETOOTH HID v0.64 Mouse [Magic Mouse 2] on 00:28:f8
I'm on 4.12.8-2-ARCH
hi @biggreenogre some update about this issue?
Hi @biggreenogre!
I'm using this proprietary software on Windows10 (https://www.trackpadmagic.com/magic-mouse/download) and my Magic Mouse 2 works perfectly.
On the other hand they have NOT Linux support. But, maybe someone can find a similar solution from this (with permission).
I hope so. Tks.
Im trying to look into how these drivers work, but I can't find any decent documentation on this subject. I understand basic linux drivers, but I can't wrap my head around the hid drivers.
Can someone give me a tip where to get started?
@RobinWeymans Sorry I can't give you any detailed guidance. The driver code for the magic* devices is in hid-magicmouse.c. The patches here will get you to the point where the MM2 will use this driver but it will not have "touch mode" enabled. From there, you can follow the code and match it to Bluetooth captures (Wireshark or Xcode dev tools) to see what is happening.
You could start with the captures and comments above
Hey, everyone. I think that I have something to share: https://github.com/svartalf/hid-magicmouse2
I was able to enable touch and scroll with MM2, but since I really don't have time to finish this driver, I hope someone will continue working on this.
There is a docs/
folder with some protocol details that I've found (based on @rxaviers and my own bluetooth dumps) and hid-magicmouse2.c
contains init code that is required to enable touch/scroll support.
Hi @svartalf ! Nice work. I just successfully built your driver. When I load the driver tho, the MM2 does not use the magicmouse2 driver. It still uses the hid generic driver.
I checked the hid-ids2, but everything seems fine. You have an idea what could be the problem?
[48593.817447] hid-generic 0005:004C:0269.0008: unknown main item tag 0x0
[48593.817627] input: Magic Mouse 2 as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/bluetooth/hci0/hci0:6/0005:004C:0269.0008/input/input48
[48593.818335] hid-generic 0005:004C:0269.0008: input,hidraw2: BLUETOOTH HID v0.64 Mouse [Magic Mouse 2] on 9c:b6:d0:89:f2:e2
@RobinWeymans yeah, that's a funny part. You need to re-bind it to hid-magicmouse2
driver, manually or via udev rules.
@svartalf I just found some time to figure out how to get this driver loaded, and i finally got it!
The vertical/horizontal scrolling and the middle mouse button seem to work fine for me. Yay! I didnt change any of your code, but you say you hoped someone will continue working on this. What improvements did you have in mind? Maybe I can look at it.
@RobinWeymans well, I'm glad that it's working not only for me!
As for work continuation:
- Code should be cleaned up, since there is a lot of debug things and I'm bad in C also :)
- I'm totally not sure about touch surface coords calculation, as you might found I just re-used coords from MM1, but I have no idea if they're totally correct (it works, but does it works properly?)
- It would be nice to continue reverse engineering of the available reports, for example, I'm not quite sure if Linux supports battery status reports now, but it would be nice to see charge percents somewhere.
UPD: It would be nice to drive it to some milestone and than create packages for common linux distros, so it can be tested by community.
@svartalf I modified your code to update hid-magicmouse. This driver also has an easy dkms install script in this repo: https://github.com/rohitpid/Linux-Magic-Trackpad-2-Driver
We now have:
- Scrolling
- Mouse middle click to paste selected text
- Regular functionality like left, right clicks and mouse motion
Please can you @RobinWeymans and anyone else test. Particularly if anyone has magic mouse 1, magic trackpad 1, magic mouse 2, and magic trackpad 2, does this driver work for all 4 devices? I've tested both trackpad2 and mouse2 work together.
I'm going to try to rework some of the code because I think multitouch could be used instead of scroll wheel emulation.