What is the API intent for the return value of SDL_GetKeyboa |
Eric Wing
Guest
|
I'm working on language bindings with SDL.
SDL_GetKeyboardState() is causing me some pain in binding, so I'm just going to make a wrapper function for my bindings, e.g. Uint8 SDL_GetKeyStateForScancodeEXT(SDL_Scancode scancode); So instead of: Uint8* current_key_states = SDL_GetKeyboardState( nil ); if( current_key_states[ SDL_SCANCODE_UP ] == SDL_PRESSED ) I can do this: if( SDL_GetKeyStateForScancodeEXT(SDL_SCANCODE_UP) == SDL_PRESSED ) But I wanted to clarify what the API intent of current_key_states[ SDL_SCANCODE_UP ] is supposed to return. Is this always intended to return a boolean, where SDL_PRESSED is true and SDL_RELEASED is false? Or is the intent that this is indeed a full Uint8 and I should be using bit masks instead? Unlike C, the intent matters for languages like Lua and Ruby because only nil and false are false values, while 0 (a number) is a true value. Thus in one of these languages, this won't work as many people might expect because it is always true in in non-boolean case: if( current_key_states[ SDL_SCANCODE_UP ] ) Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
What is the API intent for the return value of SDL_GetKeyboa |
Andre D
Guest
|
Docs say: Returns a pointer to an array of key states. A value of 1
means that the key is pressed and a value of 0 means that it is not. On Tue, Apr 15, 2014 at 7:43 PM, Eric Wing wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
What is the API intent for the return value of SDL_GetKeyboa |
Eric Wing
Guest
|
On 4/15/14, Andre D wrote:
Thank you Andre. -Eric _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|