From owner-freebsd-usb@FreeBSD.ORG Sat May 16 20:44:52 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E98A106564A for ; Sat, 16 May 2009 20:44:52 +0000 (UTC) (envelope-from christoph@rosenkeller.org) Received: from rosenkeller.org (fry.rose.uni-jena.de [141.35.60.60]) by mx1.freebsd.org (Postfix) with ESMTP id 8B6138FC1E for ; Sat, 16 May 2009 20:44:51 +0000 (UTC) (envelope-from christoph@rosenkeller.org) Received: by rosenkeller.org (Postfix, from userid 65534) id DC09926420A; Sat, 16 May 2009 22:44:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by rosenkeller.org (Postfix) with ESMTP id BFF7F26420A; Sat, 16 May 2009 22:44:45 +0200 (CEST) Received: from rosenkeller.org ([127.0.0.1]) by localhost (fry.localnet.rose [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 17079-02; Sat, 16 May 2009 22:44:34 +0200 (CEST) Received: from [192.168.0.2] (cable-static-237-100.teleport.ch [213.188.237.100]) by rosenkeller.org (Postfix) with ESMTPSA id C4EDF2641FE; Sat, 16 May 2009 22:44:31 +0200 (CEST) Message-ID: <4A0F25C5.9020706@rosenkeller.org> Date: Sat, 16 May 2009 22:44:53 +0200 From: Christoph Langguth User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Hans Petter Selasky References: <4A0DC89C.6010708@rosenkeller.org> <200905162001.30735.hselasky@c2i.net> <4A0F1039.7050403@rosenkeller.org> <200905162158.22210.hselasky@c2i.net> In-Reply-To: <200905162158.22210.hselasky@c2i.net> Content-Type: multipart/mixed; boundary="------------030500090406070609070007" X-Virus-Scanned: amavisd-new at rosenkeller.org X-Spam-Status: No, score=-4.054 tagged_above=-99 required=5 tests=[ALL_TRUSTED=-1.8, AWL=0.345, BAYES_00=-2.599] X-Spam-Score: -4.054 X-Spam-Level: Cc: freebsd-usb@freebsd.org Subject: Re: How to add support for Macbook Pro (USB) keyboard? X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:44:52 -0000 This is a multi-part message in MIME format. --------------030500090406070609070007 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, >> Finally, for curiosity, since I didn't really get how the code works: >> how do you know reliably whether to toggle the APPLE_SWAP flag? Does the >> HID descriptor give you information about that "anomaly"? (I'm just >> wondering whether it wouldn't mistakenly swap the keys on unaffected >> Apple keyboards) > > I was just taking your example. I assume that Apple make the keyboards alike. > If not we will have to adjust. I did not look too close at the HID > descriptor. I just assume that when the special HID item is present, which > indicates the EJECT, then it is an Apple keyboard and that it works like an > Apple keyboard. Hmm... well, I guess it's fine for now, but I believe that actually not all of the keyboards have this swap "bug". Apple seems to change their hardware (and the behavior thereof...) quite often :-( > >> And... one final issue here, which is low-priority for me but would be >> the topping on the cake: CAPS lock is functioning normally, but the LED >> does not light up when engaged. Is there any way to fix this? > > Can you find the bit or byte that is changing in the report which corresponds > to the CAPS lock key? Also don't forget to print the first byte which is the > ID byte. That was it... the data sent to the keyboard also needs to be prefixed with the ID. The attached patch does this in a sensitive way -- I've tested it and it behaves correctly both with the Apple, and a "normal" USB kbd attached. Hooray! :-) --Chris --------------030500090406070609070007 Content-Type: text/plain; name="ukbd-led.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ukbd-led.diff" --- ukbd.c.org 2009-05-16 20:38:08.000000000 +0000 +++ ukbd.c 2009-05-16 20:35:26.000000000 +0000 @@ -589,7 +589,8 @@ ukbd_set_leds_callback(struct usb2_xfer *xfer) { struct usb2_device_request req; - uint8_t buf[1]; + uint8_t buf[2]; + uint8_t reqsize = 0; struct ukbd_softc *sc = xfer->priv_sc; switch (USB_GET_STATE(xfer)) { @@ -603,15 +604,19 @@ USETW2(req.wValue, UHID_OUTPUT_REPORT, 0); req.wIndex[0] = sc->sc_iface_no; req.wIndex[1] = 0; - USETW(req.wLength, 1); - buf[0] = sc->sc_leds; + if (sc->sc_hid_id != 0) { + buf[reqsize++] = sc->sc_hid_id; + } + buf[reqsize++] = sc->sc_leds; + + USETW(req.wLength, reqsize); usb2_copy_in(xfer->frbuffers, 0, &req, sizeof(req)); - usb2_copy_in(xfer->frbuffers + 1, 0, buf, sizeof(buf)); + usb2_copy_in(xfer->frbuffers + 1, 0, buf, reqsize); xfer->frlengths[0] = sizeof(req); - xfer->frlengths[1] = sizeof(buf); + xfer->frlengths[1] = reqsize; xfer->nframes = 2; usb2_start_hardware(xfer); } --------------030500090406070609070007--