Wiki Page Content

Differences between revisions 1 and 2
Revision 1 as of 2010-03-14 19:16:49
Size: 973
Editor: SheenaSmith
Comment: create page, add content (Rev 5540)
Revision 2 as of 2010-08-09 23:53:50
Size: 1759
Editor: SheenaSmith
Comment: update content (old wiki)
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
An array of key states. Indexes into this array are obtained by using SDL_scancode values. ^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.* Indexes into this array are obtained by using [[SDL_scancode]] values. *The pointer returned is a pointer to an internal SDL array. It will be valid for the whole lifetime of the application and should not be freed by the caller.*
Line 22: Line 22:
<<Color2(green,Is this entered correctly? Does the \code and \endcode go in or is that doxygen markup in the header?)>> <<Color2(green,Is this entered correctly? Does the \code and \endcode go in or is that doxygen markup in the header?  There is a different example in the old wiki.)>>
Line 31: Line 31:
''You can add useful comments here'' *<<Color2(green,From SDL_GetKeyState in old wiki.)>><<BR>>
Note: Use [[SDL_PumpEvents]]() to update the state array.

Note: This function gives you the current state after all events have been processed, so if a key or button has been pressed and released before you process events, then the pressed state will never show up in the `getstate` <<Color2(green,formatting here ok?)>> calls.

Note: This function doesn't take into account whether shift has been pressed or not. <<BR>>*
Line 34: Line 39:
 .[[SDL_PumpEvents]] *

DRAFT

SDL_GetKeyboardState

Use this function to get a snapshot of the current state of the selected keyboard.

Syntax

Uint8* SDL_GetKeyboardState(int* numkeys)

Function Parameters

numkeys

if non-NULL, receives the length of the returned array

Return Value

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.* Indexes into this array are obtained by using SDL_scancode values. *The pointer returned is a pointer to an internal SDL array. It will be valid for the whole lifetime of the application and should not be freed by the caller.*

Code Examples

green

Uint8 *state = SDL_GetKeyboardState(NULL);
if ( state[SDL_SCANCODE_RETURN] ) {
    printf("<RETURN> is pressed.\n");
}

Remarks

*green


Note: Use SDL_PumpEvents() to update the state array.

Note: This function gives you the current state after all events have been processed, so if a key or button has been pressed and released before you process events, then the pressed state will never show up in the getstate green

calls.

Note: This function doesn't take into account whether shift has been pressed or not.
*


CategoryAPI, CategoryKeyboard

None: SDL_GetKeyboardState (last edited 2013-12-07 14:28:51 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit