Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Sep 2015 10:53:36 -0700
From:      Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
To:        Dirk Engling <erdgeist@erdgeist.org>
Cc:        "freebsd-bluetooth@freebsd.org" <freebsd-bluetooth@freebsd.org>
Subject:   Re: Apple Magic Mouse
Message-ID:  <CAFPOs6p%2BEZDctPodY6DBbnhfZQFz%2Bo0uKSRvvqQBcM1QL3ACXw@mail.gmail.com>
In-Reply-To: <55F4362A.4050203@erdgeist.org>
References:  <1437909200.57929.3.camel@yandex.com> <alpine.NEB.2.11.1508092034290.5638@galant.ogmig.net> <55F4362A.4050203@erdgeist.org>

next in thread | previous in thread | raw e-mail | index | archive | help
[...]

> 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,

great!

> 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?

i think it should be possible to teach bthidd to make another sdp
request to pull device id sdp record (if available). if apple mouse
answers it then it should very easy to identify it and enable all the
features.

>> 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.

well... please read above. if its possible to identify apple mouse
then its possible to implement completely different handling of
reports (including extra ones)

thanks,
max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFPOs6p%2BEZDctPodY6DBbnhfZQFz%2Bo0uKSRvvqQBcM1QL3ACXw>