Received: from eggs.gnu.org ([2001:4830:134:3::10]:52135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab8X3-0003Cr-QM for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:17:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ab8X0-0001MI-Jg for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:17:45 -0500 Received: from mail-io0-x236.google.com ([2607:f8b0:4001:c06::236]:36467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab8X0-0001M3-C3 for qemu-devel@nongnu.org; Wed, 02 Mar 2016 10:17:42 -0500 Received: by mail-io0-x236.google.com with SMTP id l127so262660596iof.3 for ; Wed, 02 Mar 2016 07:17:42 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: Date: Wed, 2 Mar 2016 10:17:39 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: References: <801CD73C-2AB1-4421-9C09-1F7AE46AA272@gmail.com> Subject: Re: [Qemu-devel] [PATCH] hw/input/adb.c: Replace pc_to_adb_keycode with more detailed array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel On Mar 2, 2016, at 7:38 AM, Peter Maydell wrote: > On 2 March 2016 at 00:31, Programmingkid = wrote: >>=20 >> On Mar 1, 2016, at 6:34 PM, Peter Maydell wrote: >>=20 >>> On 1 March 2016 at 22:10, Programmingkid = wrote: >>>> The pc_to_adb_keycode array was not very easy to work with. The = replacement >>>> array number_to_adb_keycode list all the element indexes on the = left and its >>>> value on the right. This makes finding a particular index or the = meaning for >>>> that index very easy. >>>>=20 >=20 >>> Scancodes are guaranteed to be single byte so you can just use >>> [256] like the old array. >>>=20 >>> In any case this whole array ought at some point to be >>> replaced with a Q_KEY code to ADB code lookup -- at the >>> moment we will convert Q_KEY to pc scancode to ADB code, >>> which is unfortunate if the pc scancodes don't include >>> some keys that ADB and the host keyboard do. (In fact, >>> wasn't this the reason why you wanted to do these patches?) >>=20 >> Yes it was. There was no keypad equal key and the QKeyCode looked >> like it provided this key. >=20 > But your changes don't seem to be actually using QKeyCodes > in the ADB keyboard model, so I'm confused about how you > can get the keypad-equal to go through it. Now that I think about it, you are right. I'm actually using PS/2 to ADB = here which isn't a bad thing.=20 I see what is wrong. I completely forgot to send in my input-keymap.c = patch. It is this file that I include the Q_KEY_CODE_KP_EQUALS key. = Sorry for the confusion.=20 >=20 >>>=20 >>>> + [0x2a] =3D MAC_KEY_LEFT_SHIFT, >>>> + [0x36] =3D MAC_KEY_LEFT, >>>=20 >>> This part of the patch is going to be very painful to review, >>> because I have to go through and manually correlate >>> the new array against the old table (including cross >>> referencing it against your new MAC_KEY_* codes) to >>> see if there are any changes in here beyond the format. >>=20 >> If you have a Mac OS X guest, you could use Key Caps. >=20 > I think it would be helpful if you make sure that you use > separate patches for "just rearranging how this array is > written" from "changing functionality". Then in reviewing > the former I know I just need to check that the array > contents are the same, and in reviewing the latter I > only need to think about the consequences of the function > changes. Would it be easier if I just made a new patch for adb.c that takes the = existing pc_to_adb_keycode array and just expanded it directly by having = the index on the left and the value as a named constant on the right.=20 Original code: static const uint8_t pc_to_adb_keycode[256] =3D { 0, 53, 18, ... New code: [0x00] =3D 0, [0x01] =3D MAC_KEY_ESC, [0x02] =3D MAC_KEY_1, ... The order of the values in both arrays would be the same.=20 Did you want the index to be in hexadecimal or just decimal? >=20 >>=20 >>>=20 >>>> + [0x38] =3D MAC_KEY_LEFT_OPTION, >>>> + [0xb8] =3D MAC_KEY_RIGHT, >>>> + [0x64] =3D MAC_KEY_LEFT_OPTION, >>>> + [0xe4] =3D MAC_KEY_RIGHT_OPTION, >>>> + [0x1d] =3D MAC_KEY_RIGHT_COMMAND, >>>> + [0x9d] =3D MAC_KEY_DOWN, >>>> + [0xdb] =3D MAC_KEY_LEFT_COMMAND, >>>> + [0xdc] =3D MAC_KEY_LEFT_COMMAND, >>>> + [0xdd] =3D 0, /* no Macintosh equivalent to the menu key */ >>>=20 >>> Not a new problem, but you'll note that MAC_KEY_A is 0, so >>> all these zero entries don't mean "no key, ignore", but "send >>> A instead"... (A fix for that bug deserves a patch of its own.) >>=20 >> So you want another value in place of zero. What value did you want? >=20 > Any value which isn't a possible valid ADB scancode. This should do it: #define NO_KEY 0xFF >=20 >=20 >>>> + [0x5e] =3D MAC_KEY_POWER, >>>=20 >>> MAC_KEY_POWER is a two byte scancode, but... >>=20 >> It works! >=20 > How? You need to have a change which handles this deliberately > and is clear about why it works. Just happening to work by > accident isn't sufficient. The adb.c file's function adb_kbd_request() handles keyboard requests. = Its arguments include a buffer for storing keycodes and a len argument = that keeps track of the number of bytes to read. Setting the len value = to two is probably how a two byte value can be handled.