diff mbox

wrong behaviour of caps lock

Message ID 1270224121.12075.6.camel@deep-thought
State New
Headers show

Commit Message

Benjamin Drung April 2, 2010, 4:02 p.m. UTC
Hi,

We applied the attached patch in Ubuntu to fix the wrong behavior of
caps lock.

Initial bug report: https://launchpad.net/bugs/427612

Testcase: Select German NEO 2 as keyboard layout and press "caps lock" +
"l". Then a "-" should appear instead of a "t".

Comments

Jamie Lokier April 19, 2010, 1:23 a.m. UTC | #1
Benjamin Drung wrote:
> -        /* SDL does not send the key up event, so we generate it */

Was the original comment just plain wrong?

> -        kbd_put_keycode(keycode);
> -        kbd_put_keycode(keycode | 0x80);
> +        if (ev->type == SDL_KEYUP) {
> +            kbd_put_keycode(keycode | 0x80);
> +        } else {
> +            kbd_put_keycode(keycode);
> +        }

The patch implies that SDL *does* send the key up event.

Somebody obviously thought that it doesn't, hence the comment.

So what has changed?  Is it different versions of SDL, or does the
patch only work on some hosts / distros?

-- Jamie
Kevin Wolf April 19, 2010, 8:38 a.m. UTC | #2
Am 19.04.2010 03:23, schrieb Jamie Lokier:
> Benjamin Drung wrote:
>> -        /* SDL does not send the key up event, so we generate it */
> 
> Was the original comment just plain wrong?
> 
>> -        kbd_put_keycode(keycode);
>> -        kbd_put_keycode(keycode | 0x80);
>> +        if (ev->type == SDL_KEYUP) {
>> +            kbd_put_keycode(keycode | 0x80);
>> +        } else {
>> +            kbd_put_keycode(keycode);
>> +        }
> 
> The patch implies that SDL *does* send the key up event.
> 
> Somebody obviously thought that it doesn't, hence the comment.
> 
> So what has changed?  Is it different versions of SDL, or does the
> patch only work on some hosts / distros?

I think we already have had a discussion on this and it turned out that
Ubuntu had a "special" version of SDL which changed this behaviour. So
it is considered an Ubuntu SDL bug. Googled the old discussion for you:

http://www.mail-archive.com/qemu-devel@nongnu.org/msg25246.html

Kevin
Stefan Weil April 19, 2010, 4:07 p.m. UTC | #3
Kevin Wolf schrieb:
> Am 19.04.2010 03:23, schrieb Jamie Lokier:
>> Benjamin Drung wrote:
>>> - /* SDL does not send the key up event, so we generate it */
>> Was the original comment just plain wrong?
>>
>>> - kbd_put_keycode(keycode);
>>> - kbd_put_keycode(keycode | 0x80);
>>> + if (ev->type == SDL_KEYUP) {
>>> + kbd_put_keycode(keycode | 0x80);
>>> + } else {
>>> + kbd_put_keycode(keycode);
>>> + }
>> The patch implies that SDL *does* send the key up event.
>>
>> Somebody obviously thought that it doesn't, hence the comment.
>>
>> So what has changed? Is it different versions of SDL, or does the
>> patch only work on some hosts / distros?
>
> I think we already have had a discussion on this and it turned out that
> Ubuntu had a "special" version of SDL which changed this behaviour. So
> it is considered an Ubuntu SDL bug. Googled the old discussion for you:
>
> http://www.mail-archive.com/qemu-devel@nongnu.org/msg25246.html
>
> Kevin

My report was based on the Debian testing distribution
with libsdl components version 1.2.13-5.

So if it's a bug, both Ubuntu and Debian share it
(which is not too surprising).

And as I explained in my previous mail on this thread
QEMU's caps lock handling is buggy on any distribution.

Maybe I'll find the time to write a patch until the end
of this week.

Stefan
diff mbox

Patch

From bb212d2b23bee1abe52db53231caccc1a6a27791 Mon Sep 17 00:00:00 2001
From: Shahar Havivi <shaharh@redhat.com>
Date: Fri, 12 Feb 2010 00:00:44 +0200
Subject: [PATCH] Qemu does not pass pressed capslock to client

---
 sdl.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sdl.c b/sdl.c
index cf27ad2..9074641 100644
--- a/sdl.c
+++ b/sdl.c
@@ -390,9 +390,11 @@  static void sdl_process_key(SDL_KeyboardEvent *ev)
         break;
     case 0x45: /* num lock */
     case 0x3a: /* caps lock */
-        /* SDL does not send the key up event, so we generate it */
-        kbd_put_keycode(keycode);
-        kbd_put_keycode(keycode | 0x80);
+        if (ev->type == SDL_KEYUP) {
+            kbd_put_keycode(keycode | 0x80);
+        } else {
+            kbd_put_keycode(keycode);
+        }
         return;
     }
 
-- 
1.6.3.3