2007-06-12 21:33:55

by Hans de Goede

[permalink] [raw]
Subject: Proposal: change keycode for scancode e0 32 from 150 to 172

Hi all,

As some of you might know from my earlier post/thread about atkbd and softraw,
I'm currently working on getting keyboards with internet/easy access keys to
work painlessly / plug and play.

In order to be able to better test / develop this I've bought 2 cheap such
keyboards today, one ps2 and one both usb and ps2 capable.

When comparing usb vs ps2 / testing the keycodes generated for the easy access
keys on my trust (microsoft compatible) keyboard. I noticed the homepage key
sends keycode 150 with ps2 and 172 with USB, or for those who don't know the
keycodes by head with ps2 it sends KEY_WWW and with usb it sends KEY_HOMEPAGE

I personally believe that the usb behaviour is correct and that the ps/2 code
should be modified to match for consistency. The ps/2 scancode to keycode
mapping is set up to handle easy access / internet keys for microsoft
compatible keyboards. So what is the right code to send here, tricky, see:
http://www.s2.com.br/s2arquivos/361/Imagens/555Image.jpg
http://www.keyboardco.com/keyboard_images/microsoft_ergonomic_keyboard_4000_black_usb_large.jpg

The logo on the key is a homepage logo, the text below is www/homepage. So what
to send? I believe that for consistency with the usb codes send it should be
KEY_HOMEPAGE, but thats based on a sample of 1 usb keyboard. Input on what
other usb keyboards send for the key with the homepage iocn is very much welcome.

Regards,

Hans


2007-06-12 22:30:08

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

Hans de Goede wrote:
>
> In order to be able to better test / develop this I've bought 2 cheap
> such keyboards today, one ps2 and one both usb and ps2 capable.
>
> When comparing usb vs ps2 / testing the keycodes generated for the easy
> access
> keys on my trust (microsoft compatible) keyboard. I noticed the homepage
> key sends keycode 150 with ps2 and 172 with USB, or for those who don't
> know the keycodes by head with ps2 it sends KEY_WWW and with usb it
> sends KEY_HOMEPAGE

I just tested this using Microsoft Natural Keyboard Pro, which is a
dual-mode (USB-PS/2) keyboard.

This key is labelled Web/Home and has a picture of a house on the keycap.

In PS/2 mode it reports E0 32 which gets converted to keycode 150.
In USB mode it reports E0 02 which gets converted to keycode 172.

I don't know if it's the keyboard itself that's being inconsistent, or
if it is the table in usbkbd.c that's broken (in which case it should be
fixed to be consistent with the keyboard in PS/2 mode.)

> I personally believe that the usb behaviour is correct and that the ps/2
> code should be modified to match for consistency. The ps/2 scancode to
> keycode mapping is set up to handle easy access / internet keys for
> microsoft compatible keyboards. So what is the right code to send here,
> tricky, see:
> http://www.s2.com.br/s2arquivos/361/Imagens/555Image.jpg
> http://www.keyboardco.com/keyboard_images/microsoft_ergonomic_keyboard_4000_black_usb_large.jpg
>
> The logo on the key is a homepage logo, the text below is www/homepage.
> So what to send? I believe that for consistency with the usb codes send
> it should be KEY_HOMEPAGE, but thats based on a sample of 1 usb
> keyboard. Input on what other usb keyboards send for the key with the
> homepage iocn is very much welcome.

You seem to be of the opinion that "usb behaviour is correct", but don't
give any motivation why usb should take precedence. Offhand, I would
expect there to be fewer translation layers for PS/2 and would therefore
assume PS/2 is more inherently correct.

-hpa

2007-06-13 05:53:27

by Hans de Goede

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

H. Peter Anvin wrote:
> Hans de Goede wrote:
>> In order to be able to better test / develop this I've bought 2 cheap
>> such keyboards today, one ps2 and one both usb and ps2 capable.
>>
>> When comparing usb vs ps2 / testing the keycodes generated for the easy
>> access
>> keys on my trust (microsoft compatible) keyboard. I noticed the homepage
>> key sends keycode 150 with ps2 and 172 with USB, or for those who don't
>> know the keycodes by head with ps2 it sends KEY_WWW and with usb it
>> sends KEY_HOMEPAGE
>
> I just tested this using Microsoft Natural Keyboard Pro, which is a
> dual-mode (USB-PS/2) keyboard.
>
> This key is labelled Web/Home and has a picture of a house on the keycap.
>
> In PS/2 mode it reports E0 32 which gets converted to keycode 150.
> In USB mode it reports E0 02 which gets converted to keycode 172.
>

Thanks, that confirms that the ps/2 translation (which assumes a microsoft or
compatible keyboard) is wrong.

> I don't know if it's the keyboard itself that's being inconsistent, or
> if it is the table in usbkbd.c that's broken (in which case it should be
> fixed to be consistent with the keyboard in PS/2 mode.)
>

See below.

>> I personally believe that the usb behaviour is correct and that the ps/2
>> code should be modified to match for consistency. The ps/2 scancode to
>> keycode mapping is set up to handle easy access / internet keys for
>> microsoft compatible keyboards. So what is the right code to send here,
>> tricky, see:
>> http://www.s2.com.br/s2arquivos/361/Imagens/555Image.jpg
>> http://www.keyboardco.com/keyboard_images/microsoft_ergonomic_keyboard_4000_black_usb_large.jpg
>>
>> The logo on the key is a homepage logo, the text below is www/homepage.
>> So what to send? I believe that for consistency with the usb codes send
>> it should be KEY_HOMEPAGE, but thats based on a sample of 1 usb
>> keyboard. Input on what other usb keyboards send for the key with the
>> homepage iocn is very much welcome.
>
> You seem to be of the opinion that "usb behaviour is correct", but don't
> give any motivation why usb should take precedence. Offhand, I would
> expect there to be fewer translation layers for PS/2 and would therefore
> assume PS/2 is more inherently correct.
>

I'm of the opinion that the USB behaviour is correct, because usb generates the
172 / KEY_HOMEPAGE in accordance with:
http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
Page 84

Where as in the ps2 world there is no official scancode mapping for these
special keys, hence I talk about microsoft and compatibles. Also the number of
layers of translation in both cases is just 1: one table (ps2) versus one
switch statement (usb)

Regards,

Hans

2007-06-13 09:18:31

by Jiri Kosina

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

On Tue, 12 Jun 2007, H. Peter Anvin wrote:

> In PS/2 mode it reports E0 32 which gets converted to keycode 150. In
> USB mode it reports E0 02 which gets converted to keycode 172.
> I don't know if it's the keyboard itself that's being inconsistent, or
> if it is the table in usbkbd.c that's broken (in which case it should be
> fixed to be consistent with the keyboard in PS/2 mode.)

Hi Peter,

First, usbkbd.c has very probably zero business with this - the mappings
are being done in hid-input.c, usbkdb.c is only for embedded/debugging
cases, and is almost never used on modern systems (see the corresponding
Kconfig help text).

> You seem to be of the opinion that "usb behaviour is correct", but don't
> give any motivation why usb should take precedence. Offhand, I would
> expect there to be fewer translation layers for PS/2 and would therefore
> assume PS/2 is more inherently correct.

For USB, we have Hid Usage Pages, which define this to be KEY_HOMEPAGE.
There is no such specification for PS/2 though, so what Hans is proposing
is to make it consistent with behavior of USB HID devices, which I agree
with.

--
Jiri Kosina

2007-06-13 09:30:26

by Hans de Goede

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

Jiri Kosina wrote:
> On Tue, 12 Jun 2007, H. Peter Anvin wrote:
>
>> In PS/2 mode it reports E0 32 which gets converted to keycode 150. In
>> USB mode it reports E0 02 which gets converted to keycode 172.
>> I don't know if it's the keyboard itself that's being inconsistent, or
>> if it is the table in usbkbd.c that's broken (in which case it should be
>> fixed to be consistent with the keyboard in PS/2 mode.)
>
> Hi Peter,
>
> First, usbkbd.c has very probably zero business with this - the mappings
> are being done in hid-input.c, usbkdb.c is only for embedded/debugging
> cases, and is almost never used on modern systems (see the corresponding
> Kconfig help text).
>
>> You seem to be of the opinion that "usb behaviour is correct", but don't
>> give any motivation why usb should take precedence. Offhand, I would
>> expect there to be fewer translation layers for PS/2 and would therefore
>> assume PS/2 is more inherently correct.
>
> For USB, we have Hid Usage Pages, which define this to be KEY_HOMEPAGE.
> There is no such specification for PS/2 though, so what Hans is proposing
> is to make it consistent with behavior of USB HID devices, which I agree
> with.
>

Good to hear, so as everyone smees to agree, shall I write a (massive, complex,
intrusive) patch to fix this, or are there until now silent parties that object?

Regards,

Hans


2007-06-13 09:32:35

by Jiri Kosina

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

On Wed, 13 Jun 2007, Hans de Goede wrote:

> Good to hear, so as everyone smees to agree, shall I write a (massive,
> complex, intrusive) patch to fix this, or are there until now silent
> parties that object?

Well, Dmitry is the one who has final word on this, as it is related to
PS/2 keyboards. Just noticed he is not in CC, added.

--
Jiri Kosina

2007-06-13 10:29:50

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

On Tue, Jun 12, 2007 at 11:47:14PM +0200, Hans de Goede wrote:
> Hi all,
>
> As some of you might know from my earlier post/thread about atkbd and
> softraw, I'm currently working on getting keyboards with internet/easy
> access keys to work painlessly / plug and play.
>
> In order to be able to better test / develop this I've bought 2 cheap such
> keyboards today, one ps2 and one both usb and ps2 capable.
>
> When comparing usb vs ps2 / testing the keycodes generated for the easy
> access
> keys on my trust (microsoft compatible) keyboard. I noticed the homepage
> key sends keycode 150 with ps2 and 172 with USB, or for those who don't
> know the keycodes by head with ps2 it sends KEY_WWW and with usb it sends
> KEY_HOMEPAGE
>
> I personally believe that the usb behaviour is correct and that the ps/2
> code should be modified to match for consistency. The ps/2 scancode to
> keycode mapping is set up to handle easy access / internet keys for
> microsoft compatible keyboards. So what is the right code to send here,
> tricky, see:
> http://www.s2.com.br/s2arquivos/361/Imagens/555Image.jpg
> http://www.keyboardco.com/keyboard_images/microsoft_ergonomic_keyboard_4000_black_usb_large.jpg
>
> The logo on the key is a homepage logo, the text below is www/homepage. So
> what to send? I believe that for consistency with the usb codes send it
> should be KEY_HOMEPAGE, but thats based on a sample of 1 usb keyboard.
> Input on what other usb keyboards send for the key with the homepage iocn
> is very much welcome.

KEY_HOMEPAGE is likely correct. Maybe we don't want to have KEY_WWW at
all, since it seems to be redundant.

--
Vojtech Pavlik
Director SuSE Labs

2007-06-13 10:38:31

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

On Tue, Jun 12, 2007 at 03:29:48PM -0700, H. Peter Anvin wrote:
> I just tested this using Microsoft Natural Keyboard Pro, which is a
> dual-mode (USB-PS/2) keyboard.
>
> This key is labelled Web/Home and has a picture of a house on the keycap.
>
> In PS/2 mode it reports E0 32 which gets converted to keycode 150.
> In USB mode it reports E0 02 which gets converted to keycode 172.
>
> I don't know if it's the keyboard itself that's being inconsistent, or
> if it is the table in usbkbd.c that's broken (in which case it should be
> fixed to be consistent with the keyboard in PS/2 mode.)

USB keyboards don't send scancodes, what you see is smoke and mirrors.

Yes, the atkbd.c and hid-input.c mappings are inconsistent. We probably
want to fix atkbd.c (scancode->keycode mapping), and maybe also
char/keyboard.c (keycode->synth scancode mapping).

> > The logo on the key is a homepage logo, the text below is www/homepage.
> > So what to send? I believe that for consistency with the usb codes send
> > it should be KEY_HOMEPAGE, but thats based on a sample of 1 usb
> > keyboard. Input on what other usb keyboards send for the key with the
> > homepage iocn is very much welcome.
>
> You seem to be of the opinion that "usb behaviour is correct", but don't
> give any motivation why usb should take precedence. Offhand, I would
> expect there to be fewer translation layers for PS/2 and would therefore
> assume PS/2 is more inherently correct.

KEY_HOMEPAGE seems to better fit the description of how the key looks.
Microsoft calls it "WWW Home", and it's supposed to be e0 32.

--
Vojtech Pavlik
Director SuSE Labs

2007-06-13 13:30:27

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

On Wed, Jun 13, 2007 at 11:25:34AM +0200, Hans de Goede wrote:
> Jiri Kosina wrote:
> >On Tue, 12 Jun 2007, H. Peter Anvin wrote:
> >
> >>In PS/2 mode it reports E0 32 which gets converted to keycode 150. In
> >>USB mode it reports E0 02 which gets converted to keycode 172.
> >>I don't know if it's the keyboard itself that's being inconsistent, or
> >>if it is the table in usbkbd.c that's broken (in which case it should be
> >>fixed to be consistent with the keyboard in PS/2 mode.)
> >
> >Hi Peter,
> >
> >First, usbkbd.c has very probably zero business with this - the mappings
> >are being done in hid-input.c, usbkdb.c is only for embedded/debugging
> >cases, and is almost never used on modern systems (see the corresponding
> >Kconfig help text).
> >
> >>You seem to be of the opinion that "usb behaviour is correct", but don't
> >>give any motivation why usb should take precedence. Offhand, I would
> >>expect there to be fewer translation layers for PS/2 and would therefore
> >>assume PS/2 is more inherently correct.
> >
> >For USB, we have Hid Usage Pages, which define this to be KEY_HOMEPAGE.
> >There is no such specification for PS/2 though, so what Hans is proposing
> >is to make it consistent with behavior of USB HID devices, which I agree
> >with.
>
> Good to hear, so as everyone smees to agree, shall I write a (massive,
> complex, intrusive) patch to fix this, or are there until now silent
> parties that object?

Just don't forget to update the char/keyboard.c scancode synthesis table
to generate e0 32 for keycode 172 instead for the current 150.

--
Vojtech Pavlik
Director SuSE Labs

2007-06-13 13:45:36

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

On 6/13/07, Jiri Kosina <[email protected]> wrote:
> On Wed, 13 Jun 2007, Hans de Goede wrote:
>
> > Good to hear, so as everyone smees to agree, shall I write a (massive,
> > complex, intrusive) patch to fix this, or are there until now silent
> > parties that object?
>
> Well, Dmitry is the one who has final word on this, as it is related to
> PS/2 keyboards. Just noticed he is not in CC, added.
>

Yep, just send me the patch (don't forget to make change to
drivers/char/keyboard.c that Vojtech mentioned in other e-mail).

Thanks.

--
Dmitry

2007-06-14 12:35:32

by Stanislav Brabec

[permalink] [raw]
Subject: Re: Proposal: change keycode for scancode e0 32 from 150 to 172

Vojtech Pavlik wrote:

> > > The logo on the key is a homepage logo, the text below is www/homepage.
> > > So what to send? I believe that for consistency with the usb codes send
> > > it should be KEY_HOMEPAGE, but thats based on a sample of 1 usb
> > > keyboard. Input on what other usb keyboards send for the key with the
> > > homepage iocn is very much welcome.

It seems that several keyboards have both HomePage and WWW keys:

All these AT keyboards are from Xorg symbols/inet.

A4Tech Wireless Desktop
BTC 9000A
Compaq Easy Access Keyboard
Compaq (eg. Armada, Evo) Laptop Keyboard
Logitech (common definition)
Logitech Internet Keyboard
Microsoft Office Keyboard

It would be nice if anybody can test similar AT/USB keyboard.

--
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: [email protected]
Lihovarsk? 1060/12 tel: +420 284 028 966
190 00 Praha 9 fax: +420 284 028 951
Czech Republic http://www.suse.cz/

2007-06-18 22:46:32

by Hans de Goede

[permalink] [raw]
Subject: PATCH: change keycode for scancode e0 32 from 150 to 172

Dmitry Torokhov wrote:
> On 6/13/07, Jiri Kosina <[email protected]> wrote:
>> On Wed, 13 Jun 2007, Hans de Goede wrote:
>>
>> > Good to hear, so as everyone smees to agree, shall I write a (massive,
>> > complex, intrusive) patch to fix this, or are there until now silent
>> > parties that object?
>>
>> Well, Dmitry is the one who has final word on this, as it is related to
>> PS/2 keyboards. Just noticed he is not in CC, added.
>>
>
> Yep, just send me the patch (don't forget to make change to
> drivers/char/keyboard.c that Vojtech mentioned in other e-mail).
>

Here is a patch as promised, attached.

Thanks & Regards,

Hans


Attachments:
keyboard-homepage-keycode.patch (2.19 kB)

2007-06-19 13:43:54

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: PATCH: change keycode for scancode e0 32 from 150 to 172

On Tue, Jun 19, 2007 at 12:59:50AM +0200, Hans de Goede wrote:
> Dmitry Torokhov wrote:
> >On 6/13/07, Jiri Kosina <[email protected]> wrote:
> >>On Wed, 13 Jun 2007, Hans de Goede wrote:
> >>
> >>> Good to hear, so as everyone smees to agree, shall I write a (massive,
> >>> complex, intrusive) patch to fix this, or are there until now silent
> >>> parties that object?
> >>
> >>Well, Dmitry is the one who has final word on this, as it is related to
> >>PS/2 keyboards. Just noticed he is not in CC, added.
> >>
> >
> >Yep, just send me the patch (don't forget to make change to
> >drivers/char/keyboard.c that Vojtech mentioned in other e-mail).
> >
>
> Here is a patch as promised, attached.
>
> Thanks & Regards,
>
> Hans

Patch looks OK (didn't test it, but it seems to do all what's needed).

Acked-by: Vojtech Pavlik <[email protected]>


> As discussed by mail change keycode for scancode e0 32 from 150 to 172
>
> Signed-off-by: Hans de Goede <[email protected]>
> diff -ur linux-2.6.22-rc4.orig/drivers/char/keyboard.c linux-2.6.22-rc4/drivers/char/keyboard.c
> --- linux-2.6.22-rc4.orig/drivers/char/keyboard.c 2007-06-16 22:54:47.000000000 +0200
> +++ linux-2.6.22-rc4/drivers/char/keyboard.c 2007-06-18 23:15:27.000000000 +0200
> @@ -1005,8 +1005,8 @@
> 284,285,309, 0,312, 91,327,328,329,331,333,335,336,337,338,339,
> 367,288,302,304,350, 89,334,326,267,126,268,269,125,347,348,349,
> 360,261,262,263,268,376,100,101,321,316,373,286,289,102,351,355,
> - 103,104,105,275,287,279,306,106,274,107,294,364,358,363,362,361,
> - 291,108,381,281,290,272,292,305,280, 99,112,257,258,359,113,114,
> + 103,104,105,275,287,279,258,106,274,107,294,364,358,363,362,361,
> + 291,108,381,281,290,272,292,305,280, 99,112,257,306,359,113,114,
> 264,117,271,374,379,265,266, 93, 94, 95, 85,259,375,260, 90,116,
> 377,109,111,277,278,282,283,295,296,297,299,300,301,293,303,307,
> 308,310,313,314,315,317,318,319,320,357,322,323,324,325,276,330,
> diff -ur linux-2.6.22-rc4.orig/drivers/input/keyboard/atkbd.c linux-2.6.22-rc4/drivers/input/keyboard/atkbd.c
> --- linux-2.6.22-rc4.orig/drivers/input/keyboard/atkbd.c 2007-06-16 22:54:48.000000000 +0200
> +++ linux-2.6.22-rc4/drivers/input/keyboard/atkbd.c 2007-06-18 23:07:24.000000000 +0200
> @@ -89,7 +89,7 @@
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 217,100,255, 0, 97,165, 0, 0,156, 0, 0, 0, 0, 0, 0,125,
> 173,114, 0,113, 0, 0, 0,126,128, 0, 0,140, 0, 0, 0,127,
> - 159, 0,115, 0,164, 0, 0,116,158, 0,150,166, 0, 0, 0,142,
> + 159, 0,115, 0,164, 0, 0,116,158, 0,172,166, 0, 0, 0,142,
> 157, 0, 0, 0, 0, 0, 0, 0,155, 0, 98, 0, 0,163, 0, 0,
> 226, 0, 0, 0, 0, 0, 0, 0, 0,255, 96, 0, 0, 0,143, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0,107, 0,105,102, 0, 0,112,
> @@ -111,7 +111,7 @@
> 82, 83, 80, 76, 77, 72, 69, 98, 0, 96, 81, 0, 78, 73, 55,183,
>
> 184,185,186,187, 74, 94, 92, 93, 0, 0, 0,125,126,127,112, 0,
> - 0,139,150,163,165,115,152,150,166,140,160,154,113,114,167,168,
> + 0,139,172,163,165,115,152,172,166,140,160,154,113,114,167,168,
> 148,149,147,140
> };
>


--
Vojtech Pavlik
Director SuSE Labs