From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: BALATON Zoltan <balaton@eik.bme.hu>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: peter.maydell@linaro.org, huth@tuxfamily.org,
berrange@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v4 1/2] next-kbd: convert to use qemu_input_handler_register()
Date: Wed, 6 Nov 2024 15:50:24 +0000 [thread overview]
Message-ID: <13995544-2d94-4b35-a7c2-f11e0599170f@linaro.org> (raw)
In-Reply-To: <4c127d3c-3610-e6b7-9358-3d88d28477a0@eik.bme.hu>
On 6/11/24 13:00, BALATON Zoltan wrote:
> On Wed, 6 Nov 2024, Mark Cave-Ayland wrote:
>> Convert the next-kbd device from the legacy UI
>> qemu_add_kbd_event_handler()
>> function to use qemu_input_handler_register().
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> Reviewed-by: Thomas Huth <huth@tuxfamily.org>
>> ---
>> hw/m68k/next-kbd.c | 163 ++++++++++++++++++++++++++++++---------------
>> 1 file changed, 108 insertions(+), 55 deletions(-)
>> -static const unsigned char next_keycodes[128] = {
>> - 0x00, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x50, 0x4F,
>> - 0x4E, 0x1E, 0x1F, 0x20, 0x1D, 0x1C, 0x1B, 0x00,
>> - 0x42, 0x43, 0x44, 0x45, 0x48, 0x47, 0x46, 0x06,
>> - 0x07, 0x08, 0x00, 0x00, 0x2A, 0x00, 0x39, 0x3A,
>> - 0x3B, 0x3C, 0x3D, 0x40, 0x3F, 0x3E, 0x2D, 0x2C,
>> - 0x2B, 0x26, 0x00, 0x00, 0x31, 0x32, 0x33, 0x34,
>> - 0x35, 0x37, 0x36, 0x2e, 0x2f, 0x30, 0x00, 0x00,
>> - 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
>> +#define NEXTKBD_NO_KEY 0xff
>
> Now you don't need this 0xff define any more because you can use 0 as no
> key value then the [0 ... Q_KEY_CODE__MAX] init below can also be
> dropped because static variables are 0 init automatically.
Whether 0 or 0xff is best for NO_KEY, I don't know.
However, definitions are useful when reviewing ...
>
> Regards,
> BALATON Zoltan
>
>> +static const int qcode_to_nextkbd_keycode[] = {
>> + /* Make sure future additions are automatically set to
>> NEXTKBD_NO_KEY */
>> + [0 ... Q_KEY_CODE__MAX] = NEXTKBD_NO_KEY,
>> +
>> + [Q_KEY_CODE_ESC] = 0x49,
>> + [Q_KEY_CODE_1] = 0x4a,
>> + [Q_KEY_CODE_2] = 0x4b,
>> + [Q_KEY_CODE_3] = 0x4c,
>> + [Q_KEY_CODE_4] = 0x4d,
[...]
>> +static void nextkbd_event(DeviceState *dev, QemuConsole *src,
>> InputEvent *evt)
>> +{
>> + NextKBDState *s = NEXTKBD(dev);
>> + int qcode, keycode;
>> + bool key_down = evt->u.key.data->down;
>> +
>> + qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key);
>> + if (qcode >= ARRAY_SIZE(qcode_to_nextkbd_keycode)) {
>> + return;
>> + }
>> +
>> + /* Shift key currently has no keycode, so handle separately */
>> + if (qcode == Q_KEY_CODE_SHIFT) {
>> + if (key_down) {
>> + s->shift |= KD_LSHIFT;
>> + } else {
>> + s->shift &= ~KD_LSHIFT;
>> + }
>> + }
>> +
>> + if (qcode == Q_KEY_CODE_SHIFT_R) {
>> + if (key_down) {
>> + s->shift |= KD_RSHIFT;
>> + } else {
>> + s->shift &= ~KD_RSHIFT;
>> + }
>> + }
>> +
>> + keycode = qcode_to_nextkbd_keycode[qcode];
>> + if (keycode == NEXTKBD_NO_KEY) {
... here ^
>> + return;
>> + }
>> +
>> + /* If key release event, create keyboard break code */
>> + if (!key_down) {
>> + keycode |= 0x80;
>> + }
>> +
>> + nextkbd_put_keycode(s, keycode);
>> +}
next prev parent reply other threads:[~2024-11-06 15:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 12:09 [PATCH v4 0/2] next-kbd: convert to use qemu_input_handler_register() Mark Cave-Ayland
2024-11-06 12:09 ` [PATCH v4 1/2] " Mark Cave-Ayland
2024-11-06 12:21 ` Daniel P. Berrangé
2024-11-06 13:00 ` BALATON Zoltan
2024-11-06 15:50 ` Philippe Mathieu-Daudé [this message]
2024-11-06 20:32 ` BALATON Zoltan
2024-11-08 10:05 ` Thomas Huth
2024-11-08 12:26 ` Mark Cave-Ayland
2024-11-08 13:13 ` BALATON Zoltan
2024-11-08 13:24 ` BALATON Zoltan
2024-11-08 13:36 ` Thomas Huth
2024-11-08 15:45 ` Philippe Mathieu-Daudé
2024-11-08 19:57 ` BALATON Zoltan
2024-11-06 12:09 ` [PATCH v4 2/2] ui/input-legacy.c: remove unused legacy qemu_add_kbd_event_handler() function Mark Cave-Ayland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13995544-2d94-4b35-a7c2-f11e0599170f@linaro.org \
--to=philmd@linaro.org \
--cc=balaton@eik.bme.hu \
--cc=berrange@redhat.com \
--cc=huth@tuxfamily.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).