I've compiled an AmigaOS 4.x of a game engine I'm working on that uses PDCurses/SDL for the "graphics".
Don't know why but there are strange problems when I try to use the buttons on the numpad like:
1) numlock has to be set to off (instead of on) in order for keys to produce numbers
2) when numlock is off and pressing and releasing a numpad key it gets stuck until I press another key sending the input event over and over
3) not all numpad keys produce correct codes even with numlock off
The main input loop is pretty simple ATM and looks like this:
int input; while ((input = getch()) != KEY_ESCAPE) { switch (input) { case '1': Move(map, cx, cy, -1, 1); break; case KEY_DOWN: case '2': Move(map, cx, cy, 0, 1); break; case '3': Move(map, cx, cy, 1, 1); break; case KEY_LEFT: case '4': Move(map, cx, cy, -1, 0); break; case '5': Move(map, cx, cy, 0, 0); break; case KEY_RIGHT: case '6': Move(map, cx, cy, 1, 0); break; case '7': Move(map, cx, cy, -1, -1); break; case KEY_UP: case '8': Move(map, cx, cy, 0, -1); break; case '9': Move(map, cx, cy, 1, -1); break; default: fprintf(stderr, "Unknown input: %02x\n", (unsigned int)input); break; } RefreshScreen(disp, map, cx, cy); }
PDCurses version used is latest 3.4 one compiled with:
$ tar -zxf ~/Downloads/PDCurses-3.4.tar.gz
$ cd PDCurses-3.4/sdl1
$ make CC=ppc-amigaos-gcc SFLAGS=-I/SDK/local/common/include/SDL SLIBS=-lSDL DEMOFLAGS=-use-dynld
The AmigaOS 4.x test program I made can be downloaded here:
http://dl.dropbox.com/u/26599983/cursesgame.7z
I also compiled a Linux version using normal curses under Ubuntu and it works fine there (I haven't gotten either X11 or SDL PDCurses to compile under Ubuntu so I wasn't able to check if it was a general PDCurses bug or an AmigaOS/SDL specific one).
Just tried compiling with Spot's 3.3 version of SDL PDCurses and it has the same issues. Controlling with the arrow keys works fine just not the numpad for some reason...
BTW in curses setup code I have:
to enable using the arrow and numpad keys (if I don't do this they don't work at all).
Just tried compiling on Windows with SDL PDCurses and numpad works correctly there so it appears to be a problem with AmigaOS 4.x SDL...
Currently I'm debating whether I should write an intuition backend for my game and ignore PDCurses for AmigaOS:es or write an intuition backend for PDCurses which hopefully will work better than the current SDL one.
Well, I have tried something with SDL pdcurses before and that one, while compiling without errors (don't remember if there were warnings), crashed.
SDL has had a number of keyboard bugs over time, so I would guess this one of them.
yes. i remember also i've fixed something in the past that was related to UFO or another game... if someone want to take a look at keyboard handling, this is the file:
http://code.google.com/p/os4sdl/source/browse/trunk/src/video/amigaos4/SDL_os4events.c
there are some issues on SDL i'm aware of.. onr of this is the SDL_Kill that doesn't work (but i think because we have no way to kill a thread like other platforms..)
I'm currently looking at keyboard handling in OS4 SDL and it seems that numlock key isn't handled at all (KMOD_NUM is always cleared) except indirectly due to the fact that intuition generates different rawkey codes from IDCMP_RAWKEY depending on whether numlock is enabled or not (also I made the discovery that no IDCMP_RAWKEY messages are sent by intuition when the numlock key is pressed/released).
Also KMOD_CAPS seems to be handled weirdly in that it is set while the caps lock button is being held down and unset otherwise instead of being set when it's enabled and unset when it's disabled (is this really the correct/wanted behavior?).
If I disable the "Special handling for CAPSLOCK key" in os4video_HandleKeyboard() then the capslock key works exactly like it does in SDL on Ubuntu so obviously this special handling shouldn't be there because it just causes incorrect behavior.
After some more testing it doesn't look there is a way to easily see if numlock is enabled or not in AmigaOS as IEQUALIFIER_NUMERICPAD seems to only say if the button just pressed was on the numpad or not (I guess that's why it's called IEQUALIFIER_NUMERICPAD and not IEQUALIFIER_NUMLOCK).
Probably this strange handling of numlock is because the classic Amiga keyboards did not have a numlock key, but it also makes it hard to have a standards compliant SDL implementation on AmigaOS. I guess easiest way to fix PDCurses would be to just add a hack so that it assumes that numlock is always on, only problem with this is that it might break if SDL keyboard handling is changed in the future to be more correct.
First screenshot of a test program running on PDCurses Amiga native backend:
The font used is good old topaz 8 (will be configurable).
do you have a patch for SDL? If yes.. merge it! :)
[Edit]
i've seen you did it already. thx :)