Skip to contentSkip to conversation

kbd: (#7063) make CapsLock work as expected even for non-ASCII

PATCH NAK Alexey Dobriyan 5 participants 22 messages Nov 16, 2009 – Feb 23, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbd: (#7063) make CapsLock work as expected even for non-ASCII

Steps to reproduce:

[log into console (not xterm)]
[load non-trivial keymap]
[turn on CapsLock]
[type something]

Symbols won't be capital despite CapsLock and despite Shift+* working as expected.

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols. Though extracting SMALL <=> CAPITAL mapping from unicode tables and putting it into kernel may be more correct.

Fix long-standing http://bugzilla.kernel.org/show_bug.cgi?id=7063

---

 drivers/char/keyboard.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/char/keyboard.c +7 -1
@@ -1261,8 +1261,14 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 		param.value = keysym;
 		if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNICODE, &param) == NOTIFY_STOP)
 			return;
-		if (down && !raw_mode)
+		if (down && !raw_mode) {
+			if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
+				key_map = key_maps[shift_final ^ (1 << KG_SHIFT)];
+				if (key_map)
+					keysym = key_map[keycode];
+			}
 			to_utf8(vc, keysym);
+		}
 		return;
 	}
 
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Mon, 16 Nov 2009 16:51:15 +0300 Alexey Dobriyan <[email protected]> wrote:

Steps to reproduce:

[log into console (not xterm)]
[load non-trivial keymap]
[turn on CapsLock]
[type something]

Symbols won't be capital despite CapsLock and despite Shift+* working as expected.

Quoted 7 lines

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols. Though extracting SMALL <=> CAPITAL mapping from unicode tables and putting it into kernel may be more correct.

Fix long-standing http://bugzilla.kernel.org/show_bug.cgi?id=7063

The assumptions seem reasonable and if not we'll find out. Either way its going to be an improvement.

Nacked-By on v1 1/1 NAK
#3 lore raw
In reply to Alexey Dobriyan
Quoted 9 lines · Alexey Dobriyan, le Mon 16 Nov 2009 16:51:15 +0300, a écrit :

Steps to reproduce:

[log into console (not xterm)]
[load non-trivial keymap]
[turn on CapsLock]
[type something]

Symbols won't be capital despite CapsLock and despite Shift+* working as expected.

Fix your keymap, it should use KT_LETTER instead of KT_LATIN.

Quoted 1 line

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols.

And that's not true for a lot of keyboard symbols. Strictly speaking, caps lock is caps lock, not shift lock. If you really want a shift lock, then set your caps lock key to produce shift lock. Applying your patch would turn the existing capslock behavior into shift lock, we _don't_ want that.

Quoted 2 lines

Though extracting SMALL <=> CAPITAL mapping from unicode tables and putting it into kernel may be more correct.

That's what console-setup does by using various symbol levels and it just _works_. One issue however is that then the capslock keyboard led doesn't light up while in caps mode. Maybe we should rethink the interface to light keyboard leds instead.

#2 lore raw
In reply to Alan Cox
Quoted 2 lines · Alan Cox, le Mon 16 Nov 2009 14:40:03 +0000, a écrit :

The assumptions seem reasonable and if not we'll find out. Either way its going to be an improvement.

Nope, it turns the caps lock into a shift lock, which is really not the same.

Samuel

#4 lore raw
In reply to Samuel Thibault
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Alexey Dobriyan, le Mon 16 Nov 2009 16:51:15 +0300, a écrit :

Steps to reproduce:

[log into console (not xterm)]
[load non-trivial keymap]
[turn on CapsLock]
[type something]

Quoted 4 lines
Quoted 2 lines

Symbols won't be capital despite CapsLock and despite Shift+* working as expected.

Fix your keymap, it should use KT_LETTER instead of KT_LATIN.

You have read bugzilla and patch, haven't you?

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 3 lines
Quoted 1 line

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols.

And that's not true for a lot of keyboard symbols.

That's why patch implies keymap is not fucked up.

Quoted 9 lines

Strictly speaking, caps lock is caps lock, not shift lock. If you really want a shift lock, then set your caps lock key to produce shift lock. Applying your patch would turn the existing capslock behavior into shift lock, we _don't_ want that.

Quoted 2 lines

Though extracting SMALL <=> CAPITAL mapping from unicode tables and putting it into kernel may be more correct.

That's what console-setup

What is it?

	$ sudo emerge -s console-setup
	Searching...
	[ Results for search key : console-setup ]
	[ Applications found : 0 ]
Quoted 1 line

does by using various symbol levels and it just _works_.

Ubuntu user?

Quoted 2 lines

One issue however is that then the capslock keyboard led doesn't light up while in caps mode.

Interesting breakage you have.

[presses CapsLock several times]

Quoted 1 line

Maybe we should rethink the interface to light keyboard leds instead.

Oh, and there no need to reply at every place as if Linus is going to grab it from bugzilla and apply in hurry.

#5 lore raw
Quoted 3 lines · Alexey Dobriyan, le Mon 16 Nov 2009 22:53:13 +0300, a écrit :
Quoted 1 line

Fix your keymap, it should use KT_LETTER instead of KT_LATIN.

You have read bugzilla and patch, haven't you?

Yes.

And you could probably also read bug #7746 which is probably now a dup (yes, the original report mixes several issues).

Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols.

And that's not true for a lot of keyboard symbols.

That's why patch implies keymap is not fucked up.

However you can't changed the "fucked up" keyboard of people. They have bought it and it's printed like that on it...

Quoted 11 lines
Quoted 9 lines

Strictly speaking, caps lock is caps lock, not shift lock. If you really want a shift lock, then set your caps lock key to produce shift lock. Applying your patch would turn the existing capslock behavior into shift lock, we _don't_ want that.

Quoted 2 lines

Though extracting SMALL <=> CAPITAL mapping from unicode tables and putting it into kernel may be more correct.

That's what console-setup

What is it?

google tells packages.debian.org/console-setup

Quoted 4 lines
	$ sudo emerge -s console-setup
	Searching...
	[ Results for search key : console-setup ]
	[ Applications found : 0 ]

emerge is not universal, that's all.

Quoted 3 lines
Quoted 1 line

does by using various symbol levels and it just _works_.

Ubuntu user?

Nope.

Quoted 4 lines
Quoted 2 lines

One issue however is that then the capslock keyboard led doesn't light up while in caps mode.

Interesting breakage you have.

It's not breakage. It's because instead of using the KT_LETTER way to get the caps lock behavior, console-setup uses a modifier, since it's much more powerful (you just decide what exactly will be the upper case, and not have to rely on the shifted keysym to be the expected one), but the kernel doesn't permit to assign a modifier to a keyboard LED.

Quoted 1 line

[presses CapsLock several times]

No need to be sarcastic.

Quoted 3 lines
Quoted 1 line

Maybe we should rethink the interface to light keyboard leds instead.

Oh, and there no need to reply at every place

People posting in the bugzilla usually don't read linux-kernel, that's why I posted a sum up there.

Samuel

#6 lore raw
Quoted 11 lines · Samuel Thibault

Alexey Dobriyan, le Mon 16 Nov 2009 22:53:13 +0300, a écrit :
And you could probably also read bug #7746 which is probably now a dup (yes, the original report mixes several issues).

Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

What other interfaces?

Here, U+044F is sent, now (correctly) U+042F.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols.

And that's not true for a lot of keyboard symbols.

That's why patch implies keymap is not fucked up.

However you can't changed the "fucked up" keyboard of people. They have bought it and it's printed like that on it...

keymap is loadable, what are you talking about?
/usr/share/keymaps/i386/qwerty/ru.map.gz

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

One issue however is that then the capslock keyboard led doesn't light up while in caps mode.

Interesting breakage you have.

It's not breakage. It's because instead of using the KT_LETTER way to get the caps lock behavior, console-setup uses a modifier, since it's much more powerful (you just decide what exactly will be the upper case, and not have to rely on the shifted keysym to be the expected one), but the kernel doesn't permit to assign a modifier to a keyboard LED.

#8 lore raw
In reply to Samuel Thibault
Quoted 11 lines · Samuel Thibault, le Mon 16 Nov 2009 23:27:38 +0100, a écrit :
Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

One way to go would be to decrete that keysyms between 0xD800 and 0xE000 (unused anyway) are "KT_LETTER" versions of the unicode 0x0000 - 0x0800. That however covers only part of Unicode and doesn't solve the case of keyboards where the upper case of a letter is not simply at the shifted position.

The real correct solution is really to have kbd use modifiers just like console-setup and provide a way for them to configure which leds should be lit when some modifier is locked. That way building a keymap becomes just orthogonal, no need to upload a table of lower/upper pairs (which depend on the locale see for instance i/I vs i/İ).

Samuel

#7 lore raw
In reply to Alexey Dobriyan
Quoted 12 lines · Alexey Dobriyan, le Tue 17 Nov 2009 01:53:51 +0300, a écrit :
Quoted 11 lines · Samuel Thibault

Alexey Dobriyan, le Mon 16 Nov 2009 22:53:13 +0300, a écrit :
And you could probably also read bug #7746 which is probably now a dup (yes, the original report mixes several issues).

Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 6 lines
Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

What other interfaces?

The caps lock interface. As I said, caps lock is caps lock, it's not shift lock. For now Linux uses caps lock. If you make it use shift lock it completely changes the behavior.

Quoted 1 line

Here, U+044F is sent, now (correctly) U+042F.

Yes, that's shift lock. But then any other key will also be shifted, not only the KT_LETTER ones, while it's exactly the purpose of KT_LETTER and caps lock.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols.

And that's not true for a lot of keyboard symbols.

That's why patch implies keymap is not fucked up.

However you can't changed the "fucked up" keyboard of people. They have bought it and it's printed like that on it...

keymap is loadable, what are you talking about?
/usr/share/keymaps/i386/qwerty/ru.map.gz

It seems we don't understand each other, I'll repeat what I have understood and explain more:

- you say

Quoted 1 line

Note: patch relies on keymap being consistent wrt SMALL/CAPITAL symbols.

- I understand
patch relies that keymaps always have the capital variant of letters at the shifted position of each keys.

- I answer

Quoted 1 line

And that's not true for a lot of keyboard symbols.

- I mean
Some keyboard (physical, bought at the local store, not just keymaps from CrazyHacker) do _not_ always have the capital variant of letters at the shifted position of each keys. On a french keyboard for instance, É is not at shift+é, but altgr+shift+é. So your patch won't work and actually do harm.

- You answer

Quoted 1 line

That's why patch implies keymap is not fucked up.

- I understand
That's why patch implies that french keyboard is not fucked up.

- I answer

Quoted 2 lines

However you can't changed the "fucked up" keyboard of people. They have bought it and it's printed like that on it...

- I mean
Maybe it's fucked up, but all the french keyboards are like that, you can't change that fact.

- You answer

Quoted 2 lines

keymap is loadable, what are you talking about?
/usr/share/keymaps/i386/qwerty/ru.map.gz

- I didn't understand anything.

Samuel

#9 lore raw
In reply to Samuel Thibault
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Mon 16 Nov 2009 23:27:38 +0100, a écrit :
Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 6 lines
Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

One way to go would be to decrete that keysyms between 0xD800 and 0xE000

And this is going to help me with U+042F/U+044F how?

Quoted 10 lines

(unused anyway) are "KT_LETTER" versions of the unicode 0x0000 - 0x0800. That however covers only part of Unicode and doesn't solve the case of keyboards where the upper case of a letter is not simply at the shifted position.

The real correct solution is really to have kbd use modifiers just like console-setup and provide a way for them to configure which leds should be lit when some modifier is locked. That way building a keymap becomes just orthogonal, no need to upload a table of lower/upper pairs (which depend on the locale see for instance i/I vs i/İ).

#10 lore raw
Quoted 9 lines · Alexey Dobriyan, le Tue 17 Nov 2009 02:05:23 +0300, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Mon 16 Nov 2009 23:27:38 +0100, a écrit :
Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

One way to go would be to decrete that keysyms between 0xD800 and 0xE000

And this is going to help me with U+042F/U+044F how?

This way:

drivers/char/keyboard.c +9 -0
index 737be95..264db17 100644
@@ -1258,6 +1258,15 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 	type = KTYP(keysym);
 
 	if (type < 0xf0) {
+		if (keysym >= 0xD800 && keysym < 0xE000) {
+			/* Surrogates in Unicode, here KT_LETTER variants of unicode U+0000-U+07FF */
+			keysym -= 0xD800;
+			if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
+				key_map = key_maps[shift_final ^ (1 << KG_SHIFT)];
+				if (key_map)
+					keysym = key_map[keycode];
+			}
+		}
 		param.value = keysym;
 		if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNICODE, &param) == NOTIFY_STOP)
 			return;

Which BTW is correct while the proposed patch earlier wasn't: the param.value needs to be the final keysym.

But again, that only solves the problem of the limited range U+0000-U+0800 and doesn't solve the é/É french keyboard problem.

Adding an interface to change the modifier lock / LED assignation would on the other hand permit kbd and console-setup to properly do proper capslock processing correctly.

Samuel

#11 lore raw
Quoted 22 lines · Samuel Thibault
Quoted 17 lines · Alexey Dobriyan, le Tue 17 Nov 2009 02:05:23 +0300, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Mon 16 Nov 2009 23:27:38 +0100, a écrit :
Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 6 lines
Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

One way to go would be to decrete that keysyms between 0xD800 and 0xE000

And this is going to help me with U+042F/U+044F how?

drivers/char/keyboard.c static void kbd_keycode(unsigned int keycode, int down, int hw_raw) · line 1261

Quoted 4 lines
drivers/char/keyboard.c +1 -0
@@ -1258,6 +1258,15 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 	type = KTYP(keysym);
 
 	if (type < 0xf0) {
+		if (keysym >= 0xD800 && keysym < 0xE000) {

keysym is 0x044F at this point.

Quoted 12 lines
drivers/char/keyboard.c +8 -0
+			/* Surrogates in Unicode, here KT_LETTER variants of unicode U+0000-U+07FF */
+			keysym -= 0xD800;
+			if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
+				key_map = key_maps[shift_final ^ (1 << KG_SHIFT)];
+				if (key_map)
+					keysym = key_map[keycode];
+			}
+		}
 		param.value = keysym;
 		if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNICODE, &param) == NOTIFY_STOP)
 			return;
Quoted 2 lines

Which BTW is correct while the proposed patch earlier wasn't: the param.value needs to be the final keysym.

OK, this I should fix.

Quoted 6 lines

But again, that only solves the problem of the limited range U+0000-U+0800 and doesn't solve the é/É french keyboard problem.

Adding an interface to change the modifier lock / LED assignation would on the other hand permit kbd and console-setup to properly do proper capslock processing correctly.

#12 lore raw
Quoted 25 lines · Alexey Dobriyan, le Tue 17 Nov 2009 14:55:03 +0300, a écrit :
Quoted 24 lines · Samuel Thibault
Quoted 17 lines · Alexey Dobriyan, le Tue 17 Nov 2009 02:05:23 +0300, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Mon 16 Nov 2009 23:27:38 +0100, a écrit :
Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 6 lines
Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

One way to go would be to decrete that keysyms between 0xD800 and 0xE000

And this is going to help me with U+042F/U+044F how?

drivers/char/keyboard.c +0 -0
@@ -1258,6 +1258,15 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 	type = KTYP(keysym);
 
Quoted 4 lines

drivers/char/keyboard.c static void kbd_keycode(unsigned int keycode, int down, int hw_raw) · line 1261

Quoted 2 lines
drivers/char/keyboard.c +1 -0
 	if (type < 0xf0) {
+		if (keysym >= 0xD800 && keysym < 0xE000) {

keysym is 0x044F at this point.

I'm precisely suggesting that instead of 0x044F, the keymap provides 0xdc4f, just like for +z the keysym is not K(KT_LATIN,0x0079), but K(KT_LETTER,0x79) (that's the difference between just z and +z, i.e. whether it's KT_LATIN or KT_LETTER, i.e. whether capslock acts on it or not, that's the whole point of capslock vs shift lock!).

More precisely, in the kbd source code, in the add_capslock function, in the unicode case, instead of ignoring the '+', add 0xD800 to the unicode value if it is below 0x0800.

But again, that's a very limited fix and just fixing the LED interface would allow to just use modifiers and permit much more powerful keymaps.

Samuel

#13 lore raw
Quoted 37 lines · Samuel Thibault
Quoted 25 lines · Alexey Dobriyan, le Tue 17 Nov 2009 14:55:03 +0300, a écrit :
Quoted 24 lines · Samuel Thibault
Quoted 17 lines · Alexey Dobriyan, le Tue 17 Nov 2009 02:05:23 +0300, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Mon 16 Nov 2009 23:27:38 +0100, a écrit :
Quoted 6 lines

My keymap contains

keycode 44 = +z
shift keycode 44 = +Z
altgr keycode 44 = U+044F # CYRILLIC SMALL LETTER YA
altgr shift keycode 44 = U+042F # CYRILLIC CAPITAL LETTER YA

Quoted 6 lines
Quoted 4 lines

And U+044F / U+042F is not KT_LETTER.

Yes, there's no way you can express a unicode character in KT_LETTER. Limited interface, but that's not a reason to break other interfaces.

One way to go would be to decrete that keysyms between 0xD800 and 0xE000

And this is going to help me with U+042F/U+044F how?

drivers/char/keyboard.c +0 -0
@@ -1258,6 +1258,15 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 	type = KTYP(keysym);
 
Quoted 4 lines

drivers/char/keyboard.c static void kbd_keycode(unsigned int keycode, int down, int hw_raw) · line 1261

Quoted 2 lines
drivers/char/keyboard.c +1 -0
 	if (type < 0xf0) {
+		if (keysym >= 0xD800 && keysym < 0xE000) {

keysym is 0x044F at this point.

I'm precisely suggesting that instead of 0x044F, the keymap provides 0xdc4f, just like for +z the keysym is not K(KT_LATIN,0x0079), but K(KT_LETTER,0x79) (that's the difference between just z and +z, i.e. whether it's KT_LATIN or KT_LETTER, i.e. whether capslock acts on it or not, that's the whole point of capslock vs shift lock!).

Quoted 3 lines

More precisely, in the kbd source code, in the add_capslock function, in the unicode case, instead of ignoring the '+', add 0xD800 to the unicode value if it is below 0x0800.

You suggest to change kernel and keymap and kbd and introduce 0xD800 hack. This is not going to fly.

Quoted 2 lines

But again, that's a very limited fix and just fixing the LED interface would allow to just use modifiers and permit much more powerful keymaps.

#14 lore raw
Quoted 6 lines · Alexey Dobriyan, le Thu 19 Nov 2009 16:18:54 +0300, a écrit :
Quoted 3 lines

More precisely, in the kbd source code, in the add_capslock function, in the unicode case, instead of ignoring the '+', add 0xD800 to the unicode value if it is below 0x0800.

You suggest to change kernel and keymap and kbd and introduce 0xD800 hack. This is not going to fly.

Sure, that's precisely what I said here:

Quoted 2 lines
Quoted 2 lines

But again, that's a very limited fix and just fixing the LED interface would allow to just use modifiers and permit much more powerful keymaps.

Just to make sure you understand my point: your bug is _not_ in the kernel, but in kbd, see what the add_capslock() function does when in unicode mode:

	fprintf(stderr, _("plus before %s ignored\n"), p);

No wonder capslocked keys don't work, kbd doesn't even tell the kernel which keys should get capslock behavior. Breaking the capslock behavior to make it a shiftlock to compensate kbd's bug is not going to fly either.

Now, as I said, kbd's issue is that it doesn't have any way to express that a unicode keysym should get capslock behavior, due to kernel interface limitation. But as I said, it can do like console-setup: use a modifier instead of the limited capslock interface. A side issue is that modifier locks don't get advertised through keyboard leds. That can be solved by adding an interface to make that happen.

Instead of breaking an interface (capslock by making it a shiftlock instead), add one that makes sense (being able to configure how modifier locks are advertised through LEDs). _That_ will fly.

Samuel

#15 lore raw

Just to make sure you really understand.

Quoted 3 lines · Samuel Thibault, le Thu 19 Nov 2009 14:28:28 +0100, a écrit :

Now, as I said, kbd's issue is that it doesn't have any way to express that a unicode keysym should get capslock behavior, due to kernel interface limitation.

And that's precisely why I just showed how such limitation could be lifted:

Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

More precisely, in the kbd source code, in the add_capslock function, in the unicode case, instead of ignoring the '+', add 0xD800 to the unicode value if it is below 0x0800.

You suggest to change kernel and keymap and kbd and introduce 0xD800 hack. This is not going to fly.

Sure, that's precisely what I said here:

Quoted 2 lines
Quoted 2 lines

But again, that's a very limited fix and just fixing the LED interface would allow to just use modifiers and permit much more powerful keymaps.

So we agree, and so the right solution is to either completely rework the interface (ugh), or just add LED routing (which can be very useful, actually, I for instance don't care at all about the num lock state, but I _do_ care about the lock that lets me shift between different keyboard layouts).

Samuel

#16 lore raw
Quoted 7 lines · Samuel Thibault

So we agree, and so the right solution is to either completely rework the interface (ugh), or just add LED routing (which can be very useful, actually, I for instance don't care at all about the num lock state, but I _do_ care about the lock that lets me shift between different keyboard layouts).

Adding LED routing and using keyboard levels is so clearly The Right Thing.

We already allow the LEDs to be programmed; we should probably just have, for each LED, the ability to program it off/on/flashing/connected to modifier #X.

The current KDSETLED/KDGETLED interface is of course too limited for this -- we need an interface with at least a byte per LED.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#17 lore raw

Hi!

Quoted 7 lines
Quoted 6 lines

So we agree, and so the right solution is to either completely rework the interface (ugh), or just add LED routing (which can be very useful, actually, I for instance don't care at all about the num lock state, but I _do_ care about the lock that lets me shift between different keyboard layouts).

Quoted 8 lines

Adding LED routing and using keyboard levels is so clearly The Right Thing.

We already allow the LEDs to be programmed; we should probably just have, for each LED, the ability to program it off/on/flashing/connected to modifier #X.

The current KDSETLED/KDGETLED interface is of course too limited for this -- we need an interface with at least a byte per LED.

Actually, we already have very nice /sys/class/led interface, and we should just use it for keyboard leds, too. Actually I have a patch, somewhere...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#18 lore raw

Hi!

Quoted 13 lines
Quoted 13 lines
Quoted 6 lines

So we agree, and so the right solution is to either completely rework the interface (ugh), or just add LED routing (which can be very useful, actually, I for instance don't care at all about the num lock state, but I _do_ care about the lock that lets me shift between different keyboard layouts).

Adding LED routing and using keyboard levels is so clearly The Right Thing.

We already allow the LEDs to be programmed; we should probably just have, for each LED, the ability to program it off/on/flashing/connected to modifier #X.

Quoted 6 lines
Quoted 2 lines

The current KDSETLED/KDGETLED interface is of course too limited for this -- we need an interface with at least a byte per LED.

Actually, we already have very nice /sys/class/led interface, and we should just use it for keyboard leds, too. Actually I have a patch, somewhere...

Like this... But it should probably be slightly more complex -- like making numlock/capslock/scrollock leds into trigers, and then move input LED lowlevels into drivers/led...

drivers/leds/Kconfig +7 -0
index e4f599f..c80fee8 100644
@@ -96,6 +96,13 @@ config LEDS_COBALT_RAQ
 	help
 	  This option enables support for the Cobalt Raq series LEDs.
 
+config LEDS_INPUT
+	tristate "LED Support for input layer keyboards"
+	depends on LEDS_CLASS
+	help
+	  This option enables support for LEDs on keyboards handled by
+	  input layer.
+
 config LEDS_SUNFIRE
 	tristate "LED support for SunFire servers."
 	depends on LEDS_CLASS && SPARC64
drivers/leds/Makefile +1 -0
index 46d7270..71bde81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_NET48XX)		+= leds-net48xx.o
 obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
 obj-$(CONFIG_LEDS_ALIX2)		+= leds-alix2.o
 obj-$(CONFIG_LEDS_H1940)		+= leds-h1940.o
+obj-$(CONFIG_LEDS_INPUT)		+= leds-input.o
 obj-$(CONFIG_LEDS_COBALT_QUBE)		+= leds-cobalt-qube.o
 obj-$(CONFIG_LEDS_COBALT_RAQ)		+= leds-cobalt-raq.o
 obj-$(CONFIG_LEDS_SUNFIRE)		+= leds-sunfire.o
drivers/leds/leds-input.c new file +151 -0

151 lines not on this page · raw message

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#19 lore raw
Quoted 5 lines · Pavel Machek

Like this... But it should probably be slightly more complex -- like making numlock/capslock/scrollock leds into trigers, and then move input LED lowlevels into drivers/led...

In particular, all keyboard modifiers should be available triggers.

-hpa

#20 lore raw

RFC PATCH 1/1 Route kbd leds through the generic leds layer (Was: [PATCH] kbd: (#7063) make CapsLock work as expected even for non-ASCII)

Route keyboard leds through the generic leds layer.

This permits to reassign keyboard LEDs to something else than keyboard "leds" state, and also permits to fix #7063 by using a modifier to implement proper CapsLock behavior and have the keyboard caps lock led show that caps lock state.

---

Hello,

Quoted 7 lines · H. Peter Anvin, le Fri 20 Nov 2009 13:27:48 -0800, a écrit :
Quoted 4 lines · Pavel Machek

Like this... But it should probably be slightly more complex -- like making numlock/capslock/scrollock leds into trigers, and then move input LED lowlevels into drivers/led...

In particular, all keyboard modifiers should be available triggers.

Here is a patch to be commented on. It does work for me, and the very nice thing I like is

echo phy0assoc > /sys/class/leds/input::scrolllock/trigger

because I don't have a wifi led on my laptop.

The thing I like less is that dmesg now always contains

Registered led device: input::numlock
etc.

I could perhaps inspect the set of leds supported by all the connected input devices and only register triggers for those? Not so easy, but should be doable. In the meanwhile, please comment on the attached patch.

Samuel

Documentation/leds-class.txt +0 -3
diff -ur linux-2.6.32-orig/Documentation/leds-class.txt linux-2.6.32-perso/Documentation/leds-class.txt
@@ -2,9 +2,6 @@
 LED handling under Linux
 ========================
 
-If you're reading this and thinking about keyboard leds, these are
-handled by the input subsystem and the led class is *not* needed.
-
 In its simplest form, the LED class just allows control of LEDs from
 userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
 LED is defined in max_brightness file. The brightness file will set the brightness
drivers/char/keyboard.c +94 -7

163 lines not on this page · raw message

drivers/char/vt.c +1 -0
diff -ur linux-2.6.32-orig/drivers/char/vt.c linux-2.6.32-perso/drivers/char/vt.c
@@ -1625,6 +1625,7 @@
 	clr_kbd(vc, lnm);
 	kbd_table[vc->vc_num].lockstate = 0;
 	kbd_table[vc->vc_num].slockstate = 0;
+	/* FIXME */
 	kbd_table[vc->vc_num].ledmode = LED_SHOW_FLAGS;
 	kbd_table[vc->vc_num].ledflagstate = kbd_table[vc->vc_num].default_ledflagstate;
 	/* do not do set_leds here because this causes an endless tasklet loop
drivers/leds/Kconfig +7 -3
diff -ur linux-2.6.32-orig/drivers/leds/Kconfig linux-2.6.32-perso/drivers/leds/Kconfig
@@ -4,9 +4,6 @@
 	  Say Y to enable Linux LED support.  This allows control of supported
 	  LEDs from both userspace and optionally, by kernel events (triggers).
 
-	  This is not related to standard keyboard LEDs which are controlled
-	  via the input system.
-
 if NEW_LEDS
 
 config LEDS_CLASS
@@ -17,6 +14,13 @@
 
 comment "LED drivers"
 
+config LEDS_INPUT
+	tristate "LED Support using input keyboards"
+	depends on LEDS_CLASS
+	help
+	  This option enables support for the LEDs on keyboard managed
+	  by the input layer.
+
 config LEDS_ATMEL_PWM
 	tristate "LED Support using Atmel PWM outputs"
 	depends on LEDS_CLASS && ATMEL_PWM
drivers/leds/leds-input.c +172 -0

172 lines not on this page · raw message

drivers/leds/Makefile +1 -0
diff -ur linux-2.6.32-orig/drivers/leds/Makefile linux-2.6.32-perso/drivers/leds/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 
 # LED Platform Drivers
+obj-$(CONFIG_LEDS_INPUT)		+= leds-input.o
 obj-$(CONFIG_LEDS_ATMEL_PWM)		+= leds-atmel-pwm.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
lib/Kconfig.debug +1 -1
diff -ur linux-2.6.32-orig/lib/Kconfig.debug linux-2.6.32-perso/lib/Kconfig.debug
@@ -103,7 +103,7 @@
 
 config DEBUG_SECTION_MISMATCH
 	bool "Enable full Section mismatch analysis"
-	depends on UNDEFINED
+	#depends on UNDEFINED
 	# This option is on purpose disabled for now.
 	# It will be enabled when we are down to a resonable number
 	# of section mismatch warnings (< 10 for an allyesconfig build)
#21 lore raw

Re: [RFC,PATCH] Route kbd leds through the generic leds layer (Was: [PATCH] kbd: (#7063) make CapsLock work as expected even for non-ASCII)

Hi!

Quoted 6 lines

Route keyboard leds through the generic leds layer.

This permits to reassign keyboard LEDs to something else than keyboard "leds" state, and also permits to fix #7063 by using a modifier to implement proper CapsLock behavior and have the keyboard caps lock led show that caps lock state.

Yes please.

Quoted 1 line

Looks good. ACK.

lib/Kconfig.debug line 109

Quoted 11 lines
lib/Kconfig.debug +1 -1
@@ -103,7 +103,7 @@
 
 config DEBUG_SECTION_MISMATCH
 	bool "Enable full Section mismatch analysis"
-	depends on UNDEFINED
+	#depends on UNDEFINED
 	# This option is on purpose disabled for now.
 	# It will be enabled when we are down to a resonable number
 	# of section mismatch warnings (< 10 for an allyesconfig build)

You probably want to leave this bit.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html