Re: Keys and remapping them (was Re: Daydreaming)
Re: Keys and remapping them (was Re: Daydreaming)
- Subject: Re: Keys and remapping them (was Re: Daydreaming)
- From: Ben Byer <email@hidden>
- Date: Wed, 21 Nov 2007 02:50:54 -0800
On Nov 20, 2007, at 5:42 PM, William Mortensen wrote:
On Nov 20, 2007, at 2:59 PM, Nathaniel Gray wrote:
On Nov 20, 2007 12:12 PM, Derek Fawcus <email@hidden> wrote:
Hmm - is it command that only has the one virtual keycode?
I believe some of the others (ctrl, shift, alt?) have two, and some
OSX apps can distinguish between them.
Certainly the mac keyboards generate seperate scan codes (X under
Linux
on my MacBook could distinguish the keys).
xev shows me different scan codes and key bindings for left/right
shift, cmd, and option. Control is swapped with caps-lock on my
machine, but I'll bet I would get separate codes for Control_L and
_R.
This may have changed since Tiger -- I seem to remember not being
able
to distinguish them before.
This is hardware-dependent. I believe Apple's desktop USB keyboards
send different keycodes for left and right modifiers.
There's an easy way to answer these questions ("What information do we
have available to us for each keystroke event?")
Attachment:
EventMonitorTest.app.zip
Description: Zip archive
This program was simply built from the source code available at http://developer.apple.com/samplecode/EventMonitorTest/index.html
I built it so that those of you who aren't developers but still want
to help fix our keyboard handling can help out and give informed input
(so to speak).
I recommend you unpack it into some directory; you'll get a .app
bundle. Don't just run the .app bundle from the Finder! Instead, run
the binary manually from Terminal (or xterm!), e.g.:
bbyer:Deployment bbyer$ ./EventMonitorTest.app/Contents/MacOS/
EventMonitorTest
Then, click on the dock icon to bring it to the front, and select all
four Keyboard Events, as well as Process Foreground Events.
Now, hit some keys, and watch your Terminal -- these are the very
events being translated by the code in the following places (among
others):
http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=blob;hb=a842d8a85d77a3b8657f53224bf7791c3abfe22a;f=hw/darwin/quartz/X11Application.m#l957
http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=blob;hb=a842d8a85d77a3b8657f53224bf7791c3abfe22a;f=hw/darwin/darwinEvents.c#l393
Some oddnesses to note:
* We don't actually get KeyPress/KeyRelease events from Cocoa for
modifier keys; instead, we get a NSFlagsChanged notification, which
gives us a bitmask that reflects the new state of all modifier keys.
From that, we have to synthesize KeyPress / KeyRelease events to send
to the Device Independent X (dix) code.
* Capslock is weird; instead of getting four FlagsChanged messages for
each two presses of that key, we only get two.
--
Ben Byer
CoreOS / BSD Technology Group, XDarwin maintainer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden