From owner-freebsd-bluetooth@freebsd.org Sat Sep 12 17:53:40 2015 Return-Path: Delivered-To: freebsd-bluetooth@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6B93A02B05 for ; Sat, 12 Sep 2015 17:53:39 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7B0B71BA4 for ; Sat, 12 Sep 2015 17:53:39 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by wicfx3 with SMTP id fx3so95830472wic.1 for ; Sat, 12 Sep 2015 10:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3oGIeIXYtG+CPHU06eLzDVachQ0wkiHSYSwH0CF9HeY=; b=dLAe3+Neeu/NvLj5BQKSBlV3tjebmJ98plmtxGBaE98cIbjXgDDRHOvOzzm2hbsjrh x2sNJHGutLViIchkofb2gWipY+TibEnngP3qz+Dk43e+y5+vkB3QVKYqHxtQrGhxjIra y0eDfspWcWXEWIZc4OBWX/E2XpuOAL/UX12K9fUJtFSkjExXZtvr1n79gE11owZcjToS J67VN8nnG40kLMTtwhrIBX/pPE5KOzwOXTi0ZiekcJeCwPjCdWVSkthLpR3rY+2WPREo zxsuAeBns9cbuxWxaX2x5/pzVPoXt0jjEGgFbyTfcmk5eZ96eCJtYgic2gRdIC0kWhBX VPsA== MIME-Version: 1.0 X-Received: by 10.180.21.169 with SMTP id w9mr8473842wie.73.1442080416821; Sat, 12 Sep 2015 10:53:36 -0700 (PDT) Received: by 10.28.146.132 with HTTP; Sat, 12 Sep 2015 10:53:36 -0700 (PDT) In-Reply-To: <55F4362A.4050203@erdgeist.org> References: <1437909200.57929.3.camel@yandex.com> <55F4362A.4050203@erdgeist.org> Date: Sat, 12 Sep 2015 10:53:36 -0700 Message-ID: Subject: Re: Apple Magic Mouse From: Maksim Yevmenkin To: Dirk Engling Cc: "freebsd-bluetooth@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-bluetooth@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Using Bluetooth in FreeBSD environments List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2015 17:53:40 -0000 [...] > 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