Fixed bug 1882 - SDL_GetKeyboardState should return const.
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.
This commit is contained in:
parent
a54ea6ce9f
commit
cb62e2540a
2 changed files with 3 additions and 3 deletions
|
@ -66,13 +66,13 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
|
||||||
*
|
*
|
||||||
* \b Example:
|
* \b Example:
|
||||||
* \code
|
* \code
|
||||||
* Uint8 *state = SDL_GetKeyboardState(NULL);
|
* const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||||
* if ( state[SDL_SCANCODE_RETURN] ) {
|
* if ( state[SDL_SCANCODE_RETURN] ) {
|
||||||
* printf("<RETURN> is pressed.\n");
|
* printf("<RETURN> is pressed.\n");
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \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.
|
* \brief Get the current key modifier state for the keyboard.
|
||||||
|
|
|
@ -829,7 +829,7 @@ SDL_KeyboardQuit(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8 *
|
const Uint8 *
|
||||||
SDL_GetKeyboardState(int *numkeys)
|
SDL_GetKeyboardState(int *numkeys)
|
||||||
{
|
{
|
||||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue