How do I get the key state of the Apple key?

I’m using SDL_GetKeyState() in a program to get the states of the modifier keys (shift, control, option, and command). I have no problem getting the state of shift, control, and option (using SDLK_LSHIFT, SDLK_LCTRL, and SDLK_LALT), but I don’t know what to use to get the state of the command key, i.e., the Apple Key. I found one site that says to use SDLK_LGUI, but SDL doesn’t seem to recognize that on my setup (it says: ‘SDLK_LGUI’ was not declared in this scope).

I’m using SDL1. My IDE is Xcode 3.2.6, and I’m on an iMac, running OSX 10.6. I should also probably mention that I’m still pretty new to SDL and C++, so I might have trouble getting my head around some of the more advanced stuff!

Thanks for your help.

state of the command key, i.e., the Apple Key. I found one site that
says to use SDLK_LGUI, but SDL doesn’t seem to recognize that on my
setup (it says: ‘SDLK_LGUI’ was not declared in this scope).

I’m using SDL1. My IDE is Xcode 3.2.6, and I’m on an iMac, running OSX
10.6. I should also probably mention that I’m still pretty new to SDL
and C++, so I might have trouble getting my head around some of the more
advanced stuff!

In SDL2, this is SDL_LGUI (or RGUI, left and right).

In SDL1, this is SDL_LMETA (or RMETA).

(ps: Use SDL2 unless there’s a really good reason to use SDL1. You’ll
thank me later.)

–ryan.

Thanks Ryan, that did the trick. Btw, the reason I’m learning SDL1 is because the only book on SDL2 that I could find (SDL Game Development) was too advanced for me. I chose “Focus on SDL” because, even though it’s outdated, it’s written in a way that makes sense to me. I know there are online tutorials, but I prefer real ink and paper books.

For OpenGL use there isn’t too much different between SDL1 and SDL2… The event processing APIs are largely the same, and most other APIs are either the same or very similar. the biggest change is there is no SDL_SetVideoMode… instead you do this

SDL_Window *mywin = SDL_CreateWindow(“My Awesome Game”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_OPENGL);

SDL_GLcontext myglCtx = SDL_GL_CreateContext(mywin);

… use OpenGL and do your standard event loop ?

And actually with SDL2 there is a much broader set of test examples in the test folder in the source.

So once you get your feet wet with SDL, please do switch to SDL2 asap. as that’s where all the development and modern OS support is at.

Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-366-7906On May 15, 2014, at 11:48 PM, Explodey wrote:

Thanks Ryan, that did the trick. Btw, the reason I’m learning SDL1 is because the only book on SDL2 that I could find (SDL Game Development) was too advanced for me. I chose “Focus on SDL” because, even though it’s outdated, it’s written in a way that makes sense to me. I know there are online tutorials, but I prefer real ink and paper books.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org