Hello. Last night began some alpha testing of my new roguelike called
Invader, which uses LISPBUILDER-SDL. See also
http://dto.github.com/notebook/invader.html
I told everyone to use the latest svn of lispbuilder-sdl. But some
people have trouble controlling the game because modifiers are not
recognized properly. Indeed we seem to each be getting very different
data out of SDL. I added print statements to print out 1. the raw key
symbol and modifier data coming in from the SDL:WITH-EVENTS loop, and
2. the rlx-internal format these get translated into.
On my machine (debian lenny), pressing L, Control L, H, Alt H, gives this:
-----------------------------------
SDL KEY AND MODS: (SDL-KEY-L SDL-KEY-MOD-NONE)
TRANSLATED EVENT: (L)
SDL KEY AND MODS: (SDL-KEY-LCTRL SDL-KEY-MOD-NONE)
TRANSLATED EVENT: (LCTRL)
SDL KEY AND MODS: (SDL-KEY-L SDL-KEY-MOD-LCTRL)
TRANSLATED EVENT: (L CONTROL)
SDL KEY AND MODS: (SDL-KEY-H SDL-KEY-MOD-NONE)
TRANSLATED EVENT: (H)
SDL KEY AND MODS: (SDL-KEY-LALT SDL-KEY-MOD-NONE)
TRANSLATED EVENT: (LALT)
SDL KEY AND MODS: (SDL-KEY-H SDL-KEY-MOD-LALT)
TRANSLATED EVENT: (H ALT)
------------------------------------
Whereas on other machines things like this happen when you try to press
Alt-H:
SDL KEY AND MODS: (SDL-KEY-LALT 0)
TRANSLATED EVENT: (LALT)
SDL KEY AND MODS: (SDL-KEY-H 256)
TRANSLATED EVENT: (H)
SDL KEY AND MODS: (SDL-KEY-LCTRL 0)
TRANSLATED EVENT: (LCTRL)
-----------
Or Alt-F on yet another machine:
SDL KEY AND MODS: (SDL-KEY-F 0)
TRANSLATED EVENT: (F)
SDL KEY AND MODS: (SDL-KEY-LMETA 0)
TRANSLATED EVENT: (LMETA)
SDL KEY AND MODS: (SDL-KEY-F 1024)
TRANSLATED EVENT: (F)
------------
It appears that I am always expecting a symbol or list of symbols for
the :mod argument of :key-down-event in WITH-EVENTS. But on other
machines people are getting numbers there.
But according to the LISPBUILDER-SDL documentation you should always get
symbols to represent the modifiers:
> MOD is current state of the keyboard modifiers as explained in
> SDL_GetModState. One or more of :SDL-KEY-MOD-NONE,
> :SDL-KEY-MOD-LSHIFT, :SDL-KEY-MOD-RSHIFT, :SDL-KEY-MOD-LCTRL,
> :SDL-KEY-MOD-RCTRL, :SDL-KEY-MOD-LALT, :SDL-KEY-MOD-RALT,
> :SDL-KEY-MOD-LMETA, :SDL-KEY-MOD-RMETA, :SDL-KEY-MOD-NUM,
> :SDL-KEY-MOD-CAPS, :SDL-KEY-MOD-MODE or :SDL-KEY-MOD-RESERVED.
BTW All the relevant translation code is in one file, console.lisp:
http://github.com/dto/rlx/raw/d93976f46ac0c8579b44882b49a6a82c1ada17f1/cons…
In case you would like to inspect further.
--
David O'Toole dto(a)gnu.org