diff mbox

ps2: Fix lost scancodes by recent changes

Message ID 87inqavlzj.fsf@mail.parknet.co.jp
State New
Headers show

Commit Message

OGAWA Hirofumi Dec. 23, 2016, 1 p.m. UTC
With "ps2: use QEMU qcodes instead of scancodes", key handling was
changed to qcode base. But all scancodes are not converted to new one.

This adds some missing qcodes what I found in using.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 hw/input/ps2.c    |    3 +++
 qapi-schema.json  |    3 ++-
 ui/input-keymap.c |    3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

Hervé Poussineau Dec. 23, 2016, 8:58 p.m. UTC | #1
Le 23/12/2016 à 14:00, OGAWA Hirofumi a écrit :
>
> With "ps2: use QEMU qcodes instead of scancodes", key handling was
> changed to qcode base. But all scancodes are not converted to new one.
>
> This adds some missing qcodes what I found in using.
>
> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
>
>  hw/input/ps2.c    |    3 +++
>  qapi-schema.json  |    3 ++-
>  ui/input-keymap.c |    3 +++
>  3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff -puN hw/input/ps2.c~fix-ps2-scancode hw/input/ps2.c
> --- qemu/hw/input/ps2.c~fix-ps2-scancode	2016-12-23 21:14:59.837729450 +0900
> +++ qemu-hirofumi/hw/input/ps2.c	2016-12-23 21:14:59.840729469 +0900
> @@ -394,6 +394,9 @@ static const uint16_t qcode_to_keycode_s
>      [Q_KEY_CODE_LESS] = 0x61,
>      [Q_KEY_CODE_SYSRQ] = 0x7f,
>      [Q_KEY_CODE_RO] = 0x51,
> +    [Q_KEY_CODE_HIRAGANA] = 0x13,
> +    [Q_KEY_CODE_HENKAN] = 0x64,
> +    [Q_KEY_CODE_YEN] = 0x6a,
>      [Q_KEY_CODE_KP_COMMA] = 0x6d,
>  };
>
> diff -puN qapi-schema.json~fix-ps2-scancode qapi-schema.json
> --- qemu/qapi-schema.json~fix-ps2-scancode	2016-12-23 21:14:59.838729456 +0900
> +++ qemu-hirofumi/qapi-schema.json	2016-12-23 21:14:59.840729469 +0900
> @@ -3642,7 +3642,8 @@
>              'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 'end',
>              'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again',
>              'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
> -            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause', 'ro',
> +            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause',
> +            'ro', 'hiragana', 'henkan', 'yen',
>              'kp_comma', 'kp_equals', 'power' ] }
>
>  ##
> diff -puN ui/input-keymap.c~fix-ps2-scancode ui/input-keymap.c
> --- qemu/ui/input-keymap.c~fix-ps2-scancode	2016-12-23 21:14:59.839729463 +0900
> +++ qemu-hirofumi/ui/input-keymap.c	2016-12-23 21:14:59.840729469 +0900
> @@ -131,6 +131,9 @@ static const int qcode_to_number[] = {
>      [Q_KEY_CODE_DELETE] = 0xd3,
>
>      [Q_KEY_CODE_RO] = 0x73,
> +    [Q_KEY_CODE_HIRAGANA] = 0x70,
> +    [Q_KEY_CODE_HENKAN] = 0x79,
> +    [Q_KEY_CODE_YEN] = 0x7d,
>      [Q_KEY_CODE_KP_COMMA] = 0x7e,
>
>      [Q_KEY_CODE__MAX] = 0,

Can you also add the keycodes for scancode set 1:
+    [Q_KEY_CODE_HIRAGANA] = 0x70,
+    [Q_KEY_CODE_HENKAN] = 0x79,
+    [Q_KEY_CODE_YEN] = 0x7d,

and scancode set 3:
+    [Q_KEY_CODE_HIRAGANA] = 0x87,
+    [Q_KEY_CODE_HENKAN] = 0x86,
+    [Q_KEY_CODE_YEN] = 0x51,

Hervé
Eric Blake Dec. 23, 2016, 9:58 p.m. UTC | #2
On 12/23/2016 07:00 AM, OGAWA Hirofumi wrote:
> 
> With "ps2: use QEMU qcodes instead of scancodes", key handling was
> changed to qcode base. But all scancodes are not converted to new one.
> 
> This adds some missing qcodes what I found in using.
> 
> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
> 

> +++ qemu-hirofumi/qapi-schema.json	2016-12-23 21:14:59.840729469 +0900
> @@ -3642,7 +3642,8 @@
>              'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 'end',
>              'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again',
>              'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
> -            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause', 'ro',
> +            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause',
> +            'ro', 'hiragana', 'henkan', 'yen',
>              'kp_comma', 'kp_equals', 'power' ] }

Missing documentation (including a 'since 2.9' designation) for the new
enum members.
OGAWA Hirofumi Dec. 23, 2016, 10:49 p.m. UTC | #3
Hi,

Hervé Poussineau <hpoussin@reactos.org> writes:

>>      [Q_KEY_CODE_RO] = 0x73,
>> +    [Q_KEY_CODE_HIRAGANA] = 0x70,
>> +    [Q_KEY_CODE_HENKAN] = 0x79,
>> +    [Q_KEY_CODE_YEN] = 0x7d,
>>      [Q_KEY_CODE_KP_COMMA] = 0x7e,
>>
>>      [Q_KEY_CODE__MAX] = 0,
>
> Can you also add the keycodes for scancode set 1:
> +    [Q_KEY_CODE_HIRAGANA] = 0x70,
> +    [Q_KEY_CODE_HENKAN] = 0x79,
> +    [Q_KEY_CODE_YEN] = 0x7d,

Current linux can't use set1, so untested.

> and scancode set 3:
> +    [Q_KEY_CODE_HIRAGANA] = 0x87,
> +    [Q_KEY_CODE_HENKAN] = 0x86,
> +    [Q_KEY_CODE_YEN] = 0x51,

Boot with "i8042.direct=1", then set set3.

# echo 3 > /sys/devices/platform/i8042/serio0/set
# cat /sys/devices/platform/i8042/serio0/set
3

HENKAN, HIRAGANA seems to be working, but YEN is not working.  I'm not
sure if it is your patch, testing, or kernel problem.

Can you point what is problem?

# lsinput

[...]

/dev/input/event4
   bustype : BUS_I8042
   vendor  : 0x1
   product : 0x3
   version : 43907
   name    : "AT Raw Set 3 keyboard"
   phys    : "isa0060/serio0/input0"
   bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP

# input-event
/dev/input/event4
   bustype : BUS_I8042
   vendor  : 0x1
   product : 0x3
   version : 43907
   name    : "AT Raw Set 3 keyboard"
   phys    : "isa0060/serio0/input0"
   bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP

waiting for events
[... on qemu monitor "sendkey henkan" ...]
06:49:58.061932: EV_KEY KEY_HENKAN (0x5c) pressed
06:49:58.061932: EV_SYN code=0 value=0
06:49:58.149812: EV_MSC MSC_SCAN 134
06:49:58.149812: EV_KEY KEY_HENKAN (0x5c) released
06:49:58.149812: EV_SYN code=0 value=0
06:49:58.333876: EV_MSC MSC_SCAN 135
[... on qemu monitor "sendkey hiragana" ...]
06:49:58.333876: EV_KEY KEY_KATAKANAHIRAGANA (0x5d) pressed
06:49:58.333876: EV_SYN code=0 value=0
06:49:58.421889: EV_MSC MSC_SCAN 135
06:49:58.421889: EV_KEY KEY_KATAKANAHIRAGANA (0x5d) released
06:49:58.421889: EV_SYN code=0 value=0
06:49:58.893893: EV_MSC MSC_SCAN 81
[... on qemu monitor "sendkey yen" ...]
06:49:58.893893: EV_KEY KEY_VOLUMEDOWN (0x72) pressed
06:49:58.893893: EV_SYN code=0 value=0
06:49:58.973841: EV_MSC MSC_SCAN 81
06:49:58.973841: EV_KEY KEY_VOLUMEDOWN (0x72) released
06:49:58.973841: EV_SYN code=0 value=0
timeout, quitting
OGAWA Hirofumi Dec. 23, 2016, 11:33 p.m. UTC | #4
Eric Blake <eblake@redhat.com> writes:

> On 12/23/2016 07:00 AM, OGAWA Hirofumi wrote:
>> 
>> With "ps2: use QEMU qcodes instead of scancodes", key handling was
>> changed to qcode base. But all scancodes are not converted to new one.
>> 
>> This adds some missing qcodes what I found in using.
>> 
>> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>> ---
>> 
>
>> +++ qemu-hirofumi/qapi-schema.json	2016-12-23 21:14:59.840729469 +0900
>> @@ -3642,7 +3642,8 @@
>>              'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 'end',
>>              'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again',
>>              'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
>> -            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause', 'ro',
>> +            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause',
>> +            'ro', 'hiragana', 'henkan', 'yen',
>>              'kp_comma', 'kp_equals', 'power' ] }
>
> Missing documentation (including a 'since 2.9' designation) for the new
> enum members.

Thanks for pointing out.
Hervé Poussineau Dec. 27, 2016, 2:27 p.m. UTC | #5
Le 23/12/2016 à 23:49, OGAWA Hirofumi a écrit :
> Hi,
>
> Hervé Poussineau <hpoussin@reactos.org> writes:
>
[from ui/input-keymap.c]
>>>      [Q_KEY_CODE_RO] = 0x73,
>>> +    [Q_KEY_CODE_HIRAGANA] = 0x70,
>>> +    [Q_KEY_CODE_HENKAN] = 0x79,
>>> +    [Q_KEY_CODE_YEN] = 0x7d,
>>>      [Q_KEY_CODE_KP_COMMA] = 0x7e,
>>>
>>>      [Q_KEY_CODE__MAX] = 0,
>>

[from hw/input/ps2.c]
>> Can you also add the keycodes for scancode set 1:
>> +    [Q_KEY_CODE_HIRAGANA] = 0x70,
>> +    [Q_KEY_CODE_HENKAN] = 0x79,
>> +    [Q_KEY_CODE_YEN] = 0x7d,
>
> Current linux can't use set1, so untested.

Note that those are the same as those added in input-keymap.c

>
>> and scancode set 3:
>> +    [Q_KEY_CODE_HIRAGANA] = 0x87,
>> +    [Q_KEY_CODE_HENKAN] = 0x86,
>> +    [Q_KEY_CODE_YEN] = 0x51,
>
> Boot with "i8042.direct=1", then set set3.
>
> # echo 3 > /sys/devices/platform/i8042/serio0/set
> # cat /sys/devices/platform/i8042/serio0/set
> 3
>
> HENKAN, HIRAGANA seems to be working, but YEN is not working.  I'm not
> sure if it is your patch, testing, or kernel problem.
>
> Can you point what is problem?
>
> # lsinput
>
> [...]
>
> /dev/input/event4
>    bustype : BUS_I8042
>    vendor  : 0x1
>    product : 0x3
>    version : 43907
>    name    : "AT Raw Set 3 keyboard"
>    phys    : "isa0060/serio0/input0"
>    bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP
>
> # input-event
> /dev/input/event4
>    bustype : BUS_I8042
>    vendor  : 0x1
>    product : 0x3
>    version : 43907
>    name    : "AT Raw Set 3 keyboard"
>    phys    : "isa0060/serio0/input0"
>    bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP
>
> waiting for events
> [... on qemu monitor "sendkey henkan" ...]
> 06:49:58.061932: EV_KEY KEY_HENKAN (0x5c) pressed
> 06:49:58.061932: EV_SYN code=0 value=0
> 06:49:58.149812: EV_MSC MSC_SCAN 134
-> 134 = 0x86, as expected ([Q_KEY_CODE_HENKAN] = 0x86)

> 06:49:58.149812: EV_KEY KEY_HENKAN (0x5c) released
> 06:49:58.149812: EV_SYN code=0 value=0

> [... on qemu monitor "sendkey hiragana" ...]
> 06:49:58.333876: EV_MSC MSC_SCAN 135
-> 135 = 0x87, as expected ([Q_KEY_CODE_HIRAGANA] = 0x87)

> 06:49:58.333876: EV_KEY KEY_KATAKANAHIRAGANA (0x5d) pressed
> 06:49:58.333876: EV_SYN code=0 value=0
> 06:49:58.421889: EV_MSC MSC_SCAN 135
> 06:49:58.421889: EV_KEY KEY_KATAKANAHIRAGANA (0x5d) released
> 06:49:58.421889: EV_SYN code=0 value=0

> [... on qemu monitor "sendkey yen" ...]
> 06:49:58.893893: EV_MSC MSC_SCAN 81
-> 81 = 0x51
> 06:49:58.893893: EV_KEY KEY_VOLUMEDOWN (0x72) pressed
> 06:49:58.893893: EV_SYN code=0 value=0
> 06:49:58.973841: EV_MSC MSC_SCAN 81
> 06:49:58.973841: EV_KEY KEY_VOLUMEDOWN (0x72) released
> 06:49:58.973841: EV_SYN code=0 value=0
> timeout, quitting

So, Linux is describing 0x51 make scancode as VOLUMEDOWN.

Indeed, according to http://www.quadibloc.com/comp/scan.htm
                 Set 1  Set 2  Set 3
HENKAN           79     64     86    (kanji)
HIRAGANA         70     13     87    (katakana)
YEN              7d     6a     5d    (INT 4)

So correct values for hw/input/ps2.c seem to be:

Set 1 (same values as in ui/input-keymap.c)
+    [Q_KEY_CODE_HIRAGANA] = 0x70,
+    [Q_KEY_CODE_HENKAN] = 0x79,
+    [Q_KEY_CODE_YEN] = 0x7d,

Set 2 (your initial patch)
+    [Q_KEY_CODE_HIRAGANA] = 0x13,
+    [Q_KEY_CODE_HENKAN] = 0x64,
+    [Q_KEY_CODE_YEN] = 0x6a,

Set 3:
+    [Q_KEY_CODE_HIRAGANA] = 0x87, // already verified
+    [Q_KEY_CODE_HENKAN] = 0x86, // already verified
+    [Q_KEY_CODE_YEN] = 0x5d,  // not 0x51,  as I said in a previous email

Can you check those values?

Regards,

Hervé
OGAWA Hirofumi Dec. 27, 2016, 7:49 p.m. UTC | #6
Hervé Poussineau <hpoussin@reactos.org> writes:

> [from hw/input/ps2.c]
>>> Can you also add the keycodes for scancode set 1:
>>> +    [Q_KEY_CODE_HIRAGANA] = 0x70,
>>> +    [Q_KEY_CODE_HENKAN] = 0x79,
>>> +    [Q_KEY_CODE_YEN] = 0x7d,
>>
>> Current linux can't use set1, so untested.
>
> Note that those are the same as those added in input-keymap.c

I see.

>> [... on qemu monitor "sendkey yen" ...]
>> 06:49:58.893893: EV_MSC MSC_SCAN 81
> -> 81 = 0x51
>> 06:49:58.893893: EV_KEY KEY_VOLUMEDOWN (0x72) pressed
>> 06:49:58.893893: EV_SYN code=0 value=0
>> 06:49:58.973841: EV_MSC MSC_SCAN 81
>> 06:49:58.973841: EV_KEY KEY_VOLUMEDOWN (0x72) released
>> 06:49:58.973841: EV_SYN code=0 value=0
>> timeout, quitting
>
> So, Linux is describing 0x51 make scancode as VOLUMEDOWN.
>
> Indeed, according to http://www.quadibloc.com/comp/scan.htm
>                  Set 1  Set 2  Set 3
> HENKAN           79     64     86    (kanji)
> HIRAGANA         70     13     87    (katakana)
> YEN              7d     6a     5d    (INT 4)
>
> So correct values for hw/input/ps2.c seem to be:

[...]

> Set 3:
> +    [Q_KEY_CODE_HIRAGANA] = 0x87, // already verified
> +    [Q_KEY_CODE_HENKAN] = 0x86, // already verified
> +    [Q_KEY_CODE_YEN] = 0x5d,  // not 0x51,  as I said in a previous email
>
> Can you check those values?

04:32:33.111316: EV_MSC MSC_SCAN 93
04:32:33.111316: EV_KEY KEY_BACKSLASH (0x2b) pressed
04:32:33.111316: EV_SYN code=0 value=0

Sent 93==0x5d as expected, but keycode is BACKSLASH. Of course, linux
driver is using BACKSLASH(43) keycode for 0x5d. But linux driver has
several BACKSLASH entries for multiple scancodes in set3.

And qemu doesn't have 0x5d entry in set3.  Also

	http://hp.vector.co.jp/authors/VA003720/lpproj/others/kbdjpn.htm

yet another site says 0x5d.

Some sites says about buggy keyboards using wrong scancode in set3, and
microsoft seems to removed set3 from specification. So linux translation
table for 43=>0x5d, maybe result of workarounds.

So looks like 0x5d is right value for set3.

Thanks.
diff mbox

Patch

diff -puN hw/input/ps2.c~fix-ps2-scancode hw/input/ps2.c
--- qemu/hw/input/ps2.c~fix-ps2-scancode	2016-12-23 21:14:59.837729450 +0900
+++ qemu-hirofumi/hw/input/ps2.c	2016-12-23 21:14:59.840729469 +0900
@@ -394,6 +394,9 @@  static const uint16_t qcode_to_keycode_s
     [Q_KEY_CODE_LESS] = 0x61,
     [Q_KEY_CODE_SYSRQ] = 0x7f,
     [Q_KEY_CODE_RO] = 0x51,
+    [Q_KEY_CODE_HIRAGANA] = 0x13,
+    [Q_KEY_CODE_HENKAN] = 0x64,
+    [Q_KEY_CODE_YEN] = 0x6a,
     [Q_KEY_CODE_KP_COMMA] = 0x6d,
 };
 
diff -puN qapi-schema.json~fix-ps2-scancode qapi-schema.json
--- qemu/qapi-schema.json~fix-ps2-scancode	2016-12-23 21:14:59.838729456 +0900
+++ qemu-hirofumi/qapi-schema.json	2016-12-23 21:14:59.840729469 +0900
@@ -3642,7 +3642,8 @@ 
             'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 'end',
             'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again',
             'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
-            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause', 'ro',
+            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause',
+            'ro', 'hiragana', 'henkan', 'yen',
             'kp_comma', 'kp_equals', 'power' ] }
 
 ##
diff -puN ui/input-keymap.c~fix-ps2-scancode ui/input-keymap.c
--- qemu/ui/input-keymap.c~fix-ps2-scancode	2016-12-23 21:14:59.839729463 +0900
+++ qemu-hirofumi/ui/input-keymap.c	2016-12-23 21:14:59.840729469 +0900
@@ -131,6 +131,9 @@  static const int qcode_to_number[] = {
     [Q_KEY_CODE_DELETE] = 0xd3,
 
     [Q_KEY_CODE_RO] = 0x73,
+    [Q_KEY_CODE_HIRAGANA] = 0x70,
+    [Q_KEY_CODE_HENKAN] = 0x79,
+    [Q_KEY_CODE_YEN] = 0x7d,
     [Q_KEY_CODE_KP_COMMA] = 0x7e,
 
     [Q_KEY_CODE__MAX] = 0,