[squeak-dev] Re: VM side EventSensor design questions

Andreas Raab andreas.raab at gmx.de
Wed Jun 24 04:46:22 UTC 2009


[BTW, I think this discussion is more appropriate for vm-dev]

Michael van der Gulik wrote:
> The fields are (for those that don't already know this):
> 
> 1: type (2=keyboard),
> 2: timestamp,
> 3: character in Mac Roman encoding,
> 4: key press/release (0=character, 1=press, 2=release)
> 5: modifiers (1=shift, 2=ctrl, 4=mac option, 8=cmd/alt)
> 
> and the rest of the fields are unused afaict.

http://squeakvm.org/cgi-bin/viewcvs.cgi/trunk/platforms/Cross/vm/sq.h

/* keyboard input event */
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;

> Now, why do I get both a key pressed event and a character event? The 
> key pressed event already has the character information. Is there a 
> circumstance where these two events would differ in anything other than 
> the type of event?

Yes. Whenever you have key combinations like dead keys you will see 
multiple key down events and only one corresponding character event. At 
least that's the idea I don't know how far the Unix VM implements it.

Basically the rule is: You should get a keyDown/keyUp event for every 
physical key you press/release on your keyboard, be that a letter key, a 
a navigation key, a composition key, or a meta or function key. A 
keyStroke event is generated for any combinations of keys that produce 
actual characters.

(BTW, this rule implies that the generation of character events for 
navigation keys (arrow key, home/end, function keys) is incorrect)

> The VM doesn't send any events for only a shift/ctrl/alt key press or 
> release. Should it?

Yes. It's a key you are pressing. If it can generate an event it should 
do so.

> If you hold down a key, you get a stream of key press and character 
> events for the same key. Should it? I'd prefer to have character 
> repetition handled within the image so that arcade games could be 
> implemented.

It's difficult to properly map this to the (dynamic) auto key repeat 
frequency. So I think it should do it, yes.

> Finally, I'm lazy, so I'm going to ask this mailing list how Unicode 
> input has been handled rather than read code. Do implementations modify 
> the VM to send Unicode characters through as field 3 (or whatever) of 
> the input arrays? Or do the implementations take the Mac Roman encoding 
> from the event array, look up a keyboard mapping in the image and 
> convert the result to the correct Unicode character?

See above. It's reported as utf32 in the event.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list