X.org on Mac OS X and caps-lock/control

Torrey Lyons torrey at mrcla.com
Thu Mar 17 11:35:28 PST 2005


At 10:20 AM -0500 3/17/05, Stefan Monnier wrote:
>  >> - if uControl is not in use, CapsLock does 
>send an event, but only when it's
>>>  pressed, not when it's released.  If I use xmodmap to bind this key to the
>>>  `control' modifier, I get a sticky-control (aka control-lock) behavior.
>
>>  AFAIK this is a hardware limitation.  There are some patches for the
>>  Linux kernel that try and work around it, but I think they don't work
>>  under all circumstances.
>
>This is a bog-standard USB keyboard.  I also occasionally use the built-in
>keyboard of my 2003 PowerBook G4 12" where there might be a hardware
>limitation, but for this USB keyboard it's clearly not the case.

I have never tried to use CapsLock in this way, 
although it is not an uncommon desire. So I can 
tell you what I know, without the benefit of 
actually trying it.

The standard kernel level event on Mac OS X only 
reports whether the "CapsLock state" is on or 
off. So you get an event when CapsLock is enabled 
or disabled, but you don't get the individual key 
press and key release events as you get for ever 
other button on the keyboard. As Michel Dänzer 
pointed out, some Apple supplied keyboards don't 
actually provide separate key press/release 
information for the CapsLock key at the hardware 
level.

Of course the Xserver DIX expects a separate key 
press and release event for CapsLock. The XDarwin 
DDX fakes these by generating a key press and 
release event each time the CapsLock state 
changes. I have not looked at the code for 
uControl, but my understanding is that Mac OS X 
now provides a special kernel event when the 
CapsLock button is pressed and released. The 
"right" way to solve this problem is to look for 
the new events and pass them on when present. Of 
course you have to deal with conditionalizing the 
code properly since older versions of the Darwin 
kernel likely won't support this. If some one 
wants to spend some time cozied up with the 
uControl source and darwinKeyboard.c, I'd be 
happy to help them.

(It is using this kind of newer extended kernel 
event which allows XDarwin to distinguish between 
left and right modifiers on Mac OS X 10.3 or 
newer. Here again the situation is similar as 
some older Apple keyboards don't distinguish 
these at the hardware level.)

--Torrey



More information about the xorg mailing list