Jump to content
  • Advertisement
Sign in to follow this  

SDL - Always catching SDLK_SPACE but never F4 or ALT?

This topic is 4866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
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]);

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]

Share this post

Link to post
Share on other sites
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;

Share this post

Link to post
Share on other sites
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:


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!