1 | 0 | Inverted color if possible, black
- if not. |
+ * if not.
*
*
* \sa SDL_FreeCursor()
@@ -159,14 +147,12 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
int hot_y);
/**
- * \brief Set the active cursor for the currently selected mouse.
- *
- * \note The cursor must have been created for the selected mouse.
+ * \brief Set the active cursor.
*/
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
/**
- * \brief Return the active cursor for the currently selected mouse.
+ * \brief Return the active cursor.
*/
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
@@ -178,8 +164,7 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
/**
- * \brief Toggle whether or not the cursor is shown for the currently selected
- * mouse.
+ * \brief Toggle whether or not the cursor is shown.
*
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
* state.
@@ -188,38 +173,6 @@ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
*/
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
-/**
- * \brief Gets the number of cursors a pointing device supports.
- *
- * Useful for tablet users. Useful only under Windows.
- *
- * \param index is the index of the pointing device, which number of cursors we
- * want to receive.
- *
- * \return the number of cursors supported by the pointing device. On Windows
- * if a device is a tablet it returns a number >=1. Normal mice always
- * return 1.
- *
- * On Linux every device reports one cursor.
- */
-extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index);
-
-/**
- * \brief Returns the index of the current cursor used by a specific pointing
- * device.
- *
- * Useful only under Windows.
- *
- * \param index is the index of the pointing device, which cursor index we want
- * to receive.
- *
- * \return the index of the cursor currently used by a specific pointing
- * device. Always 0 under Linux. On Windows if the device isn't a
- * tablet it returns 0. If the device is the tablet it returns the
- * cursor index. 0 - stylus, 1 - eraser, 2 - cursor.
- */
-extern DECLSPEC int SDLCALL SDL_GetCurrentCursor(int index);
-
/**
* Used as a mask when testing buttons in buttonstate.
* - Button 1: Left mouse button
diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h
index dcafbb7e2..e066f944b 100644
--- a/include/SDL_mutex.h
+++ b/include/SDL_mutex.h
@@ -194,7 +194,7 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
*
* \return 0 when it is signaled, or -1 on error.
*/
-extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mut);
+extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
/**
* Waits for at most \c ms milliseconds, and returns 0 if the condition
diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h
index 6934105aa..6024dcd0b 100644
--- a/include/SDL_pixels.h
+++ b/include/SDL_pixels.h
@@ -112,8 +112,7 @@ enum
SDL_PACKEDLAYOUT_1010102
};
-#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) \
- ((A) | ((B) << 8) | ((C) << 16) | ((D) << 24))
+#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index c7e7edd57..ba1e5b5b2 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -101,6 +101,13 @@
#endif
/*@}*//*Cast operators*/
+/* Define a four character code as a Uint32 */
+#define SDL_FOURCC(A, B, C, D) \
+ ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
+ (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
+ (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
+ (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
+
/**
* \name Basic data types
*/
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h
index 56ef7f6d2..4f7d00720 100644
--- a/include/SDL_syswm.h
+++ b/include/SDL_syswm.h
@@ -106,24 +106,6 @@ struct SDL_SysWMinfo
{
Display *display; /**< The X11 display */
Window window; /**< The X11 display window */
- /**
- * These locking functions should be called around
- * any X11 functions using the display variable.
- * They lock the event thread, so should not be
- * called around event functions or from event filters.
- */
- /*@{*/
- void (*lock_func) (void);
- void (*unlock_func) (void);
- /*@}*/
-
- /**
- * Introduced in SDL 1.0.2.
- */
- /*@{*/
- Window fswindow; /**< The X11 fullscreen window */
- Window wmwindow; /**< The X11 managed input window */
- /*@}*/
} x11;
} info;
};
diff --git a/include/SDL_thread.h b/include/SDL_thread.h
index fc3d36d75..cca172dee 100644
--- a/include/SDL_thread.h
+++ b/include/SDL_thread.h
@@ -149,16 +149,6 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
*/
extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status);
-/**
- * \deprecated This function is here for binary compatibility with legacy apps,
- * but in SDL 1.3 and later, it's a no-op.
- *
- * You cannot forcibly kill a thread in a safe manner on many platforms. You
- * should instead find a way to alert your thread that it is time to terminate,
- * and then have it gracefully exit on its own. Do not ever call this function!
- */
-extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread * thread);
-
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
diff --git a/include/SDL_video.h b/include/SDL_video.h
index a0db406cd..804869f69 100644
--- a/include/SDL_video.h
+++ b/include/SDL_video.h
@@ -88,7 +88,6 @@ typedef struct
* \sa SDL_SetWindowTitle()
* \sa SDL_ShowWindow()
*/
-struct SDL_Window;
typedef struct SDL_Window SDL_Window;
/**
diff --git a/src/SDL.c b/src/SDL.c
index 52f141578..49620a8e1 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -25,21 +25,15 @@
#include "SDL.h"
#include "SDL_fatal.h"
-#include "SDL_assert.h"
+#include "SDL_assert_c.h"
+#include "haptic/SDL_haptic_c.h"
+#include "joystick/SDL_joystick_c.h"
#if !SDL_VIDEO_DISABLED
#include "video/SDL_leaks.h"
#endif
/* Initialization/Cleanup routines */
-#if !SDL_JOYSTICK_DISABLED
-extern int SDL_JoystickInit(void);
-extern void SDL_JoystickQuit(void);
-#endif
-#if !SDL_HAPTIC_DISABLED
-extern int SDL_HapticInit(void);
-extern int SDL_HapticQuit(void);
-#endif
#if !SDL_TIMERS_DISABLED
extern void SDL_StartTicks(void);
extern int SDL_TimerInit(void);
@@ -50,8 +44,6 @@ extern int SDL_HelperWindowCreate(void);
extern int SDL_HelperWindowDestroy(void);
#endif
-extern int SDL_AssertionsInit(void);
-extern void SDL_AssertionsQuit(void);
/* The initialized subsystems */
static Uint32 SDL_initialized = 0;
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index 34cf45868..0c433d80a 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -22,6 +22,7 @@
#include "SDL.h"
#include "SDL_assert.h"
+#include "SDL_assert_c.h"
#include "video/SDL_sysvideo.h"
#ifdef _WINDOWS
diff --git a/src/SDL_assert_c.h b/src/SDL_assert_c.h
new file mode 100644
index 000000000..eb14cfbe0
--- /dev/null
+++ b/src/SDL_assert_c.h
@@ -0,0 +1,26 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2010 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+extern int SDL_AssertionsInit(void);
+extern void SDL_AssertionsQuit(void);
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/SDL_compat.c b/src/SDL_compat.c
index a985dc35f..bb8e46ba8 100644
--- a/src/SDL_compat.c
+++ b/src/SDL_compat.c
@@ -277,16 +277,13 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
case SDL_MOUSEWHEEL:
{
Uint8 button;
- int selected;
int x, y;
if (event->wheel.y == 0) {
break;
}
- selected = SDL_SelectMouse(event->wheel.which);
SDL_GetMouseState(&x, &y);
- SDL_SelectMouse(selected);
if (event->wheel.y > 0) {
button = SDL_BUTTON_WHEELUP;
@@ -294,7 +291,6 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
button = SDL_BUTTON_WHEELDOWN;
}
- fake.button.which = event->wheel.which;
fake.button.button = button;
fake.button.x = x;
fake.button.y = y;
@@ -421,7 +417,7 @@ SetupScreenSaver(int flags)
}
}
-int
+static int
SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
{
int w, h;
@@ -1754,7 +1750,6 @@ SDL_EnableUNICODE(int enable)
return previous;
}
-
int
SDL_putenv(const char *_var)
{
diff --git a/src/SDL_error.c b/src/SDL_error.c
index 894409d86..55d183a5d 100644
--- a/src/SDL_error.c
+++ b/src/SDL_error.c
@@ -116,7 +116,7 @@ SDL_SetError(const char *fmt, ...)
/* This function has a bit more overhead than most error functions
so that it supports internationalization and thread-safe errors.
*/
-char *
+static char *
SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
{
SDL_error *error;
diff --git a/src/SDL_error_c.h b/src/SDL_error_c.h
index bdb59517a..54501f5fa 100644
--- a/src/SDL_error_c.h
+++ b/src/SDL_error_c.h
@@ -58,4 +58,5 @@ typedef struct SDL_error
} SDL_error;
#endif /* _SDL_error_c_h */
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index fe2f3ff86..d115de7ee 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -257,7 +257,7 @@ finalize_audio_entry_points(void)
/* Streaming functions (for when the input and output buffer sizes are different) */
/* Write [length] bytes from buf into the streamer */
-void
+static void
SDL_StreamWrite(SDL_AudioStreamer * stream, Uint8 * buf, int length)
{
int i;
@@ -269,7 +269,7 @@ SDL_StreamWrite(SDL_AudioStreamer * stream, Uint8 * buf, int length)
}
/* Read [length] bytes out of the streamer into buf */
-void
+static void
SDL_StreamRead(SDL_AudioStreamer * stream, Uint8 * buf, int length)
{
int i;
@@ -280,14 +280,15 @@ SDL_StreamRead(SDL_AudioStreamer * stream, Uint8 * buf, int length)
}
}
-int
+static int
SDL_StreamLength(SDL_AudioStreamer * stream)
{
return (stream->write_pos - stream->read_pos) % stream->max_len;
}
/* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */
-int
+#if 0
+static int
SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
{
/* First try to allocate the buffer */
@@ -305,9 +306,10 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
return 0;
}
+#endif
/* Deinitialize the stream simply by freeing the buffer */
-void
+static void
SDL_StreamDeinit(SDL_AudioStreamer * stream)
{
if (stream->buffer != NULL) {
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index f631e4faf..7fa382818 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -335,7 +335,7 @@ SDL_GetCPUCount()
}
/* Oh, such a sweet sweet trick, just not very useful. :) */
-const char *
+static const char *
SDL_GetCPUType()
{
static char SDL_CPUType[48];
diff --git a/src/events/SDL_clipboardevents.c b/src/events/SDL_clipboardevents.c
new file mode 100644
index 000000000..2d5a2c48d
--- /dev/null
+++ b/src/events/SDL_clipboardevents.c
@@ -0,0 +1,47 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2010 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Clipboard event handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_clipboardevents_c.h"
+
+
+int
+SDL_SendClipboardUpdate(void)
+{
+ int posted;
+
+ /* Post the event, if desired */
+ posted = 0;
+ if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_CLIPBOARDUPDATE;
+
+ posted = (SDL_PushEvent(&event) > 0);
+ }
+ return (posted);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/events/SDL_clipboardevents_c.h b/src/events/SDL_clipboardevents_c.h
new file mode 100644
index 000000000..9e35a5aba
--- /dev/null
+++ b/src/events/SDL_clipboardevents_c.h
@@ -0,0 +1,31 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2010 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_clipboardevents_c_h
+#define _SDL_clipboardevents_c_h
+
+extern int SDL_SendClipboardUpdate(void);
+
+#endif /* _SDL_clipboardevents_c_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index e6a9ca0ef..a2687bd26 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -30,9 +30,19 @@
/* Global keyboard information */
-static int SDL_num_keyboards;
-static int SDL_current_keyboard;
-static SDL_Keyboard **SDL_keyboards;
+
+typedef struct SDL_Keyboard SDL_Keyboard;
+
+struct SDL_Keyboard
+{
+ /* Data common to all keyboards */
+ SDL_Window *focus;
+ Uint16 modstate;
+ Uint8 keystate[SDL_NUM_SCANCODES];
+ SDLKey keymap[SDL_NUM_SCANCODES];
+};
+
+static SDL_Keyboard SDL_keyboard;
static const SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = {
0, 0, 0, 0,
@@ -541,78 +551,22 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
int
SDL_KeyboardInit(void)
{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
+
+ /* Set the default keymap */
+ SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
return (0);
}
-SDL_Keyboard *
-SDL_GetKeyboard(int index)
-{
- if (index < 0 || index >= SDL_num_keyboards) {
- return NULL;
- }
- return SDL_keyboards[index];
-}
-
-int
-SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index)
-{
- SDL_Keyboard **keyboards;
-
- /* Add the keyboard to the list of keyboards */
- if (index < 0 || index >= SDL_num_keyboards || SDL_keyboards[index]) {
- keyboards =
- (SDL_Keyboard **) SDL_realloc(SDL_keyboards,
- (SDL_num_keyboards +
- 1) * sizeof(*keyboards));
- if (!keyboards) {
- SDL_OutOfMemory();
- return -1;
- }
-
- SDL_keyboards = keyboards;
- index = SDL_num_keyboards++;
- }
- SDL_keyboards[index] =
- (SDL_Keyboard *) SDL_malloc(sizeof(*SDL_keyboards[index]));
- if (!SDL_keyboards[index]) {
- SDL_OutOfMemory();
- return -1;
- }
- *SDL_keyboards[index] = *keyboard;
-
- return index;
-}
-
void
-SDL_DelKeyboard(int index)
+SDL_ResetKeyboard(void)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
-
- if (!keyboard) {
- return;
- }
-
- if (keyboard->FreeKeyboard) {
- keyboard->FreeKeyboard(keyboard);
- }
- SDL_free(keyboard);
-
- SDL_keyboards[index] = NULL;
-}
-
-void
-SDL_ResetKeyboard(int index)
-{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode;
- if (!keyboard) {
- return;
- }
-
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keystate[scancode] == SDL_PRESSED) {
- SDL_SendKeyboardKey(index, SDL_RELEASED, scancode);
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
}
}
}
@@ -624,13 +578,9 @@ SDL_GetDefaultKeymap(SDLKey * keymap)
}
void
-SDL_SetKeymap(int index, int start, SDLKey * keys, int length)
+SDL_SetKeymap(int start, SDLKey * keys, int length)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
-
- if (!keyboard) {
- return;
- }
+ SDL_Keyboard *keyboard = &SDL_keyboard;
if (start < 0 || start + length > SDL_NUM_SCANCODES) {
return;
@@ -645,33 +595,23 @@ SDL_SetScancodeName(SDL_scancode scancode, const char *name)
SDL_scancode_names[scancode] = name;
}
-void
-SDL_SetKeyboardFocus(int index, SDL_Window * window)
+SDL_Window *
+SDL_GetKeyboardFocus(void)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
- int i;
- SDL_bool focus;
+ SDL_Keyboard *keyboard = &SDL_keyboard;
- if (!keyboard) {
- return;
- }
+ return keyboard->focus;
+}
+
+void
+SDL_SetKeyboardFocus(SDL_Window * window)
+{
+ SDL_Keyboard *keyboard = &SDL_keyboard;
/* See if the current window has lost focus */
if (keyboard->focus && keyboard->focus != window) {
- focus = SDL_FALSE;
- for (i = 0; i < SDL_num_keyboards; ++i) {
- if (i != index) {
- SDL_Keyboard *check = SDL_GetKeyboard(i);
- if (check && check->focus == keyboard->focus) {
- focus = SDL_TRUE;
- break;
- }
- }
- }
- if (!focus) {
- SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
- 0, 0);
- }
+ SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
+ 0, 0);
}
keyboard->focus = window;
@@ -687,14 +627,14 @@ SDL_SetKeyboardFocus(int index, SDL_Window * window)
}
int
-SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
+SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
Uint16 modstate;
Uint32 type;
- if (!keyboard || !scancode) {
+ if (!scancode) {
return 0;
}
#if 0
@@ -807,7 +747,6 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.key.type = type;
- event.key.which = (Uint8) index;
event.key.state = state;
event.key.keysym.scancode = scancode;
event.key.keysym.sym = keyboard->keymap[scancode];
@@ -820,22 +759,17 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
}
int
-SDL_SendKeyboardText(int index, const char *text)
+SDL_SendKeyboardText(const char *text)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
- if (!keyboard) {
- return 0;
- }
-
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
SDL_Event event;
event.text.type = SDL_TEXTINPUT;
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
- event.text.which = (Uint8) index;
SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
@@ -844,22 +778,17 @@ SDL_SendKeyboardText(int index, const char *text)
}
int
-SDL_SendEditingText(int index, const char *text, int start, int length)
+SDL_SendEditingText(const char *text, int start, int length)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
- if (!keyboard) {
- return 0;
- }
-
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
SDL_Event event;
event.edit.type = SDL_TEXTEDITING;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
- event.text.which = (Uint8) index;
event.edit.start = start;
event.edit.length = length;
SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
@@ -871,93 +800,49 @@ SDL_SendEditingText(int index, const char *text, int start, int length)
void
SDL_KeyboardQuit(void)
{
- int i;
-
- for (i = 0; i < SDL_num_keyboards; ++i) {
- SDL_DelKeyboard(i);
- }
- SDL_num_keyboards = 0;
- SDL_current_keyboard = 0;
-
- if (SDL_keyboards) {
- SDL_free(SDL_keyboards);
- SDL_keyboards = NULL;
- }
-}
-
-int
-SDL_GetNumKeyboards(void)
-{
- return SDL_num_keyboards;
-}
-
-int
-SDL_SelectKeyboard(int index)
-{
- if (index >= 0 && index < SDL_num_keyboards) {
- SDL_current_keyboard = index;
- }
- return SDL_current_keyboard;
}
Uint8 *
SDL_GetKeyboardState(int *numkeys)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
if (numkeys != (int *) 0) {
*numkeys = SDL_NUM_SCANCODES;
}
-
- if (!keyboard) {
- return NULL;
- }
return keyboard->keystate;
}
SDLMod
SDL_GetModState(void)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
- if (!keyboard) {
- return KMOD_NONE;
- }
return keyboard->modstate;
}
void
SDL_SetModState(SDLMod modstate)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
- if (!keyboard) {
- return;
- }
keyboard->modstate = modstate;
}
SDLKey
SDL_GetKeyFromScancode(SDL_scancode scancode)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
- if (!keyboard) {
- return SDLK_UNKNOWN;
- }
return keyboard->keymap[scancode];
}
SDL_scancode
SDL_GetScancodeFromKey(SDLKey key)
{
- SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
+ SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode;
- if (!keyboard) {
- return SDL_SCANCODE_UNKNOWN;
- }
-
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
++scancode) {
if (keyboard->keymap[scancode] == key) {
diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h
index d4021ff35..1eeb9718c 100644
--- a/src/events/SDL_keyboard_c.h
+++ b/src/events/SDL_keyboard_c.h
@@ -27,44 +27,17 @@
#include "SDL_keysym.h"
#include "SDL_events.h"
-typedef struct SDL_Keyboard SDL_Keyboard;
-
-struct SDL_Keyboard
-{
- /* Free the keyboard when it's time */
- void (*FreeKeyboard) (SDL_Keyboard * keyboard);
-
- /* Data common to all keyboards */
- SDL_Window *focus;
- Uint16 modstate;
- Uint8 keystate[SDL_NUM_SCANCODES];
- SDLKey keymap[SDL_NUM_SCANCODES];
-
- void *driverdata;
-};
-
/* Initialize the keyboard subsystem */
extern int SDL_KeyboardInit(void);
-/* Get the keyboard at an index */
-extern SDL_Keyboard *SDL_GetKeyboard(int index);
-
-/* Add a keyboard, possibly reattaching at a particular index (or -1),
- returning the index of the keyboard, or -1 if there was an error.
- */
-extern int SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index);
-
-/* Remove a keyboard at an index, clearing the slot for later */
-extern void SDL_DelKeyboard(int index);
-
-/* Clear the state of a keyboard at an index */
-extern void SDL_ResetKeyboard(int index);
+/* Clear the state of the keyboard */
+extern void SDL_ResetKeyboard(void);
/* Get the default keymap */
extern void SDL_GetDefaultKeymap(SDLKey * keymap);
-/* Set the mapping of scancode to key codes for this keyboard */
-extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length);
+/* Set the mapping of scancode to key codes */
+extern void SDL_SetKeymap(int start, SDLKey * keys, int length);
/* 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
@@ -73,16 +46,16 @@ extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length);
extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
/* Set the keyboard focus window */
-extern void SDL_SetKeyboardFocus(int index, SDL_Window * window);
+extern void SDL_SetKeyboardFocus(SDL_Window * window);
-/* Send a keyboard event for a keyboard at an index */
-extern int SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode);
+/* Send a keyboard key event */
+extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
-/* Send keyboard text input for a keyboard at an index */
-extern int SDL_SendKeyboardText(int index, const char *text);
+/* Send keyboard text input */
+extern int SDL_SendKeyboardText(const char *text);
/* Send editing text for selected range from start to end */
-extern int SDL_SendEditingText(int index, const char *text, int start, int end);
+extern int SDL_SendEditingText(const char *text, int start, int end);
/* Shutdown the keyboard subsystem */
extern void SDL_KeyboardQuit(void);
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index c9e229654..87e47479b 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -29,9 +29,44 @@
#include "../video/SDL_sysvideo.h"
-static int SDL_num_mice = 0;
-static int SDL_current_mouse = -1;
-static SDL_Mouse **SDL_mice = NULL;
+/* Global mouse information */
+
+typedef struct SDL_Mouse SDL_Mouse;
+
+struct SDL_Mouse
+{
+ /* Create a cursor from a surface */
+ SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
+
+ /* Show the specified cursor, or hide if cursor is NULL */
+ int (*ShowCursor) (SDL_Cursor * cursor);
+
+ /* This is called when a mouse motion event occurs */
+ void (*MoveCursor) (SDL_Cursor * cursor);
+
+ /* Free a window manager cursor */
+ void (*FreeCursor) (SDL_Cursor * cursor);
+
+ /* Warp the mouse to (x,y) */
+ void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y);
+
+ /* Data common to all mice */
+ SDL_Window *focus;
+ int x;
+ int y;
+ int xdelta;
+ int ydelta;
+ int last_x, last_y; /* the last reported x and y coordinates */
+ Uint8 buttonstate;
+ SDL_bool relative_mode;
+
+ SDL_Cursor *cursors;
+ SDL_Cursor *def_cursor;
+ SDL_Cursor *cur_cursor;
+ SDL_bool cursor_shown;
+};
+
+static SDL_Mouse SDL_mouse;
/* Public functions */
@@ -41,368 +76,52 @@ SDL_MouseInit(void)
return (0);
}
-SDL_Mouse *
-SDL_GetMouse(int index)
-{
- if (index < 0 || index >= SDL_num_mice) {
- return NULL;
- }
- return SDL_mice[index];
-}
-
-static int
-SDL_GetMouseIndexId(int id)
-{
- int index;
- SDL_Mouse *mouse;
-
- for (index = 0; index < SDL_num_mice; ++index) {
- mouse = SDL_GetMouse(index);
- if (mouse->id == id) {
- return index;
- }
- }
- return -1;
-}
-
-int
-SDL_AddMouse(const SDL_Mouse * mouse, char *name, int pressure_max,
- int pressure_min, int ends)
-{
- SDL_Mouse **mice;
- int selected_mouse;
- int index;
- size_t length;
-
- if (SDL_GetMouseIndexId(mouse->id) != -1) {
- SDL_SetError("Mouse ID already in use");
- }
-
- /* Add the mouse to the list of mice */
- mice = (SDL_Mouse **) SDL_realloc(SDL_mice,
- (SDL_num_mice + 1) * sizeof(*mice));
- if (!mice) {
- SDL_OutOfMemory();
- return -1;
- }
-
- SDL_mice = mice;
- index = SDL_num_mice++;
-
- SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index]));
- if (!SDL_mice[index]) {
- SDL_OutOfMemory();
- return -1;
- }
- *SDL_mice[index] = *mouse;
-
- /* we're setting the mouse properties */
- length = 0;
- length = SDL_strlen(name);
- SDL_mice[index]->focus = 0;
- SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char));
- SDL_strlcpy(SDL_mice[index]->name, name, length + 1);
- SDL_mice[index]->pressure_max = pressure_max;
- SDL_mice[index]->pressure_min = pressure_min;
- SDL_mice[index]->cursor_shown = SDL_TRUE;
- selected_mouse = SDL_SelectMouse(index);
- SDL_mice[index]->cur_cursor = NULL;
- SDL_mice[index]->def_cursor =
- SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH,
- DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
- SDL_SetCursor(SDL_mice[index]->def_cursor);
- /* we're assuming that all mice are in the computer sensing zone */
- SDL_mice[index]->proximity = SDL_TRUE;
- /* we're assuming that all mice are working in the absolute position mode
- thanx to that, the users that don't want to use many mice don't have to
- worry about anything */
- SDL_mice[index]->relative_mode = SDL_FALSE;
- SDL_mice[index]->current_end = 0;
- SDL_mice[index]->total_ends = ends;
- SDL_SelectMouse(selected_mouse);
-
- return index;
-}
-
void
-SDL_DelMouse(int index)
+SDL_ResetMouse(void)
{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- return;
- }
-
- mouse->def_cursor = NULL;
- SDL_free(mouse->name);
- while (mouse->cursors) {
- SDL_FreeCursor(mouse->cursors);
- }
-
- if (mouse->FreeMouse) {
- mouse->FreeMouse(mouse);
- }
- SDL_free(mouse);
-
- SDL_mice[index] = NULL;
-}
-
-void
-SDL_ResetMouse(int index)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- return;
- }
-
/* FIXME */
}
-void
-SDL_MouseQuit(void)
-{
- int i;
-
- for (i = 0; i < SDL_num_mice; ++i) {
- SDL_DelMouse(i);
- }
- SDL_num_mice = 0;
- SDL_current_mouse = -1;
-
- if (SDL_mice) {
- SDL_free(SDL_mice);
- SDL_mice = NULL;
- }
-}
-
-int
-SDL_GetNumMice(void)
-{
- return SDL_num_mice;
-}
-
-int
-SDL_SelectMouse(int index)
-{
- if (index >= 0 && index < SDL_num_mice) {
- SDL_current_mouse = index;
- }
- return SDL_current_mouse;
-}
-
SDL_Window *
-SDL_GetMouseFocusWindow(int index)
+SDL_GetMouseFocus(void)
{
- SDL_Mouse *mouse = SDL_GetMouse(index);
+ SDL_Mouse *mouse = &SDL_mouse;
- if (!mouse) {
- return 0;
- }
return mouse->focus;
}
-static int SDLCALL
-FlushMouseMotion(void *param, SDL_Event * event)
-{
- if (event->type == SDL_MOUSEMOTION
- && event->motion.which == (Uint8) SDL_current_mouse) {
- return 0;
- } else {
- return 1;
- }
-}
-
-int
-SDL_SetRelativeMouseMode(int index, SDL_bool enabled)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- return -1;
- }
-
- /* Flush pending mouse motion */
- mouse->flush_motion = SDL_TRUE;
- SDL_PumpEvents();
- mouse->flush_motion = SDL_FALSE;
- SDL_FilterEvents(FlushMouseMotion, mouse);
-
- /* Set the relative mode */
- mouse->relative_mode = enabled;
-
- /* Update cursor visibility */
- SDL_SetCursor(NULL);
-
- if (!enabled) {
- /* Restore the expected mouse position */
- SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
- }
- return 0;
-}
-
-SDL_bool
-SDL_GetRelativeMouseMode(int index)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- return SDL_FALSE;
- }
- return mouse->relative_mode;
-}
-
-Uint8
-SDL_GetMouseState(int *x, int *y)
-{
- SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
-
- if (!mouse) {
- if (x) {
- *x = 0;
- }
- if (y) {
- *y = 0;
- }
- return 0;
- }
-
- if (x) {
- *x = mouse->x;
- }
- if (y) {
- *y = mouse->y;
- }
- return mouse->buttonstate;
-}
-
-Uint8
-SDL_GetRelativeMouseState(int index, int *x, int *y)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- if (x) {
- *x = 0;
- }
- if (y) {
- *y = 0;
- }
- return 0;
- }
-
- if (x) {
- *x = mouse->xdelta;
- }
- if (y) {
- *y = mouse->ydelta;
- }
- mouse->xdelta = 0;
- mouse->ydelta = 0;
- return mouse->buttonstate;
-}
-
void
-SDL_SetMouseFocus(int id, SDL_Window * window)
+SDL_SetMouseFocus(SDL_Window * window)
{
- int index = SDL_GetMouseIndexId(id);
- SDL_Mouse *mouse = SDL_GetMouse(index);
- int i;
- SDL_bool focus;
+ SDL_Mouse *mouse = &SDL_mouse;
- if (!mouse || (mouse->focus == window)) {
+ if (mouse->focus == window) {
return;
}
/* See if the current window has lost focus */
if (mouse->focus) {
- focus = SDL_FALSE;
- for (i = 0; i < SDL_num_mice; ++i) {
- SDL_Mouse *check;
- if (i != index) {
- check = SDL_GetMouse(i);
- if (check && check->focus == mouse->focus) {
- focus = SDL_TRUE;
- break;
- }
- }
- }
- if (!focus) {
- SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
- }
+ SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
}
mouse->focus = window;
if (mouse->focus) {
- focus = SDL_FALSE;
- for (i = 0; i < SDL_num_mice; ++i) {
- SDL_Mouse *check;
- if (i != index) {
- check = SDL_GetMouse(i);
- if (check && check->focus == mouse->focus) {
- focus = SDL_TRUE;
- break;
- }
- }
- }
- if (!focus) {
- SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
- }
+ SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
}
}
int
-SDL_SendProximity(int id, int x, int y, int type)
+SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
{
- int index = SDL_GetMouseIndexId(id);
- SDL_Mouse *mouse = SDL_GetMouse(index);
- int posted = 0;
-
- if (!mouse) {
- return 0;
- }
-
- mouse->last_x = x;
- mouse->last_y = y;
- if (SDL_GetEventState(type) == SDL_ENABLE) {
- SDL_Event event;
- event.proximity.which = (Uint8) index;
- event.proximity.x = x;
- event.proximity.y = y;
- event.proximity.cursor = mouse->current_end;
- event.proximity.type = type;
- /* FIXME: is this right? */
- event.proximity.windowID = mouse->focus ? mouse->focus->id : 0;
- posted = (SDL_PushEvent(&event) > 0);
- if (type == SDL_PROXIMITYIN) {
- mouse->proximity = SDL_TRUE;
- } else {
- mouse->proximity = SDL_FALSE;
- }
- }
- return posted;
-}
-
-int
-SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
-{
- int index = SDL_GetMouseIndexId(id);
- SDL_Mouse *mouse = SDL_GetMouse(index);
+ SDL_Mouse *mouse = &SDL_mouse;
int posted;
int xrel;
int yrel;
int x_max = 0, y_max = 0;
- if (!mouse || mouse->flush_motion) {
- return 0;
- }
-
- /* if the mouse is out of proximity we don't to want to have any motion from it */
- if (mouse->proximity == SDL_FALSE) {
- mouse->last_x = x;
- mouse->last_y = y;
- return 0;
+ if (window) {
+ SDL_SetMouseFocus(window);
}
/* the relative motion is calculated regarding the system cursor last position */
@@ -451,35 +170,26 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
mouse->xdelta += xrel;
mouse->ydelta += yrel;
- mouse->pressure = pressure;
+#if 0 /* FIXME */
/* Move the mouse cursor, if needed */
if (mouse->cursor_shown && !mouse->relative_mode &&
mouse->MoveCursor && mouse->cur_cursor) {
mouse->MoveCursor(mouse->cur_cursor);
}
+#endif
/* Post the event, if desired */
posted = 0;
- if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE &&
- mouse->proximity == SDL_TRUE) {
+ if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
SDL_Event event;
event.motion.type = SDL_MOUSEMOTION;
- event.motion.which = (Uint8) index;
+ event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
event.motion.state = mouse->buttonstate;
event.motion.x = mouse->x;
event.motion.y = mouse->y;
- event.motion.z = mouse->z;
- event.motion.pressure = mouse->pressure;
- event.motion.pressure_max = mouse->pressure_max;
- event.motion.pressure_min = mouse->pressure_min;
- event.motion.rotation = 0;
- event.motion.tilt_x = 0;
- event.motion.tilt_y = 0;
- event.motion.cursor = mouse->current_end;
event.motion.xrel = xrel;
event.motion.yrel = yrel;
- event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
mouse->last_x = mouse->x;
@@ -488,15 +198,14 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
}
int
-SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
+SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
{
- int index = SDL_GetMouseIndexId(id);
- SDL_Mouse *mouse = SDL_GetMouse(index);
+ SDL_Mouse *mouse = &SDL_mouse;
int posted;
Uint32 type;
- if (!mouse) {
- return 0;
+ if (window) {
+ SDL_SetMouseFocus(window);
}
/* Figure out which event to perform */
@@ -527,7 +236,6 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.type = type;
- event.button.which = (Uint8) index;
event.button.state = state;
event.button.button = button;
event.button.x = mouse->x;
@@ -539,12 +247,16 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
}
int
-SDL_SendMouseWheel(int index, int x, int y)
+SDL_SendMouseWheel(SDL_Window * window, int x, int y)
{
- SDL_Mouse *mouse = SDL_GetMouse(index);
+ SDL_Mouse *mouse = &SDL_mouse;
int posted;
- if (!mouse || (!x && !y)) {
+ if (window) {
+ SDL_SetMouseFocus(window);
+ }
+
+ if (!x && !y) {
return 0;
}
@@ -553,53 +265,107 @@ SDL_SendMouseWheel(int index, int x, int y)
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_MOUSEWHEEL;
- event.wheel.which = (Uint8) index;
+ event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
event.wheel.x = x;
event.wheel.y = y;
- event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
+void
+SDL_MouseQuit(void)
+{
+}
+
+Uint8
+SDL_GetMouseState(int *x, int *y)
+{
+ SDL_Mouse *mouse = &SDL_mouse;
+
+ if (x) {
+ *x = mouse->x;
+ }
+ if (y) {
+ *y = mouse->y;
+ }
+ return mouse->buttonstate;
+}
+
+Uint8
+SDL_GetRelativeMouseState(int *x, int *y)
+{
+ SDL_Mouse *mouse = &SDL_mouse;
+
+ if (x) {
+ *x = mouse->xdelta;
+ }
+ if (y) {
+ *y = mouse->ydelta;
+ }
+ mouse->xdelta = 0;
+ mouse->ydelta = 0;
+ return mouse->buttonstate;
+}
+
void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
- SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
-
- if (!mouse) {
- return;
- }
+ SDL_Mouse *mouse = &SDL_mouse;
if (mouse->WarpMouse) {
mouse->WarpMouse(mouse, window, x, y);
} else {
- SDL_SetMouseFocus(SDL_current_mouse, window);
- SDL_SendMouseMotion(SDL_current_mouse, 0, x, y, 0);
+ SDL_SendMouseMotion(window, 0, x, y);
}
}
+int
+SDL_SetRelativeMouseMode(SDL_bool enabled)
+{
+ SDL_Mouse *mouse = &SDL_mouse;
+
+ /* Flush pending mouse motion */
+ SDL_FlushEvent(SDL_MOUSEMOTION);
+
+ /* Set the relative mode */
+ mouse->relative_mode = enabled;
+
+ if (!enabled) {
+ /* Restore the expected mouse position */
+ SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
+ }
+
+ /* Update cursor visibility */
+ SDL_SetCursor(NULL);
+
+ return 0;
+}
+
+SDL_bool
+SDL_GetRelativeMouseMode()
+{
+ SDL_Mouse *mouse = &SDL_mouse;
+
+ return mouse->relative_mode;
+}
+
SDL_Cursor *
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
int w, int h, int hot_x, int hot_y)
{
- SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
+ SDL_Mouse *mouse = &SDL_mouse;
SDL_Surface *surface;
SDL_Cursor *cursor;
int x, y;
Uint32 *pixel;
- Uint8 datab, maskb;
+ Uint8 datab = 0, maskb = 0;
const Uint32 black = 0xFF000000;
const Uint32 white = 0xFFFFFFFF;
const Uint32 transparent = 0x00000000;
- if (!mouse) {
- SDL_SetError("No mice are initialized");
- return NULL;
- }
-
if (!mouse->CreateCursor) {
- SDL_SetError("Current mouse doesn't have cursor support");
+ SDL_SetError("Cursors are not currently supported");
return NULL;
}
@@ -638,7 +404,6 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
if (cursor) {
- cursor->mouse = mouse;
cursor->next = mouse->cursors;
mouse->cursors = cursor;
}
@@ -655,12 +420,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
void
SDL_SetCursor(SDL_Cursor * cursor)
{
- SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
-
- if (!mouse) {
- SDL_SetError("No mice are initialized");
- return;
- }
+ SDL_Mouse *mouse = &SDL_mouse;
/* Set the new cursor */
if (cursor) {
@@ -694,7 +454,7 @@ SDL_SetCursor(SDL_Cursor * cursor)
SDL_Cursor *
SDL_GetCursor(void)
{
- SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
+ SDL_Mouse *mouse = &SDL_mouse;
if (!mouse) {
return NULL;
@@ -705,13 +465,12 @@ SDL_GetCursor(void)
void
SDL_FreeCursor(SDL_Cursor * cursor)
{
- SDL_Mouse *mouse;
+ SDL_Mouse *mouse = &SDL_mouse;
SDL_Cursor *curr, *prev;
if (!cursor) {
return;
}
- mouse = cursor->mouse;
if (cursor == mouse->def_cursor) {
return;
@@ -740,7 +499,7 @@ SDL_FreeCursor(SDL_Cursor * cursor)
int
SDL_ShowCursor(int toggle)
{
- SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
+ SDL_Mouse *mouse = &SDL_mouse;
SDL_bool shown;
if (!mouse) {
@@ -761,47 +520,4 @@ SDL_ShowCursor(int toggle)
return shown;
}
-char *
-SDL_GetMouseName(int index)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
- if (!mouse) {
- return NULL;
- }
- return mouse->name;
-}
-
-void
-SDL_ChangeEnd(int id, int end)
-{
- int index = SDL_GetMouseIndexId(id);
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (mouse) {
- mouse->current_end = end;
- }
-}
-
-int
-SDL_GetCursorsNumber(int index)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- return -1;
- }
- return mouse->total_ends;
-}
-
-int
-SDL_GetCurrentCursor(int index)
-{
- SDL_Mouse *mouse = SDL_GetMouse(index);
-
- if (!mouse) {
- return -1;
- }
- return mouse->current_end;
-}
-
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index 7ed0cf7b6..0f0f6de54 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -24,108 +24,33 @@
#ifndef _SDL_mouse_c_h
#define _SDL_mouse_c_h
-typedef struct SDL_Mouse SDL_Mouse;
-
struct SDL_Cursor
{
- SDL_Mouse *mouse;
SDL_Cursor *next;
void *driverdata;
};
-struct SDL_Mouse
-{
- /* Create a cursor from a surface */
- SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
-
- /* Show the specified cursor, or hide if cursor is NULL */
- int (*ShowCursor) (SDL_Cursor * cursor);
-
- /* This is called when a mouse motion event occurs */
- void (*MoveCursor) (SDL_Cursor * cursor);
-
- /* Free a window manager cursor */
- void (*FreeCursor) (SDL_Cursor * cursor);
-
- /* Warp the mouse to (x,y) */
- void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x,
- int y);
-
- /* Free the mouse when it's time */
- void (*FreeMouse) (SDL_Mouse * mouse);
-
- /* data common for tablets */
- int pressure;
- int pressure_max;
- int pressure_min;
- int tilt; /* for future use */
- int rotation; /* for future use */
- int total_ends;
- int current_end;
-
- /* Data common to all mice */
- int id;
- SDL_Window *focus;
- int which;
- int x;
- int y;
- int z; /* for future use */
- int xdelta;
- int ydelta;
- int last_x, last_y; /* the last reported x and y coordinates */
- char *name;
- Uint8 buttonstate;
- SDL_bool relative_mode;
- SDL_bool proximity;
- SDL_bool flush_motion;
-
- SDL_Cursor *cursors;
- SDL_Cursor *def_cursor;
- SDL_Cursor *cur_cursor;
- SDL_bool cursor_shown;
-
- void *driverdata;
-};
-
/* Initialize the mouse subsystem */
extern int SDL_MouseInit(void);
-/* Get the mouse at an index */
-extern SDL_Mouse *SDL_GetMouse(int index);
-
-/* Add a mouse, possibly reattaching at a particular index (or -1),
- returning the index of the mouse, or -1 if there was an error.
- */
-extern int SDL_AddMouse(const SDL_Mouse * mouse, char *name,
- int pressure_max, int pressure_min, int ends);
-
-/* Remove a mouse at an index, clearing the slot for later */
-extern void SDL_DelMouse(int index);
-
-/* Clear the button state of a mouse at an index */
-extern void SDL_ResetMouse(int index);
+/* Clear the mouse state */
+extern void SDL_ResetMouse(void);
/* Set the mouse focus window */
-extern void SDL_SetMouseFocus(int id, SDL_Window * window);
+extern void SDL_SetMouseFocus(SDL_Window * window);
-/* Send a mouse motion event for a mouse */
-extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z);
+/* Send a mouse motion event */
+extern int SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y);
-/* Send a mouse button event for a mouse */
-extern int SDL_SendMouseButton(int id, Uint8 state, Uint8 button);
+/* Send a mouse button event */
+extern int SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button);
-/* Send a mouse wheel event for a mouse */
-extern int SDL_SendMouseWheel(int id, int x, int y);
-
-/* Send a proximity event for a mouse */
-extern int SDL_SendProximity(int id, int x, int y, int type);
+/* Send a mouse wheel event */
+extern int SDL_SendMouseWheel(SDL_Window * window, int x, int y);
/* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void);
-/* FIXME: Where do these functions go in this header? */
-extern void SDL_ChangeEnd(int id, int end);
-
#endif /* _SDL_mouse_c_h */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.m b/src/file/cocoa/SDL_rwopsbundlesupport.m
index d9ce0210a..39b4c0e9c 100644
--- a/src/file/cocoa/SDL_rwopsbundlesupport.m
+++ b/src/file/cocoa/SDL_rwopsbundlesupport.m
@@ -1,6 +1,8 @@
#ifdef __APPLE__
#import