File style cleanup for the SDL 2.0 release

This commit is contained in:
Sam Lantinga 2013-05-18 14:17:52 -07:00
parent 2ac8624930
commit 0cb6385637
376 changed files with 17562 additions and 17773 deletions

View file

@ -53,7 +53,7 @@ static SDL_DisabledEventBlock *SDL_disabled_events[256];
static Uint32 SDL_userevents = SDL_USEREVENT;
/* Private data -- event queue */
#define MAXEVENTS 128
#define MAXEVENTS 128
static struct
{
SDL_mutex *lock;

View file

@ -35,13 +35,10 @@
#include <stdio.h>
#include <math.h>
//TODO: Replace with malloc
/* TODO: Replace with malloc */
#define MAXPATHSIZE 1024
#define DOLLARNPOINTS 64
#define DOLLARSIZE 256

View file

@ -860,7 +860,7 @@ SDL_Keycode
SDL_GetKeyFromScancode(SDL_Scancode scancode)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
SDL_InvalidParamError("scancode");
return 0;
@ -890,7 +890,7 @@ SDL_GetScancodeName(SDL_Scancode scancode)
const char *name;
if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
SDL_InvalidParamError("scancode");
return "";
return "";
}
name = SDL_scancode_names[scancode];
@ -902,24 +902,24 @@ SDL_GetScancodeName(SDL_Scancode scancode)
SDL_Scancode SDL_GetScancodeFromName(const char *name)
{
int i;
int i;
if (!name || !*name) {
SDL_InvalidParamError("name");
return SDL_SCANCODE_UNKNOWN;
}
if (!name || !*name) {
SDL_InvalidParamError("name");
return SDL_SCANCODE_UNKNOWN;
}
for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
if (!SDL_scancode_names[i]) {
continue;
}
if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
return (SDL_Scancode)i;
}
}
for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
if (!SDL_scancode_names[i]) {
continue;
}
if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
return (SDL_Scancode)i;
}
}
SDL_InvalidParamError("name");
return SDL_SCANCODE_UNKNOWN;
SDL_InvalidParamError("name");
return SDL_SCANCODE_UNKNOWN;
}
const char *
@ -964,51 +964,51 @@ SDL_GetKeyName(SDL_Keycode key)
SDL_Keycode
SDL_GetKeyFromName(const char *name)
{
SDL_Keycode key;
SDL_Keycode key;
/* Check input */
if (name == NULL) return SDLK_UNKNOWN;
/* If it's a single UTF-8 character, then that's the keycode itself */
key = *(const unsigned char *)name;
if (key >= 0xF0) {
if (SDL_strlen(name) == 4) {
int i = 0;
key = (Uint16)(name[i]&0x07) << 18;
key |= (Uint16)(name[++i]&0x3F) << 12;
key |= (Uint16)(name[++i]&0x3F) << 6;
key |= (Uint16)(name[++i]&0x3F);
return key;
}
return SDLK_UNKNOWN;
} else if (key >= 0xE0) {
if (SDL_strlen(name) == 3) {
int i = 0;
key = (Uint16)(name[i]&0x0F) << 12;
key |= (Uint16)(name[++i]&0x3F) << 6;
key |= (Uint16)(name[++i]&0x3F);
return key;
}
return SDLK_UNKNOWN;
} else if (key >= 0xC0) {
if (SDL_strlen(name) == 2) {
int i = 0;
key = (Uint16)(name[i]&0x1F) << 6;
key |= (Uint16)(name[++i]&0x3F);
return key;
}
return SDLK_UNKNOWN;
} else {
if (SDL_strlen(name) == 1) {
if (key >= 'A' && key <= 'Z') {
key += 32;
}
return key;
}
/* Get the scancode for this name, and the associated keycode */
return SDL_default_keymap[SDL_GetScancodeFromName(name)];
}
/* If it's a single UTF-8 character, then that's the keycode itself */
key = *(const unsigned char *)name;
if (key >= 0xF0) {
if (SDL_strlen(name) == 4) {
int i = 0;
key = (Uint16)(name[i]&0x07) << 18;
key |= (Uint16)(name[++i]&0x3F) << 12;
key |= (Uint16)(name[++i]&0x3F) << 6;
key |= (Uint16)(name[++i]&0x3F);
return key;
}
return SDLK_UNKNOWN;
} else if (key >= 0xE0) {
if (SDL_strlen(name) == 3) {
int i = 0;
key = (Uint16)(name[i]&0x0F) << 12;
key |= (Uint16)(name[++i]&0x3F) << 6;
key |= (Uint16)(name[++i]&0x3F);
return key;
}
return SDLK_UNKNOWN;
} else if (key >= 0xC0) {
if (SDL_strlen(name) == 2) {
int i = 0;
key = (Uint16)(name[i]&0x1F) << 6;
key |= (Uint16)(name[++i]&0x3F);
return key;
}
return SDLK_UNKNOWN;
} else {
if (SDL_strlen(name) == 1) {
if (key >= 'A' && key <= 'Z') {
key += 32;
}
return key;
}
/* Get the scancode for this name, and the associated keycode */
return SDL_default_keymap[SDL_GetScancodeFromName(name)];
}
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -397,12 +397,12 @@ void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
if ( window == NULL )
window = mouse->focus;
if ( window == NULL )
return;
if ( window == NULL )
window = mouse->focus;
if ( window == NULL )
return;
if (mouse->WarpMouse) {
mouse->WarpMouse(window, x, y);
@ -572,13 +572,13 @@ SDL_CreateSystemCursor(SDL_SystemCursor id)
return NULL;
}
cursor = mouse->CreateSystemCursor(id);
cursor = mouse->CreateSystemCursor(id);
if (cursor) {
cursor->next = mouse->cursors;
mouse->cursors = cursor;
}
return cursor;
return cursor;
}
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,

View file

@ -39,7 +39,7 @@ typedef struct
SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
/* Create a system cursor */
SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id);
SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id);
/* Show the specified cursor, or hide if cursor is NULL */
int (*ShowCursor) (SDL_Cursor * cursor);

View file

@ -165,7 +165,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name)
return index;
}
static int
static int
SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
{
SDL_Finger *finger;
@ -258,7 +258,7 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
event.tfinger.touchId = id;
event.tfinger.fingerId = fingerid;
/* I don't trust the coordinates passed on fingerUp */
event.tfinger.x = finger->x;
event.tfinger.x = finger->x;
event.tfinger.y = finger->y;
event.tfinger.dx = 0;
event.tfinger.dy = 0;
@ -287,7 +287,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
finger = SDL_GetFinger(touch,fingerid);
if (!finger) {
return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure);
return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure);
}
xrel = x - finger->x;
@ -306,7 +306,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
finger->x = x;
finger->y = y;
finger->pressure = pressure;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
@ -317,7 +317,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.dx = xrel;
event.tfinger.dy = yrel;
event.tfinger.dy = yrel;
event.tfinger.pressure = pressure;
posted = (SDL_PushEvent(&event) > 0);
}

View file

@ -38,17 +38,17 @@ extern int SDL_TouchInit(void);
/* Add a touch, returning the index of the touch, or -1 if there was an error. */
extern int SDL_AddTouch(SDL_TouchID id, const char *name);
/* Get the touch with a given id */
extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
/* Send a touch down/up event for a touch */
extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
SDL_bool down, float x, float y, float pressure);
extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
SDL_bool down, float x, float y, float pressure);
/* Send a touch motion event for a touch */
extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
float x, float y, float pressure);
float x, float y, float pressure);
/* Remove a touch */
extern void SDL_DelTouch(SDL_TouchID id);

View file

@ -155,7 +155,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
return 0;
}
window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
SDL_OnWindowLeave(window);
SDL_OnWindowLeave(window);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
@ -196,13 +196,13 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
posted = (SDL_PushEvent(&event) > 0);
}
if (windowevent == SDL_WINDOWEVENT_CLOSE) {
if ( !window->prev && !window->next ) {
// This is the last window in the list so send the SDL_QUIT event
SDL_SendQuit();
}
}
if (windowevent == SDL_WINDOWEVENT_CLOSE) {
if ( !window->prev && !window->next ) {
/* This is the last window in the list so send the SDL_QUIT event */
SDL_SendQuit();
}
}
return (posted);
}

View file

@ -19,13 +19,13 @@
3. This notice may not be removed or altered from any source distribution.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* A default blank 8x8 cursor */
#define BLANK_CWIDTH 8
#define BLANK_CHEIGHT 8
#define BLANK_CHOTX 0
#define BLANK_CHOTY 0
#define BLANK_CWIDTH 8
#define BLANK_CHEIGHT 8
#define BLANK_CHOTX 0
#define BLANK_CHOTY 0
static const unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
static const unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

View file

@ -19,13 +19,13 @@
3. This notice may not be removed or altered from any source distribution.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Default cursor - it happens to be the Mac cursor, but could be anything */
#define DEFAULT_CWIDTH 16
#define DEFAULT_CHEIGHT 16
#define DEFAULT_CHOTX 0
#define DEFAULT_CHOTY 0
#define DEFAULT_CWIDTH 16
#define DEFAULT_CHEIGHT 16
#define DEFAULT_CHOTX 0
#define DEFAULT_CHOTY 0
/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */
#define USE_MACOS_CURSOR