Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Caps lock in event taps doesn't send flags changed upon release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Caps lock in event taps doesn't send flags changed upon release




On 1/31/07, Mike Paquette <email@hidden> wrote:

The Caps Lock, and on many keyboards, Num Lock, is
electromechanically implemented as a toggling device.  One press
toggles it to a 'down' state, and a second press toggles it to an
'up' state. 
 

Event taps, as well as the modifier flags in Carbon events and
NSEvents, are working correctly.  The hardware may not be behaving in
the manner you were expecting.

Interesting.  To confirm this hardware behavior, I took the keyboard in question (a standard Apple USB keyboard), and plugged it into a Linux host running X.org 1.1.1.

I ran 'xev' in an xterm, then pressed and held the caps-lock key for several seconds, then released it.  I saw the following:

(I hold down the Caps Lock key)

 KeyPress event, serial 30, synthetic NO, window 0x4e00001,
    root 0x187, subw 0x4e00002, time 2071490745, (36,56), root:(101,495),
    state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

(I wait several seconds, then release the Caps Lock key)

KeyRelease event, serial 30, synthetic NO, window 0x4e00001,
    root 0x187, subw 0x4e00002, time 2071490929, (36,56), root:(101,495),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

So, I would argue that this is not an electromechanical implementation detail of the hardware, but perhaps an implementation detail of the USB HID driver that talks to USB keyboards on Mac OS X 10.4 hosts.

I tried 4 other USB keyboards I had lying around (Apple and non-Apple), and all of them behaved identically.

I also found this intriguing behavior of keyboard event taps with the source program I sent in my initial post to this thread:

[beng@beng-macpro:~]% ./test         

(I hold down the left Option key)

Got flags changed event. Old flags 0x100, new 0x80120, changed 0x80020.

(I hold down the left arrow key)

Got key down event, keycode 0x007B.

(I release the left Option key while keeping the left arrow key held down)

Got flags changed event. Old flags 0x80120, new 0x200100, changed 0x280020.

0x200000 is NX_NUMERICPADMASK.  Why am I being told Num-Lock is being pressed in this case?

The next flags changed event (whatever it ends up being) clears 0x200000.

Ben

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Caps lock in event taps doesn't send flags changed upon release (From: "Ben Gertzfield" <email@hidden>)
 >Re: Caps lock in event taps doesn't send flags changed upon release (From: Mike Paquette <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.