if (mainApp.GetKey(SDLK_LALT) && mainApp.GetKey(SDLK_F4))
return false;
// Where GetKey is this:
Uint8 CApp_Input::GetKey(Uint8 aKey)
{
return (SDL_GetKeyState(NULL)[aKey]);
}
SDL - Always catching SDLK_SPACE but never F4 or ALT?
Ok, what's wrong with SDL? For some reason it always catches SDLK_SPACE and even a combo with SDLK_SPACE and SDLK_q... But when I try ANYTHING with SDLK_LALT(or RALT) it doesn't work... Look how I'm doing it:
Again, it works with SDLK_q or SDLK_SPACE... What can be wrong?
Oh, and yeah, mainApp is an instance of CApp, which inherits from CApp_Event, CApp_Input, and other stuff..
This is SDL in C++.
Thanks to all!
aKey has to be an int, not a Uint8.
[Edited by - agi_shi on November 26, 2005 9:30:49 AM]
I think there are problems with telling left/right alt/shift/control apart on some OSes. Try this:
if ((mainApp.GetKey(SDLK_LALT) || mainApp.GetKey(SDLK_RALT)) && mainApp.GetKey(SDLK_F4)) return false;
I haven't personally used it, but you might try SDL_GetModStat() for ALT. This is from the documentation:
typedef enum { KMOD_NONE = 0x0000, KMOD_LSHIFT= 0x0001, KMOD_RSHIFT= 0x0002, KMOD_LCTRL = 0x0040, KMOD_RCTRL = 0x0080, KMOD_LALT = 0x0100, KMOD_RALT = 0x0200, KMOD_LMETA = 0x0400, KMOD_RMETA = 0x0800, KMOD_NUM = 0x1000, KMOD_CAPS = 0x2000, KMOD_MODE = 0x4000,} SDLMod;SDL also defines the following symbols for convenience:#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)#define KMOD_ALT (KMOD_LALT|KMOD_RALT)#define KMOD_META (KMOD_LMETA|KMOD_RMETA)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement