Mac Keyboard Events (was: Which version of image ?)

Bert Freudenberg bert at impara.de
Thu Oct 27 14:53:14 UTC 2005


Am 27.10.2005 um 14:28 schrieb Tetsuya HAYASHI:

> Thanks for your quick response and hack, it's cool.
> But, the gap of change is between '3.8.7b1' and '3.8.7b2' ;-)
> Now, I'm coding for parsing vmVersion info using your code as  
> example. thank you.

I know, but I thought that it was not necessary to distinguish  
between the beta levels. If someone is using beta VMs at all, she's  
surely using the latest one, right?

This is actually the code I have in Tweak's CMacOSPlatform class -  
since 3.8.7 the VM provides Mac Virtual Keycodes.

When I investigated this, I found some irregularities in the keyboard  
handling. Here's an email I meant to send to the VM dev list but  
apparently forgot to send:

==============================================================

I'm trying to make sense of what the current Mac VM (3.8.8b6) does  
wrt keyboard events:

/* sq.h */
typedef struct sqKeyboardEvent
{
   int type;            /* EventTypeKeyboard */
   unsigned int timeStamp;    /* time stamp */
   int charCode;            /* character code in Mac Roman encoding */
   int pressCode;        /* press code; any of EventKeyXXX */
   int modifiers;        /* combination of xxxKeyBit */
   int utf32Code;        /* UTF-32 unicode value */
   int reserved1;        /* reserved for future use */
   int windowIndex;        /* host window structure */
} sqKeyboardEvent;


I added this output to HandMorph>>generateKeyboardEvent:

Transcript
     show: type; space;
     show: evtBuf third asString; space;
     show: evtBuf sixth asString; cr.

So this should show the type, char code, and the unicode.

"s"
keyDown 1 1
keystroke 115 115
keyUp 1 1

"ß"
keyDown 1 0
keystroke 167 223
keyUp 1 0

"ú = Option-e u (dead key)"
keyUp 14 0
keyDown 32 13
keystroke 156 250
keyUp 32 0

"left arrow"
keyDown 124 0
keystroke 29 29
keyUp 124 0

"s"
keyDown 1 0
keystroke 115 115
keyUp 1 0

"F1"
keyDown 122 0
keystroke 16 16
keyUp 122 0

"F2"
keyDown 120 0
keystroke 16 16
keyUp 120 0


My findings:

- charCode in stroke events is MacRoman
- charCode in up/down events is virtual keycodes
- utf32Code in stroke events is Unicode, except for non-printable  
keys, where it uses MacRoman
- utf32Code in up/down events is something I don't get.
- there is an "up" event before the down event in the option-e dead  
key sequence
- the two "s" down/ups differ in the utf32Code
- all "F#" keys have the same stroke value
- there are no up/down events for modifier keys


- Bert -




More information about the Squeak-dev mailing list