Date: Sat, 12 Sep 2015 16:26:50 +0200 From: Dirk Engling <erdgeist@erdgeist.org> To: freebsd-bluetooth@freebsd.org Subject: Re: Apple Magic Mouse Message-ID: <55F4362A.4050203@erdgeist.org> In-Reply-To: <alpine.NEB.2.11.1508092034290.5638@galant.ogmig.net> References: <1437909200.57929.3.camel@yandex.com> <alpine.NEB.2.11.1508092034290.5638@galant.ogmig.net>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------000402030101070808000407 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 09.08.15 21:47, plunky at ogmig.net (Iain Hibbert) wrote: > I'd say that using the NetBSD driver (I am the author) is not really > possible on FreeBSD, since FreeBSD does things related to Bluetooth HIDs > differently. It should be simple enough to add the Magic Mouse handling to > the bthidd(8) daemon though, but I don't know how easy that would be, or a > separate daemon could be written instead. I've taken a look and there's several obstacles in the way. But first the good news, once I add if (fd == srv->ctrl) { static uint8_t rep[] = { 0x53, 0xd7, 0x01 }; write(new_fd, rep, 3 ); } to usr.sbin/bluetooth/bthidd/server.c:272, the hid_interrupt function in usr.sbin/bluetooth/bthidd/hid.c gets trackpad-events and mouse lift/drop from the magic mouse. My problem is now, that this feature report is hard coded and obviously not every device should be served this. But, > The way I worked the identification in NetBSD, was that when configuring a > HID device, I checked the descriptor as normal and also the > Manufacturer/Product ID via the PNP profile. When the latter matched the > Apple Magic Mouse, then it just attaches a different driver. it looks like the Manufacturer/Product ID is ignored on the hci level and thus not available at higher layers. Maybe I'm missing something here? > The Magic Mouse then needs an initialization command to be sent via the > standard HID protocol "SET_REPORT(FEATURE, 0xd7) = 0x01" once connected to > enable the special extra functionality that it provides. Also I noticed that the reports sent by the magic mouse are not reported in their hid descriptor. I get the following reports there (see attachment) 09 02 (LOCAL) USAGE Mouse (CA=Application Collection) 85 10 (GLOBAL) REPORT_ID 0x10 (16) 09 20 (LOCAL) USAGE Battery Strength 85 47 (GLOBAL) REPORT_ID 0x47 (71) 'G' 09 55 (LOCAL) USAGE 0xFF020055 85 55 (GLOBAL) REPORT_ID 0x55 (85) 'U' But when enabling the magic mouse modes as seen above, I see reports: HID Interrupt: A1 60 01 HID Interrupt: A1 61 01 Which is 0x60 and 0x61, corresponding with mouse surface lift and drop. When touching the trackpad area on the mouse, I get HID Interrupt: A1 29 00 00 80 D0 6B 9F E3 11 4D 16 83 80 32 which is report 0x29 and corresponds to the magic trackpad messages handled in the NetBSD [1] and Linux driver [2]. Problem is, that the bthidd code does not handle reports not announced in hid descriptors at all. So I would need to either manually inject the report id in hid_device->desc and add handler code, handle magic mouse in a completely different code path, or write my own driver. Maybe Maksim has some ideas, the daemon is his code, after all. Regards, erdgeist [1] http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/bluetooth/btmagic.c?rev=1.14&content-type=text/x-cvsweb-markup [2] http://lxr.free-electrons.com/source/drivers/hid/hid-magicmouse.c --------------000402030101070808000407 Content-Type: text/plain; charset=UTF-8; name="magic-mouse.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="magic-mouse.txt" Ly8tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQovLyBEZWNvZGVkIEFwcGxpY2F0aW9uIENv bGxlY3Rpb24KLy8tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQoKLyoKMDUgMDEgICAgICAg IChHTE9CQUwpIFVTQUdFX1BBR0UgICAgICAgICAweDAwMDEgR2VuZXJpYyBEZXNrdG9wIFBh Z2UKMDkgMDIgICAgICAgIChMT0NBTCkgIFVTQUdFICAgICAgICAgICAgICAweDAwMDEwMDAy IE1vdXNlIChDQT1BcHBsaWNhdGlvbiBDb2xsZWN0aW9uKQpBMSAwMSAgICAgIC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ICAgICAg IDB4NTUgKDg1KSAnVScKMTUgMDAgICAgICAgICAgKEdMT0JBTCkgTE9HSUNBTF9NSU5JTVVN ICAgIDB4MDAgKDApIDwtLSBSZWR1bmRhbnQ6IExPR0lDQUxfTUlOSU1VTSBpcyBhbHJlYWR5 IDAKMjYgRkYwMCAgICAgICAgKEdMT0JBTCkgTE9HSUNBTF9NQVhJTVVNICAgIDB4MDBGRiAo MjU1KQo3NSAwOCAgICAgICAgICAoR0xPQkFMKSBSRVBPUlRfU0laRSAgICAgICAgMHgwOCAo OCkgTnVtYmVyIG9mIGJpdHMgcGVyIGZpZWxkIDwtLSBSZWR1bmRhbnQ6IFJFUE9SVF9TSVpF IGlzIGFscmVhZHkgOAo5NSA0MCAgICAgICAgICAoR0xPQkFMKSBSRVBPUlRfQ09VTlQgICAg ICAgMHg0MCAoNjQpIE51bWJlciBvZiBmaWVsZHMKQjEgQTIgICAgICAgICAgKE1BSU4pICAg RkVBVFVSRSAgICAgICAgICAgIDB4MDAwMDAwQTIgKDY0IGZpZWxkcyB4IDggYml0cykgMD1E YXRhIDE9VmFyaWFibGUgMD1BYnNvbHV0ZSAwPU5vV3JhcCAwPUxpbmVhciAxPU5vUHJlZlN0 YXRlIDA9Tm9OdWxsIDE9Vm9sYXRpbGUgMD1CaXRtYXAKQzAgICAgICAgICAgIChNQUlOKSAg IEVORF9DT0xMRUNUSU9OICAgICBBcHBsaWNhdGlvbgoqLwoKCg== --------------000402030101070808000407--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55F4362A.4050203>