qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Programmingkid <programmingkidx@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support
Date: Mon, 14 Mar 2016 19:06:45 -0400	[thread overview]
Message-ID: <77582ECD-0206-4FD9-AE2C-3B31E78FA44F@gmail.com> (raw)
In-Reply-To: <CAFEAcA_kyi+AVgvL8RLqWPmRXt5XbxLr1o4iJoOgp-fXPEbudg@mail.gmail.com>


On Mar 13, 2016, at 11:40 AM, Peter Maydell wrote:

> On 12 March 2016 at 05:40, Programmingkid <programmingkidx@gmail.com> wrote:
>> 
>> 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.
> 
> Ah, I hadn't noticed that -- that is not a good approach.
> You should either:
> (a) deal with the fact that ADB_KEY values may be 16 bits
> all the way through (including having that array be uint16_t
> rather than uint8_t)
> (b) have the power key be a completely special case which
> is handled by
> if (qcode == Q_KEY_CODE_POWER) {
>    /* put power key into buffer */
>    [...]
> } else {
>    keycode = qcode_to_adb_keycode[...];
>    etc;
> }
> and not put it into the array at all.
> 
> Also, you need to handle the power-key key-release
> scancode; as far as I can tell (by looking for info via
> google about the ADB protocol) power-key-down is
> 0x7f 0x7f, and power-key-up is 0xff 0xff. (This is
> kind of weird and suggests we should just take option
> (a) and special case the power key completely.)

The power-key-up (break) keycode is 0xff 0xff? Could you send me your source for this information? I always thought the up (break) code was the keycode AND with 0x80. Or this if code is easier to understand:
break_keycode = keycode & 0x80.

  parent reply	other threads:[~2016-03-14 23:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11  2:32 [Qemu-devel] [PATCH v4 4/4] hw/input/adb.c: implement QKeyCode support Programmingkid
2016-03-12  3:30 ` Peter Maydell
2016-03-12  4:27   ` Programmingkid
2016-03-13 16:00     ` Peter Maydell
2016-03-12  5:40   ` Programmingkid
2016-03-13 15:40     ` Peter Maydell
2016-03-13 16:39       ` Programmingkid
2016-03-13 16:42         ` Peter Maydell
2016-03-14 23:06       ` Programmingkid [this message]
2016-03-14 23:10         ` M A
2016-03-15  9:22         ` Peter Maydell
2016-03-15 15:24           ` Programmingkid
2016-03-15 15:34             ` Peter Maydell

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=77582ECD-0206-4FD9-AE2C-3B31E78FA44F@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=kraxel@redhat.com \
    --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).