From owner-freebsd-hackers@freebsd.org Fri Sep 30 15:29:08 2016 Return-Path: Delivered-To: freebsd-hackers@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 8903DC02C2A for ; Fri, 30 Sep 2016 15:29:08 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from hydra.pix.net (hydra.pix.net [IPv6:2001:470:e254::4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.pix.net", Issuer "Pix.Com Technologies LLC CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F8BA271 for ; Fri, 30 Sep 2016 15:29:08 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from torb.pix.net (torb.pix.net [192.168.16.32]) (authenticated bits=0) by hydra.pix.net (8.15.2/8.15.2) with ESMTPA id u8UFT6Je005847; Fri, 30 Sep 2016 11:29:07 -0400 (EDT) (envelope-from lidl@FreeBSD.org) To: freebsd-hackers@freebsd.org References: Subject: Re: Logitech G510s keyboard fail. From: Kurt Lidl Reply-To: lidl@FreeBSD.org Message-ID: <336fa405-dc7d-4715-bbc9-6f1cbf049bbd@FreeBSD.org> Date: Fri, 30 Sep 2016 11:29:06 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Sep 2016 15:29:08 -0000 On 30 September 2016 at 4:35, Eitan Adler wrote: > On 30 September 2016 at 01:49, Zaphod Beeblebrox wrote: > >> The largest number it was "skipping" was 993 ... awfully close to 10 >> bits. was thinking that 16 bits (a short int) was a more appropriate size, >> was all? >> > > Unless there is a particualr reason to keep it small (such as memory > pressure) lets use a fairly large number of bits. As I understand it, the way the USB keyboards with true N-key-rollover work is that they send a bitmap of which keys are pressed in each usb packet. (My terminology might be a little off here...) The most basic mode is the "BOOT" (aka "standard") mode, where each packet is 8 bytes in length, so you only get an array of up to six simultaneous key-presses. There's an "extended" mode, that can be either 16/32/64 bytes in length. In the extended mode, there's a 2 byte overhead, so you get N-2 simultaneous key-presses in each packet. Finally, there's the "bitmap" mode, where keyboard sends a packet with a bunch of control data, and also 16/32/64 bytes of bitmap data. The bitmap represents all the keys that are pressed simultaneously. The number of simultaneous keypresses one can track is related to the size of the bitmap. With the 16 bytes of bitmap, you get up up to 128 simultaneous key-presses, etc... The 32 bytes of bitmap get you up to 256 bits of presence detection. I don't know if there's a 128 byte variant of the bitmap support packet or not. Someone would have to do some usb low-level debugging to figure that out... It seems straightforward - there's just a byte in the middle of the bitmap packet support that says how many bytes of bitmap data there are present. There's some relevant data here: https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/USB_NKRO.txt -Kurt