[Spice-devel] using scan code from hardware keyboards
David Jaša
djasa at redhat.com
Thu Feb 13 03:56:08 PST 2014
Hi,
On St, 2014-02-12 at 22:03 -0500, i iordanov wrote:
> Hey guys,
>
> When my hardware keyboard is connected/paired with my Android device, key
> events do contain a scan code. I would love to just send that scan code
> through to the VM, however, the Android documentation is really
> discouraging on this matter.
>
> Can you guys take a look at the docs for the method which retrieves the
> scan code, and tell me whether you would rely on the value returned by
> getScanCode() given what's written?
>
> http://developer.android.com/reference/android/view/KeyEvent.html#getScanCode%28%29
>
> In addition, my hardware keyboard has an English layout, and I have no way
> of testing what a hardware keyboard with a non-English layout generates
> when one presses a key which is not in the ASCII table. The reason it's
> interesting is that Android key events may contain a key code, and scan
> code. The documented key codes for Android are all within the ASCII table.
> When a soft-keyboard KeyEvent carries unicode data outside the ASCII table,
> its key code == 0, and its "action" is not DOWN or UP, but MULTIPLE. So,
> will (for example) a German hardware keyboard on which u-umlaut is pressed
> generate an event with action == ACTION_MULTIPLE and a key code == 0, or
> will it generate an event with action == DOWN/UP and key code set to
> something inaccurate? Does anybody own an Android and a hardware keyboard
> with a non-English layout to help me test this?
I still have to see a keyboard that would tell the computer what it's
layout is. That being said, I'm now typing on keyboard with german
labels that didn't actaully type a german-specific character in it's
whole lifetime. :)
So what you need to test is to switch the keyboard layout in the OS to
the interesting one (no idea how you do that in android) and press some
key. For example, the key with semicolon ";" on english/us layout
produces "ů" when switched to czech layout.
David
>
> As things stand, if I don't trust the scan code the keyboard generates, I
> cannot use my English layout hardware keyboard to type any language other
> than English because the scan codes are simulated based on the unicode
> character the event contains. On my English keyboard, the event inevitably
> contains unicode characters that fall within the ASCII table, as you can
> imagine :).
>
> Your thoughts and suggestions are welcome.
>
> Thanks!
> iordan
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list