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

Commit

Permalink
Renamed SDL_keysym to SDL_KeySym
Browse files Browse the repository at this point in the history
Renamed SDL_scancode to SDL_ScanCode
Added #defines to SDL_compat.h
  • Loading branch information
krogoway committed Jan 24, 2011
1 parent 998cbf8 commit 4bc9a57
Show file tree
Hide file tree
Showing 29 changed files with 84 additions and 81 deletions.
8 changes: 4 additions & 4 deletions Xcode-iPhoneOS/Demos/src/keyboard.c
Expand Up @@ -34,7 +34,7 @@ static SDL_Color bg_color = { 50, 50, 100, 255 }; /* color of background *
*/
typedef struct
{
SDL_scancode scancode; /* scancode of the key we want to map */
SDL_ScanCode scancode; /* scancode of the key we want to map */
int allow_no_mod; /* is the map valid if the key has no modifiers? */
SDLMod mod; /* what modifiers are allowed for the mapping */
int index; /* what index in the font does the scancode map to */
Expand Down Expand Up @@ -103,7 +103,7 @@ fontMapping map[TABLE_SIZE] = {
};

/*
This function maps an SDL_keysym to an index in the bitmap font.
This function maps an SDL_KeySym to an index in the bitmap font.
It does so by scanning through the font mapping table one entry
at a time.
Expand All @@ -113,7 +113,7 @@ fontMapping map[TABLE_SIZE] = {
If there is no entry for the key, -1 is returned
*/
int
keyToIndex(SDL_keysym key)
keyToIndex(SDL_KeySym key)
{
int i, index = -1;
for (i = 0; i < TABLE_SIZE; i++) {
Expand Down Expand Up @@ -240,7 +240,7 @@ main(int argc, char *argv[])
SDL_Window *window;
SDL_Event event; /* last event received */
SDLMod mod; /* key modifiers of last key we pushed */
SDL_scancode scancode; /* scancode of last key we pushed */
SDL_ScanCode scancode; /* scancode of last key we pushed */

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("Error initializing SDL: %s", SDL_GetError());
Expand Down
3 changes: 3 additions & 0 deletions include/SDL_compat.h
Expand Up @@ -223,6 +223,9 @@ struct SDL_SysWMinfo;
*/
/*@{*/

#define SDL_keysym SDL_KeySym
#define SDL_scancode SDL_ScanCode

/**
* \name Renamed keys
*
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_events.h
Expand Up @@ -151,7 +151,7 @@ typedef struct SDL_KeyboardEvent
Uint8 repeat; /**< Non-zero if this is a key repeat */
Uint8 padding2;
Uint8 padding3;
SDL_keysym keysym; /**< The key that was pressed or released */
SDL_KeySym keysym; /**< The key that was pressed or released */
} SDL_KeyboardEvent;

#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
Expand Down
18 changes: 9 additions & 9 deletions include/SDL_keyboard.h
Expand Up @@ -45,13 +45,13 @@ extern "C" {
/**
* \brief The SDL keysym structure, used in key events.
*/
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 */
Uint16 mod; /**< current key modifiers */
Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
} SDL_keysym;
} SDL_KeySym;

/* Function prototypes */

Expand All @@ -65,7 +65,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
*
* \param numkeys if non-NULL, receives the length of the returned array.
*
* \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
* \return An array of key states. Indexes into this array are obtained by using ::SDL_ScanCode values.
*
* \b Example:
* \code
Expand Down Expand Up @@ -97,17 +97,17 @@ extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
*
* \sa SDL_GetKeyName()
*/
extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_ScanCode scancode);

/**
* \brief Get the scancode corresponding to the given key code according to the
* current keyboard layout.
*
* See ::SDL_scancode for details.
* See ::SDL_ScanCode for details.
*
* \sa SDL_GetScancodeName()
*/
extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
extern DECLSPEC SDL_ScanCode SDLCALL SDL_GetScancodeFromKey(SDLKey key);

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

/**
Expand Down
4 changes: 2 additions & 2 deletions include/SDL_scancode.h
Expand Up @@ -35,7 +35,7 @@
* \brief The SDL keyboard scancode representation.
*
* Values of this type are used to represent keyboard keys, among other places
* in the \link SDL_keysym::scancode key.keysym.scancode \endlink field of the
* in the \link SDL_KeySym::scancode key.keysym.scancode \endlink field of the
* SDL_Event structure.
*
* The values in this enumeration are based on the USB usage page standard:
Expand Down Expand Up @@ -392,7 +392,7 @@ typedef enum

SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes
for array bounds */
} SDL_scancode;
} SDL_ScanCode;

#endif /* _SDL_scancode_h */

Expand Down
16 changes: 8 additions & 8 deletions src/events/SDL_keyboard.c
Expand Up @@ -562,7 +562,7 @@ void
SDL_ResetKeyboard(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode;
SDL_ScanCode scancode;

for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keystate[scancode] == SDL_PRESSED) {
Expand Down Expand Up @@ -590,7 +590,7 @@ SDL_SetKeymap(int start, SDLKey * keys, int length)
}

void
SDL_SetScancodeName(SDL_scancode scancode, const char *name)
SDL_SetScancodeName(SDL_ScanCode scancode, const char *name)
{
SDL_scancode_names[scancode] = name;
}
Expand Down Expand Up @@ -638,7 +638,7 @@ SDL_SetKeyboardFocus(SDL_Window * window)
}

int
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
SDL_SendKeyboardKey(Uint8 state, SDL_ScanCode scancode)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
Expand Down Expand Up @@ -849,18 +849,18 @@ SDL_SetModState(SDLMod modstate)
}

SDLKey
SDL_GetKeyFromScancode(SDL_scancode scancode)
SDL_GetKeyFromScancode(SDL_ScanCode scancode)
{
SDL_Keyboard *keyboard = &SDL_keyboard;

return keyboard->keymap[scancode];
}

SDL_scancode
SDL_ScanCode
SDL_GetScancodeFromKey(SDLKey key)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode;
SDL_ScanCode scancode;

for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
++scancode) {
Expand All @@ -872,7 +872,7 @@ SDL_GetScancodeFromKey(SDLKey key)
}

const char *
SDL_GetScancodeName(SDL_scancode scancode)
SDL_GetScancodeName(SDL_ScanCode scancode)
{
const char *name = SDL_scancode_names[scancode];

Expand All @@ -890,7 +890,7 @@ SDL_GetKeyName(SDLKey key)

if (key & SDLK_SCANCODE_MASK) {
return
SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK));
SDL_GetScancodeName((SDL_ScanCode) (key & ~SDLK_SCANCODE_MASK));
}

switch (key) {
Expand Down
4 changes: 2 additions & 2 deletions src/events/SDL_keyboard_c.h
Expand Up @@ -43,13 +43,13 @@ extern void SDL_SetKeymap(int start, SDLKey * keys, int length);
name. Encoded as UTF-8. The string is not copied, thus the pointer given to
this function must stay valid forever (or at least until the call to
VideoQuit()). */
extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
extern void SDL_SetScancodeName(SDL_ScanCode scancode, const char *name);

/* Set the keyboard focus window */
extern void SDL_SetKeyboardFocus(SDL_Window * window);

/* Send a keyboard key event */
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
extern int SDL_SendKeyboardKey(Uint8 state, SDL_ScanCode scancode);

/* Send keyboard text input */
extern int SDL_SendKeyboardText(const char *text);
Expand Down
2 changes: 1 addition & 1 deletion src/events/scancodes_darwin.h
Expand Up @@ -27,7 +27,7 @@
- experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
*/
/* *INDENT-OFF* */
static const SDL_scancode darwin_scancode_table[] = {
static const SDL_ScanCode darwin_scancode_table[] = {
/* 0 */ SDL_SCANCODE_A,
/* 1 */ SDL_SCANCODE_S,
/* 2 */ SDL_SCANCODE_D,
Expand Down
2 changes: 1 addition & 1 deletion src/events/scancodes_linux.h
Expand Up @@ -26,7 +26,7 @@
- Linux kernel source input.h
*/
/* *INDENT-OFF* */
static SDL_scancode const linux_scancode_table[] = {
static SDL_ScanCode const linux_scancode_table[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
Expand Down
2 changes: 1 addition & 1 deletion src/events/scancodes_windows.h
Expand Up @@ -26,7 +26,7 @@
- msdn.microsoft.com
*/
/* *INDENT-OFF* */
static const SDL_scancode windows_scancode_table[] = {
static const SDL_ScanCode windows_scancode_table[] = {
/* 0, 0x00 */ SDL_SCANCODE_UNKNOWN,
/* 1, 0x01 */ SDL_SCANCODE_UNKNOWN,
/* 2, 0x02 */ SDL_SCANCODE_UNKNOWN,
Expand Down
4 changes: 2 additions & 2 deletions src/events/scancodes_xfree86.h
Expand Up @@ -26,7 +26,7 @@
- atKeyNames.h from XFree86 source code
*/
/* *INDENT-OFF* */
static const SDL_scancode xfree86_scancode_table[] = {
static const SDL_ScanCode xfree86_scancode_table[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
Expand Down Expand Up @@ -177,7 +177,7 @@ static const SDL_scancode xfree86_scancode_table[] = {
};

/* for wireless usb keyboard (manufacturer TRUST) without numpad. */
static const SDL_scancode xfree86_scancode_table2[] = {
static const SDL_ScanCode xfree86_scancode_table2[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
Expand Down
6 changes: 3 additions & 3 deletions src/video/android/SDL_androidkeyboard.c
Expand Up @@ -37,7 +37,7 @@ void Android_InitKeyboard()
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
}

static SDL_scancode Android_Keycodes[] = {
static SDL_ScanCode Android_Keycodes[] = {
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
Expand Down Expand Up @@ -151,10 +151,10 @@ static SDL_scancode Android_Keycodes[] = {
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
};

static SDL_scancode
static SDL_ScanCode
TranslateKeycode(int keycode)
{
SDL_scancode scancode = SDL_SCANCODE_UNKNOWN;
SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;

if (keycode < SDL_arraysize(Android_Keycodes)) {
scancode = Android_Keycodes[keycode];
Expand Down
4 changes: 2 additions & 2 deletions src/video/bwindow/SDL_BWin.h
Expand Up @@ -509,7 +509,7 @@ class SDL_BWin:public BDirectWindow

if (msg->FindInt32("key", &key) == B_OK
&& msg->FindInt32("modifiers", &modifiers) == B_OK) {
SDL_keysym keysym;
SDL_KeySym keysym;
keysym.scancode = key;
if ((key > 0) && (key < 128)) {
keysym.sym = keymap[key];
Expand Down Expand Up @@ -543,7 +543,7 @@ class SDL_BWin:public BDirectWindow
int32 modifiers;
if (msg->FindInt32("key", &key) == B_OK
&& msg->FindInt32("modifiers", &modifiers) == B_OK) {
SDL_keysym keysym;
SDL_KeySym keysym;
keysym.scancode = key;
if ((key > 0) && (key < 128)) {
keysym.sym = keymap[key];
Expand Down
20 changes: 10 additions & 10 deletions src/video/cocoa/SDL_cocoakeyboard.m
Expand Up @@ -246,7 +246,7 @@ - (NSArray *) validAttributesForMarkedText
HandleNonDeviceModifier(unsigned int device_independent_mask,
unsigned int oldMods,
unsigned int newMods,
SDL_scancode scancode)
SDL_ScanCode scancode)
{
unsigned int oldMask, newMask;

Expand All @@ -268,7 +268,7 @@ - (NSArray *) validAttributesForMarkedText
*/
static void
HandleModifierOneSide(unsigned int oldMods, unsigned int newMods,
SDL_scancode scancode,
SDL_ScanCode scancode,
unsigned int sided_device_dependent_mask)
{
unsigned int old_dep_mask, new_dep_mask;
Expand Down Expand Up @@ -297,8 +297,8 @@ - (NSArray *) validAttributesForMarkedText
static void
HandleModifierSide(int device_independent_mask,
unsigned int oldMods, unsigned int newMods,
SDL_scancode left_scancode,
SDL_scancode right_scancode,
SDL_ScanCode left_scancode,
SDL_ScanCode right_scancode,
unsigned int left_device_dependent_mask,
unsigned int right_device_dependent_mask)
{
Expand Down Expand Up @@ -341,8 +341,8 @@ - (NSArray *) validAttributesForMarkedText
static void
ReleaseModifierSide(unsigned int device_independent_mask,
unsigned int oldMods, unsigned int newMods,
SDL_scancode left_scancode,
SDL_scancode right_scancode,
SDL_ScanCode left_scancode,
SDL_ScanCode right_scancode,
unsigned int left_device_dependent_mask,
unsigned int right_device_dependent_mask)
{
Expand Down Expand Up @@ -409,13 +409,13 @@ - (NSArray *) validAttributesForMarkedText
unsigned int oldMods, unsigned int newMods)
{
/* Set up arrays for the key syms for the left and right side. */
const SDL_scancode left_mapping[] = {
const SDL_ScanCode left_mapping[] = {
SDL_SCANCODE_LSHIFT,
SDL_SCANCODE_LCTRL,
SDL_SCANCODE_LALT,
SDL_SCANCODE_LGUI
};
const SDL_scancode right_mapping[] = {
const SDL_ScanCode right_mapping[] = {
SDL_SCANCODE_RSHIFT,
SDL_SCANCODE_RCTRL,
SDL_SCANCODE_RALT,
Expand Down Expand Up @@ -489,7 +489,7 @@ - (NSArray *) validAttributesForMarkedText
#endif
const void *chr_data;
int i;
SDL_scancode scancode;
SDL_ScanCode scancode;
SDLKey keymap[SDL_NUM_SCANCODES];

/* See if the keymap needs to be updated */
Expand Down Expand Up @@ -675,7 +675,7 @@ - (NSArray *) validAttributesForMarkedText
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
unsigned short scancode = [event keyCode];
SDL_scancode code;
SDL_ScanCode code;
#if 0
const char *text;
#endif
Expand Down

0 comments on commit 4bc9a57

Please sign in to comment.