First post, by emendelson
A few years ago, with the help of experts on this forum, I added a couple of features to my project. They were designed to do two things: clear the keyboard shift states in case capslock or numlock got stuck, and also redraw the screen. They used to work a few years ago, but when I tried to include them in my current project, they seem to have no effect.
I'm almost certainly making a beginner's mistake, but I'm too much of a beginner to figure out what might be going wrong.
Here is the code, which I add to sdl_mapper.cpp:
static void ClearShiftStates(bool pressed) {
if (!pressed)
return;
KEYBOARD_AddKey(KBD_leftalt, false);
KEYBOARD_AddKey(KBD_rightalt, false);
KEYBOARD_AddKey(KBD_leftctrl, false);
KEYBOARD_AddKey(KBD_rightctrl, false);
KEYBOARD_AddKey(KBD_leftshift, false);
KEYBOARD_AddKey(KBD_rightshift, false);
// KEYBOARD_AddKey(KBD_capslock, false); // No - this turns on CapsLock if off
}
static void FixKeyboardScreen(bool pressed) {
if (!pressed)
return;
// Next two functions will clear keyboard buffer
KEYBOARD_ClrBuffer();
GFX_LosingFocus();
int cursor = SDL_ShowCursor(SDL_QUERY);
SDL_SetPalette(mapper.surface, SDL_LOGPAL|SDL_PHYSPAL, map_pal, 0, 5);
SDL_ShowCursor(cursor);
GFX_ResetScreen();
// next clears shift states
KEYBOARD_AddKey(KBD_leftalt, false);
KEYBOARD_AddKey(KBD_rightalt, false);
KEYBOARD_AddKey(KBD_leftctrl, false);
KEYBOARD_AddKey(KBD_rightctrl, false);
KEYBOARD_AddKey(KBD_leftshift, false);
KEYBOARD_AddKey(KBD_rightshift, false);
}
MAPPER_AddHandler(&ClearShiftStates,MK_f6,MMOD1|MMOD2,"unshift","Clr Shifts");
MAPPER_AddHandler(&FixKeyboardScreen,MK_f3,MMOD1|MMOD2,"fixall","FixKBD/Scr");
As I said, I remember being very pleased to get this working, but that was a long time ago, and I wonder if some revisions to SVN might have caused it to stop working. I'll be very grateful for any advice.