All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org, shaharh@gmail.com, kwolf@redhat.com
Subject: [Qemu-devel] Re: Qemu does not pass pressed caps lock to client
Date: Fri, 12 Feb 2010 13:39:32 +0100	[thread overview]
Message-ID: <4B754C04.4080907@redhat.com> (raw)
In-Reply-To: <b0ae6fcc1002120309ya8e9160p414e94d9875c7956@mail.gmail.com>

On 02/12/2010 12:09 PM, Shahar Havivi wrote:
> It's not true that SDL is not sending up event like the comment say,
>
> On Fedora 12 it behave like a toggle button, first press/release will send
> caps-down event second press/release send caps-up event
 >
> On Ubuntu 9.10 it work like any other key, i.e. pressing caps will generate two
> events down and up.

True.  To see why, start at 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=317010 and 
http://archive.ubuntu.com/ubuntu/pool/main/libs/libsdl1.2/libsdl1.2_1.2.13-4ubuntu4.diff.gz 
-- it's a nice code reading exercise, so I'll suggest a possible 
solution before pointing out the reason for this behavior.  The solution 
would be to put hack after hack, i.e. something like this (untested):

     case 0x3a: /* caps lock */
         /* SDL will usually send only 2 events instead of 4, so we
            generate the missing ones.  However, on Debian/Ubuntu
            systems it may generate 4; in this case we have to discard
            the extra events.  On Debian/Ubuntu ev->key.keysym.mod
            will always be zero, but for other systems we need the
            complicated condition below.  */
	if ((ev->key.keysym.mod & KMOD_CAPS) ==
             (ev->type == SDL_KEYDOWN ? KMOD_CAPS : 0)) {
             kbd_put_keycode(keycode);
             kbd_put_keycode(keycode | 0x80);
         }
         return;
     case 0x45: /* num lock */
         /* Same as above.  */
	if ((ev->key.keysym.mod & KMOD_NUM) ==
             (ev->type == SDL_KEYDOWN ? KMOD_NUM : 0)) {
             kbd_put_keycode(keycode);
             kbd_put_keycode(keycode | 0x80);
         }
         return;

Now, the solution of the riddle.  The patch was correctly submitted as

+	SDL_UseLockKeys = getenv ("SDL_DISABLE_LOCK_KEYS") == NULL;

...

+	use_lock_keys = SDL_UseLockKeys;

...

+				if (!use_lock_keys)
+					break;

(i.e. by default do not change anything) but the maintainer apparently 
morphed it into

+	SDL_UseLockKeys = getenv("SDL_DISABLE_LOCK_KEYS");

...

+ 	use_lock_keys = ( SDL_UseLockKeys && *SDL_UseLockKeys );

...

+ 				if ( ! use_lock_keys )
+ 					break;

which changed the default and the meaning of SDL_DISABLE_LOCK_KEYS.

I initially thought about removing the caps lock/num lock hack 
altogether and add the following, however it would need SDL 1.2.14 
because SDL_NO_LOCK_KEYS support was added exactly two months after 
1.2.13 was released. :-( :-(

     /* There are two versions around of a Debian patch that changes the
        way Caps Lock and Num Lock are handled.  The first version
        by default sends only one of the KeyDown/KeyUp events, unless
        SDL_DISABLE_LOCK_KEYS is present in the environment.  The second
        version instead by default sends both events, unless
        SDL_DISABLE_LOCK_KEYS is present and not empty.  This version
        is the most commonly found (and a totally braindead idea).

        Upstream instead supports SDL_NO_LOCK_KEYS which, if set to 1,
        will generate all four events---which is what we want.  Luckily,
        there is a combination of environment variable that will satisfy
        all variant.  */

     putenv ("SDL_DISABLE_LOCK_KEYS", "");
     putenv ("SDL_NO_LOCK_KEYS", "1");

Yes, I love Debian.

Paolo

  parent reply	other threads:[~2010-02-12 12:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 21:13 [Qemu-devel] Qemu does not pass pressed caps lock to client Shahar Havivi
2010-02-12  9:54 ` Kevin Wolf
2010-02-12 11:09   ` Shahar Havivi
2010-02-12 11:43     ` Kevin Wolf
2010-02-12 12:39     ` Paolo Bonzini [this message]
2010-02-12 15:15       ` [Qemu-devel] " Anthony Liguori
2010-02-12 18:17         ` Paolo Bonzini
2010-02-12 18:44           ` Anthony Liguori
2010-02-12 20:49             ` Dustin Kirkland
2010-02-13 11:21               ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B754C04.4080907@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shaharh@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.