zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_keyboard.c File Reference
#include "SDL_config.h"
#include "SDL_timer.h"
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "../video/SDL_sysvideo.h"

Go to the source code of this file.

Typedefs

typedef struct SDL_Keyboard SDL_Keyboard
 

Functions

void SDL_GetDefaultKeymap (SDL_Keycode *keymap)
 
SDL_WindowSDL_GetKeyboardFocus (void)
 Get the window which currently has keyboard focus. More...
 
const Uint8SDL_GetKeyboardState (int *numkeys)
 Get a snapshot of the current state of the keyboard. More...
 
SDL_Keycode SDL_GetKeyFromName (const char *name)
 Get a key code from a human-readable name. More...
 
SDL_Keycode SDL_GetKeyFromScancode (SDL_Scancode scancode)
 Get the key code corresponding to the given scancode according to the current keyboard layout. More...
 
const char * SDL_GetKeyName (SDL_Keycode key)
 Get a human-readable name for a key. More...
 
SDL_Keymod SDL_GetModState (void)
 Get the current key modifier state for the keyboard. More...
 
SDL_Scancode SDL_GetScancodeFromKey (SDL_Keycode key)
 Get the scancode corresponding to the given key code according to the current keyboard layout. More...
 
SDL_Scancode SDL_GetScancodeFromName (const char *name)
 Get a scancode from a human-readable name. More...
 
const char * SDL_GetScancodeName (SDL_Scancode scancode)
 Get a human-readable name for a scancode. More...
 
int SDL_KeyboardInit (void)
 
void SDL_KeyboardQuit (void)
 
void SDL_ResetKeyboard (void)
 
int SDL_SendEditingText (const char *text, int start, int length)
 
int SDL_SendKeyboardKey (Uint8 state, SDL_Scancode scancode)
 
int SDL_SendKeyboardText (const char *text)
 
void SDL_SetKeyboardFocus (SDL_Window *window)
 
void SDL_SetKeymap (int start, SDL_Keycode *keys, int length)
 
void SDL_SetModState (SDL_Keymod modstate)
 Set the current key modifier state for the keyboard. More...
 
void SDL_SetScancodeName (SDL_Scancode scancode, const char *name)
 
static char * SDL_UCS4ToUTF8 (Uint32 ch, char *dst)
 

Variables

static const SDL_Keycode SDL_default_keymap [SDL_NUM_SCANCODES]
 
static SDL_Keyboard SDL_keyboard
 
static const char * SDL_scancode_names [SDL_NUM_SCANCODES]
 

Typedef Documentation

typedef struct SDL_Keyboard SDL_Keyboard

Definition at line 35 of file SDL_keyboard.c.

Function Documentation

void SDL_GetDefaultKeymap ( SDL_Keycode keymap)

Definition at line 579 of file SDL_keyboard.c.

References SDL_default_keymap, and SDL_memcpy().

SDL_Window* SDL_GetKeyboardFocus ( void  )

Get the window which currently has keyboard focus.

Definition at line 603 of file SDL_keyboard.c.

References SDL_keyboard.

Referenced by SDL_DestroyWindow(), SDL_PrivateJoystickShouldIgnoreEvent(), and SDL_SetRelativeMouseMode().

const Uint8* SDL_GetKeyboardState ( int numkeys)

Get a snapshot of the current state of the keyboard.

Parameters
numkeysif non-NULL, receives the length of the returned array.
Returns
An array of key states. Indexes into this array are obtained by using SDL_Scancode values.

Example:

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

Definition at line 832 of file SDL_keyboard.c.

References SDL_keyboard, and SDL_NUM_SCANCODES.

SDL_Keycode SDL_GetKeyFromName ( const char *  name)

Get a key code from a human-readable name.

Returns
key code, or SDLK_UNKNOWN if the name wasn't recognized
See Also
SDL_Keycode

Definition at line 964 of file SDL_keyboard.c.

References i, NULL, SDL_default_keymap, SDL_GetScancodeFromName(), SDL_strlen(), and SDLK_UNKNOWN.

SDL_Keycode SDL_GetKeyFromScancode ( SDL_Scancode  scancode)

Get the key code corresponding to the given scancode according to the current keyboard layout.

See SDL_Keycode for details.

See Also
SDL_GetKeyName()

Definition at line 859 of file SDL_keyboard.c.

References SDL_InvalidParamError, SDL_keyboard, and SDL_NUM_SCANCODES.

const char* SDL_GetKeyName ( SDL_Keycode  key)

Get a human-readable name for a key.

Returns
A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it. If the key doesn't have a name, this function returns an empty string ("").
See Also
SDL_Key

Definition at line 925 of file SDL_keyboard.c.

References SDL_GetScancodeName(), SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_DELETE, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_RETURN, SDL_SCANCODE_SPACE, SDL_SCANCODE_TAB, SDL_UCS4ToUTF8(), SDLK_BACKSPACE, SDLK_DELETE, SDLK_ESCAPE, SDLK_RETURN, SDLK_SCANCODE_MASK, SDLK_SPACE, and SDLK_TAB.

Referenced by SDLTest_PrintEvent().

SDL_Keymod SDL_GetModState ( void  )

Get the current key modifier state for the keyboard.

Definition at line 843 of file SDL_keyboard.c.

References SDL_keyboard.

Referenced by Zeni::Game::run().

SDL_Scancode SDL_GetScancodeFromKey ( SDL_Keycode  key)

Get the scancode corresponding to the given key code according to the current keyboard layout.

See SDL_Scancode for details.

See Also
SDL_GetScancodeName()

Definition at line 872 of file SDL_keyboard.c.

References SDL_keyboard, SDL_NUM_SCANCODES, and SDL_SCANCODE_UNKNOWN.

Referenced by PSP_PumpEvents().

SDL_Scancode SDL_GetScancodeFromName ( const char *  name)

Get a scancode from a human-readable name.

Returns
scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized
See Also
SDL_Scancode

Definition at line 902 of file SDL_keyboard.c.

References i, SDL_arraysize, SDL_InvalidParamError, SDL_scancode_names, SDL_SCANCODE_UNKNOWN, and SDL_strcasecmp().

Referenced by SDL_GetKeyFromName().

const char* SDL_GetScancodeName ( SDL_Scancode  scancode)

Get a human-readable name for a scancode.

Returns
A pointer to the name for the scancode. If the scancode doesn't have a name, this function returns an empty string ("").
See Also
SDL_Scancode

Definition at line 887 of file SDL_keyboard.c.

References SDL_InvalidParamError, SDL_NUM_SCANCODES, and SDL_scancode_names.

Referenced by SDL_GetKeyName(), SDL_SendKeyboardKey(), and SDLTest_PrintEvent().

int SDL_KeyboardInit ( void  )

Definition at line 553 of file SDL_keyboard.c.

References SDL_default_keymap, SDL_keyboard, and SDL_memcpy().

Referenced by SDL_VideoInit().

void SDL_KeyboardQuit ( void  )

Definition at line 827 of file SDL_keyboard.c.

Referenced by SDL_VideoQuit().

void SDL_ResetKeyboard ( void  )
int SDL_SendEditingText ( const char *  text,
int  start,
int  length 
)
void SDL_SetKeymap ( int  start,
SDL_Keycode keys,
int  length 
)

Definition at line 585 of file SDL_keyboard.c.

References SDL_keyboard, SDL_memcpy(), and SDL_NUM_SCANCODES.

void SDL_SetModState ( SDL_Keymod  modstate)

Set the current key modifier state for the keyboard.

Note
This does not change the keyboard state, only the key modifier flags.

Definition at line 851 of file SDL_keyboard.c.

References SDL_keyboard.

void SDL_SetScancodeName ( SDL_Scancode  scancode,
const char *  name 
)

Definition at line 597 of file SDL_keyboard.c.

References SDL_scancode_names.

static char* SDL_UCS4ToUTF8 ( Uint32  ch,
char *  dst 
)
static

Definition at line 511 of file SDL_keyboard.c.

Referenced by SDL_GetKeyName().

Variable Documentation

const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES]
static

Definition at line 48 of file SDL_keyboard.c.

Referenced by SDL_GetDefaultKeymap(), SDL_GetKeyFromName(), and SDL_KeyboardInit().

const char* SDL_scancode_names[SDL_NUM_SCANCODES]
static