From 54753025c9e23b920021e97f1c22d3e1f087a4fc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 9 May 2010 20:47:22 -0700 Subject: [PATCH] Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API. Plus, this lets me start implementing cursor support. --- Makefile.in | 2 +- include/SDL_events.h | 50 +- include/SDL_input.h | 88 +++ include/SDL_keyboard.h | 28 +- include/SDL_mouse.h | 149 ++--- include/SDL_video.h | 1 - src/SDL_compat.c | 4 - src/events/SDL_keyboard.c | 203 ++----- src/events/SDL_keyboard_c.h | 47 +- src/events/SDL_mouse.c | 549 ++++-------------- src/events/SDL_mouse_c.h | 93 +-- src/video/cocoa/SDL_cocoakeyboard.m | 96 ++- src/video/cocoa/SDL_cocoamouse.m | 36 +- src/video/cocoa/SDL_cocoavideo.h | 2 - src/video/cocoa/SDL_cocoawindow.m | 54 +- src/video/uikit/SDL_uikitview.h | 4 +- src/video/uikit/SDL_uikitview.m | 10 +- src/video/win32/SDL_win32events.c | 177 +----- src/video/win32/SDL_win32keyboard.c | 12 +- src/video/win32/SDL_win32keyboard.h | 2 +- src/video/win32/SDL_win32modes.c | 1 - src/video/win32/SDL_win32mouse.c | 168 ------ src/video/win32/SDL_win32video.c | 40 +- src/video/win32/SDL_win32video.h | 15 - src/video/win32/SDL_win32window.c | 56 +- src/video/win32/wactab/pktdef.h | 237 -------- src/video/win32/wactab/wintab.h | 866 ---------------------------- src/video/win32/wactab/wintabx.h | 136 ----- src/video/x11/SDL_x11events.c | 118 +--- src/video/x11/SDL_x11keyboard.c | 8 +- src/video/x11/SDL_x11mouse.c | 125 ---- src/video/x11/SDL_x11video.h | 1 - src/video/x11/SDL_x11window.c | 42 +- test/common.c | 33 +- test/testime.c | 7 +- test/testintersections.c | 20 +- 36 files changed, 504 insertions(+), 2976 deletions(-) create mode 100644 include/SDL_input.h delete mode 100644 src/video/win32/wactab/pktdef.h delete mode 100644 src/video/win32/wactab/wintab.h delete mode 100644 src/video/win32/wactab/wintabx.h diff --git a/Makefile.in b/Makefile.in index bbcae1177..87df4de3d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,7 +44,7 @@ EMBEDSPU = @EMBEDSPU@ DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS include INSTALL Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-Win32.zip WhatsNew Xcode Xcode-iPhoneOS -HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h +HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_input.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ diff --git a/include/SDL_events.h b/include/SDL_events.h index fbdc46c94..91bdd8624 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -75,9 +75,13 @@ typedef enum SDL_MOUSEBUTTONUP, /**< Mouse button released */ SDL_MOUSEWHEEL, /**< Mouse wheel motion */ - /* Tablet events */ - SDL_PROXIMITYIN = 0x500, /**< Proximity In event */ - SDL_PROXIMITYOUT, /**< Proximity Out event */ + /* Tablet or multiple mice input device events */ + SDL_INPUTMOTION = 0x500, /**< Input moved */ + SDL_INPUTBUTTONDOWN, /**< Input button pressed */ + SDL_INPUTBUTTONUP, /**< Input button released */ + SDL_INPUTWHEEL, /**< Input wheel motion */ + SDL_INPUTPROXIMITYIN, /**< Input pen entered proximity */ + SDL_INPUTPROXIMITYOUT, /**< Input pen left proximity */ /* Joystick events */ SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ @@ -124,10 +128,10 @@ typedef struct SDL_KeyboardEvent { Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ Uint32 windowID; /**< The window with keyboard focus, if any */ - Uint8 which; /**< The keyboard device index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 padding1; Uint8 padding2; + Uint8 padding3; SDL_keysym keysym; /**< The key that was pressed or released */ } SDL_KeyboardEvent; @@ -139,7 +143,6 @@ typedef struct SDL_TextEditingEvent { Uint32 type; /**< ::SDL_TEXTEDITING */ Uint32 windowID; /**< The window with keyboard focus, if any */ - Uint8 which; /**< The keyboard device index */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ int start; /**< The start cursor of selected editing text */ int length; /**< The length of selected editing text */ @@ -154,10 +157,6 @@ typedef struct SDL_TextInputEvent { Uint32 type; /**< ::SDL_TEXTINPUT */ Uint32 windowID; /**< The window with keyboard focus, if any */ - Uint8 which; /**< The keyboard device index */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ } SDL_TextInputEvent; @@ -168,20 +167,12 @@ typedef struct SDL_MouseMotionEvent { Uint32 type; /**< ::SDL_MOUSEMOTION */ Uint32 windowID; /**< The window with mouse focus, if any */ - Uint8 which; /**< The mouse device index */ Uint8 state; /**< The current button state */ Uint8 padding1; Uint8 padding2; + Uint8 padding3; int x; /**< X coordinate, relative to window */ int y; /**< Y coordinate, relative to window */ - int z; /**< Z coordinate, for future use */ - int pressure; /**< Pressure reported by tablets */ - int pressure_max; /**< Maximum value of the pressure reported by the device */ - int pressure_min; /**< Minimum value of the pressure reported by the device */ - int rotation; /**< For future use */ - int tilt_x; /**< For future use */ - int tilt_y; /**< For future use */ - int cursor; /**< The cursor being used in the event */ int xrel; /**< The relative motion in the X direction */ int yrel; /**< The relative motion in the Y direction */ } SDL_MouseMotionEvent; @@ -193,10 +184,10 @@ typedef struct SDL_MouseButtonEvent { Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ Uint32 windowID; /**< The window with mouse focus, if any */ - Uint8 which; /**< The mouse device index */ Uint8 button; /**< The mouse button index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 padding1; + Uint8 padding2; int x; /**< X coordinate, relative to window */ int y; /**< Y coordinate, relative to window */ } SDL_MouseButtonEvent; @@ -208,30 +199,10 @@ typedef struct SDL_MouseWheelEvent { Uint32 type; /**< ::SDL_MOUSEWHEEL */ Uint32 windowID; /**< The window with mouse focus, if any */ - Uint8 which; /**< The mouse device index */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; int x; /**< The amount scrolled horizontally */ int y; /**< The amount scrolled vertically */ } SDL_MouseWheelEvent; -/** - * \brief Tablet pen proximity event - */ -typedef struct SDL_ProximityEvent -{ - Uint32 type; /**< ::SDL_PROXIMITYIN or ::SDL_PROXIMITYOUT */ - Uint32 windowID; /**< The associated window */ - Uint8 which; - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - int cursor; - int x; - int y; -} SDL_ProximityEvent; - /** * \brief Joystick axis motion event structure (event.jaxis.*) */ @@ -371,7 +342,6 @@ typedef union SDL_Event SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */ - SDL_ProximityEvent proximity; /**< Proximity In or Out event */ /** Temporarily here for backwards compatibility */ /*@{*/ diff --git a/include/SDL_input.h b/include/SDL_input.h new file mode 100644 index 000000000..455138f1b --- /dev/null +++ b/include/SDL_input.h @@ -0,0 +1,88 @@ +/* + 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 +*/ + +/** + * \file SDL_input.h + * + * Include file for lowlevel SDL input device handling. + * + * This talks about individual devices, and not the system cursor. If you + * just want to know when the user moves the pointer somewhere in your + * window, this is NOT the API you want. This one handles things like + * multi-touch, drawing tablets, and multiple, separate mice. + * + * The other API is in SDL_mouse.h + */ + +#ifndef _SDL_input_h +#define _SDL_input_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + + +/* Function prototypes */ + +/* !!! FIXME: real documentation + * - Redetect devices + * - This invalidates all existing device information from previous queries! + * - There is an implicit (re)detect upon SDL_Init(). + */ +extern DECLSPEC int SDLCALL SDL_RedetectInputDevices(void); + +/** + * \brief Get the number of mouse input devices available. + */ +extern DECLSPEC int SDLCALL SDL_GetNumInputDevices(void); + +/** + * \brief Gets the name of a device with the given index. + * + * \param index is the index of the device, whose name is to be returned. + * + * \return the name of the device with the specified index + */ +extern DECLSPEC const char *SDLCALL SDL_GetInputDeviceName(int index); + + +extern DECLSPEC int SDLCALL SDL_IsDeviceDisconnected(int index); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h index 4c013ba2c..4482ac028 100644 --- a/include/SDL_keyboard.h +++ b/include/SDL_keyboard.h @@ -32,6 +32,7 @@ #include "SDL_stdinc.h" #include "SDL_error.h" #include "SDL_keysym.h" +#include "SDL_video.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -55,25 +56,12 @@ typedef struct SDL_keysym /* Function prototypes */ /** - * \brief Get the number of keyboard input devices available. - * - * \sa SDL_SelectKeyboard() - */ -extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void); - -/** - * \brief Set the index of the currently selected keyboard. - * - * \return The index of the previously selected keyboard. - * - * \note You can query the currently selected keyboard by passing an index of -1. - * - * \sa SDL_GetNumKeyboards() + * \brief Get the window which currently has keyboard focus. */ -extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index); +extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); /** - * \brief Get a snapshot of the current state of the selected keyboard. + * \brief Get a snapshot of the current state of the keyboard. * * \param numkeys if non-NULL, receives the length of the returned array. * @@ -90,20 +78,20 @@ extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index); extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); /** - * \brief Get the current key modifier state for the selected keyboard. + * \brief Get the current key modifier state for the keyboard. */ extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); /** - * \brief Set the current key modifier state for the selected keyboard. + * \brief Set the current key modifier state for the keyboard. * * \note This does not change the keyboard state, only the key modifier flags. */ extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); /** - * \brief Get the key code corresponding to the given scancode according to the - * current keyboard layout. + * \brief Get the key code corresponding to the given scancode according + * to the current keyboard layout. * * See ::SDLKey for details. * diff --git a/include/SDL_mouse.h b/include/SDL_mouse.h index a52ad8836..cb3cd9ccf 100644 --- a/include/SDL_mouse.h +++ b/include/SDL_mouse.h @@ -24,6 +24,22 @@ * \file SDL_mouse.h * * Include file for SDL mouse event handling. + * + * Please note that this ONLY discusses "mice" with the notion of the + * desktop GUI. You (usually) have one system cursor, and the OS hides + * the hardware details from you. If you plug in 10 mice, all ten move that + * one cursor. For many applications and games, this is perfect, and this + * API has served hundreds of SDL programs well since its birth. + * + * It's not the whole picture, though. If you want more lowlevel control, + * SDL offers a different API, that gives you visibility into each input + * device, multi-touch interfaces, etc. + * + * Those two APIs are incompatible, and you usually should not use both + * at the same time. But for legacy purposes, this API refers to a "mouse" + * when it actually means the system pointer and not a physical mouse. + * + * The other API is in SDL_input.h */ #ifndef _SDL_mouse_h @@ -43,45 +59,50 @@ extern "C" { typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ + /* Function prototypes */ /** - * \brief Get the number of mouse input devices available. - * - * \sa SDL_SelectMouse() + * \brief Get the window which currently has mouse focus. */ -extern DECLSPEC int SDLCALL SDL_GetNumMice(void); +extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); /** - * \brief Gets the name of a mouse with the given index. - * - * \param index is the index of the mouse, which name is to be returned. + * \brief Retrieve the current state of the mouse. * - * \return the name of the mouse with the specified index + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse cursor position relative to the focus window for the currently + * selected mouse. You can pass NULL for either x or y. */ -extern DECLSPEC char *SDLCALL SDL_GetMouseName(int index); +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); /** - * \brief Set the index of the currently selected mouse. - * - * \return The index of the previously selected mouse. - * - * \note You can query the currently selected mouse by passing an index of -1. - * - * \sa SDL_GetNumMice() + * \brief Retrieve the relative state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). */ -extern DECLSPEC int SDLCALL SDL_SelectMouse(int index); +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); /** - * \brief Get the window which currently has focus for the specified mouse. + * \brief Moves the mouse to the given position within the window. + * + * \param window The window to move the mouse into, or NULL for the current mouse focus + * \param x The x coordinate within the window + * \param y The y coordinate within the window + * + * \note This function generates a mouse motion event */ -extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocusWindow(int index); +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, + int x, int y); /** - * \brief Set relative mouse mode for the specified mouse. + * \brief Set relative mouse mode. * * \param enabled Whether or not to enable relative mode - * + * * \return 0 on success, or -1 if relative mode is not supported. * * While the mouse is in relative mode, the cursor is hidden, and the @@ -93,51 +114,18 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocusWindow(int index); * * \sa SDL_GetRelativeMouseMode() */ -extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(int index, - SDL_bool enabled); +extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); /** - * \brief Query whether relative mouse mode is enabled for the specified mouse. + * \brief Query whether relative mouse mode is enabled. * * \sa SDL_SetRelativeMouseMode() */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(int index); - -/** - * \brief Retrieve the current state of the specified mouse. - * - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse cursor position relative to the focus window for the currently - * selected mouse. You can pass NULL for either x or y. - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); - -/** - * \brief Retrieve the state of the specified mouse. - * - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse deltas since the last call to SDL_GetRelativeMouseState(). - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int index, int *x, - int *y); +extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); /** - * \brief Moves the currently selected mouse to the given position within the window. - * - * \param window The window to move the mouse into, or NULL for the current mouse focus - * \param x The x coordinate within the window - * \param y The y coordinate within the window - * - * \note This function generates a mouse motion event - */ -extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, - int x, int y); - -/** - * \brief Create a cursor for the currently selected mouse, using the - * specified bitmap data and mask (in MSB format). + * \brief Create a cursor, using the specified bitmap data and + * mask (in MSB format). * * The cursor width must be a multiple of 8 bits. * @@ -148,7 +136,7 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, * 1 1 Black * 0 0 Transparent * 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_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_compat.c b/src/SDL_compat.c index a985dc35f..0c094e8a7 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; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index e6a9ca0ef..f25bc6af8 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, @@ -544,75 +554,15 @@ SDL_KeyboardInit(void) 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_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_ResetKeyboard(void) { - 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 +574,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 +591,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 +623,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 +743,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 +755,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 +774,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 +796,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..e8a9ccd75 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -29,382 +29,97 @@ #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; -/* Public functions */ -int -SDL_MouseInit(void) +struct SDL_Mouse { - return (0); -} + /* Create a cursor from a surface */ + SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y); -SDL_Mouse * -SDL_GetMouse(int index) -{ - if (index < 0 || index >= SDL_num_mice) { - return NULL; - } - return SDL_mice[index]; -} + /* Show the specified cursor, or hide if cursor is NULL */ + int (*ShowCursor) (SDL_Cursor * cursor); -static int -SDL_GetMouseIndexId(int id) -{ - int index; - SDL_Mouse *mouse; + /* This is called when a mouse motion event occurs */ + void (*MoveCursor) (SDL_Cursor * cursor); - for (index = 0; index < SDL_num_mice; ++index) { - mouse = SDL_GetMouse(index); - if (mouse->id == id) { - return index; - } - } - return -1; -} + /* Free a window manager cursor */ + void (*FreeCursor) (SDL_Cursor * cursor); -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; -} + /* Warp the mouse to (x,y) */ + void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y); -void -SDL_DelMouse(int index) -{ - 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); + /* 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_mice[index] = NULL; -} + SDL_Cursor *cursors; + SDL_Cursor *def_cursor; + SDL_Cursor *cur_cursor; + SDL_bool cursor_shown; +}; -void -SDL_ResetMouse(int index) -{ - SDL_Mouse *mouse = SDL_GetMouse(index); +static SDL_Mouse SDL_mouse; - 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; - } -} +/* Public functions */ int -SDL_GetNumMice(void) +SDL_MouseInit(void) { - return SDL_num_mice; + return (0); } -int -SDL_SelectMouse(int index) +void +SDL_ResetMouse(void) { - if (index >= 0 && index < SDL_num_mice) { - SDL_current_mouse = index; - } - return SDL_current_mouse; + /* FIXME */ } 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(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; - } - /* the relative motion is calculated regarding the system cursor last position */ if (relative) { xrel = x; @@ -451,35 +166,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,17 +194,12 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure) } int -SDL_SendMouseButton(int id, Uint8 state, Uint8 button) +SDL_SendMouseButton(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; - } - /* Figure out which event to perform */ switch (state) { case SDL_PRESSED: @@ -527,7 +228,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 +239,12 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button) } int -SDL_SendMouseWheel(int index, int x, int y) +SDL_SendMouseWheel(int x, int y) { - SDL_Mouse *mouse = SDL_GetMouse(index); + SDL_Mouse *mouse = &SDL_mouse; int posted; - if (!mouse || (!x && !y)) { + if (!x && !y) { return 0; } @@ -553,53 +253,108 @@ 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_WarpMouseInWindow(SDL_Window * window, int x, int y) +SDL_MouseQuit(void) { - SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); +} - if (!mouse) { - return; +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_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_SetMouseFocus(window); + SDL_SendMouseMotion(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 +393,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 +409,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 +443,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 +454,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 +488,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 +509,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..284468fa9 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(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(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(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/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index e6266c9e4..9fd89d15d 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -62,20 +62,13 @@ @interface SDLTranslatorResponder : NSView NSRange _markedRange; NSRange _selectedRange; SDL_Rect _inputRect; - int _keyboard; } - (void) doCommandBySelector:(SEL)myselector; - (void) setInputRect:(SDL_Rect *) rect; -- (void) setKeyboard:(int) keyboard; @end @implementation SDLTranslatorResponder -- (void) setKeyboard:(int) keyboard -{ - _keyboard = keyboard; -} - - (void) setInputRect:(SDL_Rect *) rect { _inputRect = *rect; @@ -94,7 +87,7 @@ - (void) insertText:(id) aString else str = [aString UTF8String]; - SDL_SendKeyboardText(_keyboard, str); + SDL_SendKeyboardText(str); } - (void) doCommandBySelector:(SEL) myselector @@ -140,7 +133,7 @@ - (void) setMarkedText:(id) aString _selectedRange = selRange; _markedRange = NSMakeRange(0, [aString length]); - SDL_SendEditingText(_keyboard, [aString UTF8String], + SDL_SendEditingText([aString UTF8String], selRange.location, selRange.length); DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText, @@ -204,7 +197,7 @@ - (NSArray *) validAttributesForMarkedText * differentiating between left and right versions of the keys. */ static void -DoUnsidedModifiers(int keyboard, unsigned short scancode, +DoUnsidedModifiers(unsigned short scancode, unsigned int oldMods, unsigned int newMods) { const int mapping[] = { @@ -226,14 +219,14 @@ - (NSArray *) validAttributesForMarkedText if (oldMask && oldMask != newMask) { /* modifier up event */ /* If this was Caps Lock, we need some additional voodoo to make SDL happy */ if (bit == NSAlphaShiftKeyMask) { - SDL_SendKeyboardKey(keyboard, SDL_PRESSED, mapping[i]); + SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]); } - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, mapping[i]); + SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]); } else if (newMask && oldMask != newMask) { /* modifier down event */ - SDL_SendKeyboardKey(keyboard, SDL_PRESSED, mapping[i]); + SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]); /* If this was Caps Lock, we need some additional voodoo to make SDL happy */ if (bit == NSAlphaShiftKeyMask) { - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, mapping[i]); + SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]); } } } @@ -244,8 +237,7 @@ - (NSArray *) validAttributesForMarkedText * sides was made. */ static void -HandleNonDeviceModifier(int keyboard, - unsigned int device_independent_mask, +HandleNonDeviceModifier(unsigned int device_independent_mask, unsigned int oldMods, unsigned int newMods, SDL_scancode scancode) @@ -259,9 +251,9 @@ - (NSArray *) validAttributesForMarkedText newMask = newMods & device_independent_mask; if (oldMask && oldMask != newMask) { - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, scancode); + SDL_SendKeyboardKey(SDL_RELEASED, scancode); } else if (newMask && oldMask != newMask) { - SDL_SendKeyboardKey(keyboard, SDL_PRESSED, scancode); + SDL_SendKeyboardKey(SDL_PRESSED, scancode); } } @@ -269,8 +261,7 @@ - (NSArray *) validAttributesForMarkedText * This function sets the actual SDL_PrivateKeyboard event. */ static void -HandleModifierOneSide(int keyboard, - unsigned int oldMods, unsigned int newMods, +HandleModifierOneSide(unsigned int oldMods, unsigned int newMods, SDL_scancode scancode, unsigned int sided_device_dependent_mask) { @@ -287,9 +278,9 @@ - (NSArray *) validAttributesForMarkedText * find out which it is. */ if (new_dep_mask && old_dep_mask != new_dep_mask) { - SDL_SendKeyboardKey(keyboard, SDL_PRESSED, scancode); + SDL_SendKeyboardKey(SDL_PRESSED, scancode); } else { - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, scancode); + SDL_SendKeyboardKey(SDL_RELEASED, scancode); } } @@ -298,8 +289,7 @@ - (NSArray *) validAttributesForMarkedText * e.g. left-shift vs right-shift. */ static void -HandleModifierSide(int keyboard, - int device_independent_mask, +HandleModifierSide(int device_independent_mask, unsigned int oldMods, unsigned int newMods, SDL_scancode left_scancode, SDL_scancode right_scancode, @@ -316,7 +306,7 @@ - (NSArray *) validAttributesForMarkedText */ if ((device_dependent_mask & newMods) == 0) { /* Revert to the old behavior */ - HandleNonDeviceModifier(keyboard, device_independent_mask, oldMods, newMods, left_scancode); + HandleNonDeviceModifier(device_independent_mask, oldMods, newMods, left_scancode); return; } @@ -329,10 +319,10 @@ - (NSArray *) validAttributesForMarkedText * change or if the bits don't both exist. */ if (left_device_dependent_mask & diff_mod) { - HandleModifierOneSide(keyboard, oldMods, newMods, left_scancode, left_device_dependent_mask); + HandleModifierOneSide(oldMods, newMods, left_scancode, left_device_dependent_mask); } if (right_device_dependent_mask & diff_mod) { - HandleModifierOneSide(keyboard, oldMods, newMods, right_scancode, right_device_dependent_mask); + HandleModifierOneSide(oldMods, newMods, right_scancode, right_device_dependent_mask); } } } @@ -343,8 +333,7 @@ - (NSArray *) validAttributesForMarkedText * can't still be down). */ static void -ReleaseModifierSide(int keyboard, - unsigned int device_independent_mask, +ReleaseModifierSide(unsigned int device_independent_mask, unsigned int oldMods, unsigned int newMods, SDL_scancode left_scancode, SDL_scancode right_scancode, @@ -362,7 +351,7 @@ - (NSArray *) validAttributesForMarkedText /* In this case, we can't detect the keyboard, so use the left side * to represent both, and release it. */ - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, left_scancode); + SDL_SendKeyboardKey(SDL_RELEASED, left_scancode); return; } @@ -373,10 +362,10 @@ - (NSArray *) validAttributesForMarkedText * so I hope this doesn't cause other problems. */ if ( left_device_dependent_mask & oldMods ) { - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, left_scancode); + SDL_SendKeyboardKey(SDL_RELEASED, left_scancode); } if ( right_device_dependent_mask & oldMods ) { - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, right_scancode); + SDL_SendKeyboardKey(SDL_RELEASED, right_scancode); } } @@ -384,7 +373,7 @@ - (NSArray *) validAttributesForMarkedText * This function handles the CapsLock case. */ static void -HandleCapsLock(int keyboard, unsigned short scancode, +HandleCapsLock(unsigned short scancode, unsigned int oldMods, unsigned int newMods) { unsigned int oldMask, newMask; @@ -393,16 +382,16 @@ - (NSArray *) validAttributesForMarkedText newMask = newMods & NSAlphaShiftKeyMask; if (oldMask != newMask) { - SDL_SendKeyboardKey(keyboard, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); } oldMask = oldMods & NSNumericPadKeyMask; newMask = newMods & NSNumericPadKeyMask; if (oldMask != newMask) { - SDL_SendKeyboardKey(keyboard, SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR); - SDL_SendKeyboardKey(keyboard, SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR); } } @@ -410,7 +399,7 @@ - (NSArray *) validAttributesForMarkedText * correct side of the key. */ static void -DoSidedModifiers(int keyboard, unsigned short scancode, +DoSidedModifiers(unsigned short scancode, unsigned int oldMods, unsigned int newMods) { /* Set up arrays for the key syms for the left and right side. */ @@ -435,7 +424,7 @@ - (NSArray *) validAttributesForMarkedText unsigned int i, bit; /* Handle CAPSLOCK separately because it doesn't have a left/right side */ - HandleCapsLock(keyboard, scancode, oldMods, newMods); + HandleCapsLock(scancode, oldMods, newMods); /* Iterate through the bits, testing each against the old modifiers */ for (i = 0, bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) { @@ -448,7 +437,7 @@ - (NSArray *) validAttributesForMarkedText * and right side keys may alternate or both may be pressed. */ if (newMask) { - HandleModifierSide(keyboard, bit, oldMods, newMods, + HandleModifierSide(bit, oldMods, newMods, left_mapping[i], right_mapping[i], left_device_mapping[i], right_device_mapping[i]); } @@ -456,7 +445,7 @@ - (NSArray *) validAttributesForMarkedText * the device dependent bits to release the correct keys. */ else if (oldMask && oldMask != newMask) { - ReleaseModifierSide(keyboard, bit, oldMods, newMods, + ReleaseModifierSide(bit, oldMods, newMods, left_mapping[i], right_mapping[i], left_device_mapping[i], right_device_mapping[i]); } @@ -477,9 +466,9 @@ - (NSArray *) validAttributesForMarkedText * left side and right side modifiers is available. */ if (data->osversion >= 0x1030) { - DoSidedModifiers(data->keyboard, scancode, data->modifierFlags, modifierFlags); + DoSidedModifiers(scancode, data->modifierFlags, modifierFlags); } else { - DoUnsidedModifiers(data->keyboard, scancode, data->modifierFlags, modifierFlags); + DoUnsidedModifiers(scancode, data->modifierFlags, modifierFlags); } data->modifierFlags = modifierFlags; } @@ -549,7 +538,7 @@ - (NSArray *) validAttributesForMarkedText keymap[scancode] = s[0]; } } - SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES); + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); return; } @@ -603,7 +592,7 @@ - (NSArray *) validAttributesForMarkedText keymap[scancode] = c; } } - SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES); + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); return; } #endif @@ -613,10 +602,7 @@ - (NSArray *) validAttributesForMarkedText Cocoa_InitKeyboard(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_Keyboard keyboard; - SDL_zero(keyboard); - data->keyboard = SDL_AddKeyboard(&keyboard, -1); UpdateKeymap(data); /* Set our own names for the platform-dependent but layout-independent keys */ @@ -645,8 +631,6 @@ - (NSArray *) validAttributesForMarkedText [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)]; } - [data->fieldEdit setKeyboard: data->keyboard]; - if (![[data->fieldEdit superview] isEqual: parentView]) { // DEBUG_IME(@"add fieldEdit to window contentView"); @@ -686,7 +670,9 @@ - (NSArray *) validAttributesForMarkedText SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; unsigned short scancode = [event keyCode]; SDL_scancode code; +#if 0 const char *text; +#endif if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { /* see comments in SDL_cocoakeys.h */ @@ -706,7 +692,7 @@ - (NSArray *) validAttributesForMarkedText /* See if we need to rebuild the keyboard layout */ UpdateKeymap(data); - SDL_SendKeyboardKey(data->keyboard, SDL_PRESSED, code); + SDL_SendKeyboardKey(SDL_PRESSED, code); #if 1 if (code == SDL_SCANCODE_UNKNOWN) { fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list or to Christian Walther . Mac virtual key code is %d.\n", scancode); @@ -719,14 +705,14 @@ - (NSArray *) validAttributesForMarkedText #if 0 text = [[event characters] UTF8String]; if(text && *text) { - SDL_SendKeyboardText(data->keyboard, text); + SDL_SendKeyboardText(text); [data->fieldEdit setString:@""]; } #endif } break; case NSKeyUp: - SDL_SendKeyboardKey(data->keyboard, SDL_RELEASED, code); + SDL_SendKeyboardKey(SDL_RELEASED, code); break; case NSFlagsChanged: /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */ @@ -740,10 +726,6 @@ - (NSArray *) validAttributesForMarkedText void Cocoa_QuitKeyboard(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - NSAutoreleasePool *pool; - - SDL_DelKeyboard(data->keyboard); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 1a71840c7..02ad198b4 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -29,11 +29,6 @@ void Cocoa_InitMouse(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_Mouse mouse; - - SDL_zero(mouse); - data->mouse = SDL_AddMouse(&mouse, "Mouse", 0, 0, 1); } static int @@ -54,10 +49,8 @@ void Cocoa_HandleMouseEvent(_THIS, NSEvent *event) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_Mouse *mouse = SDL_GetMouse(data->mouse); int i; - NSPoint point; + NSPoint point = { 0, 0 }; SDL_Window *window; /* See if there are any fullscreen windows that might handle this event */ @@ -73,44 +66,38 @@ point = [NSEvent mouseLocation]; point.x = point.x - bounds.x; point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - bounds.y; - if (point.x < 0 || point.x >= candidate->w || - point.y < 0 || point.y >= candidate->h) { - /* The mouse is out of this fullscreen display */ - if (mouse->focus == candidate) { - SDL_SetMouseFocus(data->mouse, 0); - } - } else { + if ((point.x >= 0 && point.x < candidate->w) || + (point.y >= 0 && point.y < candidate->h)) { /* This is it! */ window = candidate; break; } } } - if (!window) { - return; - } /* Set the focus appropriately */ - if (mouse->focus != window) { - SDL_SetMouseFocus(data->mouse, window); + SDL_SetMouseFocus(window); + + if (window) { + return; } switch ([event type]) { case NSLeftMouseDown: case NSOtherMouseDown: case NSRightMouseDown: - SDL_SendMouseButton(data->mouse, SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber])); + SDL_SendMouseButton(SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber])); break; case NSLeftMouseUp: case NSOtherMouseUp: case NSRightMouseUp: - SDL_SendMouseButton(data->mouse, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber])); + SDL_SendMouseButton(SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber])); break; case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDragged: /* usually middle mouse dragged */ case NSMouseMoved: - SDL_SendMouseMotion(data->mouse, 0, (int)point.x, (int)point.y, 0); + SDL_SendMouseMotion(0, (int)point.x, (int)point.y); break; default: /* just to avoid compiler warnings */ break; @@ -120,9 +107,6 @@ void Cocoa_QuitMouse(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - - SDL_DelMouse(data->mouse); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index 0ddb91a7c..8f12dc056 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -57,8 +57,6 @@ typedef struct SDL_VideoData { SInt32 osversion; unsigned int modifierFlags; - int mouse; - int keyboard; void *key_layout; SDLTranslatorResponder *fieldEdit; Uint32 screensaver_activity; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 110b839a1..1f3fc515e 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -126,28 +126,21 @@ - (void)windowDidDeminiaturize:(NSNotification *)aNotification - (void)windowDidBecomeKey:(NSNotification *)aNotification { - int index; - /* We're going to get keyboard events, since we're key. */ - index = _data->videodata->keyboard; - SDL_SetKeyboardFocus(index, _data->window); + SDL_SetKeyboardFocus(_data->window); } - (void)windowDidResignKey:(NSNotification *)aNotification { - int index; - SDL_Mouse *mouse; - /* Some other window will get mouse events, since we're not key. */ - index = _data->videodata->mouse; - mouse = SDL_GetMouse(index); - if (mouse->focus == _data->window) { - SDL_SetMouseFocus(index, 0); + if (SDL_GetMouseFocus() == _data->window) { + SDL_SetMouseFocus(NULL); } /* Some other window will get keyboard events, since we're not key. */ - index = _data->videodata->keyboard; - SDL_SetKeyboardFocus(index, 0); + if (SDL_GetKeyboardFocus() == _data->window) { + SDL_SetKeyboardFocus(NULL); + } } - (void)windowDidHide:(NSNotification *)aNotification @@ -162,10 +155,8 @@ - (void)windowDidUnhide:(NSNotification *)aNotification - (void)mouseDown:(NSEvent *)theEvent { - int index; int button; - index = _data->videodata->mouse; switch ([theEvent buttonNumber]) { case 0: button = SDL_BUTTON_LEFT; @@ -180,7 +171,7 @@ - (void)mouseDown:(NSEvent *)theEvent button = [theEvent buttonNumber]; break; } - SDL_SendMouseButton(index, SDL_PRESSED, button); + SDL_SendMouseButton(SDL_PRESSED, button); } - (void)rightMouseDown:(NSEvent *)theEvent @@ -195,10 +186,8 @@ - (void)otherMouseDown:(NSEvent *)theEvent - (void)mouseUp:(NSEvent *)theEvent { - int index; int button; - index = _data->videodata->mouse; switch ([theEvent buttonNumber]) { case 0: button = SDL_BUTTON_LEFT; @@ -213,7 +202,7 @@ - (void)mouseUp:(NSEvent *)theEvent button = [theEvent buttonNumber]; break; } - SDL_SendMouseButton(index, SDL_RELEASED, button); + SDL_SendMouseButton(SDL_RELEASED, button); } - (void)rightMouseUp:(NSEvent *)theEvent @@ -229,24 +218,18 @@ - (void)otherMouseUp:(NSEvent *)theEvent - (void)mouseMoved:(NSEvent *)theEvent { SDL_Window *window = _data->window; - int index; - SDL_Mouse *mouse; NSPoint point; - index = _data->videodata->mouse; - mouse = SDL_GetMouse(index); point = [theEvent locationInWindow]; point.y = window->h - point.y; if ( point.x < 0 || point.x >= window->w || point.y < 0 || point.y >= window->h ) { - if (mouse->focus != 0) { - SDL_SetMouseFocus(index, 0); + if (SDL_GetMouseFocus() == window) { + SDL_SetMouseFocus(NULL); } } else { - if (mouse->focus != _data->window) { - SDL_SetMouseFocus(index, _data->window); - } - SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0); + SDL_SetMouseFocus(_data->window); + SDL_SendMouseMotion(0, (int)point.x, (int)point.y); } } @@ -267,10 +250,7 @@ - (void)otherMouseDragged:(NSEvent *)theEvent - (void)scrollWheel:(NSEvent *)theEvent { - int index; - - index = _data->videodata->mouse; - SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f)); + SDL_SendMouseWheel((int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f)); } @end @@ -361,9 +341,8 @@ - (BOOL)canBecomeMainWindow window->flags &= ~SDL_WINDOW_MINIMIZED; } if ([nswindow isKeyWindow]) { - int index = data->videodata->keyboard; window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(index, data->window); + SDL_SetKeyboardFocus(data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { /* FIXME */ @@ -385,8 +364,6 @@ - (BOOL)canBecomeMainWindow NSRect rect; SDL_Rect bounds; unsigned int style; - NSString *title; - int status; Cocoa_GetDisplayBounds(_this, display, &bounds); if ((window->flags & SDL_WINDOW_FULLSCREEN) @@ -452,7 +429,6 @@ - (BOOL)canBecomeMainWindow NSAutoreleasePool *pool; NSWindow *nswindow = (NSWindow *) data; NSString *title; - int status; pool = [[NSAutoreleasePool alloc] init]; @@ -625,7 +601,7 @@ - (BOOL)canBecomeMainWindow SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) { - NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; + //NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; if (info->version.major <= SDL_MAJOR_VERSION) { //info->window = nswindow; diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index a2f182b32..3e0315704 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -38,8 +38,10 @@ #else @interface SDL_uikitview : UIView { #endif - + +#if FIXME_MULTITOUCH SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES]; +#endif #if SDL_IPHONE_KEYBOARD UITextField *textField; diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index e3dc19ec7..da03d0c2e 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -47,6 +47,7 @@ - (id)initWithFrame:(CGRect)frame { [self initializeKeyboard]; #endif +#if FIXME_MULTITOUCH int i; for (i=0; ivideodata; - if (videodata->wintabDLL - && videodata->WTPacket((HCTX) lParam, (UINT) wParam, &packet)) { - SDL_ChangeEnd(tablet, (int) packet.pkCursor); - pressure = (int) packet.pkNormalPressure; - } - } - break; - - case WT_PROXIMITY: - { - /* checking where the proximity message showed up */ - int h_context = LOWORD(lParam); - POINT point; - GetCursorPos(&point); - ScreenToClient(hwnd, &point); - - /* are we in proximity or out of proximity */ - if (h_context == 0) { - SDL_SendProximity(tablet, point.x, point.y, SDL_PROXIMITYOUT); - } else { - SDL_SendProximity(tablet, point.x, point.y, SDL_PROXIMITYIN); - } - } - break; - case WM_SHOWWINDOW: { if (wParam) { @@ -183,13 +146,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_ACTIVATE: { - int index; - SDL_Keyboard *keyboard; BOOL minimized; minimized = HIWORD(wParam); - index = data->videodata->keyboard; - keyboard = SDL_GetKeyboard(index); if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); SDL_SendWindowEvent(data->window, @@ -200,13 +159,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_WINDOWEVENT_MAXIMIZED, 0, 0); } #endif - if (keyboard && keyboard->focus != data->window) { - SDL_SetKeyboardFocus(index, data->window); + if (SDL_GetKeyboardFocus() != data->window) { + SDL_SetKeyboardFocus(data->window); } /* FIXME: Update keyboard state */ } else { - if (keyboard && keyboard->focus == data->window) { - SDL_SetKeyboardFocus(index, 0); + if (SDL_GetKeyboardFocus() == data->window) { + SDL_SetKeyboardFocus(NULL); } if (minimized) { SDL_SendWindowEvent(data->window, @@ -217,124 +176,22 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; -/* WinCE has no RawInput, so we use the classic mouse events. - In classic Win32 this is done by WM_INPUT - */ -#ifdef _WIN32_WCE case WM_MOUSEMOVE: - SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); + SDL_SendMouseMotion(0, LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONDOWN: - SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); - SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT); + SDL_SendMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT); break; case WM_LBUTTONUP: - SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); - SDL_SendMouseButton(0, SDL_RELEASED, SDL_BUTTON_LEFT); - break; -#else /* _WIN32_WCE */ - - case WM_INPUT: /* mouse events */ - { - LPBYTE lpb; - const RAWINPUTHEADER *header; - int index = -1; - int i; - int size = 0; - const RAWMOUSE *raw_mouse = NULL; - POINT point; - USHORT flags; - int w, h; - - /* we're collecting raw data to be able to identify the mouse (if there are several) */ - GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, - sizeof(RAWINPUTHEADER)); - lpb = SDL_stack_alloc(BYTE, size); - GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, - sizeof(RAWINPUTHEADER)); - raw = (RAWINPUT *) lpb; - header = &raw->header; - flags = raw->data.mouse.usButtonFlags; - - /* we're checking which mouse generated the event */ - for (i = 0; i < total_mice; ++i) { - if (mice[i] == header->hDevice) { - index = i; - break; - } - } - if (index < 0) { - /* New mouse? Should we dynamically update mouse list? */ - returnCode = 0; - break; - } - - GetCursorPos(&point); - ScreenToClient(hwnd, &point); - - SDL_GetWindowSize(data->window, &w, &h); - if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) { - SDL_SetMouseFocus(index, data->window); - } else { - SDL_SetMouseFocus(index, 0); - /* FIXME: Should we be doing anything else here? */ - break; - } - - /* if the message was sent by a tablet we have to send also pressure */ - if (index == tablet) { - SDL_SendMouseMotion(index, 0, point.x, point.y, pressure); - } else { - SDL_SendMouseMotion(index, 0, point.x, point.y, 0); - } - /* we're sending mouse buttons messages to check up if sth changed */ - if (flags & RI_MOUSE_LEFT_BUTTON_DOWN) { - SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_LEFT); - } else if (flags & RI_MOUSE_LEFT_BUTTON_UP) { - SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_LEFT); - } - if (flags & RI_MOUSE_MIDDLE_BUTTON_DOWN) { - SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_MIDDLE); - } else if (flags & RI_MOUSE_MIDDLE_BUTTON_UP) { - SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_MIDDLE); - } - if (flags & RI_MOUSE_RIGHT_BUTTON_DOWN) { - SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_RIGHT); - } else if (flags & RI_MOUSE_RIGHT_BUTTON_UP) { - SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_RIGHT); - } - if (flags & RI_MOUSE_BUTTON_4_DOWN) { - SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_X1); - } else if (flags & RI_MOUSE_BUTTON_4_UP) { - SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_X1); - } - if (flags & RI_MOUSE_BUTTON_5_DOWN) { - SDL_SendMouseButton(index, SDL_PRESSED, SDL_BUTTON_X2); - } else if (flags & RI_MOUSE_BUTTON_5_UP) { - SDL_SendMouseButton(index, SDL_RELEASED, SDL_BUTTON_X2); - } - if (flags & RI_MOUSE_WHEEL) { - SDL_SendMouseWheel(index, 0, - (short) raw->data.mouse.usButtonData); - } - SDL_stack_free(lpb); - } - returnCode = 0; + SDL_SendMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT); break; -#endif /* _WIN32_WCE */ case WM_MOUSELEAVE: { - int i; - - for (i = 0; i < SDL_GetNumMice(); ++i) { - SDL_Mouse *mouse = SDL_GetMouse(i); - - if (mouse->focus == data->window) { - SDL_SetMouseFocus(i, 0); - } + if (SDL_GetMouseFocus() == data->window) { + SDL_SetMouseFocus(NULL); } } returnCode = 0; @@ -343,15 +200,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SYSKEYDOWN: case WM_KEYDOWN: { - int index; - /* Ignore repeated keys */ if (lParam & REPEATED_KEYMASK) { returnCode = 0; break; } - index = data->videodata->keyboard; wParam = RemapVKEY(wParam, lParam); switch (wParam) { case VK_CONTROL: @@ -388,7 +242,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; } if (wParam < 256) { - SDL_SendKeyboardKey(index, SDL_PRESSED, + SDL_SendKeyboardKey(SDL_PRESSED, data->videodata->key_layout[wParam]); } } @@ -398,9 +252,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SYSKEYUP: case WM_KEYUP: { - int index; - - index = data->videodata->keyboard; wParam = RemapVKEY(wParam, lParam); switch (wParam) { case VK_CONTROL: @@ -441,11 +292,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (wParam == VK_SNAPSHOT && SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] == SDL_RELEASED) { - SDL_SendKeyboardKey(index, SDL_PRESSED, + SDL_SendKeyboardKey(SDL_PRESSED, data->videodata->key_layout[wParam]); } if (wParam < 256) { - SDL_SendKeyboardKey(index, SDL_RELEASED, + SDL_SendKeyboardKey(SDL_RELEASED, data->videodata->key_layout[wParam]); } } @@ -470,14 +321,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) text[2] = 0x80 | (char) (wParam & 0x3F); text[3] = '\0'; } - SDL_SendKeyboardText(data->videodata->keyboard, text); + SDL_SendKeyboardText(text); } returnCode = 0; break; case WM_INPUTLANGCHANGE: { - WIN_UpdateKeymap(data->videodata->keyboard); + WIN_UpdateKeymap(); } returnCode = 1; break; diff --git a/src/video/win32/SDL_win32keyboard.c b/src/video/win32/SDL_win32keyboard.c index d975be28e..fb4e0ff41 100644 --- a/src/video/win32/SDL_win32keyboard.c +++ b/src/video/win32/SDL_win32keyboard.c @@ -50,7 +50,6 @@ void WIN_InitKeyboard(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_Keyboard keyboard; int i; /* Make sure the alpha scancodes are correct. T isn't usually remapped */ @@ -82,9 +81,7 @@ WIN_InitKeyboard(_THIS) data->key_layout = win32_scancode_table; - SDL_zero(keyboard); - data->keyboard = SDL_AddKeyboard(&keyboard, -1); - WIN_UpdateKeymap(data->keyboard); + WIN_UpdateKeymap(); SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows"); @@ -92,7 +89,7 @@ WIN_InitKeyboard(_THIS) } void -WIN_UpdateKeymap(int keyboard) +WIN_UpdateKeymap() { int i; SDL_scancode scancode; @@ -117,15 +114,12 @@ WIN_UpdateKeymap(int keyboard) keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF); } } - SDL_SetKeymap(keyboard, 0, keymap, SDL_NUM_SCANCODES); + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); } void WIN_QuitKeyboard(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - - SDL_DelKeyboard(data->keyboard); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32keyboard.h b/src/video/win32/SDL_win32keyboard.h index dd5b28de6..c67410a63 100644 --- a/src/video/win32/SDL_win32keyboard.h +++ b/src/video/win32/SDL_win32keyboard.h @@ -28,7 +28,7 @@ extern BYTE alpha_scancodes[26]; extern BYTE keypad_scancodes[10]; extern void WIN_InitKeyboard(_THIS); -extern void WIN_UpdateKeymap(int keyboard); +extern void WIN_UpdateKeymap(void); extern void WIN_QuitKeyboard(_THIS); #endif /* _SDL_win32keyboard_h */ diff --git a/src/video/win32/SDL_win32modes.c b/src/video/win32/SDL_win32modes.c index f8cfde9a5..847e08343 100644 --- a/src/video/win32/SDL_win32modes.c +++ b/src/video/win32/SDL_win32modes.c @@ -160,7 +160,6 @@ WIN_AddDisplay(LPTSTR DeviceName) int WIN_InitModes(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; DWORD i, j, count; DISPLAY_DEVICE device; diff --git a/src/video/win32/SDL_win32mouse.c b/src/video/win32/SDL_win32mouse.c index ca9847f05..093720bcb 100644 --- a/src/video/win32/SDL_win32mouse.c +++ b/src/video/win32/SDL_win32mouse.c @@ -31,182 +31,14 @@ #include "SDL_win32video.h" -#include "../../events/SDL_mouse_c.h" - -extern HANDLE *mice; -extern int total_mice; -extern int tablet; - void WIN_InitMouse(_THIS) { - int index = 0; - RAWINPUTDEVICELIST *deviceList = NULL; - int devCount = 0; - int i; - UINT tmp = 0; - char *buffer = NULL; - char *tab = "wacom"; /* since windows does't give us handles to tablets, we have to detect a tablet by it's name */ - const char *rdp = "rdp_mou"; - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - -/* WinCE has no RawInputDeviceList */ -#ifdef _WIN32_WCE - SDL_Mouse mouse; - SDL_zero(mouse); - mouse.id = 0; - SDL_AddMouse(&mouse, "Stylus", 0, 0, 1); -#else - /* we're checking for the number of rawinput devices */ - if (GetRawInputDeviceList(NULL, &devCount, sizeof(RAWINPUTDEVICELIST))) { - return; - } - - deviceList = SDL_malloc(sizeof(RAWINPUTDEVICELIST) * devCount); - - /* we're getting the raw input device list */ - GetRawInputDeviceList(deviceList, &devCount, sizeof(RAWINPUTDEVICELIST)); - mice = SDL_malloc(devCount * sizeof(HANDLE)); - - /* we're getting the details of the devices */ - for (i = 0; i < devCount; ++i) { - int is_rdp = 0; - UINT j; - UINT k; - char *default_device_name = "Pointing device xx"; - const char *reg_key_root = "System\\CurrentControlSet\\Enum\\"; - char *device_name = SDL_malloc(256 * sizeof(char)); - char *key_name = NULL; - char *tmp_name = NULL; - LONG rc = 0; - HKEY hkey; - DWORD regtype = REG_SZ; - DWORD out = 256 * sizeof(char); - SDL_Mouse mouse; - size_t l; - if (deviceList[i].dwType != RIM_TYPEMOUSE) { /* if a device isn't a mouse type we don't want it */ - continue; - } - if (GetRawInputDeviceInfoA - (deviceList[i].hDevice, RIDI_DEVICENAME, NULL, &tmp) < 0) { - continue; - } - buffer = SDL_malloc((tmp + 1) * sizeof(char)); - key_name = - SDL_malloc((tmp + SDL_strlen(reg_key_root) + 1) * sizeof(char)); - - /* we're getting the device registry path and polishing it to get it's name, - surely there must be an easier way, but we haven't found it yet */ - if (GetRawInputDeviceInfoA - (deviceList[i].hDevice, RIDI_DEVICENAME, buffer, &tmp) < 0) { - continue; - } - buffer += 4; - tmp -= 4; - tmp_name = buffer; - for (j = 0; j < tmp; ++j) { - if (*tmp_name == '#') { - *tmp_name = '\\'; - } - - else if (*tmp_name == '{') { - break; - } - ++tmp_name; - } - *tmp_name = '\0'; - SDL_memcpy(key_name, reg_key_root, SDL_strlen(reg_key_root)); - SDL_memcpy(key_name + (SDL_strlen(reg_key_root)), buffer, j + 1); - l = SDL_strlen(key_name); - is_rdp = 0; - if (l >= 7) { - for (j = 0; j < l - 7; ++j) { - for (k = 0; k < 7; ++k) { - if (rdp[k] != - SDL_tolower((unsigned char) key_name[j + k])) { - break; - } - } - if (k == 7) { - is_rdp = 1; - break; - } - } - } - - buffer -= 4; - - if (is_rdp == 1) { - SDL_free(buffer); - SDL_free(key_name); - SDL_free(device_name); - is_rdp = 0; - continue; - } - - /* we're opening the registry key to get the mouse name */ - rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, key_name, 0, KEY_READ, &hkey); - if (rc != ERROR_SUCCESS) { - SDL_memcpy(device_name, default_device_name, - SDL_strlen(default_device_name)); - } - rc = RegQueryValueExA(hkey, "DeviceDesc", NULL, ®type, device_name, - &out); - RegCloseKey(hkey); - if (rc != ERROR_SUCCESS) { - SDL_memcpy(device_name, default_device_name, - SDL_strlen(default_device_name)); - } - - /* we're saving the handle to the device */ - mice[index] = deviceList[i].hDevice; - SDL_zero(mouse); - mouse.id = index; - l = SDL_strlen(device_name); - - /* we're checking if the device isn't by any chance a tablet */ - if (data->wintabDLL && tablet == -1) { - for (j = 0; j < l - 5; ++j) { - for (k = 0; k < 5; ++k) { - if (tab[k] != - SDL_tolower((unsigned char) device_name[j + k])) { - break; - } - } - if (k == 5) { - tablet = index; - break; - } - } - } - - /* if it's a tablet, let's read it's maximum and minimum pressure */ - if (tablet == index) { - AXIS pressure; - int cursors; - data->WTInfoA(WTI_DEVICES, DVC_NPRESSURE, &pressure); - data->WTInfoA(WTI_DEVICES, DVC_NCSRTYPES, &cursors); - SDL_AddMouse(&mouse, device_name, pressure.axMax, pressure.axMin, - cursors); - } else { - SDL_AddMouse(&mouse, device_name, 0, 0, 1); - } - ++index; - SDL_free(buffer); - SDL_free(key_name); - } - total_mice = index; - SDL_free(deviceList); -#endif /*_WIN32_WCE*/ } void WIN_QuitMouse(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - - /* let's delete all of the mice */ - SDL_MouseQuit(); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32video.c b/src/video/win32/SDL_win32video.c index 1ee4f64b2..c93d4f72e 100644 --- a/src/video/win32/SDL_win32video.c +++ b/src/video/win32/SDL_win32video.c @@ -35,11 +35,6 @@ static int WIN_VideoInit(_THIS); static void WIN_VideoQuit(_THIS); -int total_mice = 0; /* total mouse count */ -HANDLE *mice = NULL; /* the handles to the detected mice */ -HCTX *g_hCtx = NULL; /* handles to tablet contexts */ -int tablet = -1; /* we're assuming that there is no tablet */ - /* WIN32 driver bootstrap functions */ static int @@ -66,9 +61,6 @@ WIN_DeleteDevice(SDL_VideoDevice * device) FreeLibrary(data->ddrawDLL); } #endif - if (data->wintabDLL) { - FreeLibrary(data->wintabDLL); - } SDL_free(device->driverdata); SDL_free(device); } @@ -85,8 +77,10 @@ WIN_CreateDevice(int devindex) device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + } else { + data = NULL; } - if (!device || !data) { + if (!data) { SDL_OutOfMemory(); if (device) { SDL_free(device); @@ -131,32 +125,6 @@ WIN_CreateDevice(int devindex) } #endif /* SDL_VIDEO_RENDER_DDRAW */ - data->wintabDLL = LoadLibrary(TEXT("WINTAB32.DLL")); - if (data->wintabDLL) { -#define PROCNAME(X) #X - data->WTInfoA = - (UINT(*)(UINT, UINT, LPVOID)) GetProcAddress(data->wintabDLL, - PROCNAME(WTInfoA)); - data->WTOpenA = - (HCTX(*)(HWND, LPLOGCONTEXTA, BOOL)) GetProcAddress(data-> - wintabDLL, - PROCNAME - (WTOpenA)); - data->WTPacket = - (int (*)(HCTX, UINT, LPVOID)) GetProcAddress(data->wintabDLL, - PROCNAME(WTPacket)); - data->WTClose = - (BOOL(*)(HCTX)) GetProcAddress(data->wintabDLL, - PROCNAME(WTClose)); -#undef PROCNAME - - if (!data->WTInfoA || !data->WTOpenA || !data->WTPacket - || !data->WTClose) { - FreeLibrary(data->wintabDLL); - data->wintabDLL = NULL; - } - } - /* Set the function pointers */ device->VideoInit = WIN_VideoInit; device->VideoQuit = WIN_VideoQuit; @@ -225,7 +193,6 @@ WIN_VideoInit(_THIS) GAPI_AddRenderDriver(_this); #endif - g_hCtx = SDL_malloc(sizeof(HCTX)); WIN_InitKeyboard(_this); WIN_InitMouse(_this); @@ -238,7 +205,6 @@ WIN_VideoQuit(_THIS) WIN_QuitModes(_this); WIN_QuitKeyboard(_this); WIN_QuitMouse(_this); - SDL_free(g_hCtx); } /* vim: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32video.h b/src/video/win32/SDL_win32video.h index fb1e96f96..3cfb63219 100644 --- a/src/video/win32/SDL_win32video.h +++ b/src/video/win32/SDL_win32video.h @@ -45,11 +45,6 @@ #include "ddraw.h" #endif -#include "wactab/wintab.h" -#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_CURSOR) -#define PACKETMODE 0 -#include "wactab/pktdef.h" - #include "SDL_win32events.h" #include "SDL_win32gamma.h" #include "SDL_win32keyboard.h" @@ -79,16 +74,6 @@ typedef struct SDL_VideoData IDirectDraw *ddraw; #endif -/* *INDENT-OFF* */ - /* Function pointers for the Wacom API */ - HANDLE wintabDLL; - UINT (*WTInfoA) (UINT, UINT, LPVOID); - HCTX (*WTOpenA) (HWND, LPLOGCONTEXTA, BOOL); - int (*WTPacket) (HCTX, UINT, LPVOID); - BOOL (*WTClose) (HCTX); -/* *INDENT-ON* */ - - int keyboard; const SDL_scancode *key_layout; } SDL_VideoData; diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c index f69d38573..fc1cd154f 100644 --- a/src/video/win32/SDL_win32window.c +++ b/src/video/win32/SDL_win32window.c @@ -73,9 +73,6 @@ CE_SHFullScreen(HWND hwndRequester, DWORD dwState) #endif -extern HCTX *g_hCtx; /* the table of tablet event contexts, each windows has to have it's own tablet context */ -static Uint32 highestId = 0; /* the highest id of the tablet context */ - /* Fake window to help with DirectInput events. */ HWND SDL_HelperWindow = NULL; static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); @@ -165,9 +162,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) } } if (GetFocus() == hwnd) { - int index = data->videodata->keyboard; window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(index, data->window); + SDL_SetKeyboardFocus(data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { RECT rect; @@ -186,11 +182,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) int WIN_CreateWindow(_THIS, SDL_Window * window) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_VideoDisplay *display = window->display; - RAWINPUTDEVICE Rid; - AXIS TabX, TabY; - LOGCONTEXTA lc; HWND hwnd; HWND top; RECT rect; @@ -257,48 +249,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) return -1; } - /* we're configuring the tablet data. See Wintab reference for more info */ - if (videodata->wintabDLL - && videodata->WTInfoA(WTI_DEFSYSCTX, 0, &lc) != 0) { - lc.lcPktData = PACKETDATA; - lc.lcPktMode = PACKETMODE; - lc.lcOptions |= CXO_MESSAGES; - lc.lcOptions |= CXO_SYSTEM; - lc.lcMoveMask = PACKETDATA; - lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA; - videodata->WTInfoA(WTI_DEVICES, DVC_X, &TabX); - videodata->WTInfoA(WTI_DEVICES, DVC_Y, &TabY); - lc.lcInOrgX = 0; - lc.lcInOrgY = 0; - lc.lcInExtX = TabX.axMax; - lc.lcInExtY = TabY.axMax; - lc.lcOutOrgX = 0; - lc.lcOutOrgY = 0; - lc.lcOutExtX = GetSystemMetrics(SM_CXSCREEN); - lc.lcOutExtY = -GetSystemMetrics(SM_CYSCREEN); - if (window->id > highestId) { - HCTX *tmp_hctx; - highestId = window->id; - tmp_hctx = - (HCTX *) SDL_realloc(g_hCtx, (highestId + 1) * sizeof(HCTX)); - if (!tmp_hctx) { - SDL_OutOfMemory(); - DestroyWindow(hwnd); - return -1; - } - g_hCtx = tmp_hctx; - } - g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE); - } -#ifndef _WIN32_WCE /* has no RawInput */ - /* we're telling the window, we want it to report raw input events from mice */ - Rid.usUsagePage = 0x01; - Rid.usUsage = 0x02; - Rid.dwFlags = RIDEV_INPUTSINK; - Rid.hwndTarget = hwnd; - RegisterRawInputDevices(&Rid, 1, sizeof(Rid)); -#endif - WIN_PumpEvents(_this); if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) { @@ -620,15 +570,11 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window) void WIN_DestroyWindow(_THIS, SDL_Window * window) { - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; if (data) { ReleaseDC(data->hwnd, data->hdc); if (data->created) { - if (videodata->wintabDLL) { - videodata->WTClose(g_hCtx[window->id]); - } DestroyWindow(data->hwnd); } SDL_free(data); diff --git a/src/video/win32/wactab/pktdef.h b/src/video/win32/wactab/pktdef.h deleted file mode 100644 index 4c8f573d8..000000000 --- a/src/video/win32/wactab/pktdef.h +++ /dev/null @@ -1,237 +0,0 @@ -/* *INDENT-OFF* */ -/* -------------------------------- pktdef.h -------------------------------- */ -/* Combined 16 & 32-bit version. */ - -/*------------------------------------------------------------------------------ -The text and information contained in this file may be freely used, -copied, or distributed without compensation or licensing restrictions. - -This file is copyright 1991-1998 by LCS/Telegraphics. -------------------------------------------------------------------------------*/ -/*------------------------------------------------------------------------------ - -How to use pktdef.h: - -1. Include wintab.h -2. if using just one packet format: - a. Define PACKETDATA and PACKETMODE as or'ed combinations of WTPKT bits - (use the PK_* identifiers). - b. Include pktdef.h. - c. The generated structure typedef will be called PACKET. Use PACKETDATA - and PACKETMODE to fill in the LOGCONTEXT structure. -3. If using multiple packet formats, for each one: - a. Define PACKETNAME. Its text value will be a prefix for this packet's - parameters and names. - b. Define PACKETDATA and PACKETMODE similar to - 2.a. above. - c. Include pktdef.h. - d. The generated structure typedef will be called - PACKET. Compare with 2.c. above and example #2 below. -4. If using extension packet data, do the following additional steps - for each extension: - a. Before including pktdef.h, define PACKET - as either PKEXT_ABSOLUTE or PKEXT_RELATIVE. - b. The generated structure typedef will contain a field for the - extension data. - c. Scan the WTI_EXTENSION categories to find the extension's - packet mask bit. - d. OR the packet mask bit with PACKETDATA and use the - result in the lcPktData field of the LOGCONTEXT structure. - e. If PACKET was PKEXT_RELATIVE, OR the - packet mask bit with PACKETMODE and use the result - in the lcPktMode field of the LOGCONTEXT structure. - - -Example #1. -- single packet format - -#include -#define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/ -#define PACKETMODE PK_BUTTONS /@ buttons relative mode @/ -#include -... - lc.lcPktData = PACKETDATA; - lc.lcPktMode = PACKETMODE; - -Example #2. -- multiple formats - -#include -#define PACKETNAME MOE -#define MOEPACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/ -#define MOEPACKETMODE PK_BUTTONS /@ buttons relative mode @/ -#include -#define PACKETNAME LARRY -#define LARRYPACKETDATA PK_Y | PK_Z | PK_BUTTONS /@ y, z, buttons @/ -#define LARRYPACKETMODE PK_BUTTONS /@ buttons relative mode @/ -#include -#define PACKETNAME CURLY -#define CURLYPACKETDATA PK_X | PK_Z | PK_BUTTONS /@ x, z, buttons @/ -#define CURLYPACKETMODE PK_BUTTONS /@ buttons relative mode @/ -#include -... - lcMOE.lcPktData = MOEPACKETDATA; - lcMOE.lcPktMode = MOEPACKETMODE; -... - lcLARRY.lcPktData = LARRYPACKETDATA; - lcLARRY.lcPktMode = LARRYPACKETMODE; -... - lcCURLY.lcPktData = CURLYPACKETDATA; - lcCURLY.lcPktMode = CURLYPACKETMODE; - -Example #3. -- extension packet data "XFOO". - -#include -#define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/ -#define PACKETMODE PK_BUTTONS /@ buttons relative mode @/ -#define PACKETXFOO PKEXT_ABSOLUTE /@ XFOO absolute mode @/ -#include -... -UINT ScanExts(UINT wTag) -{ - UINT i; - UINT wScanTag; - - /@ scan for wTag's info category. @/ - for (i = 0; WTInfo(WTI_EXTENSIONS + i, EXT_TAG, &wScanTag); i++) { - if (wTag == wScanTag) { - /@ return category offset from WTI_EXTENSIONS. @/ - return i; - } - } - /@ return error code. @/ - return 0xFFFF; -} -... - lc.lcPktData = PACKETDATA; - lc.lcPktMode = PACKETMODE; -#ifdef PACKETXFOO - categoryXFOO = ScanExts(WTX_XFOO); - WTInfo(WTI_EXTENSIONS + categoryXFOO, EXT_MASK, &maskXFOO); - lc.lcPktData |= maskXFOO; -#if PACKETXFOO == PKEXT_RELATIVE - lc.lcPktMode |= maskXFOO; -#endif -#endif - WTOpen(hWnd, &lc, TRUE); - - -------------------------------------------------------------------------------*/ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef PACKETNAME - /* if no packet name prefix */ - #define __PFX(x) x - #define __IFX(x,y) x ## y -#else - /* add prefixes and infixes to packet format names */ - #define __PFX(x) __PFX2(PACKETNAME,x) - #define __PFX2(p,x) __PFX3(p,x) - #define __PFX3(p,x) p ## x - #define __IFX(x,y) __IFX2(x,PACKETNAME,y) - #define __IFX2(x,i,y) __IFX3(x,i,y) - #define __IFX3(x,i,y) x ## i ## y -#endif - -#define __SFX2(x,s) __SFX3(x,s) -#define __SFX3(x,s) x ## s - -#define __TAG __IFX(tag,PACKET) -#define __TYPES __PFX(PACKET), * __IFX(P,PACKET), NEAR * __IFX(NP,PACKET), \ - FAR * __IFX(LP,PACKET) - -#define __DATA (__PFX(PACKETDATA)) -#define __MODE (__PFX(PACKETMODE)) -#define __EXT(x) __SFX2(__PFX(PACKET),x) - - -typedef struct __TAG { - #if (__DATA & PK_CONTEXT) - HCTX pkContext; - #endif - #if (__DATA & PK_STATUS) - UINT pkStatus; - #endif - #if (__DATA & PK_TIME) - DWORD pkTime; - #endif - #if (__DATA & PK_CHANGED) - WTPKT pkChanged; - #endif - #if (__DATA & PK_SERIAL_NUMBER) - UINT pkSerialNumber; - #endif - #if (__DATA & PK_CURSOR) - UINT pkCursor; - #endif - #if (__DATA & PK_BUTTONS) - DWORD pkButtons; - #endif - #if (__DATA & PK_X) - LONG pkX; - #endif - #if (__DATA & PK_Y) - LONG pkY; - #endif - #if (__DATA & PK_Z) - LONG pkZ; - #endif - #if (__DATA & PK_NORMAL_PRESSURE) - #if (__MODE & PK_NORMAL_PRESSURE) - /* relative */ - int pkNormalPressure; - #else - /* absolute */ - UINT pkNormalPressure; - #endif - #endif - #if (__DATA & PK_TANGENT_PRESSURE) - #if (__MODE & PK_TANGENT_PRESSURE) - /* relative */ - int pkTangentPressure; - #else - /* absolute */ - UINT pkTangentPressure; - #endif - #endif - #if (__DATA & PK_ORIENTATION) - ORIENTATION pkOrientation; - #endif - #if (__DATA & PK_ROTATION) - ROTATION pkRotation; /* 1.1 */ - #endif - -#ifndef NOWTEXTENSIONS - /* extensions begin here. */ - #if (__EXT(FKEYS) == PKEXT_RELATIVE) || (__EXT(FKEYS) == PKEXT_ABSOLUTE) - UINT pkFKeys; - #endif - #if (__EXT(TILT) == PKEXT_RELATIVE) || (__EXT(TILT) == PKEXT_ABSOLUTE) - TILT pkTilt; - #endif - #if (__EXT(EXPKEYS) == PKEXT_RELATIVE) || (__EXT(EXPKEYS) == PKEXT_ABSOLUTE) - WORD pkExpKeys[4]; /* 1.3 */ - #endif -#endif - -} __TYPES ; - -#undef PACKETNAME -#undef __TAG -#undef __TAG2 -#undef __TYPES -#undef __TYPES2 -#undef __DATA -#undef __MODE -#undef __PFX -#undef __PFX2 -#undef __PFX3 -#undef __IFX -#undef __IFX2 -#undef __IFX3 -#undef __SFX2 -#undef __SFX3 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ diff --git a/src/video/win32/wactab/wintab.h b/src/video/win32/wactab/wintab.h deleted file mode 100644 index d1f495e8e..000000000 --- a/src/video/win32/wactab/wintab.h +++ /dev/null @@ -1,866 +0,0 @@ -/* *INDENT-OFF* */ -/* -------------------------------- wintab.h -------------------------------- */ -/* Combined 16 & 32-bit version. */ - -/*------------------------------------------------------------------------------ -The text and information contained in this file may be freely used, -copied, or distributed without compensation or licensing restrictions. - -This file is copyright 1991-1998 by LCS/Telegraphics. -------------------------------------------------------------------------------*/ - -#ifndef _INC_WINTAB /* prevent multiple includes */ -#define _INC_WINTAB - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* -------------------------------------------------------------------------- */ -/* Messages */ -#ifndef NOWTMESSAGES - - #define WT_DEFBASE 0x7FF0 - #define WT_MAXOFFSET 0xF - - #define _WT_PACKET(b) ((b)+0) - #define _WT_CTXOPEN(b) ((b)+1) - #define _WT_CTXCLOSE(b) ((b)+2) - #define _WT_CTXUPDATE(b) ((b)+3) - #define _WT_CTXOVERLAP(b) ((b)+4) - #define _WT_PROXIMITY(b) ((b)+5) - #define _WT_INFOCHANGE(b) ((b)+6) - #define _WT_CSRCHANGE(b) ((b)+7) /* 1.1 */ - #define _WT_MAX(b) ((b)+WT_MAXOFFSET) - - #define WT_PACKET _WT_PACKET(WT_DEFBASE) - #define WT_CTXOPEN _WT_CTXOPEN(WT_DEFBASE) - #define WT_CTXCLOSE _WT_CTXCLOSE(WT_DEFBASE) - #define WT_CTXUPDATE _WT_CTXUPDATE(WT_DEFBASE) - #define WT_CTXOVERLAP _WT_CTXOVERLAP(WT_DEFBASE) - #define WT_PROXIMITY _WT_PROXIMITY(WT_DEFBASE) - #define WT_INFOCHANGE _WT_INFOCHANGE(WT_DEFBASE) - #define WT_CSRCHANGE _WT_CSRCHANGE(WT_DEFBASE) /* 1.1 */ - #define WT_MAX _WT_MAX(WT_DEFBASE) - -#endif - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* Data Types */ - -/* -------------------------------------------------------------------------- */ -/* COMMON DATA DEFS */ - -DECLARE_HANDLE(HMGR); /* manager handle */ -DECLARE_HANDLE(HCTX); /* context handle */ -DECLARE_HANDLE(HWTHOOK); /* hook handle */ - -typedef DWORD WTPKT; /* packet mask */ - - -#ifndef NOWTPKT - - /* WTPKT bits */ - #define PK_CONTEXT 0x0001 /* reporting context */ - #define PK_STATUS 0x0002 /* status bits */ - #define PK_TIME 0x0004 /* time stamp */ - #define PK_CHANGED 0x0008 /* change bit vector */ - #define PK_SERIAL_NUMBER 0x0010 /* packet serial number */ - #define PK_CURSOR 0x0020 /* reporting cursor */ - #define PK_BUTTONS 0x0040 /* button information */ - #define PK_X 0x0080 /* x axis */ - #define PK_Y 0x0100 /* y axis */ - #define PK_Z 0x0200 /* z axis */ - #define PK_NORMAL_PRESSURE 0x0400 /* normal or tip pressure */ - #define PK_TANGENT_PRESSURE 0x0800 /* tangential or barrel pressure */ - #define PK_ORIENTATION 0x1000 /* orientation info: tilts */ - #define PK_ROTATION 0x2000 /* rotation info; 1.1 */ - -#endif - -typedef DWORD FIX32; /* fixed-point arithmetic type */ - -#ifndef NOFIX32 - #define INT(x) HIWORD(x) - #define FRAC(x) LOWORD(x) - - #define CASTFIX32(x) ((FIX32)((x)*65536L)) - - #define ROUND(x) (INT(x) + (FRAC(x) > (WORD)0x8000)) - - #define FIX_MUL(c, a, b) \ - (c = (((DWORD)FRAC(a) * FRAC(b)) >> 16) + \ - (DWORD)INT(a) * FRAC(b) + \ - (DWORD)INT(b) * FRAC(a) + \ - ((DWORD)INT(a) * INT(b) << 16)) - - #ifdef _WINDLL - #define FIX_DIV_SC static - #else - #define FIX_DIV_SC - #endif - - #define FIX_DIV(c, a, b) \ - { \ - FIX_DIV_SC DWORD temp, rem, btemp; \ - \ - /* fraction done bytewise */ \ - temp = ((a / b) << 16); \ - rem = a % b; \ - btemp = b; \ - if (INT(btemp) < 256) { \ - rem <<= 8; \ - } \ - else { \ - btemp >>= 8; \ - } \ - temp += ((rem / btemp) << 8); \ - rem %= btemp; \ - rem <<= 8; \ - temp += rem / btemp; \ - c = temp; \ - } -#endif - -/* -------------------------------------------------------------------------- */ -/* INFO DATA DEFS */ - -#ifndef NOWTINFO - -#ifndef NOWTAXIS - -typedef struct tagAXIS { - LONG axMin; - LONG axMax; - UINT axUnits; - FIX32 axResolution; -} AXIS, *PAXIS, NEAR *NPAXIS, FAR *LPAXIS; - - /* unit specifiers */ - #define TU_NONE 0 - #define TU_INCHES 1 - #define TU_CENTIMETERS 2 - #define TU_CIRCLE 3 - -#endif - -#ifndef NOWTSYSBUTTONS - -/* system button assignment values */ -#define SBN_NONE 0x00 -#define SBN_LCLICK 0x01 -#define SBN_LDBLCLICK 0x02 -#define SBN_LDRAG 0x03 -#define SBN_RCLICK 0x04 -#define SBN_RDBLCLICK 0x05 -#define SBN_RDRAG 0x06 -#define SBN_MCLICK 0x07 -#define SBN_MDBLCLICK 0x08 -#define SBN_MDRAG 0x09 -/* for Pen Windows */ -#define SBN_PTCLICK 0x10 -#define SBN_PTDBLCLICK 0x20 -#define SBN_PTDRAG 0x30 -#define SBN_PNCLICK 0x40 -#define SBN_PNDBLCLICK 0x50 -#define SBN_PNDRAG 0x60 -#define SBN_P1CLICK 0x70 -#define SBN_P1DBLCLICK 0x80 -#define SBN_P1DRAG 0x90 -#define SBN_P2CLICK 0xA0 -#define SBN_P2DBLCLICK 0xB0 -#define SBN_P2DRAG 0xC0 -#define SBN_P3CLICK 0xD0 -#define SBN_P3DBLCLICK 0xE0 -#define SBN_P3DRAG 0xF0 - -#endif - -#ifndef NOWTCAPABILITIES - -/* hardware capabilities */ -#define HWC_INTEGRATED 0x0001 -#define HWC_TOUCH 0x0002 -#define HWC_HARDPROX 0x0004 -#define HWC_PHYSID_CURSORS 0x0008 /* 1.1 */ -#endif - -#ifndef NOWTIFC - -#ifndef NOWTCURSORS - -/* cursor capabilities */ -#define CRC_MULTIMODE 0x0001 /* 1.1 */ -#define CRC_AGGREGATE 0x0002 /* 1.1 */ -#define CRC_INVERT 0x0004 /* 1.1 */ - -#endif - -/* info categories */ -#define WTI_INTERFACE 1 - #define IFC_WINTABID 1 - #define IFC_SPECVERSION 2 - #define IFC_IMPLVERSION 3 - #define IFC_NDEVICES 4 - #define IFC_NCURSORS 5 - #define IFC_NCONTEXTS 6 - #define IFC_CTXOPTIONS 7 - #define IFC_CTXSAVESIZE 8 - #define IFC_NEXTENSIONS 9 - #define IFC_NMANAGERS 10 - #define IFC_MAX 10 - - -#endif - -#ifndef NOWTSTATUS - -#define WTI_STATUS 2 - #define STA_CONTEXTS 1 - #define STA_SYSCTXS 2 - #define STA_PKTRATE 3 - #define STA_PKTDATA 4 - #define STA_MANAGERS 5 - #define STA_SYSTEM 6 - #define STA_BUTTONUSE 7 - #define STA_SYSBTNUSE 8 - #define STA_MAX 8 - -#endif - -#ifndef NOWTDEFCONTEXT - -#define WTI_DEFCONTEXT 3 -#define WTI_DEFSYSCTX 4 -#define WTI_DDCTXS 400 /* 1.1 */ -#define WTI_DSCTXS 500 /* 1.1 */ - #define CTX_NAME 1 - #define CTX_OPTIONS 2 - #define CTX_STATUS 3 - #define CTX_LOCKS 4 - #define CTX_MSGBASE 5 - #define CTX_DEVICE 6 - #define CTX_PKTRATE 7 - #define CTX_PKTDATA 8 - #define CTX_PKTMODE 9 - #define CTX_MOVEMASK 10 - #define CTX_BTNDNMASK 11 - #define CTX_BTNUPMASK 12 - #define CTX_INORGX 13 - #define CTX_INORGY 14 - #define CTX_INORGZ 15 - #define CTX_INEXTX 16 - #define CTX_INEXTY 17 - #define CTX_INEXTZ 18 - #define CTX_OUTORGX 19 - #define CTX_OUTORGY 20 - #define CTX_OUTORGZ 21 - #define CTX_OUTEXTX 22 - #define CTX_OUTEXTY 23 - #define CTX_OUTEXTZ 24 - #define CTX_SENSX 25 - #define CTX_SENSY 26 - #define CTX_SENSZ 27 - #define CTX_SYSMODE 28 - #define CTX_SYSORGX 29 - #define CTX_SYSORGY 30 - #define CTX_SYSEXTX 31 - #define CTX_SYSEXTY 32 - #define CTX_SYSSENSX 33 - #define CTX_SYSSENSY 34 - #define CTX_MAX 34 - -#endif - -#ifndef NOWTDEVICES - -#define WTI_DEVICES 100 - #define DVC_NAME 1 - #define DVC_HARDWARE 2 - #define DVC_NCSRTYPES 3 - #define DVC_FIRSTCSR 4 - #define DVC_PKTRATE 5 - #define DVC_PKTDATA 6 - #define DVC_PKTMODE 7 - #define DVC_CSRDATA 8 - #define DVC_XMARGIN 9 - #define DVC_YMARGIN 10 - #define DVC_ZMARGIN 11 - #define DVC_X 12 - #define DVC_Y 13 - #define DVC_Z 14 - #define DVC_NPRESSURE 15 - #define DVC_TPRESSURE 16 - #define DVC_ORIENTATION 17 - #define DVC_ROTATION 18 /* 1.1 */ - #define DVC_PNPID 19 /* 1.1 */ - #define DVC_MAX 19 - -#endif - -#ifndef NOWTCURSORS - -#define WTI_CURSORS 200 - #define CSR_NAME 1 - #define CSR_ACTIVE 2 - #define CSR_PKTDATA 3 - #define CSR_BUTTONS 4 - #define CSR_BUTTONBITS 5 - #define CSR_BTNNAMES 6 - #define CSR_BUTTONMAP 7 - #define CSR_SYSBTNMAP 8 - #define CSR_NPBUTTON 9 - #define CSR_NPBTNMARKS 10 - #define CSR_NPRESPONSE 11 - #define CSR_TPBUTTON 12 - #define CSR_TPBTNMARKS 13 - #define CSR_TPRESPONSE 14 - #define CSR_PHYSID 15 /* 1.1 */ - #define CSR_MODE 16 /* 1.1 */ - #define CSR_MINPKTDATA 17 /* 1.1 */ - #define CSR_MINBUTTONS 18 /* 1.1 */ - #define CSR_CAPABILITIES 19 /* 1.1 */ - #define CSR_TYPE 20 /* 1.2 */ - #define CSR_MAX 20 - -#endif - -#ifndef NOWTEXTENSIONS - -#define WTI_EXTENSIONS 300 - #define EXT_NAME 1 - #define EXT_TAG 2 - #define EXT_MASK 3 - #define EXT_SIZE 4 - #define EXT_AXES 5 - #define EXT_DEFAULT 6 - #define EXT_DEFCONTEXT 7 - #define EXT_DEFSYSCTX 8 - #define EXT_CURSORS 9 - #define EXT_MAX 109 /* Allow 100 cursors */ - -#endif - -#endif - -/* -------------------------------------------------------------------------- */ -/* CONTEXT DATA DEFS */ - -#define LCNAMELEN 40 -#define LC_NAMELEN 40 -#ifdef WIN32 -typedef struct tagLOGCONTEXTA { - char lcName[LCNAMELEN]; - UINT lcOptions; - UINT lcStatus; - UINT lcLocks; - UINT lcMsgBase; - UINT lcDevice; - UINT lcPktRate; - WTPKT lcPktData; - WTPKT lcPktMode; - WTPKT lcMoveMask; - DWORD lcBtnDnMask; - DWORD lcBtnUpMask; - LONG lcInOrgX; - LONG lcInOrgY; - LONG lcInOrgZ; - LONG lcInExtX; - LONG lcInExtY; - LONG lcInExtZ; - LONG lcOutOrgX; - LONG lcOutOrgY; - LONG lcOutOrgZ; - LONG lcOutExtX; - LONG lcOutExtY; - LONG lcOutExtZ; - FIX32 lcSensX; - FIX32 lcSensY; - FIX32 lcSensZ; - BOOL lcSysMode; - int lcSysOrgX; - int lcSysOrgY; - int lcSysExtX; - int lcSysExtY; - FIX32 lcSysSensX; - FIX32 lcSysSensY; -} LOGCONTEXTA, *PLOGCONTEXTA, NEAR *NPLOGCONTEXTA, FAR *LPLOGCONTEXTA; -typedef struct tagLOGCONTEXTW { - WCHAR lcName[LCNAMELEN]; - UINT lcOptions; - UINT lcStatus; - UINT lcLocks; - UINT lcMsgBase; - UINT lcDevice; - UINT lcPktRate; - WTPKT lcPktData; - WTPKT lcPktMode; - WTPKT lcMoveMask; - DWORD lcBtnDnMask; - DWORD lcBtnUpMask; - LONG lcInOrgX; - LONG lcInOrgY; - LONG lcInOrgZ; - LONG lcInExtX; - LONG lcInExtY; - LONG lcInExtZ; - LONG lcOutOrgX; - LONG lcOutOrgY; - LONG lcOutOrgZ; - LONG lcOutExtX; - LONG lcOutExtY; - LONG lcOutExtZ; - FIX32 lcSensX; - FIX32 lcSensY; - FIX32 lcSensZ; - BOOL lcSysMode; - int lcSysOrgX; - int lcSysOrgY; - int lcSysExtX; - int lcSysExtY; - FIX32 lcSysSensX; - FIX32 lcSysSensY; -} LOGCONTEXTW, *PLOGCONTEXTW, NEAR *NPLOGCONTEXTW, FAR *LPLOGCONTEXTW; -#ifdef UNICODE -typedef LOGCONTEXTW LOGCONTEXT; -typedef PLOGCONTEXTW PLOGCONTEXT; -typedef NPLOGCONTEXTW NPLOGCONTEXT; -typedef LPLOGCONTEXTW LPLOGCONTEXT; -#else -typedef LOGCONTEXTA LOGCONTEXT; -typedef PLOGCONTEXTA PLOGCONTEXT; -typedef NPLOGCONTEXTA NPLOGCONTEXT; -typedef LPLOGCONTEXTA LPLOGCONTEXT; -#endif /* UNICODE */ -#else /* WIN32 */ -typedef struct tagLOGCONTEXT { - char lcName[LCNAMELEN]; - UINT lcOptions; - UINT lcStatus; - UINT lcLocks; - UINT lcMsgBase; - UINT lcDevice; - UINT lcPktRate; - WTPKT lcPktData; - WTPKT lcPktMode; - WTPKT lcMoveMask; - DWORD lcBtnDnMask; - DWORD lcBtnUpMask; - LONG lcInOrgX; - LONG lcInOrgY; - LONG lcInOrgZ; - LONG lcInExtX; - LONG lcInExtY; - LONG lcInExtZ; - LONG lcOutOrgX; - LONG lcOutOrgY; - LONG lcOutOrgZ; - LONG lcOutExtX; - LONG lcOutExtY; - LONG lcOutExtZ; - FIX32 lcSensX; - FIX32 lcSensY; - FIX32 lcSensZ; - BOOL lcSysMode; - int lcSysOrgX; - int lcSysOrgY; - int lcSysExtX; - int lcSysExtY; - FIX32 lcSysSensX; - FIX32 lcSysSensY; -} LOGCONTEXT, *PLOGCONTEXT, NEAR *NPLOGCONTEXT, FAR *LPLOGCONTEXT; -#endif /* WIN32 */ - - /* context option values */ - #define CXO_SYSTEM 0x0001 - #define CXO_PEN 0x0002 - #define CXO_MESSAGES 0x0004 - #define CXO_MARGIN 0x8000 - #define CXO_MGNINSIDE 0x4000 - #define CXO_CSRMESSAGES 0x0008 /* 1.1 */ - - /* context status values */ - #define CXS_DISABLED 0x0001 - #define CXS_OBSCURED 0x0002 - #define CXS_ONTOP 0x0004 - - /* context lock values */ - #define CXL_INSIZE 0x0001 - #define CXL_INASPECT 0x0002 - #define CXL_SENSITIVITY 0x0004 - #define CXL_MARGIN 0x0008 - #define CXL_SYSOUT 0x0010 - -/* -------------------------------------------------------------------------- */ -/* EVENT DATA DEFS */ - -/* For packet structure definition, see pktdef.h */ - -/* packet status values */ -#define TPS_PROXIMITY 0x0001 -#define TPS_QUEUE_ERR 0x0002 -#define TPS_MARGIN 0x0004 -#define TPS_GRAB 0x0008 -#define TPS_INVERT 0x0010 /* 1.1 */ - -typedef struct tagORIENTATION { - int orAzimuth; - int orAltitude; - int orTwist; -} ORIENTATION, *PORIENTATION, NEAR *NPORIENTATION, FAR *LPORIENTATION; - -typedef struct tagROTATION { /* 1.1 */ - int roPitch; - int roRoll; - int roYaw; -} ROTATION, *PROTATION, NEAR *NPROTATION, FAR *LPROTATION; -// grandfather in obsolete member names. -#define rotPitch roPitch -#define rotRoll roRoll -#define rotYaw roYaw - -/* relative buttons */ -#define TBN_NONE 0 -#define TBN_UP 1 -#define TBN_DOWN 2 - -/* -------------------------------------------------------------------------- */ -/* DEVICE CONFIG CONSTANTS */ - -#ifndef NOWTDEVCFG - -#define WTDC_NONE 0 -#define WTDC_CANCEL 1 -#define WTDC_OK 2 -#define WTDC_RESTART 3 - -#endif - -/* -------------------------------------------------------------------------- */ -/* HOOK CONSTANTS */ - -#ifndef NOWTHOOKS - -#define WTH_PLAYBACK 1 -#define WTH_RECORD 2 - -#define WTHC_GETLPLPFN (-3) -#define WTHC_LPLPFNNEXT (-2) -#define WTHC_LPFNNEXT (-1) -#define WTHC_ACTION 0 -#define WTHC_GETNEXT 1 -#define WTHC_SKIP 2 - -#endif - -/* -------------------------------------------------------------------------- */ -/* PREFERENCE FUNCTION CONSTANTS */ - -#ifndef NOWTPREF - -#define WTP_LPDEFAULT ((LPVOID)-1L) -#define WTP_DWDEFAULT ((DWORD)-1L) - -#endif - -/* -------------------------------------------------------------------------- */ -/* EXTENSION TAGS AND CONSTANTS */ - -#ifndef NOWTEXTENSIONS - -/* constants for use with pktdef.h */ -#define PKEXT_ABSOLUTE 1 -#define PKEXT_RELATIVE 2 - -/* Extension tags. */ -#define WTX_OBT 0 /* Out of bounds tracking */ -#define WTX_FKEYS 1 /* Function keys */ -#define WTX_TILT 2 /* Raw Cartesian tilt; 1.1 */ -#define WTX_CSRMASK 3 /* select input by cursor type; 1.1 */ -#define WTX_XBTNMASK 4 /* Extended button mask; 1.1 */ -#define WTX_EXPKEYS 5 /* ExpressKeys; 1.3 */ - -typedef struct tagXBTNMASK { - BYTE xBtnDnMask[32]; - BYTE xBtnUpMask[32]; -} XBTNMASK; - -typedef struct tagTILT { /* 1.1 */ - int tiltX; - int tiltY; -} TILT; - -#endif - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* Functions */ - - #ifndef API - #ifndef WINAPI - #define API FAR PASCAL - #else - #define API WINAPI - #endif - #endif - -#ifndef NOWTCALLBACKS - - #ifndef CALLBACK - #define CALLBACK FAR PASCAL - #endif - - #ifndef NOWTMANAGERFXNS - /* callback function types */ - typedef BOOL (WINAPI * WTENUMPROC)(HCTX, LPARAM); /* changed CALLBACK->WINAPI, 1.1 */ - typedef BOOL (WINAPI * WTCONFIGPROC)(HCTX, HWND); - typedef LRESULT (WINAPI * WTHOOKPROC)(int, WPARAM, LPARAM); - typedef WTHOOKPROC FAR *LPWTHOOKPROC; - #endif - -#endif - - -#ifndef NOWTFUNCTIONS - - #ifndef NOWTBASICFXNS - /* BASIC FUNCTIONS */ -#ifdef WIN32 - UINT API WTInfoA(UINT, UINT, LPVOID); - #define ORD_WTInfoA 20 - UINT API WTInfoW(UINT, UINT, LPVOID); - #define ORD_WTInfoW 1020 - #ifdef UNICODE - #define WTInfo WTInfoW - #define ORD_WTInfo ORD_WTInfoW - #else - #define WTInfo WTInfoA - #define ORD_WTInfo ORD_WTInfoA - #endif /* !UNICODE */ -#else - UINT API WTInfo(UINT, UINT, LPVOID); - #define ORD_WTInfo 20 -#endif -#ifdef WIN32 - HCTX API WTOpenA(HWND, LPLOGCONTEXTA, BOOL); - #define ORD_WTOpenA 21 - HCTX API WTOpenW(HWND, LPLOGCONTEXTW, BOOL); - #define ORD_WTOpenW 1021 - #ifdef UNICODE - #define WTOpen WTOpenW - #define ORD_WTOpen ORD_WTOpenW - #else - #define WTOpen WTOpenA - #define ORD_WTOpen ORD_WTOpenA - #endif /* !UNICODE */ -#else - HCTX API WTOpen(HWND, LPLOGCONTEXT, BOOL); - #define ORD_WTOpen 21 -#endif - BOOL API WTClose(HCTX); - #define ORD_WTClose 22 - int API WTPacketsGet(HCTX, int, LPVOID); - #define ORD_WTPacketsGet 23 - BOOL API WTPacket(HCTX, UINT, LPVOID); - #define ORD_WTPacket 24 - #endif - - #ifndef NOWTVISIBILITYFXNS - /* VISIBILITY FUNCTIONS */ - BOOL API WTEnable(HCTX, BOOL); - #define ORD_WTEnable 40 - BOOL API WTOverlap(HCTX, BOOL); - #define ORD_WTOverlap 41 - #endif - - #ifndef NOWTCTXEDITFXNS - /* CONTEXT EDITING FUNCTIONS */ - BOOL API WTConfig(HCTX, HWND); - #define ORD_WTConfig 60 -#ifdef WIN32 - BOOL API WTGetA(HCTX, LPLOGCONTEXTA); - #define ORD_WTGetA 61 - BOOL API WTGetW(HCTX, LPLOGCONTEXTW); - #define ORD_WTGetW 1061 - #ifdef UNICODE - #define WTGet WTGetW - #define ORD_WTGet ORD_WTGetW - #else - #define WTGet WTGetA - #define ORD_WTGet ORD_WTGetA - #endif /* !UNICODE */ -#else - BOOL API WTGet(HCTX, LPLOGCONTEXT); - #define ORD_WTGet 61 -#endif -#ifdef WIN32 - BOOL API WTSetA(HCTX, LPLOGCONTEXTA); - #define ORD_WTSetA 62 - BOOL API WTSetW(HCTX, LPLOGCONTEXTW); - #define ORD_WTSetW 1062 - #ifdef UNICODE - #define WTSet WTSetW - #define ORD_WTSet ORD_WTSetW - #else - #define WTSet WTSetA - #define ORD_WTSet ORD_WTSetA - #endif /* !UNICODE */ -#else - BOOL API WTSet(HCTX, LPLOGCONTEXT); - #define ORD_WTSet 62 -#endif - BOOL API WTExtGet(HCTX, UINT, LPVOID); - #define ORD_WTExtGet 63 - BOOL API WTExtSet(HCTX, UINT, LPVOID); - #define ORD_WTExtSet 64 - BOOL API WTSave(HCTX, LPVOID); - #define ORD_WTSave 65 - HCTX API WTRestore(HWND, LPVOID, BOOL); - #define ORD_WTRestore 66 - #endif - - #ifndef NOWTQUEUEFXNS - /* ADVANCED PACKET AND QUEUE FUNCTIONS */ - int API WTPacketsPeek(HCTX, int, LPVOID); - #define ORD_WTPacketsPeek 80 - int API WTDataGet(HCTX, UINT, UINT, int, LPVOID, LPINT); - #define ORD_WTDataGet 81 - int API WTDataPeek(HCTX, UINT, UINT, int, LPVOID, LPINT); - #define ORD_WTDataPeek 82 -#ifndef WIN32 -/* OBSOLETE IN WIN32! */ - DWORD API WTQueuePackets(HCTX); - #define ORD_WTQueuePackets 83 -#endif - int API WTQueueSizeGet(HCTX); - #define ORD_WTQueueSizeGet 84 - BOOL API WTQueueSizeSet(HCTX, int); - #define ORD_WTQueueSizeSet 85 - #endif - - #ifndef NOWTHMGRFXNS - /* MANAGER HANDLE FUNCTIONS */ - HMGR API WTMgrOpen(HWND, UINT); - #define ORD_WTMgrOpen 100 - BOOL API WTMgrClose(HMGR); - #define ORD_WTMgrClose 101 - #endif - - #ifndef NOWTMGRCTXFXNS - /* MANAGER CONTEXT FUNCTIONS */ - BOOL API WTMgrContextEnum(HMGR, WTENUMPROC, LPARAM); - #define ORD_WTMgrContextEnum 120 - HWND API WTMgrContextOwner(HMGR, HCTX); - #define ORD_WTMgrContextOwner 121 - HCTX API WTMgrDefContext(HMGR, BOOL); - #define ORD_WTMgrDefContext 122 - HCTX API WTMgrDefContextEx(HMGR, UINT, BOOL); /* 1.1 */ - #define ORD_WTMgrDefContextEx 206 - #endif - - #ifndef NOWTMGRCONFIGFXNS - /* MANAGER CONFIG BOX FUNCTIONS */ - UINT API WTMgrDeviceConfig(HMGR, UINT, HWND); - #define ORD_WTMgrDeviceConfig 140 -#ifndef WIN32 -/* OBSOLETE IN WIN32! */ - BOOL API WTMgrConfigReplace(HMGR, BOOL, WTCONFIGPROC); - #define ORD_WTMgrConfigReplace 141 -#endif - #endif - - #ifndef NOWTMGRHOOKFXNS - /* MANAGER PACKET HOOK FUNCTIONS */ -#ifndef WIN32 -/* OBSOLETE IN WIN32! */ - WTHOOKPROC API WTMgrPacketHook(HMGR, BOOL, int, WTHOOKPROC); - #define ORD_WTMgrPacketHook 160 - LRESULT API WTMgrPacketHookDefProc(int, WPARAM, LPARAM, LPWTHOOKPROC); - #define ORD_WTMgrPacketHookDefProc 161 -#endif - #endif - - #ifndef NOWTMGRPREFFXNS - /* MANAGER PREFERENCE DATA FUNCTIONS */ - BOOL API WTMgrExt(HMGR, UINT, LPVOID); - #define ORD_WTMgrExt 180 - BOOL API WTMgrCsrEnable(HMGR, UINT, BOOL); - #define ORD_WTMgrCsrEnable 181 - BOOL API WTMgrCsrButtonMap(HMGR, UINT, LPBYTE, LPBYTE); - #define ORD_WTMgrCsrButtonMap 182 - BOOL API WTMgrCsrPressureBtnMarks(HMGR, UINT, DWORD, DWORD); - #define ORD_WTMgrCsrPressureBtnMarks 183 - BOOL API WTMgrCsrPressureResponse(HMGR, UINT, UINT FAR *, UINT FAR *); - #define ORD_WTMgrCsrPressureResponse 184 - BOOL API WTMgrCsrExt(HMGR, UINT, UINT, LPVOID); - #define ORD_WTMgrCsrExt 185 - #endif - -/* Win32 replacements for non-portable functions. */ - #ifndef NOWTQUEUEFXNS - /* ADVANCED PACKET AND QUEUE FUNCTIONS */ - BOOL API WTQueuePacketsEx(HCTX, UINT FAR *, UINT FAR *); - #define ORD_WTQueuePacketsEx 200 - #endif - - #ifndef NOWTMGRCONFIGFXNS - /* MANAGER CONFIG BOX FUNCTIONS */ -#ifdef WIN32 - BOOL API WTMgrConfigReplaceExA(HMGR, BOOL, LPSTR, LPSTR); - #define ORD_WTMgrConfigReplaceExA 202 - BOOL API WTMgrConfigReplaceExW(HMGR, BOOL, LPWSTR, LPSTR); - #define ORD_WTMgrConfigReplaceExW 1202 - #ifdef UNICODE - #define WTMgrConfigReplaceEx WTMgrConfigReplaceExW - #define ORD_WTMgrConfigReplaceEx ORD_WTMgrConfigReplaceExW - #else - #define WTMgrConfigReplaceEx WTMgrConfigReplaceExA - #define ORD_WTMgrConfigReplaceEx ORD_WTMgrConfigReplaceExA - #endif /* !UNICODE */ -#else - BOOL API WTMgrConfigReplaceEx(HMGR, BOOL, LPSTR, LPSTR); - #define ORD_WTMgrConfigReplaceEx 202 -#endif - #endif - - #ifndef NOWTMGRHOOKFXNS - /* MANAGER PACKET HOOK FUNCTIONS */ -#ifdef WIN32 - HWTHOOK API WTMgrPacketHookExA(HMGR, int, LPSTR, LPSTR); - #define ORD_WTMgrPacketHookExA 203 - HWTHOOK API WTMgrPacketHookExW(HMGR, int, LPWSTR, LPSTR); - #define ORD_WTMgrPacketHookExW 1203 - #ifdef UNICODE - #define WTMgrPacketHookEx WTMgrPacketHookExW - #define ORD_WTMgrPacketHookEx ORD_WTMgrPacketHookExW - #else - #define WTMgrPacketHookEx WTMgrPacketHookExA - #define ORD_WTMgrPacketHookEx ORD_WTMgrPacketHookExA - #endif /* !UNICODE */ -#else - HWTHOOK API WTMgrPacketHookEx(HMGR, int, LPSTR, LPSTR); - #define ORD_WTMgrPacketHookEx 203 -#endif - BOOL API WTMgrPacketUnhook(HWTHOOK); - #define ORD_WTMgrPacketUnhook 204 - LRESULT API WTMgrPacketHookNext(HWTHOOK, int, WPARAM, LPARAM); - #define ORD_WTMgrPacketHookNext 205 - #endif - - #ifndef NOWTMGRPREFFXNS - /* MANAGER PREFERENCE DATA FUNCTIONS */ - BOOL API WTMgrCsrPressureBtnMarksEx(HMGR, UINT, UINT FAR *, UINT FAR *); - #define ORD_WTMgrCsrPressureBtnMarksEx 201 - #endif - - - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* #define _INC_WINTAB */ - diff --git a/src/video/win32/wactab/wintabx.h b/src/video/win32/wactab/wintabx.h deleted file mode 100644 index 7bd4ef18e..000000000 --- a/src/video/win32/wactab/wintabx.h +++ /dev/null @@ -1,136 +0,0 @@ -/* *INDENT-OFF* */ -/* ------------------------------- wintabx.h -------------------------------- */ -/* Combined 16 & 32-bit version. */ - - -/*------------------------------------------------------------------------------ -The text and information contained in this file may be freely used, -copied, or distributed without compensation or licensing restrictions. - -This file is copyright 1991-1998 by LCS/Telegraphics. -------------------------------------------------------------------------------*/ - -#ifndef _INC_WINTABX /* prevent multiple includes */ -#define _INC_WINTABX - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* prototype for wintabx.lib. */ -#define _UnlinkWinTab _UnlinkWintab -#ifdef WIN32 - extern WINAPI _UnlinkWintab(void); -#else - extern FAR _UnlinkWintab(void); -#endif - -/****** Wintab message crackers ***********************************************/ - -#ifndef HANDLE_MSG -#define HANDLE_MSG(hwnd, message, fn) \ - case (message): return HANDLE_##message((hwnd), (wParam), (lParam), (fn)) -#endif - -/* void Cls_OnWintabPacket(HWND hwnd, HCTX hCtx, UINT sn) */ -#define HANDLE_WT_PACKET(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HCTX)(lParam), (UINT)(wParam)), 0L) -#define FORWARD__WT_PACKET(hwnd, bs, hCtx, sn, fn) \ - (void)(fn)((hwnd), _WT_PACKET(bs), (WPARAM)(UINT)(sn), (LPARAM)(HCTX)(hCtx)) -#define FORWARD_WT_PACKET(hwnd, hCtx, sn, fn) \ - FORWARD__WT_PACKET(hwnd, WT_DEFBASE, hCtx, sn, fn) - -/* void Cls_OnWintabCtxOpen(HWND hwnd, HCTX hCtx, UINT sf) */ -#define HANDLE_WT_CTXOPEN(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HCTX)(wParam), (UINT)(lParam)), 0L) -#define FORWARD__WT_CTXOPEN(hwnd, bs, hCtx, sf, fn) \ - (void)(fn)((hwnd), _WT_CTXOPEN(bs), (WPARAM)(HCTX)(hCtx), (LPARAM)(UINT)(sf)) -#define FORWARD_WT_CTXOPEN(hwnd, hCtx, sf, fn) \ - FORWARD__WT_CTXOPEN(hwnd, WT_DEFBASE, hCtx, sf, fn) - -/* void Cls_OnWintabCtxClose(HWND hwnd, HCTX hCtx, UINT sf) */ -#define HANDLE_WT_CTXCLOSE(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HCTX)(wParam), (UINT)(lParam)), 0L) -#define FORWARD__WT_CTXCLOSE(hwnd, bs, hCtx, sf, fn) \ - (void)(fn)((hwnd), _WT_CTXCLOSE(bs), (WPARAM)(HCTX)(hCtx), (LPARAM)(UINT)(sf)) -#define FORWARD_WT_CTXCLOSE(hwnd, hCtx, sf, fn) \ - FORWARD__WT_CTXCLOSE(hwnd, WT_DEFBASE, hCtx, sf, fn) - -/* void Cls_OnWintabCtxUpdate(HWND hwnd, HCTX hCtx, UINT sf) */ -#define HANDLE_WT_CTXUPDATE(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HCTX)(wParam), (UINT)(lParam)), 0L) -#define FORWARD__WT_CTXUPDATE(hwnd, bs, hCtx, sf, fn) \ - (void)(fn)((hwnd), _WT_CTXUPDATE(bs), (WPARAM)(HCTX)(hCtx), (LPARAM)(UINT)(sf)) -#define FORWARD_WT_CTXUPDATE(hwnd, hCtx, sf, fn) \ - FORWARD__WT_CTXUPDATE(hwnd, WT_DEFBASE, hCtx, sf, fn) - -/* void Cls_OnWintabCtxOverlap(HWND hwnd, HCTX hCtx, UINT sf) */ -#define HANDLE_WT_CTXOVERLAP(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HCTX)(wParam), (UINT)(lParam)), 0L) -#define FORWARD__WT_CTXOVERLAP(hwnd, bs, hCtx, sf, fn) \ - (void)(fn)((hwnd), _WT_CTXOVERLAP(bs), (WPARAM)(HCTX)(hCtx), (LPARAM)(UINT)(sf)) -#define FORWARD_WT_CTXOVERLAP(hwnd, hCtx, sf, fn) \ - FORWARD__WT_CTXOVERLAP(hwnd, WT_DEFBASE, hCtx, sf, fn) - -/* void Cls_OnWintabProximity(HWND hwnd, HCTX hCtx, BOOL cp, BOOL hp) */ -#define HANDLE_WT_PROXIMITY(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HCTX)(wParam), (BOOL)LOWORD(lParam), (BOOL)HIWORD(lParam)), 0L) -#define FORWARD__WT_PROXIMITY(hwnd, bs, hCtx, cp, hp, fn) \ - (void)(fn)((hwnd), _WT_PROXIMITY(bs), (WPARAM)(HCTX)(hCtx), MAKELPARAM((cp), (hp)) -#define FORWARD_WT_PROXIMITY(hwnd, hCtx, sf, fn) \ - FORWARD__WT_PROXIMITY(hwnd, WT_DEFBASE, hCtx, cp, hp, fn) - -/* void Cls_OnWintabInfoChange(HWND hwnd, HMGR hMgr, UINT c, UINT i) */ -#define HANDLE_WT_INFOCHANGE(hwnd, wParam, lParam, fn) \ - ((fn)((hwnd), (HMGR)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L) -#define FORWARD__WT_INFOCHANGE(hwnd, bs, hMgr, cp, hp, fn) \ - (void)(fn)((hwnd), _WT_INFOCHANGE(bs), (WPARAM)(HMGR)(hMgr), MAKELPARAM((c), (i)) -#define FORWARD_WT_INFOCHANGE(hwnd, hMgr, sf, fn) \ - FORWARD__WT_INFOCHANGE(hwnd, WT_DEFBASE, hMgr, cp, hp, fn) - -/****** Alternate porting layer macros ****************************************/ - -#define GET_WT_PACKET_HCTX(wp, lp) ((HCTX)lp) -#define GET_WT_PACKET_SERIAL(wp, lp) (wp) -#define GET_WT_PACKET_MPS(h, s) \ - (s), (LPARAM)(h) - -#define GET_WT_CTXOPEN_HCTX(wp, lp) ((HCTX)wp) -#define GET_WT_CTXOPEN_STATUS(wp, lp) ((UINT)lp) -#define GET_WT_CTXOPEN_MPS(h, s) \ - (WPARAM)(h), (LPARAM)(s) - -#define GET_WT_CTXCLOSE_HCTX(wp, lp) ((HCTX)wp) -#define GET_WT_CTXCLOSE_STATUS(wp, lp) ((UINT)lp) -#define GET_WT_CTXCLOSE_MPS(h, s) \ - (WPARAM)(h), (LPARAM)(s) - -#define GET_WT_CTXUPDATE_HCTX(wp, lp) ((HCTX)wp) -#define GET_WT_CTXUPDATE_STATUS(wp, lp) ((UINT)lp) -#define GET_WT_CTXUPDATE_MPS(h, s) \ - (WPARAM)(h), (LPARAM)(s) - -#define GET_WT_CTXOVERLAP_HCTX(wp, lp) ((HCTX)wp) -#define GET_WT_CTXOVERLAP_STATUS(wp, lp) ((UINT)lp) -#define GET_WT_CTXOVERLAP_MPS(h, s) \ - (WPARAM)(h), (LPARAM)(s) - -#define GET_WT_PROXIMITY_HCTX(wp, lp) ((HCTX)wp) -#define GET_WT_PROXIMITY_CTXPROX(wp, lp) LOWORD(lp) -#define GET_WT_PROXIMITY_HARDPROX(wp, lp) HIWORD(lp) -#define GET_WT_PROXIMITY_MPS(h, fc, fh) \ - (WPARAM)(h), MAKELONG(fc, fh) - -#define GET_WT_INFOCHANGE_HMGR(wp, lp) ((HMGR)wp) -#define GET_WT_INFOCHANGE_CATEGORY(wp, lp) LOWORD(lp) -#define GET_WT_INFOCHANGE_INDEX(wp, lp) HIWORD(lp) -#define GET_WT_INFOCHANGE_MPS(h, c, i) \ - (WPARAM)(h), MAKELONG(c, i) - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* #define _INC_WINTABX */ - diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 598093fed..6b7003994 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -23,12 +23,14 @@ #include #include +#include #include #include "SDL_x11video.h" #include "../../events/SDL_events_c.h" #include "../../events/SDL_mouse_c.h" +#include "SDL_timer.h" #include "SDL_syswm.h" static void @@ -93,13 +95,7 @@ X11_DispatchEvent(_THIS) if (xevent.xcrossing.mode == NotifyUngrab) printf("Mode: NotifyUngrab\n"); #endif -#if 1 - /* FIXME: Should we reset data for all mice? */ - for (i = 0; i < SDL_GetNumMice(); ++i) { - SDL_Mouse *mouse = SDL_GetMouse(i); - SDL_SetMouseFocus(mouse->id, data->window); - } -#endif + SDL_SetMouseFocus(data->window); } break; @@ -116,13 +112,7 @@ X11_DispatchEvent(_THIS) printf("Mode: NotifyUngrab\n"); #endif if (xevent.xcrossing.detail != NotifyInferior) { -#if 1 - /* FIXME: Should we reset data for all mice? */ - for (i = 0; i < SDL_GetNumMice(); ++i) { - SDL_Mouse *mouse = SDL_GetMouse(i); - SDL_SetMouseFocus(mouse->id, 0); - } -#endif + SDL_SetMouseFocus(NULL); } } break; @@ -132,7 +122,7 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("FocusIn!\n"); #endif - SDL_SetKeyboardFocus(videodata->keyboard, data->window); + SDL_SetKeyboardFocus(data->window); #ifdef X_HAVE_UTF8_STRING if (data->ic) { XSetICFocus(data->ic); @@ -146,7 +136,7 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("FocusOut!\n"); #endif - SDL_SetKeyboardFocus(videodata->keyboard, 0); + SDL_SetKeyboardFocus(NULL); #ifdef X_HAVE_UTF8_STRING if (data->ic) { XUnsetICFocus(data->ic); @@ -185,8 +175,7 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif - SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED, - videodata->key_layout[keycode]); + SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); #if 0 if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { int min_keycode, max_keycode; @@ -210,7 +199,7 @@ X11_DispatchEvent(_THIS) XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL); #endif if (*text) { - SDL_SendKeyboardText(videodata->keyboard, text); + SDL_SendKeyboardText(text); } } break; @@ -222,8 +211,7 @@ X11_DispatchEvent(_THIS) #ifdef DEBUG_XEVENTS printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif - SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED, - videodata->key_layout[keycode]); + SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]); } break; @@ -280,79 +268,25 @@ X11_DispatchEvent(_THIS) } break; - default:{ - for (i = 0; i < SDL_GetNumMice(); ++i) { - SDL_Mouse *mouse; -#if SDL_VIDEO_DRIVER_X11_XINPUT - X11_MouseData *data; -#endif - - mouse = SDL_GetMouse(i); - if (!mouse->driverdata) { - switch (xevent.type) { - case MotionNotify: -#ifdef DEBUG_MOTION - printf("X11 motion: %d,%d\n", xevent.xmotion.x, - xevent.xmotion.y); -#endif - SDL_SendMouseMotion(mouse->id, 0, xevent.xmotion.x, - xevent.xmotion.y, 0); - break; - - case ButtonPress: - SDL_SendMouseButton(mouse->id, SDL_PRESSED, - xevent.xbutton.button); - break; - - case ButtonRelease: - SDL_SendMouseButton(mouse->id, SDL_RELEASED, - xevent.xbutton.button); - break; - } - continue; - } -#if SDL_VIDEO_DRIVER_X11_XINPUT - data = (X11_MouseData *) mouse->driverdata; - if (xevent.type == data->motion) { - XDeviceMotionEvent *move = - (XDeviceMotionEvent *) & xevent; + case MotionNotify:{ #ifdef DEBUG_MOTION - printf("X11 motion: %d,%d\n", move->x, move->y); + printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); #endif - SDL_SendMouseMotion(move->deviceid, 0, move->x, move->y, - move->axis_data[2]); - return; - } - if (xevent.type == data->button_pressed) { - XDeviceButtonPressedEvent *pressed = - (XDeviceButtonPressedEvent *) & xevent; - SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED, - pressed->button); - return; - } - if (xevent.type == data->button_released) { - XDeviceButtonReleasedEvent *released = - (XDeviceButtonReleasedEvent *) & xevent; - SDL_SendMouseButton(released->deviceid, SDL_RELEASED, - released->button); - return; - } - if (xevent.type == data->proximity_in) { - XProximityNotifyEvent *proximity = - (XProximityNotifyEvent *) & xevent; - SDL_SendProximity(proximity->deviceid, proximity->x, - proximity->y, SDL_PROXIMITYIN); - return; - } - if (xevent.type == data->proximity_out) { - XProximityNotifyEvent *proximity = - (XProximityNotifyEvent *) & xevent; - SDL_SendProximity(proximity->deviceid, proximity->x, - proximity->y, SDL_PROXIMITYOUT); - return; - } -#endif - } + SDL_SendMouseMotion(0, xevent.xmotion.x, xevent.xmotion.y); + } + break; + + case ButtonPress:{ + SDL_SendMouseButton(SDL_PRESSED, xevent.xbutton.button); + } + break; + + case ButtonRelease:{ + SDL_SendMouseButton(SDL_RELEASED, xevent.xbutton.button); + } + break; + + default:{ #ifdef DEBUG_XEVENTS printf("Unhandled event %d\n", xevent.type); #endif diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 0726d99e6..dc80195a1 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -172,7 +172,6 @@ int X11_InitKeyboard(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_Keyboard keyboard; int i, j; int min_keycode, max_keycode; struct { @@ -251,8 +250,6 @@ X11_InitKeyboard(_THIS) } } - SDL_zero(keyboard); - data->keyboard = SDL_AddKeyboard(&keyboard, -1); X11_UpdateKeymap(_this); SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); @@ -280,15 +277,12 @@ X11_UpdateKeymap(_THIS) keymap[scancode] = X11_KeyCodeToSDLKey(data->display, (KeyCode)i); } - SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES); + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); } void X11_QuitKeyboard(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - - SDL_DelKeyboard(data->keyboard); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 8b999f8d5..dbf5b6189 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -24,139 +24,14 @@ #include "SDL_x11mouse.h" #include "../../events/SDL_mouse_c.h" -#if SDL_VIDEO_DRIVER_X11_XINPUT -static void -X11_FreeMouse(SDL_Mouse * mouse) -{ - X11_MouseData *data = (X11_MouseData *) mouse->driverdata; - - if (data) { - XCloseDevice(data->display, data->device); - SDL_free(data); - } -} -#endif - void X11_InitMouse(_THIS) { - SDL_Mouse mouse; -#if SDL_VIDEO_DRIVER_X11_XINPUT - Display *display = ((SDL_VideoData *) _this->driverdata)->display; - X11_MouseData *data; - int i, j, n; - XDeviceInfo *DevList; - XAnyClassPtr deviceClass; - int event_code; - XEventClass xEvent; -#endif - int num_mice = 0; - - SDL_zero(mouse); - -#if SDL_VIDEO_DRIVER_X11_XINPUT - /* we're getting the list of input devices */ - n = 0; - if (SDL_X11_HAVE_XINPUT) { - DevList = XListInputDevices(display, &n); - } - - /* we're aquiring valuators: mice, tablets, etc. */ - for (i = 0; i < n; ++i) { - /* if it's the core pointer or core keyborard we don't want it */ - if ((DevList[i].use != IsXPointer && DevList[i].use != IsXKeyboard)) { - /* we have to check all of the device classes */ - deviceClass = DevList[i].inputclassinfo; - for (j = 0; j < DevList[i].num_classes; ++j) { - if (deviceClass->class == ValuatorClass) { /* bingo ;) */ - XValuatorInfo *valInfo; - - data = (X11_MouseData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - continue; - } - data->display = display; - data->device = XOpenDevice(display, DevList[i].id); - - /* motion events */ - DeviceMotionNotify(data->device, event_code, xEvent); - if (xEvent) { - data->xevents[data->num_xevents++] = xEvent; - data->motion = event_code; - } - - /* button events */ - DeviceButtonPress(data->device, event_code, xEvent); - if (xEvent) { - data->xevents[data->num_xevents++] = xEvent; - data->button_pressed = event_code; - } - DeviceButtonRelease(data->device, event_code, xEvent); - if (xEvent) { - data->xevents[data->num_xevents++] = xEvent; - data->button_released = event_code; - } - - /* proximity events */ - ProximityIn(data->device, event_code, xEvent); - if (xEvent) { - data->xevents[data->num_xevents++] = xEvent; - data->proximity_in = event_code; - } - ProximityOut(data->device, event_code, xEvent); - if (xEvent) { - data->xevents[data->num_xevents++] = xEvent; - data->proximity_out = event_code; - } - - SDL_zero(mouse); - mouse.id = DevList[i].id; - mouse.FreeMouse = X11_FreeMouse; - mouse.driverdata = data; - - /* lets get the device parameters */ - valInfo = (XValuatorInfo *) deviceClass; - /* if the device reports pressure, lets check it parameteres */ - if (valInfo->num_axes > 2) { - SDL_AddMouse(&mouse, DevList[i].name, - valInfo->axes[2].max_value, - valInfo->axes[2].min_value, 1); - } else { - SDL_AddMouse(&mouse, DevList[i].name, 0, 0, 1); - } -#ifndef IsXExtensionPointer -#define IsXExtensionPointer 4 -#endif - if (DevList[i].use == IsXExtensionPointer) { - ++num_mice; - } - break; - } - /* if it's not class we're interested in, lets go further */ - deviceClass = - (XAnyClassPtr) ((char *) deviceClass + - deviceClass->length); - } - } - } - XFreeDeviceList(DevList); -#endif - - if (num_mice == 0) { - SDL_zero(mouse); - SDL_AddMouse(&mouse, "CorePointer", 0, 0, 1); - } } void X11_QuitMouse(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - - /* !!! FIXME: use XCloseDevice()? Or maybe handle under SDL_MouseQuit()? */ - - /* let's delete all of the mice */ - SDL_MouseQuit(); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 1ba0ba392..9989911c9 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -67,7 +67,6 @@ typedef struct SDL_VideoData int numwindows; SDL_WindowData **windowlist; int windowlistlength; - int keyboard; Atom WM_DELETE_WINDOW; SDL_scancode key_layout[256]; } SDL_VideoData; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 18c0e478e..699740418 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -22,6 +22,7 @@ #include "SDL_config.h" #include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" @@ -34,6 +35,7 @@ #include "SDL_x11opengles.h" #endif +#include "SDL_timer.h" #include "SDL_syswm.h" #define _NET_WM_STATE_REMOVE 0l @@ -67,7 +69,6 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) int numwindows = videodata->numwindows; int windowlistlength = videodata->windowlistlength; SDL_WindowData **windowlist = videodata->windowlist; - int index; /* Allocate the window data */ data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); @@ -275,8 +276,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) if (visual->class == PseudoColor) { printf("asking for PseudoColor\n"); - Status status; - XStandardColormap cmap; +/* Status status; */ XColor *colorcells; Colormap colormap; Sint32 pix; @@ -387,7 +387,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) } } else if (visual->class == DirectColor) { Status status; - XStandardColormap cmap; XColor *colorcells; Colormap colormap; int i; @@ -397,9 +396,9 @@ X11_CreateWindow(_THIS, SDL_Window * window) int rshift, gshift, bshift; /* Is the colormap we need already registered in SDL? */ - if (colormap = - X11_LookupColormap(data->display, - displaydata->screen, visual->visualid)) { + if ((colormap = + X11_LookupColormap(data->display, + displaydata->screen, visual->visualid))) { xattr.colormap = colormap; /* printf("found existing colormap\n"); */ } else { @@ -647,7 +646,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) /* Tell KDE to keep fullscreen windows on top */ if (window->flags & SDL_WINDOW_FULLSCREEN) { XEvent ev; - long mask; SDL_zero(ev); ev.xclient.type = ClientMessage; @@ -710,32 +708,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) } #endif -#if SDL_VIDEO_DRIVER_X11_XINPUT - /* we're informing the display what extension events we want to receive from it */ - { - int i, j, n = 0; - XEventClass xevents[256]; - - for (i = 0; i < SDL_GetNumMice(); ++i) { - SDL_Mouse *mouse; - X11_MouseData *data; - - mouse = SDL_GetMouse(i); - data = (X11_MouseData *) mouse->driverdata; - if (!data) { - continue; - } - - for (j = 0; j < data->num_xevents; ++j) { - xevents[n++] = data->xevents[j]; - } - } - if (n > 0) { - XSelectExtensionEvent(data->display, w, xevents, n); - } - } -#endif - return 0; } @@ -869,8 +841,6 @@ void X11_SetWindowPosition(_THIS, SDL_Window * window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *displaydata = - (SDL_DisplayData *) window->display->driverdata; Display *display = data->videodata->display; int x, y; diff --git a/test/common.c b/test/common.c index 694fa196c..a3e19c909 100644 --- a/test/common.c +++ b/test/common.c @@ -929,45 +929,44 @@ PrintEvent(SDL_Event * event) break; case SDL_KEYDOWN: fprintf(stderr, - "Keyboard %d: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", - event->key.which, event->key.windowID, + "Keyboard: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", + event->key.windowID, event->key.keysym.scancode, SDL_GetScancodeName(event->key.keysym.scancode), event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); break; case SDL_KEYUP: fprintf(stderr, - "Keyboard %d: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", - event->key.which, event->key.windowID, + "Keyboard: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", + event->key.windowID, event->key.keysym.scancode, SDL_GetScancodeName(event->key.keysym.scancode), event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); break; case SDL_TEXTINPUT: - fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d", - event->text.which, event->text.text, event->text.windowID); + fprintf(stderr, "Keyboard: text input \"%s\" in window %d", + event->text.text, event->text.windowID); break; case SDL_MOUSEMOTION: - fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d", - event->motion.which, event->motion.x, event->motion.y, + fprintf(stderr, "Mouse: moved to %d,%d (%d,%d) in window %d", + event->motion.x, event->motion.y, event->motion.xrel, event->motion.yrel, event->motion.windowID); break; case SDL_MOUSEBUTTONDOWN: - fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d", - event->button.which, event->button.button, event->button.x, - event->button.y, event->button.windowID); + fprintf(stderr, "Mouse: button %d pressed at %d,%d in window %d", + event->button.button, event->button.x, event->button.y, + event->button.windowID); break; case SDL_MOUSEBUTTONUP: - fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d", - event->button.which, event->button.button, event->button.x, - event->button.y, event->button.windowID); + fprintf(stderr, "Mouse: button %d released at %d,%d in window %d", + event->button.button, event->button.x, event->button.y, + event->button.windowID); break; case SDL_MOUSEWHEEL: fprintf(stderr, - "Mouse %d: wheel scrolled %d in x and %d in y in window %d", - event->wheel.which, event->wheel.x, event->wheel.y, - event->wheel.windowID); + "Mouse: wheel scrolled %d in x and %d in y in window %d", + event->wheel.x, event->wheel.y, event->wheel.windowID); break; case SDL_JOYBALLMOTION: fprintf(stderr, "Joystick %d: ball %d moved by %d,%d", diff --git a/test/testime.c b/test/testime.c index cf6768ac8..6975d652d 100644 --- a/test/testime.c +++ b/test/testime.c @@ -279,8 +279,8 @@ int main(int argc, char *argv[]) } fprintf(stderr, - "Keyboard %d: scancode 0x%08X = %s, keycode 0x%08X = %s\n", - event.key.which, event.key.keysym.scancode, + "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n", + event.key.keysym.scancode, SDL_GetScancodeName(event.key.keysym.scancode), event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym)); break; @@ -290,8 +290,7 @@ int main(int argc, char *argv[]) markedRect.w < 0) break; - fprintf(stderr, "Keyboard %d: text input \"%s\"\n", - event.text.which, event.text.text); + fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text); if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) strcpy(text + SDL_strlen(text), event.text.text); diff --git a/test/testintersections.c b/test/testintersections.c index 7327e3a02..9eed373e2 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -288,20 +288,16 @@ main(int argc, char *argv[]) CommonEvent(state, &event, &done); switch (event.type) { case SDL_MOUSEBUTTONDOWN: - if (event.button.which == 0) { - mouse_begin_x = event.button.x; - mouse_begin_y = event.button.y; - } + mouse_begin_x = event.button.x; + mouse_begin_y = event.button.y; break; case SDL_MOUSEBUTTONUP: - if (event.button.which == 0) { - if (event.button.button == 3) - add_line(mouse_begin_x, mouse_begin_y, event.button.x, - event.button.y); - if (event.button.button == 1) - add_rect(mouse_begin_x, mouse_begin_y, event.button.x, - event.button.y); - } + if (event.button.button == 3) + add_line(mouse_begin_x, mouse_begin_y, event.button.x, + event.button.y); + if (event.button.button == 1) + add_rect(mouse_begin_x, mouse_begin_y, event.button.x, + event.button.y); break; case SDL_KEYDOWN: switch (event.key.keysym.sym) {