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

Commit

Permalink
Renamed SDLKey and SDLMod for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Feb 7, 2011
1 parent d86cf56 commit 8317baa
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 33 deletions.
2 changes: 2 additions & 0 deletions include/SDL_compat.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ struct SDL_SysWMinfo;
#define SDL_KeySym SDL_Keysym #define SDL_KeySym SDL_Keysym
#define SDL_scancode SDL_Scancode #define SDL_scancode SDL_Scancode
#define SDL_ScanCode SDL_Scancode #define SDL_ScanCode SDL_Scancode
#define SDLKey SDL_Key
#define SDLMod SDL_Mod


/** /**
* \name Renamed keys * \name Renamed keys
Expand Down
16 changes: 8 additions & 8 deletions include/SDL_keyboard.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {
typedef struct SDL_Keysym typedef struct SDL_Keysym
{ {
SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */ SDL_Key sym; /**< SDL virtual key code - see ::SDL_Key for details */
Uint16 mod; /**< current key modifiers */ Uint16 mod; /**< current key modifiers */
Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */ Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
} SDL_Keysym; } SDL_Keysym;
Expand Down Expand Up @@ -80,24 +80,24 @@ extern DECLSPEC 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.
*/ */
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); extern DECLSPEC SDL_Mod SDLCALL SDL_GetModState(void);


/** /**
* \brief Set the current key modifier state for the keyboard. * \brief Set the current key modifier state for the keyboard.
* *
* \note This does not change the keyboard state, only the key modifier flags. * \note This does not change the keyboard state, only the key modifier flags.
*/ */
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Mod modstate);


/** /**
* \brief Get the key code corresponding to the given scancode according * \brief Get the key code corresponding to the given scancode according
* to the current keyboard layout. * to the current keyboard layout.
* *
* See ::SDLKey for details. * See ::SDL_Key for details.
* *
* \sa SDL_GetKeyName() * \sa SDL_GetKeyName()
*/ */
extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); extern DECLSPEC SDL_Key SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);


/** /**
* \brief Get the scancode corresponding to the given key code according to the * \brief Get the scancode corresponding to the given key code according to the
Expand All @@ -107,7 +107,7 @@ extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);
* *
* \sa SDL_GetScancodeName() * \sa SDL_GetScancodeName()
*/ */
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key); extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Key key);


/** /**
* \brief Get a human-readable name for a scancode. * \brief Get a human-readable name for a scancode.
Expand All @@ -130,9 +130,9 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode
* copy it. If the key doesn't have a name, this function returns an * copy it. If the key doesn't have a name, this function returns an
* empty string (""). * empty string ("").
* *
* \sa SDLKey * \sa SDL_Key
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key); extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Key key);


/** /**
* \brief Start accepting Unicode text input events. * \brief Start accepting Unicode text input events.
Expand Down
4 changes: 2 additions & 2 deletions include/SDL_keysym.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* the unmodified character that would be generated by pressing the key, or * the unmodified character that would be generated by pressing the key, or
* an SDLK_* constant for those keys that do not generate characters. * an SDLK_* constant for those keys that do not generate characters.
*/ */
typedef Sint32 SDLKey; typedef Sint32 SDL_Key;


#define SDLK_SCANCODE_MASK (1<<30) #define SDLK_SCANCODE_MASK (1<<30)
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) #define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
Expand Down Expand Up @@ -330,7 +330,7 @@ typedef enum
KMOD_CAPS = 0x2000, KMOD_CAPS = 0x2000,
KMOD_MODE = 0x4000, KMOD_MODE = 0x4000,
KMOD_RESERVED = 0x8000 KMOD_RESERVED = 0x8000
} SDLMod; } SDL_Mod;


#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) #define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) #define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)
Expand Down
18 changes: 9 additions & 9 deletions src/events/SDL_keyboard.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ struct SDL_Keyboard
SDL_Window *focus; SDL_Window *focus;
Uint16 modstate; Uint16 modstate;
Uint8 keystate[SDL_NUM_SCANCODES]; Uint8 keystate[SDL_NUM_SCANCODES];
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];
}; };


static SDL_Keyboard SDL_keyboard; static SDL_Keyboard SDL_keyboard;


static const SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = { static const SDL_Key SDL_default_keymap[SDL_NUM_SCANCODES] = {
0, 0, 0, 0, 0, 0, 0, 0,
'a', 'a',
'b', 'b',
Expand Down Expand Up @@ -572,13 +572,13 @@ SDL_ResetKeyboard(void)
} }


void void
SDL_GetDefaultKeymap(SDLKey * keymap) SDL_GetDefaultKeymap(SDL_Key * keymap)
{ {
SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
} }


void void
SDL_SetKeymap(int start, SDLKey * keys, int length) SDL_SetKeymap(int start, SDL_Key * keys, int length)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Keyboard *keyboard = &SDL_keyboard;


Expand Down Expand Up @@ -832,7 +832,7 @@ SDL_GetKeyboardState(int *numkeys)
return keyboard->keystate; return keyboard->keystate;
} }


SDLMod SDL_Mod
SDL_GetModState(void) SDL_GetModState(void)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Keyboard *keyboard = &SDL_keyboard;
Expand All @@ -841,14 +841,14 @@ SDL_GetModState(void)
} }


void void
SDL_SetModState(SDLMod modstate) SDL_SetModState(SDL_Mod modstate)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Keyboard *keyboard = &SDL_keyboard;


keyboard->modstate = modstate; keyboard->modstate = modstate;
} }


SDLKey SDL_Key
SDL_GetKeyFromScancode(SDL_Scancode scancode) SDL_GetKeyFromScancode(SDL_Scancode scancode)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Keyboard *keyboard = &SDL_keyboard;
Expand All @@ -857,7 +857,7 @@ SDL_GetKeyFromScancode(SDL_Scancode scancode)
} }


SDL_Scancode SDL_Scancode
SDL_GetScancodeFromKey(SDLKey key) SDL_GetScancodeFromKey(SDL_Key key)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Scancode scancode; SDL_Scancode scancode;
Expand All @@ -883,7 +883,7 @@ SDL_GetScancodeName(SDL_Scancode scancode)
} }


const char * const char *
SDL_GetKeyName(SDLKey key) SDL_GetKeyName(SDL_Key key)
{ {
static char name[8]; static char name[8];
char *end; char *end;
Expand Down
4 changes: 2 additions & 2 deletions src/events/SDL_keyboard_c.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ extern int SDL_KeyboardInit(void);
extern void SDL_ResetKeyboard(void); extern void SDL_ResetKeyboard(void);


/* Get the default keymap */ /* Get the default keymap */
extern void SDL_GetDefaultKeymap(SDLKey * keymap); extern void SDL_GetDefaultKeymap(SDL_Key * keymap);


/* Set the mapping of scancode to key codes */ /* Set the mapping of scancode to key codes */
extern void SDL_SetKeymap(int start, SDLKey * keys, int length); extern void SDL_SetKeymap(int start, SDL_Key * keys, int length);


/* Set a platform-dependent key name, overriding the default platform-agnostic /* Set a platform-dependent key name, overriding the default platform-agnostic
name. Encoded as UTF-8. The string is not copied, thus the pointer given to name. Encoded as UTF-8. The string is not copied, thus the pointer given to
Expand Down
2 changes: 1 addition & 1 deletion src/events/scancodes_linux.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/ */
#include "../../include/SDL_scancode.h" #include "../../include/SDL_scancode.h"


/* Linux virtual key code to SDLKey mapping table /* Linux virtual key code to SDL_Key mapping table
Sources: Sources:
- Linux kernel source input.h - Linux kernel source input.h
*/ */
Expand Down
2 changes: 1 addition & 1 deletion src/video/android/SDL_androidkeyboard.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


void Android_InitKeyboard() void Android_InitKeyboard()
{ {
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];


/* Add default scancode to key mapping */ /* Add default scancode to key mapping */
SDL_GetDefaultKeymap(keymap); SDL_GetDefaultKeymap(keymap);
Expand Down
2 changes: 1 addition & 1 deletion src/video/bwindow/SDL_BWin.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ class SDL_BWin:public BDirectWindow
bool inhibit_resize; bool inhibit_resize;


int32 last_buttons; int32 last_buttons;
SDLKey keymap[128]; SDL_Key keymap[128];
}; };


#endif /* _SDL_BWin_h */ #endif /* _SDL_BWin_h */
Expand Down
2 changes: 1 addition & 1 deletion src/video/cocoa/SDL_cocoakeyboard.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ - (NSArray *) validAttributesForMarkedText
const void *chr_data; const void *chr_data;
int i; int i;
SDL_Scancode scancode; SDL_Scancode scancode;
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];


/* See if the keymap needs to be updated */ /* See if the keymap needs to be updated */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
Expand Down
2 changes: 1 addition & 1 deletion src/video/directfb/SDL_DirectFB_events.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ EnumKeyboards(DFBInputDeviceID device_id,
#if USE_MULTI_API #if USE_MULTI_API
SDL_Keyboard keyboard; SDL_Keyboard keyboard;
#endif #endif
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];


if (!cb->sys_kbd) { if (!cb->sys_kbd) {
if (cb->sys_ids) { if (cb->sys_ids) {
Expand Down
2 changes: 1 addition & 1 deletion src/video/windows/SDL_windowskeyboard.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ WIN_UpdateKeymap()
{ {
int i; int i;
SDL_Scancode scancode; SDL_Scancode scancode;
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];


SDL_GetDefaultKeymap(keymap); SDL_GetDefaultKeymap(keymap);


Expand Down
12 changes: 6 additions & 6 deletions src/video/x11/SDL_x11keyboard.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/* *INDENT-OFF* */ /* *INDENT-OFF* */
static const struct { static const struct {
KeySym keysym; KeySym keysym;
SDLKey sdlkey; SDL_Key sdlkey;
} KeySymToSDLKey[] = { } KeySymToSDLKey[] = {
{ XK_Return, SDLK_RETURN }, { XK_Return, SDLK_RETURN },
{ XK_Escape, SDLK_ESCAPE }, { XK_Escape, SDLK_ESCAPE },
Expand Down Expand Up @@ -143,7 +143,7 @@ static const struct
}; };
/* *INDENT-OFF* */ /* *INDENT-OFF* */


static SDLKey static SDL_Key
X11_KeyCodeToSDLKey(Display *display, KeyCode keycode) X11_KeyCodeToSDLKey(Display *display, KeyCode keycode)
{ {
KeySym keysym; KeySym keysym;
Expand All @@ -157,7 +157,7 @@ X11_KeyCodeToSDLKey(Display *display, KeyCode keycode)


ucs4 = X11_KeySymToUcs4(keysym); ucs4 = X11_KeySymToUcs4(keysym);
if (ucs4) { if (ucs4) {
return (SDLKey) ucs4; return (SDL_Key) ucs4;
} }


for (i = 0; i < SDL_arraysize(KeySymToSDLKey); ++i) { for (i = 0; i < SDL_arraysize(KeySymToSDLKey); ++i) {
Expand Down Expand Up @@ -222,7 +222,7 @@ X11_InitKeyboard(_THIS)
} }


if (!fingerprint_detected) { if (!fingerprint_detected) {
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];


printf printf
("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n"); ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n");
Expand All @@ -233,7 +233,7 @@ X11_InitKeyboard(_THIS)
KeySym sym; KeySym sym;
sym = XKeycodeToKeysym(data->display, i, 0); sym = XKeycodeToKeysym(data->display, i, 0);
if (sym != NoSymbol) { if (sym != NoSymbol) {
SDLKey key; SDL_Key key;
printf("code = %d, sym = 0x%X (%s) ", i - min_keycode, printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
(unsigned int) sym, XKeysymToString(sym)); (unsigned int) sym, XKeysymToString(sym));
key = X11_KeyCodeToSDLKey(data->display, i); key = X11_KeyCodeToSDLKey(data->display, i);
Expand Down Expand Up @@ -265,7 +265,7 @@ X11_UpdateKeymap(_THIS)
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
int i; int i;
SDL_Scancode scancode; SDL_Scancode scancode;
SDLKey keymap[SDL_NUM_SCANCODES]; SDL_Key keymap[SDL_NUM_SCANCODES];


SDL_zero(keymap); SDL_zero(keymap);


Expand Down

0 comments on commit 8317baa

Please sign in to comment.