[Scummvm-devel] Keys in events.h

Max Horn max at quendi.de
Fri Jun 15 10:14:01 CEST 2007


Am 15.06.2007 um 06:29 schrieb Paul Gilbert:

> Ah. Then I'd be interested in clone2727's proposal as well. I recently
> completed (but not yet commited) the fighting sequences code of Lure,
> and had used the SDLK_ constants, since I didn't really like putting
> arbitrary numbers directly in the code. It would be good if there were
> a common set of constants I could refer to.

Indeed, using the SDLK_ constants is not a good idea, since the SDL  
headers are not even be present on all target systems. It's been on  
the TODO for a long time now (see also common/events.h, line 122ff).

So you are most welcome to add such a list, and even better, modify  
existing engines to use it :-). Keys that should be added at the very  
least include ESC, RETURN, ENTER, F1-F10. Define an enum for it then,  
e.g. KEYCODE_ESC

In addition, though, we also map certain keys in a special way to  
fake 16bit "ASCII" values. This is currently totally undocumented yet  
used heavily by the SCUMM engine at least. The only "documentation"  
for the mapping can be found in the form of the mapKey() function  
inside backends/platform/sdl/events.cpp. A separate enum should be  
added for that, maybe like KEYASCII_ESC etc. =

While we are at it, we might consider to rename KBD_CTRL KBD_ALT,  
KBD_SHIFT globally to KEYMOD_CTRL etc. to unify the names a bit.

Finally, it would be terrific if you could also add some doxygen  
comments to each, explaining when to use what... Err, if that is even  
clear to you (I am not sure whether it's 100% clear to me right now  
*g*).


> Speaking of which, how are keys handled on other systems? For example,
> Lure's fight code, as well as providing mouse support, uses the arrow
> keys to move the player and the numeric keypad for attack and defence
> at high/mid/low levels. Do other systems have a mapping table that
> converts their various keys to PC keyboard equivalents? Or does it
> mean that the PC-based key handling code won't get triggered on other
> systems.

Other systems, especially those w/o a keyboard, have to remap their  
few input controls depending on the game/engine running at the time,  
and/or provide a virtual keyboard on-screen, to generate fake  
keyboard events in both cases. The difficult on mapping a potentially  
extremly limited set of hardware buttons to the potentially huge  
number of keys a game might use, obviously causes problems, and makes  
it necessary for backends to "peek" at which game is currently  
running, a rather undesirable behavior. That's why I recently started  
that thread: "RFC: Flexible keymapping via new EVENT_ (post 0.10)".


Cheers,
Max




More information about the Scummvm-devel mailing list