[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: switch from ADB to linux keycodes ...



> That is sort of what I did. However, the way the caps lock key works
> makes it impracticle: The keypress event is sent when you first press
> the key... The key release event is sent when the key is released the

Nope, it's subtly different: a release event is inserted each time the key
is pressed or released, similar to Albert's suggestion (the release itself
generates a key down event as well).
Code snippet:

                /*
                 * adb kludge!! Imitate pc caps lock behaviour by
                 * generating an up/down event for each time caps
                 * is pressed/released. Also, makes sure that the
                 * LED are handled.  atong@uiuc.edu
                 */
                 switch (keycode) {
                 /*case 0xb9:*/
                 case 0x39:
                        handle_scancode(0x39, 1);
                        handle_scancode(0x39, 0);
                        mark_bh(KEYBOARD_BH);
                        return;
                 case 0x47:
                 /*case 0xc7:*/
                        mark_bh(KEYBOARD_BH);
                        break;
                 }

Plus the key down/up event pair is seen when depressing the key one time,
and when releasing it the next time - this is what Apple used to simulate
sticky keys, and this makes capslock useless for anything else.

The whole thing may work different in raw mode. But X seems to handle the
keyboard the same (both keypress and release generate a down/up event
pair).

I think you could try to use a similar hack with the control key or any
other key to use it as capslock (on either up or down event, generate the
down/up pair). But that's not what you want.

> second time. This leads to rather inconsistant behaivior. The
> workaround would be to train oneself to simply release the key every
> time, but I don't really like that, and it makes Emacs sequences a
> pain (e.g., C-x-s becomes: C-x C-s).

Yep, you cannot make the capslock key behave like a regular key (even when
it isn't sticky in hardware): There's no event generated when you release
it the first time, or press it the second time. So you cannot compute the
current key state reliably.

Haven't we hashed this out previously here?

	Michael



Reply to: