[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode suppo
From: |
Programmingkid |
Subject: |
Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support |
Date: |
Sat, 12 Mar 2016 00:40:37 -0500 |
On Mar 11, 2016, at 10:30 PM, Peter Maydell wrote:
>
>> + }
>> + keycode = s->data[s->rptr];
>> + if (++s->rptr == sizeof(s->data)) {
>> + s->rptr = 0;
>> }
>> + s->count--;
>> +
>> + obuf[0] = keycode;
>
> You are still trying to put a two byte keycode (ADB_KEY_POWER)
> into this one-byte array slot. I don't know what the right way to
> send a two-byte keycode is but this is obviously not it, as
> I said before.
>
>> + /* NOTE: could put a second keycode if needed */
>> + obuf[1] = 0xff;
>> + olen = 2;
>> +
>> return olen;
>> }
Is this ok?
/* The power key is the only two byte value key, so it is a special case. */
if (keycode == (ADB_KEY_POWER & 0x00ff)) {
obuf[0] = ADB_KEY_POWER & 0x00ff;
obuf[1] = ADB_KEY_POWER & 0xff00 >> 8;
olen = 2;
} else {
obuf[0] = keycode;
/* NOTE: could put a second keycode if needed */
obuf[1] = 0xff;
olen = 2;
}
The keycode value comes from an 8 bit array so holding the full value of the
power key is not possible. That is the reason for the "if (keycode ==
(ADB_KEY_POWER & 0x00ff))".
The code might be a little more efficient if we did this:
/* The power key is the only two byte value key, so it is a special case. */
if (keycode == 0x7f) {
obuf[0] = 0x7f;
obuf[1] = 0x7f;
olen = 2;
} else {
obuf[0] = keycode;
/* NOTE: could put a second keycode if needed */
obuf[1] = 0xff;
olen = 2;
}
The speed difference isn't noticeable so either way works well.
- [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Programmingkid, 2016/03/10
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Peter Maydell, 2016/03/11
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Programmingkid, 2016/03/11
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support,
Programmingkid <=
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Programmingkid, 2016/03/14
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, M A, 2016/03/14
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Peter Maydell, 2016/03/15
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Programmingkid, 2016/03/15
- Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support, Peter Maydell, 2016/03/15