Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1882 - SDL_GetKeyboardState should return const.
Browse files Browse the repository at this point in the history
Yuri K. Schlesner

The array returned by SDL_GetKeyboardState is also used internally by SDL to keep track of pressed/released keys and must not be modified, lest weird behaviour occurs. Because of this I believe it's return type should be changed to return a const pointer, which will provide a code indication of that fact.
  • Loading branch information
slouken committed Jun 2, 2013
1 parent 449d1c7 commit 88f3b00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/SDL_keyboard.h
Expand Up @@ -66,13 +66,13 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
*
* \b Example:
* \code
* Uint8 *state = SDL_GetKeyboardState(NULL);
* const Uint8 *state = SDL_GetKeyboardState(NULL);
* if ( state[SDL_SCANCODE_RETURN] ) {
* printf("<RETURN> is pressed.\n");
* }
* \endcode
*/
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);

/**
* \brief Get the current key modifier state for the keyboard.
Expand Down
2 changes: 1 addition & 1 deletion src/events/SDL_keyboard.c
Expand Up @@ -829,7 +829,7 @@ SDL_KeyboardQuit(void)
{
}

Uint8 *
const Uint8 *
SDL_GetKeyboardState(int *numkeys)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
Expand Down

0 comments on commit 88f3b00

Please sign in to comment.