The aalib video driver + arrow keys

There seems to be a problem with the arrow keys when using the aalib video
driver. At least with aalib 1.2. In AA_InitOSKeymap( ) the keymap[ ] array
is initialized to handle the arrow keys

keymap[AA_UP] = SDLK_UP;            <-- AA_UP    = 300
keymap[AA_DOWN] = SDLK_DOWN;        <-- AA_DOWN  = 301
keymap[AA_LEFT] = SDLK_LEFT;        <-- AA_LEFT  = 302
keymap[AA_RIGHT] = SDLK_RIGHT;      <-- AA_RIGHT = 303

but later it sets up translations for the keypad

keymap[302] = SDLK_KP0;             <--
keymap[300] = SDLK_KP1;             <--
keymap[297] = SDLK_KP2;
keymap[299] = SDLK_KP3;
keymap[294] = SDLK_KP4;
keymap[301] = SDLK_KP5;             <--
keymap[296] = SDLK_KP6;
keymap[293] = SDLK_KP7;
keymap[295] = SDLK_KP8;
keymap[298] = SDLK_KP9;

which overwrite the translations for three of the arrow keys.

Come to think of it I’m not sure the keypad works either. If it doesn’t,
then the bugfix is trivial. If it does… Anyway I can’t test that right
now. (I do have access to Linux, and I do have access to the Internet, but
rarely at the same time and place. :slight_smile:

Torbj?rn Andersson

In article <8aqjnu$gu0$1 at ftp.lokigames.com>,
“Torbj?rn Andersson” writes:

There seems to be a problem with the arrow keys when using the aalib video
driver. At least with aalib 1.2. In AA_InitOSKeymap( ) the keymap[ ] array
is initialized to handle the arrow keys

keymap[AA_UP] = SDLK_UP;            <-- AA_UP    = 300
keymap[AA_DOWN] = SDLK_DOWN;        <-- AA_DOWN  = 301
keymap[AA_LEFT] = SDLK_LEFT;        <-- AA_LEFT  = 302
keymap[AA_RIGHT] = SDLK_RIGHT;      <-- AA_RIGHT = 303

but later it sets up translations for the keypad

keymap[302] = SDLK_KP0;             <--
keymap[300] = SDLK_KP1;             <--
keymap[297] = SDLK_KP2;
keymap[299] = SDLK_KP3;
keymap[294] = SDLK_KP4;
keymap[301] = SDLK_KP5;             <--
keymap[296] = SDLK_KP6;
keymap[293] = SDLK_KP7;
keymap[295] = SDLK_KP8;
keymap[298] = SDLK_KP9;

which overwrite the translations for three of the arrow keys.

Come to think of it I’m not sure the keypad works either. If it doesn’t,
then the bugfix is trivial. If it does… Anyway I can’t test that right
now. (I do have access to Linux, and I do have access to the Internet, but
rarely at the same time and place. :slight_smile:

Torbj?rn Andersson

Hum, that’s probably a bug ;-). The way I determined the index values
for this array was very empiric: basically just trying all the keys
and looking are their values. I guess the cursor values should be kept,
although they seem to conflict with different keys … Arrow keys
are more useful anyway ;)–
Stephane Peter
Programmer
Loki Entertainment Software

“Microsoft has done to computers what McDonald’s has done to gastronomy”