Commit 338f95eb authored by Sam Lantinga's avatar Sam Lantinga

Removed multi-mouse / multi-keyboard support in anticipation of a real...

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.
parent d12afdae
...@@ -44,7 +44,7 @@ EMBEDSPU = @EMBEDSPU@ ...@@ -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 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_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@ LT_CURRENT = @LT_CURRENT@
......
...@@ -75,9 +75,13 @@ typedef enum ...@@ -75,9 +75,13 @@ typedef enum
SDL_MOUSEBUTTONUP, /**< Mouse button released */ SDL_MOUSEBUTTONUP, /**< Mouse button released */
SDL_MOUSEWHEEL, /**< Mouse wheel motion */ SDL_MOUSEWHEEL, /**< Mouse wheel motion */
/* Tablet events */ /* Tablet or multiple mice input device events */
SDL_PROXIMITYIN = 0x500, /**< Proximity In event */ SDL_INPUTMOTION = 0x500, /**< Input moved */
SDL_PROXIMITYOUT, /**< Proximity Out event */ 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 */ /* Joystick events */
SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
...@@ -124,10 +128,10 @@ typedef struct SDL_KeyboardEvent ...@@ -124,10 +128,10 @@ typedef struct SDL_KeyboardEvent
{ {
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
Uint8 which; /**< The keyboard device index */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3;
SDL_keysym keysym; /**< The key that was pressed or released */ SDL_keysym keysym; /**< The key that was pressed or released */
} SDL_KeyboardEvent; } SDL_KeyboardEvent;
...@@ -139,7 +143,6 @@ typedef struct SDL_TextEditingEvent ...@@ -139,7 +143,6 @@ typedef struct SDL_TextEditingEvent
{ {
Uint32 type; /**< ::SDL_TEXTEDITING */ Uint32 type; /**< ::SDL_TEXTEDITING */
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
Uint8 which; /**< The keyboard device index */
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
int start; /**< The start cursor of selected editing text */ int start; /**< The start cursor of selected editing text */
int length; /**< The length of selected editing text */ int length; /**< The length of selected editing text */
...@@ -154,10 +157,6 @@ typedef struct SDL_TextInputEvent ...@@ -154,10 +157,6 @@ typedef struct SDL_TextInputEvent
{ {
Uint32 type; /**< ::SDL_TEXTINPUT */ Uint32 type; /**< ::SDL_TEXTINPUT */
Uint32 windowID; /**< The window with keyboard focus, if any */ 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 */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
} SDL_TextInputEvent; } SDL_TextInputEvent;
...@@ -168,20 +167,12 @@ typedef struct SDL_MouseMotionEvent ...@@ -168,20 +167,12 @@ typedef struct SDL_MouseMotionEvent
{ {
Uint32 type; /**< ::SDL_MOUSEMOTION */ Uint32 type; /**< ::SDL_MOUSEMOTION */
Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 windowID; /**< The window with mouse focus, if any */
Uint8 which; /**< The mouse device index */
Uint8 state; /**< The current button state */ Uint8 state; /**< The current button state */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3;
int x; /**< X coordinate, relative to window */ int x; /**< X coordinate, relative to window */
int y; /**< Y 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 xrel; /**< The relative motion in the X direction */
int yrel; /**< The relative motion in the Y direction */ int yrel; /**< The relative motion in the Y direction */
} SDL_MouseMotionEvent; } SDL_MouseMotionEvent;
...@@ -193,10 +184,10 @@ typedef struct SDL_MouseButtonEvent ...@@ -193,10 +184,10 @@ typedef struct SDL_MouseButtonEvent
{ {
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 windowID; /**< The window with mouse focus, if any */
Uint8 which; /**< The mouse device index */
Uint8 button; /**< The mouse button index */ Uint8 button; /**< The mouse button index */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
Uint8 padding1; Uint8 padding1;
Uint8 padding2;
int x; /**< X coordinate, relative to window */ int x; /**< X coordinate, relative to window */
int y; /**< Y coordinate, relative to window */ int y; /**< Y coordinate, relative to window */
} SDL_MouseButtonEvent; } SDL_MouseButtonEvent;
...@@ -208,30 +199,10 @@ typedef struct SDL_MouseWheelEvent ...@@ -208,30 +199,10 @@ typedef struct SDL_MouseWheelEvent
{ {
Uint32 type; /**< ::SDL_MOUSEWHEEL */ Uint32 type; /**< ::SDL_MOUSEWHEEL */
Uint32 windowID; /**< The window with mouse focus, if any */ 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 x; /**< The amount scrolled horizontally */
int y; /**< The amount scrolled vertically */ int y; /**< The amount scrolled vertically */
} SDL_MouseWheelEvent; } 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.*) * \brief Joystick axis motion event structure (event.jaxis.*)
*/ */
...@@ -371,7 +342,6 @@ typedef union SDL_Event ...@@ -371,7 +342,6 @@ typedef union SDL_Event
SDL_QuitEvent quit; /**< Quit request event data */ SDL_QuitEvent quit; /**< Quit request event data */
SDL_UserEvent user; /**< Custom event data */ SDL_UserEvent user; /**< Custom event data */
SDL_SysWMEvent syswm; /**< System dependent window event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */
SDL_ProximityEvent proximity; /**< Proximity In or Out event */
/** Temporarily here for backwards compatibility */ /** Temporarily here for backwards compatibility */
/*@{*/ /*@{*/
......
/*
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: */
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_keysym.h" #include "SDL_keysym.h"
#include "SDL_video.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
...@@ -55,25 +56,12 @@ typedef struct SDL_keysym ...@@ -55,25 +56,12 @@ typedef struct SDL_keysym
/* Function prototypes */ /* Function prototypes */
/** /**
* \brief Get the number of keyboard input devices available. * \brief Get the window which currently has keyboard focus.
*
* \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()
*/ */
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. * \param numkeys if non-NULL, receives the length of the returned array.
* *
...@@ -90,20 +78,20 @@ extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index); ...@@ -90,20 +78,20 @@ extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); 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); 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. * \note This does not change the keyboard state, only the key modifier flags.
*/ */
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
/** /**
* \brief Get the key code corresponding to the given scancode according to the * \brief Get the key code corresponding to the given scancode according
* current keyboard layout. * to the current keyboard layout.
* *
* See ::SDLKey for details. * See ::SDLKey for details.
* *
......
...@@ -24,6 +24,22 @@ ...@@ -24,6 +24,22 @@
* \file SDL_mouse.h * \file SDL_mouse.h
* *
* Include file for SDL mouse event handling. * 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 #ifndef _SDL_mouse_h
...@@ -43,45 +59,50 @@ extern "C" { ...@@ -43,45 +59,50 @@ extern "C" {
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
/* Function prototypes */ /* Function prototypes */
/** /**
* \brief Get the number of mouse input devices available. * \brief Get the window which currently has mouse focus.
*
* \sa SDL_SelectMouse()
*/ */
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. * \brief Retrieve the current state of the mouse.
*
* \param index is the index of the mouse, which name is to be returned.
* *
* \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. * \brief Retrieve the relative state of the mouse.
* *
* \return The index of the previously selected 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
* \note You can query the currently selected mouse by passing an index of -1. * mouse deltas since the last call to SDL_GetRelativeMouseState().
*
* \sa SDL_GetNumMice()
*/ */
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 * \param enabled Whether or not to enable relative mode
* *
* \return 0 on success, or -1 if relative mode is not supported. * \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 * 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); ...@@ -93,51 +114,18 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocusWindow(int index);
* *
* \sa SDL_GetRelativeMouseMode() * \sa SDL_GetRelativeMouseMode()
*/ */
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(int index, extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
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() * \sa SDL_SetRelativeMouseMode()
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(int index); extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
/**
* \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);
/** /**
* \brief Moves the currently selected mouse to the given position within the window. * \brief Create a cursor, using the specified bitmap data and
* * mask (in MSB format).
* \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).
* *
* The cursor width must be a multiple of 8 bits. * The cursor width must be a multiple of 8 bits.
* *
...@@ -148,7 +136,7 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, ...@@ -148,7 +136,7 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
* <tr><td> 1 </td><td> 1 </td><td> Black </td></tr> * <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>
* <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr> * <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>
* <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black * <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black
if not. </td></tr> * if not. </td></tr>
* </table> * </table>
* *
* \sa SDL_FreeCursor() * \sa SDL_FreeCursor()
...@@ -159,14 +147,12 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, ...@@ -159,14 +147,12 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
int hot_y); int hot_y);
/** /**
* \brief Set the active cursor for the currently selected mouse. * \brief Set the active cursor.
*
* \note The cursor must have been created for the selected mouse.
*/ */
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * 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); extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
...@@ -178,8 +164,7 @@ 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); extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
/** /**
* \brief Toggle whether or not the cursor is shown for the currently selected * \brief Toggle whether or not the cursor is shown.
* mouse.
* *
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
* state. * state.
...@@ -188,38 +173,6 @@ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); ...@@ -188,38 +173,6 @@ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
*/ */
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); 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. * Used as a mask when testing buttons in buttonstate.
* - Button 1: Left mouse button * - Button 1: Left mouse button
......
...@@ -88,7 +88,6 @@ typedef struct ...@@ -88,7 +88,6 @@ typedef struct
* \sa SDL_SetWindowTitle() * \sa SDL_SetWindowTitle()
* \sa SDL_ShowWindow() * \sa SDL_ShowWindow()
*/ */
struct SDL_Window;
typedef struct SDL_Window SDL_Window; typedef struct SDL_Window SDL_Window;
/** /**
......
...@@ -277,16 +277,13 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) ...@@ -277,16 +277,13 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
{ {
Uint8 button; Uint8 button;
int selected;
int x, y; int x, y;
if (event->wheel.y == 0) { if (event->wheel.y == 0) {
break; break;
} }
selected = SDL_SelectMouse(event->wheel.which);
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
SDL_SelectMouse(selected);
if (event->wheel.y > 0) { if (event->wheel.y > 0) {
button = SDL_BUTTON_WHEELUP; button = SDL_BUTTON_WHEELUP;
...@@ -294,7 +291,6 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) ...@@ -294,7 +291,6 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event)
button = SDL_BUTTON_WHEELDOWN; button = SDL_BUTTON_WHEELDOWN;
} }
fake.button.which = event->wheel.which;
fake.button.button = button; fake.button.button = button;
fake.button.x = x; fake.button.x = x;
fake.button.y = y; fake.button.y = y;
......
...@@ -30,9 +30,19 @@ ...@@ -30,9 +30,19 @@
/* Global keyboard information */ /* Global keyboard information */
static int SDL_num_keyboards;
static int SDL_current_keyboard; typedef struct SDL_Keyboard SDL_Keyboard;
static SDL_Keyboard **SDL_keyboards;
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] = { static const SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = {
0, 0, 0, 0, 0, 0, 0, 0,
...@@ -544,75 +554,15 @@ SDL_KeyboardInit(void) ...@@ -544,75 +554,15 @@ SDL_KeyboardInit(void)
return (0); 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 void
SDL_ResetKeyboard(int index) SDL_ResetKeyboard(void)
{ {
SDL_Keyboard *keyboard = SDL_GetKeyboard(index); SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode; SDL_scancode scancode;
if (!keyboard) {
return;
}
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keystate[scancode] == SDL_PRESSED) { 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) ...@@ -624,13 +574,9 @@ SDL_GetDefaultKeymap(SDLKey * keymap)
} }
void 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); SDL_Keyboard *keyboard = &SDL_keyboard;
if (!keyboard) {
return;
}
if (start < 0 || start + length > SDL_NUM_SCANCODES) { if (start < 0 || start + length > SDL_NUM_SCANCODES) {
return; return;
...@@ -645,33 +591,23 @@ SDL_SetScancodeName(SDL_scancode scancode, const char *name) ...@@ -645,33 +591,23 @@ SDL_SetScancodeName(SDL_scancode scancode, const char *name)
SDL_scancode_names[scancode] = name; SDL_scancode_names[scancode] = name;
} }
void SDL_Window *
SDL_SetKeyboardFocus(int index, SDL_Window * window) SDL_GetKeyboardFocus(void)
{ {
SDL_Keyboard *keyboard = SDL_GetKeyboard(index); SDL_Keyboard *keyboard = &SDL_keyboard;
int i;
SDL_bool focus;
if (!keyboard) { return keyboard->focus;
return; }
}
void
SDL_SetKeyboardFocus(SDL_Window * window)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
/* See if the current window has lost focus */ /* See if the current window has lost focus */
if (keyboard->focus && keyboard->focus != window) { if (keyboard->focus && keyboard->focus != window) {
focus = SDL_FALSE; SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
for (i = 0; i < SDL_num_keyboards; ++i) { 0, 0);
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);
}
} }
keyboard->focus = window; keyboard->focus = window;
...@@ -687,14 +623,14 @@ SDL_SetKeyboardFocus(int index, SDL_Window * window) ...@@ -687,14 +623,14 @@ SDL_SetKeyboardFocus(int index, SDL_Window * window)
} }
int 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; int posted;
Uint16 modstate; Uint16 modstate;
Uint32 type; Uint32 type;
if (!keyboard || !scancode) { if (!scancode) {
return 0; return 0;
} }
#if 0 #if 0
...@@ -807,7 +743,6 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode) ...@@ -807,7 +743,6 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
if (SDL_GetEventState(type) == SDL_ENABLE) { if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.key.type = type; event.key.type = type;
event.key.which = (Uint8) index;
event.key.state = state; event.key.state = state;
event.key.keysym.scancode = scancode; event.key.keysym.scancode = scancode;
event.key.keysym.sym = keyboard->keymap[scancode]; event.key.keysym.sym = keyboard->keymap[scancode];
...@@ -820,22 +755,17 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode) ...@@ -820,22 +755,17 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
} }
int 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; int posted;
if (!keyboard) {
return 0;
}
/* Post the event, if desired */ /* Post the event, if desired */
posted = 0; posted = 0;
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.text.type = SDL_TEXTINPUT; event.text.type = SDL_TEXTINPUT;
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; 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)); SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
...@@ -844,22 +774,17 @@ SDL_SendKeyboardText(int index, const char *text) ...@@ -844,22 +774,17 @@ SDL_SendKeyboardText(int index, const char *text)
} }
int 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; int posted;
if (!keyboard) {
return 0;
}
/* Post the event, if desired */ /* Post the event, if desired */
posted = 0; posted = 0;
if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) { if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.edit.type = SDL_TEXTEDITING; event.edit.type = SDL_TEXTEDITING;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0; event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.text.which = (Uint8) index;
event.edit.start = start; event.edit.start = start;
event.edit.length = length; event.edit.length = length;
SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text)); 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) ...@@ -871,93 +796,49 @@ SDL_SendEditingText(int index, const char *text, int start, int length)
void void
SDL_KeyboardQuit(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 * Uint8 *
SDL_GetKeyboardState(int *numkeys) SDL_GetKeyboardState(int *numkeys)
{ {
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); SDL_Keyboard *keyboard = &SDL_keyboard;
if (numkeys != (int *) 0) { if (numkeys != (int *) 0) {
*numkeys = SDL_NUM_SCANCODES; *numkeys = SDL_NUM_SCANCODES;
} }
if (!keyboard) {
return NULL;
}
return keyboard->keystate; return keyboard->keystate;
} }
SDLMod SDLMod
SDL_GetModState(void) SDL_GetModState(void)
{ {
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); SDL_Keyboard *keyboard = &SDL_keyboard;
if (!keyboard) {
return KMOD_NONE;
}
return keyboard->modstate; return keyboard->modstate;
} }
void void
SDL_SetModState(SDLMod modstate) SDL_SetModState(SDLMod modstate)
{ {
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); SDL_Keyboard *keyboard = &SDL_keyboard;
if (!keyboard) {
return;
}
keyboard->modstate = modstate; keyboard->modstate = modstate;
} }
SDLKey SDLKey
SDL_GetKeyFromScancode(SDL_scancode scancode) 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]; return keyboard->keymap[scancode];
} }
SDL_scancode SDL_scancode
SDL_GetScancodeFromKey(SDLKey key) SDL_GetScancodeFromKey(SDLKey key)
{ {
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode; SDL_scancode scancode;
if (!keyboard) {
return SDL_SCANCODE_UNKNOWN;
}
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
++scancode) { ++scancode) {
if (keyboard->keymap[scancode] == key) { if (keyboard->keymap[scancode] == key) {
......
...@@ -27,44 +27,17 @@ ...@@ -27,44 +27,17 @@
#include "SDL_keysym.h" #include "SDL_keysym.h"
#include "SDL_events.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 */ /* Initialize the keyboard subsystem */
extern int SDL_KeyboardInit(void); extern int SDL_KeyboardInit(void);
/* Get the keyboard at an index */ /* Clear the state of the keyboard */
extern SDL_Keyboard *SDL_GetKeyboard(int index); extern void SDL_ResetKeyboard(void);
/* 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);
/* Get the default keymap */ /* Get the default keymap */
extern void SDL_GetDefaultKeymap(SDLKey * keymap); extern void SDL_GetDefaultKeymap(SDLKey * keymap);
/* Set the mapping of scancode to key codes for this keyboard */ /* Set the mapping of scancode to key codes */
extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length); extern void SDL_SetKeymap(int start, SDLKey * keys, int length);
/* Set a platform-dependent key name, overriding the default platform-agnostic /* Set a platform-dependent key name, overriding the default platform-agnostic
name. Encoded as UTF-8. The string is not copied, thus the pointer given to name. Encoded as UTF-8. The string is not copied, thus the pointer given to
...@@ -73,16 +46,16 @@ extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length); ...@@ -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); extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
/* Set the keyboard focus window */ /* 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 */ /* Send a keyboard key event */
extern int SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode); extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
/* Send keyboard text input for a keyboard at an index */ /* Send keyboard text input */
extern int SDL_SendKeyboardText(int index, const char *text); extern int SDL_SendKeyboardText(const char *text);
/* Send editing text for selected range from start to end */ /* 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 */ /* Shutdown the keyboard subsystem */
extern void SDL_KeyboardQuit(void); extern void SDL_KeyboardQuit(void);
......
...@@ -29,382 +29,97 @@ ...@@ -29,382 +29,97 @@
#include "../video/SDL_sysvideo.h" #include "../video/SDL_sysvideo.h"
static int SDL_num_mice = 0; /* Global mouse information */
static int SDL_current_mouse = -1;
static SDL_Mouse **SDL_mice = NULL;
typedef struct SDL_Mouse SDL_Mouse;
/* Public functions */ struct SDL_Mouse
int
SDL_MouseInit(void)
{ {
return (0); /* Create a cursor from a surface */
} SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
SDL_Mouse * /* Show the specified cursor, or hide if cursor is NULL */
SDL_GetMouse(int index) int (*ShowCursor) (SDL_Cursor * cursor);
{
if (index < 0 || index >= SDL_num_mice) {
return NULL;
}
return SDL_mice[index];
}
static int /* This is called when a mouse motion event occurs */
SDL_GetMouseIndexId(int id) void (*MoveCursor) (SDL_Cursor * cursor);
{
int index;
SDL_Mouse *mouse;
for (index = 0; index < SDL_num_mice; ++index) { /* Free a window manager cursor */
mouse = SDL_GetMouse(index); void (*FreeCursor) (SDL_Cursor * cursor);
if (mouse->id == id) {
return index;
}
}
return -1;
}
int /* Warp the mouse to (x,y) */
SDL_AddMouse(const SDL_Mouse * mouse, char *name, int pressure_max, void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y);
int pressure_min, int ends)
{
SDL_Mouse **mice;
int selected_mouse;
int index;
size_t length;
if (SDL_GetMouseIndexId(mouse->id) != -1) {
SDL_SetError("Mouse ID already in use");
}
/* Add the mouse to the list of mice */
mice = (SDL_Mouse **) SDL_realloc(SDL_mice,
(SDL_num_mice + 1) * sizeof(*mice));
if (!mice) {
SDL_OutOfMemory();
return -1;
}
SDL_mice = mice;
index = SDL_num_mice++;
SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index]));
if (!SDL_mice[index]) {
SDL_OutOfMemory();
return -1;
}
*SDL_mice[index] = *mouse;
/* we're setting the mouse properties */
length = 0;
length = SDL_strlen(name);
SDL_mice[index]->focus = 0;
SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char));
SDL_strlcpy(SDL_mice[index]->name, name, length + 1);
SDL_mice[index]->pressure_max = pressure_max;
SDL_mice[index]->pressure_min = pressure_min;
SDL_mice[index]->cursor_shown = SDL_TRUE;
selected_mouse = SDL_SelectMouse(index);
SDL_mice[index]->cur_cursor = NULL;
SDL_mice[index]->def_cursor =
SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH,
DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
SDL_SetCursor(SDL_mice[index]->def_cursor);
/* we're assuming that all mice are in the computer sensing zone */
SDL_mice[index]->proximity = SDL_TRUE;
/* we're assuming that all mice are working in the absolute position mode
thanx to that, the users that don't want to use many mice don't have to
worry about anything */
SDL_mice[index]->relative_mode = SDL_FALSE;
SDL_mice[index]->current_end = 0;
SDL_mice[index]->total_ends = ends;
SDL_SelectMouse(selected_mouse);
return index;
}
void /* Data common to all mice */
SDL_DelMouse(int index) SDL_Window *focus;
{ int x;
SDL_Mouse *mouse = SDL_GetMouse(index); int y;
int xdelta;
if (!mouse) { int ydelta;
return; int last_x, last_y; /* the last reported x and y coordinates */
} Uint8 buttonstate;
SDL_bool relative_mode;
mouse->def_cursor = NULL;
SDL_free(mouse->name);
while (mouse->cursors) {
SDL_FreeCursor(mouse->cursors);
}
if (mouse->FreeMouse) {
mouse->FreeMouse(mouse);
}
SDL_free(mouse);
SDL_mice[index] = NULL; SDL_Cursor *cursors;
} SDL_Cursor *def_cursor;
SDL_Cursor *cur_cursor;
SDL_bool cursor_shown;
};
void static SDL_Mouse SDL_mouse;
SDL_ResetMouse(int index)
{
SDL_Mouse *mouse = SDL_GetMouse(index);
if (!mouse) {
return;
}
/* FIXME */
}
void
SDL_MouseQuit(void)
{
int i;
for (i = 0; i < SDL_num_mice; ++i) {
SDL_DelMouse(i);
}
SDL_num_mice = 0;
SDL_current_mouse = -1;
if (SDL_mice) {
SDL_free(SDL_mice);
SDL_mice = NULL;
}
}
/* Public functions */
int int
SDL_GetNumMice(void) SDL_MouseInit(void)
{ {
return SDL_num_mice; return (0);
} }
int void
SDL_SelectMouse(int index) SDL_ResetMouse(void)
{ {
if (index >= 0 && index < SDL_num_mice) { /* FIXME */
SDL_current_mouse = index;
}
return SDL_current_mouse;
} }
SDL_Window * 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; 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 void
SDL_SetMouseFocus(int id, SDL_Window * window) SDL_SetMouseFocus(SDL_Window * window)
{ {
int index = SDL_GetMouseIndexId(id); SDL_Mouse *mouse = &SDL_mouse;
SDL_Mouse *mouse = SDL_GetMouse(index);
int i;
SDL_bool focus;
if (!mouse || (mouse->focus == window)) { if (mouse->focus == window) {
return; return;
} }
/* See if the current window has lost focus */ /* See if the current window has lost focus */
if (mouse->focus) { if (mouse->focus) {
focus = SDL_FALSE; SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
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);
}
} }
mouse->focus = window; mouse->focus = window;
if (mouse->focus) { if (mouse->focus) {
focus = SDL_FALSE; SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
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);
}
} }
} }
int 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_mouse;
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);
int posted; int posted;
int xrel; int xrel;
int yrel; int yrel;
int x_max = 0, y_max = 0; 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 */ /* the relative motion is calculated regarding the system cursor last position */
if (relative) { if (relative) {
xrel = x; xrel = x;
...@@ -451,35 +166,26 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure) ...@@ -451,35 +166,26 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
mouse->xdelta += xrel; mouse->xdelta += xrel;
mouse->ydelta += yrel; mouse->ydelta += yrel;
mouse->pressure = pressure;
#if 0 /* FIXME */
/* Move the mouse cursor, if needed */ /* Move the mouse cursor, if needed */
if (mouse->cursor_shown && !mouse->relative_mode && if (mouse->cursor_shown && !mouse->relative_mode &&
mouse->MoveCursor && mouse->cur_cursor) { mouse->MoveCursor && mouse->cur_cursor) {
mouse->MoveCursor(mouse->cur_cursor); mouse->MoveCursor(mouse->cur_cursor);
} }
#endif
/* Post the event, if desired */ /* Post the event, if desired */
posted = 0; posted = 0;
if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE && if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
mouse->proximity == SDL_TRUE) {
SDL_Event event; SDL_Event event;
event.motion.type = SDL_MOUSEMOTION; 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.state = mouse->buttonstate;
event.motion.x = mouse->x; event.motion.x = mouse->x;
event.motion.y = mouse->y; 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.xrel = xrel;
event.motion.yrel = yrel; event.motion.yrel = yrel;
event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
} }
mouse->last_x = mouse->x; mouse->last_x = mouse->x;
...@@ -488,17 +194,12 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure) ...@@ -488,17 +194,12 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
} }
int int
SDL_SendMouseButton(int id, Uint8 state, Uint8 button) SDL_SendMouseButton(Uint8 state, Uint8 button)
{ {
int index = SDL_GetMouseIndexId(id); SDL_Mouse *mouse = &SDL_mouse;
SDL_Mouse *mouse = SDL_GetMouse(index);
int posted; int posted;
Uint32 type; Uint32 type;
if (!mouse) {
return 0;
}
/* Figure out which event to perform */ /* Figure out which event to perform */
switch (state) { switch (state) {
case SDL_PRESSED: case SDL_PRESSED:
...@@ -527,7 +228,6 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button) ...@@ -527,7 +228,6 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
if (SDL_GetEventState(type) == SDL_ENABLE) { if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.type = type; event.type = type;
event.button.which = (Uint8) index;
event.button.state = state; event.button.state = state;
event.button.button = button; event.button.button = button;
event.button.x = mouse->x; event.button.x = mouse->x;
...@@ -539,12 +239,12 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button) ...@@ -539,12 +239,12 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
} }
int 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; int posted;
if (!mouse || (!x && !y)) { if (!x && !y) {
return 0; return 0;
} }
...@@ -553,53 +253,108 @@ SDL_SendMouseWheel(int index, int x, int y) ...@@ -553,53 +253,108 @@ SDL_SendMouseWheel(int index, int x, int y)
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) { if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.type = SDL_MOUSEWHEEL; event.type = SDL_MOUSEWHEEL;
event.wheel.which = (Uint8) index; event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
event.wheel.x = x; event.wheel.x = x;
event.wheel.y = y; event.wheel.y = y;
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
} }
return posted; return posted;
} }
void void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) SDL_MouseQuit(void)
{ {
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); }
if (!mouse) { Uint8
return; 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) { if (mouse->WarpMouse) {
mouse->WarpMouse(mouse, window, x, y); mouse->WarpMouse(mouse, window, x, y);
} else { } else {
SDL_SetMouseFocus(SDL_current_mouse, window); SDL_SetMouseFocus(window);
SDL_SendMouseMotion(SDL_current_mouse, 0, x, y, 0); 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_Cursor *
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
int w, int h, int hot_x, int hot_y) 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_Surface *surface;
SDL_Cursor *cursor; SDL_Cursor *cursor;
int x, y; int x, y;
Uint32 *pixel; Uint32 *pixel;
Uint8 datab, maskb; Uint8 datab = 0, maskb = 0;
const Uint32 black = 0xFF000000; const Uint32 black = 0xFF000000;
const Uint32 white = 0xFFFFFFFF; const Uint32 white = 0xFFFFFFFF;
const Uint32 transparent = 0x00000000; const Uint32 transparent = 0x00000000;
if (!mouse) {
SDL_SetError("No mice are initialized");
return NULL;
}
if (!mouse->CreateCursor) { if (!mouse->CreateCursor) {
SDL_SetError("Current mouse doesn't have cursor support"); SDL_SetError("Cursors are not currently supported");
return NULL; return NULL;
} }
...@@ -638,7 +393,6 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, ...@@ -638,7 +393,6 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
cursor = mouse->CreateCursor(surface, hot_x, hot_y); cursor = mouse->CreateCursor(surface, hot_x, hot_y);
if (cursor) { if (cursor) {
cursor->mouse = mouse;
cursor->next = mouse->cursors; cursor->next = mouse->cursors;
mouse->cursors = cursor; mouse->cursors = cursor;
} }
...@@ -655,12 +409,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, ...@@ -655,12 +409,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
void void
SDL_SetCursor(SDL_Cursor * cursor) SDL_SetCursor(SDL_Cursor * cursor)
{ {
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); SDL_Mouse *mouse = &SDL_mouse;
if (!mouse) {
SDL_SetError("No mice are initialized");
return;
}
/* Set the new cursor */ /* Set the new cursor */
if (cursor) { if (cursor) {
...@@ -694,7 +443,7 @@ SDL_SetCursor(SDL_Cursor * cursor) ...@@ -694,7 +443,7 @@ SDL_SetCursor(SDL_Cursor * cursor)
SDL_Cursor * SDL_Cursor *
SDL_GetCursor(void) SDL_GetCursor(void)
{ {
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); SDL_Mouse *mouse = &SDL_mouse;
if (!mouse) { if (!mouse) {
return NULL; return NULL;
...@@ -705,13 +454,12 @@ SDL_GetCursor(void) ...@@ -705,13 +454,12 @@ SDL_GetCursor(void)
void void
SDL_FreeCursor(SDL_Cursor * cursor) SDL_FreeCursor(SDL_Cursor * cursor)
{ {
SDL_Mouse *mouse; SDL_Mouse *mouse = &SDL_mouse;
SDL_Cursor *curr, *prev; SDL_Cursor *curr, *prev;
if (!cursor) { if (!cursor) {
return; return;
} }
mouse = cursor->mouse;
if (cursor == mouse->def_cursor) { if (cursor == mouse->def_cursor) {
return; return;
...@@ -740,7 +488,7 @@ SDL_FreeCursor(SDL_Cursor * cursor) ...@@ -740,7 +488,7 @@ SDL_FreeCursor(SDL_Cursor * cursor)
int int
SDL_ShowCursor(int toggle) SDL_ShowCursor(int toggle)
{ {
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); SDL_Mouse *mouse = &SDL_mouse;
SDL_bool shown; SDL_bool shown;
if (!mouse) { if (!mouse) {
...@@ -761,47 +509,4 @@ SDL_ShowCursor(int toggle) ...@@ -761,47 +509,4 @@ SDL_ShowCursor(int toggle)
return shown; 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: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -24,108 +24,33 @@ ...@@ -24,108 +24,33 @@
#ifndef _SDL_mouse_c_h #ifndef _SDL_mouse_c_h
#define _SDL_mouse_c_h #define _SDL_mouse_c_h
typedef struct SDL_Mouse SDL_Mouse;
struct SDL_Cursor struct SDL_Cursor
{ {
SDL_Mouse *mouse;
SDL_Cursor *next; SDL_Cursor *next;
void *driverdata; 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 */ /* Initialize the mouse subsystem */
extern int SDL_MouseInit(void); extern int SDL_MouseInit(void);
/* Get the mouse at an index */ /* Clear the mouse state */
extern SDL_Mouse *SDL_GetMouse(int index); extern void SDL_ResetMouse(void);
/* 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);
/* Set the mouse focus window */ /* 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 */ /* Send a mouse motion event */
extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z); extern int SDL_SendMouseMotion(int relative, int x, int y);
/* Send a mouse button event for a mouse */ /* Send a mouse button event */
extern int SDL_SendMouseButton(int id, Uint8 state, Uint8 button); extern int SDL_SendMouseButton(Uint8 state, Uint8 button);
/* Send a mouse wheel event for a mouse */ /* Send a mouse wheel event */
extern int SDL_SendMouseWheel(int id, int x, int y); extern int SDL_SendMouseWheel(int x, int y);
/* Send a proximity event for a mouse */
extern int SDL_SendProximity(int id, int x, int y, int type);
/* Shutdown the mouse subsystem */ /* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void); 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 */ #endif /* _SDL_mouse_c_h */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -62,20 +62,13 @@ ...@@ -62,20 +62,13 @@
NSRange _markedRange; NSRange _markedRange;
NSRange _selectedRange; NSRange _selectedRange;
SDL_Rect _inputRect; SDL_Rect _inputRect;
int _keyboard;
} }
- (void) doCommandBySelector:(SEL)myselector; - (void) doCommandBySelector:(SEL)myselector;
- (void) setInputRect:(SDL_Rect *) rect; - (void) setInputRect:(SDL_Rect *) rect;
- (void) setKeyboard:(int) keyboard;
@end @end
@implementation SDLTranslatorResponder @implementation SDLTranslatorResponder
- (void) setKeyboard:(int) keyboard
{
_keyboard = keyboard;
}
- (void) setInputRect:(SDL_Rect *) rect - (void) setInputRect:(SDL_Rect *) rect
{ {
_inputRect = *rect; _inputRect = *rect;
...@@ -94,7 +87,7 @@ ...@@ -94,7 +87,7 @@
else else
str = [aString UTF8String]; str = [aString UTF8String];
SDL_SendKeyboardText(_keyboard, str); SDL_SendKeyboardText(str);
} }
- (void) doCommandBySelector:(SEL) myselector - (void) doCommandBySelector:(SEL) myselector
...@@ -140,7 +133,7 @@ ...@@ -140,7 +133,7 @@
_selectedRange = selRange; _selectedRange = selRange;
_markedRange = NSMakeRange(0, [aString length]); _markedRange = NSMakeRange(0, [aString length]);
SDL_SendEditingText(_keyboard, [aString UTF8String], SDL_SendEditingText([aString UTF8String],
selRange.location, selRange.length); selRange.location, selRange.length);
DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText, DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
...@@ -204,7 +197,7 @@ ...@@ -204,7 +197,7 @@
* differentiating between left and right versions of the keys. * differentiating between left and right versions of the keys.
*/ */
static void static void
DoUnsidedModifiers(int keyboard, unsigned short scancode, DoUnsidedModifiers(unsigned short scancode,
unsigned int oldMods, unsigned int newMods) unsigned int oldMods, unsigned int newMods)
{ {
const int mapping[] = { const int mapping[] = {
...@@ -226,14 +219,14 @@ DoUnsidedModifiers(int keyboard, unsigned short scancode, ...@@ -226,14 +219,14 @@ DoUnsidedModifiers(int keyboard, unsigned short scancode,
if (oldMask && oldMask != newMask) { /* modifier up event */ if (oldMask && oldMask != newMask) { /* modifier up event */
/* If this was Caps Lock, we need some additional voodoo to make SDL happy */ /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
if (bit == NSAlphaShiftKeyMask) { 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 */ } 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 this was Caps Lock, we need some additional voodoo to make SDL happy */
if (bit == NSAlphaShiftKeyMask) { if (bit == NSAlphaShiftKeyMask) {
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, mapping[i]); SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
} }
} }
} }
...@@ -244,8 +237,7 @@ DoUnsidedModifiers(int keyboard, unsigned short scancode, ...@@ -244,8 +237,7 @@ DoUnsidedModifiers(int keyboard, unsigned short scancode,
* sides was made. * sides was made.
*/ */
static void static void
HandleNonDeviceModifier(int keyboard, HandleNonDeviceModifier(unsigned int device_independent_mask,
unsigned int device_independent_mask,
unsigned int oldMods, unsigned int oldMods,
unsigned int newMods, unsigned int newMods,
SDL_scancode scancode) SDL_scancode scancode)
...@@ -259,9 +251,9 @@ HandleNonDeviceModifier(int keyboard, ...@@ -259,9 +251,9 @@ HandleNonDeviceModifier(int keyboard,
newMask = newMods & device_independent_mask; newMask = newMods & device_independent_mask;
if (oldMask && oldMask != newMask) { if (oldMask && oldMask != newMask) {
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, scancode); SDL_SendKeyboardKey(SDL_RELEASED, scancode);
} else if (newMask && oldMask != newMask) { } else if (newMask && oldMask != newMask) {
SDL_SendKeyboardKey(keyboard, SDL_PRESSED, scancode); SDL_SendKeyboardKey(SDL_PRESSED, scancode);
} }
} }
...@@ -269,8 +261,7 @@ HandleNonDeviceModifier(int keyboard, ...@@ -269,8 +261,7 @@ HandleNonDeviceModifier(int keyboard,
* This function sets the actual SDL_PrivateKeyboard event. * This function sets the actual SDL_PrivateKeyboard event.
*/ */
static void static void
HandleModifierOneSide(int keyboard, HandleModifierOneSide(unsigned int oldMods, unsigned int newMods,
unsigned int oldMods, unsigned int newMods,
SDL_scancode scancode, SDL_scancode scancode,
unsigned int sided_device_dependent_mask) unsigned int sided_device_dependent_mask)
{ {
...@@ -287,9 +278,9 @@ HandleModifierOneSide(int keyboard, ...@@ -287,9 +278,9 @@ HandleModifierOneSide(int keyboard,
* find out which it is. * find out which it is.
*/ */
if (new_dep_mask && old_dep_mask != new_dep_mask) { if (new_dep_mask && old_dep_mask != new_dep_mask) {
SDL_SendKeyboardKey(keyboard, SDL_PRESSED, scancode); SDL_SendKeyboardKey(SDL_PRESSED, scancode);
} else { } else {
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, scancode); SDL_SendKeyboardKey(SDL_RELEASED, scancode);
} }
} }
...@@ -298,8 +289,7 @@ HandleModifierOneSide(int keyboard, ...@@ -298,8 +289,7 @@ HandleModifierOneSide(int keyboard,
* e.g. left-shift vs right-shift. * e.g. left-shift vs right-shift.
*/ */
static void static void
HandleModifierSide(int keyboard, HandleModifierSide(int device_independent_mask,
int device_independent_mask,
unsigned int oldMods, unsigned int newMods, unsigned int oldMods, unsigned int newMods,
SDL_scancode left_scancode, SDL_scancode left_scancode,
SDL_scancode right_scancode, SDL_scancode right_scancode,
...@@ -316,7 +306,7 @@ HandleModifierSide(int keyboard, ...@@ -316,7 +306,7 @@ HandleModifierSide(int keyboard,
*/ */
if ((device_dependent_mask & newMods) == 0) { if ((device_dependent_mask & newMods) == 0) {
/* Revert to the old behavior */ /* Revert to the old behavior */
HandleNonDeviceModifier(keyboard, device_independent_mask, oldMods, newMods, left_scancode); HandleNonDeviceModifier(device_independent_mask, oldMods, newMods, left_scancode);
return; return;
} }
...@@ -329,10 +319,10 @@ HandleModifierSide(int keyboard, ...@@ -329,10 +319,10 @@ HandleModifierSide(int keyboard,
* change or if the bits don't both exist. * change or if the bits don't both exist.
*/ */
if (left_device_dependent_mask & diff_mod) { 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) { 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 @@ HandleModifierSide(int keyboard, ...@@ -343,8 +333,7 @@ HandleModifierSide(int keyboard,
* can't still be down). * can't still be down).
*/ */
static void static void
ReleaseModifierSide(int keyboard, ReleaseModifierSide(unsigned int device_independent_mask,
unsigned int device_independent_mask,
unsigned int oldMods, unsigned int newMods, unsigned int oldMods, unsigned int newMods,
SDL_scancode left_scancode, SDL_scancode left_scancode,
SDL_scancode right_scancode, SDL_scancode right_scancode,
...@@ -362,7 +351,7 @@ ReleaseModifierSide(int keyboard, ...@@ -362,7 +351,7 @@ ReleaseModifierSide(int keyboard,
/* In this case, we can't detect the keyboard, so use the left side /* In this case, we can't detect the keyboard, so use the left side
* to represent both, and release it. * to represent both, and release it.
*/ */
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, left_scancode); SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
return; return;
} }
...@@ -373,10 +362,10 @@ ReleaseModifierSide(int keyboard, ...@@ -373,10 +362,10 @@ ReleaseModifierSide(int keyboard,
* so I hope this doesn't cause other problems. * so I hope this doesn't cause other problems.
*/ */
if ( left_device_dependent_mask & oldMods ) { 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 ) { if ( right_device_dependent_mask & oldMods ) {
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, right_scancode); SDL_SendKeyboardKey(SDL_RELEASED, right_scancode);
} }
} }
...@@ -384,7 +373,7 @@ ReleaseModifierSide(int keyboard, ...@@ -384,7 +373,7 @@ ReleaseModifierSide(int keyboard,
* This function handles the CapsLock case. * This function handles the CapsLock case.
*/ */
static void static void
HandleCapsLock(int keyboard, unsigned short scancode, HandleCapsLock(unsigned short scancode,
unsigned int oldMods, unsigned int newMods) unsigned int oldMods, unsigned int newMods)
{ {
unsigned int oldMask, newMask; unsigned int oldMask, newMask;
...@@ -393,16 +382,16 @@ HandleCapsLock(int keyboard, unsigned short scancode, ...@@ -393,16 +382,16 @@ HandleCapsLock(int keyboard, unsigned short scancode,
newMask = newMods & NSAlphaShiftKeyMask; newMask = newMods & NSAlphaShiftKeyMask;
if (oldMask != newMask) { if (oldMask != newMask) {
SDL_SendKeyboardKey(keyboard, SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
} }
oldMask = oldMods & NSNumericPadKeyMask; oldMask = oldMods & NSNumericPadKeyMask;
newMask = newMods & NSNumericPadKeyMask; newMask = newMods & NSNumericPadKeyMask;
if (oldMask != newMask) { if (oldMask != newMask) {
SDL_SendKeyboardKey(keyboard, SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
SDL_SendKeyboardKey(keyboard, SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
} }
} }
...@@ -410,7 +399,7 @@ HandleCapsLock(int keyboard, unsigned short scancode, ...@@ -410,7 +399,7 @@ HandleCapsLock(int keyboard, unsigned short scancode,
* correct side of the key. * correct side of the key.
*/ */
static void static void
DoSidedModifiers(int keyboard, unsigned short scancode, DoSidedModifiers(unsigned short scancode,
unsigned int oldMods, unsigned int newMods) unsigned int oldMods, unsigned int newMods)
{ {
/* Set up arrays for the key syms for the left and right side. */ /* Set up arrays for the key syms for the left and right side. */
...@@ -435,7 +424,7 @@ DoSidedModifiers(int keyboard, unsigned short scancode, ...@@ -435,7 +424,7 @@ DoSidedModifiers(int keyboard, unsigned short scancode,
unsigned int i, bit; unsigned int i, bit;
/* Handle CAPSLOCK separately because it doesn't have a left/right side */ /* 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 */ /* Iterate through the bits, testing each against the old modifiers */
for (i = 0, bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) { for (i = 0, bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) {
...@@ -448,7 +437,7 @@ DoSidedModifiers(int keyboard, unsigned short scancode, ...@@ -448,7 +437,7 @@ DoSidedModifiers(int keyboard, unsigned short scancode,
* and right side keys may alternate or both may be pressed. * and right side keys may alternate or both may be pressed.
*/ */
if (newMask) { if (newMask) {
HandleModifierSide(keyboard, bit, oldMods, newMods, HandleModifierSide(bit, oldMods, newMods,
left_mapping[i], right_mapping[i], left_mapping[i], right_mapping[i],
left_device_mapping[i], right_device_mapping[i]); left_device_mapping[i], right_device_mapping[i]);
} }
...@@ -456,7 +445,7 @@ DoSidedModifiers(int keyboard, unsigned short scancode, ...@@ -456,7 +445,7 @@ DoSidedModifiers(int keyboard, unsigned short scancode,
* the device dependent bits to release the correct keys. * the device dependent bits to release the correct keys.
*/ */
else if (oldMask && oldMask != newMask) { else if (oldMask && oldMask != newMask) {
ReleaseModifierSide(keyboard, bit, oldMods, newMods, ReleaseModifierSide(bit, oldMods, newMods,
left_mapping[i], right_mapping[i], left_mapping[i], right_mapping[i],
left_device_mapping[i], right_device_mapping[i]); left_device_mapping[i], right_device_mapping[i]);
} }
...@@ -477,9 +466,9 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags) ...@@ -477,9 +466,9 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
* left side and right side modifiers is available. * left side and right side modifiers is available.
*/ */
if (data->osversion >= 0x1030) { if (data->osversion >= 0x1030) {
DoSidedModifiers(data->keyboard, scancode, data->modifierFlags, modifierFlags); DoSidedModifiers(scancode, data->modifierFlags, modifierFlags);
} else { } else {
DoUnsidedModifiers(data->keyboard, scancode, data->modifierFlags, modifierFlags); DoUnsidedModifiers(scancode, data->modifierFlags, modifierFlags);
} }
data->modifierFlags = modifierFlags; data->modifierFlags = modifierFlags;
} }
...@@ -549,7 +538,7 @@ UpdateKeymap(SDL_VideoData *data) ...@@ -549,7 +538,7 @@ UpdateKeymap(SDL_VideoData *data)
keymap[scancode] = s[0]; keymap[scancode] = s[0];
} }
} }
SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES); SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
return; return;
} }
...@@ -603,7 +592,7 @@ cleanup: ...@@ -603,7 +592,7 @@ cleanup:
keymap[scancode] = c; keymap[scancode] = c;
} }
} }
SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES); SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
return; return;
} }
#endif #endif
...@@ -613,10 +602,7 @@ void ...@@ -613,10 +602,7 @@ void
Cocoa_InitKeyboard(_THIS) Cocoa_InitKeyboard(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Keyboard keyboard;
SDL_zero(keyboard);
data->keyboard = SDL_AddKeyboard(&keyboard, -1);
UpdateKeymap(data); UpdateKeymap(data);
/* Set our own names for the platform-dependent but layout-independent keys */ /* Set our own names for the platform-dependent but layout-independent keys */
...@@ -645,8 +631,6 @@ Cocoa_StartTextInput(_THIS) ...@@ -645,8 +631,6 @@ Cocoa_StartTextInput(_THIS)
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)]; [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
} }
[data->fieldEdit setKeyboard: data->keyboard];
if (![[data->fieldEdit superview] isEqual: parentView]) if (![[data->fieldEdit superview] isEqual: parentView])
{ {
// DEBUG_IME(@"add fieldEdit to window contentView"); // DEBUG_IME(@"add fieldEdit to window contentView");
...@@ -686,7 +670,9 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) ...@@ -686,7 +670,9 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
unsigned short scancode = [event keyCode]; unsigned short scancode = [event keyCode];
SDL_scancode code; SDL_scancode code;
#if 0
const char *text; const char *text;
#endif
if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) {
/* see comments in SDL_cocoakeys.h */ /* see comments in SDL_cocoakeys.h */
...@@ -706,7 +692,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) ...@@ -706,7 +692,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
/* See if we need to rebuild the keyboard layout */ /* See if we need to rebuild the keyboard layout */
UpdateKeymap(data); UpdateKeymap(data);
SDL_SendKeyboardKey(data->keyboard, SDL_PRESSED, code); SDL_SendKeyboardKey(SDL_PRESSED, code);
#if 1 #if 1
if (code == SDL_SCANCODE_UNKNOWN) { 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 <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode); fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
...@@ -719,14 +705,14 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) ...@@ -719,14 +705,14 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
#if 0 #if 0
text = [[event characters] UTF8String]; text = [[event characters] UTF8String];
if(text && *text) { if(text && *text) {
SDL_SendKeyboardText(data->keyboard, text); SDL_SendKeyboardText(text);
[data->fieldEdit setString:@""]; [data->fieldEdit setString:@""];
} }
#endif #endif
} }
break; break;
case NSKeyUp: case NSKeyUp:
SDL_SendKeyboardKey(data->keyboard, SDL_RELEASED, code); SDL_SendKeyboardKey(SDL_RELEASED, code);
break; break;
case NSFlagsChanged: case NSFlagsChanged:
/* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */ /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */
...@@ -740,10 +726,6 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) ...@@ -740,10 +726,6 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
void void
Cocoa_QuitKeyboard(_THIS) Cocoa_QuitKeyboard(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
NSAutoreleasePool *pool;
SDL_DelKeyboard(data->keyboard);
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -29,11 +29,6 @@ ...@@ -29,11 +29,6 @@
void void
Cocoa_InitMouse(_THIS) 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 static int
...@@ -54,10 +49,8 @@ ConvertMouseButtonToSDL(int button) ...@@ -54,10 +49,8 @@ ConvertMouseButtonToSDL(int button)
void void
Cocoa_HandleMouseEvent(_THIS, NSEvent *event) Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Mouse *mouse = SDL_GetMouse(data->mouse);
int i; int i;
NSPoint point; NSPoint point = { 0, 0 };
SDL_Window *window; SDL_Window *window;
/* See if there are any fullscreen windows that might handle this event */ /* See if there are any fullscreen windows that might handle this event */
...@@ -73,44 +66,38 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) ...@@ -73,44 +66,38 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
point = [NSEvent mouseLocation]; point = [NSEvent mouseLocation];
point.x = point.x - bounds.x; point.x = point.x - bounds.x;
point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - bounds.y; point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - bounds.y;
if (point.x < 0 || point.x >= candidate->w || if ((point.x >= 0 && point.x < candidate->w) ||
point.y < 0 || point.y >= candidate->h) { (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 {
/* This is it! */ /* This is it! */
window = candidate; window = candidate;
break; break;
} }
} }
} }
if (!window) {
return;
}
/* Set the focus appropriately */ /* Set the focus appropriately */
if (mouse->focus != window) { SDL_SetMouseFocus(window);
SDL_SetMouseFocus(data->mouse, window);
if (window) {
return;
} }
switch ([event type]) { switch ([event type]) {
case NSLeftMouseDown: case NSLeftMouseDown:
case NSOtherMouseDown: case NSOtherMouseDown:
case NSRightMouseDown: case NSRightMouseDown:
SDL_SendMouseButton(data->mouse, SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber])); SDL_SendMouseButton(SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber]));
break; break;
case NSLeftMouseUp: case NSLeftMouseUp:
case NSOtherMouseUp: case NSOtherMouseUp:
case NSRightMouseUp: case NSRightMouseUp:
SDL_SendMouseButton(data->mouse, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber])); SDL_SendMouseButton(SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
break; break;
case NSLeftMouseDragged: case NSLeftMouseDragged:
case NSRightMouseDragged: case NSRightMouseDragged:
case NSOtherMouseDragged: /* usually middle mouse dragged */ case NSOtherMouseDragged: /* usually middle mouse dragged */
case NSMouseMoved: case NSMouseMoved:
SDL_SendMouseMotion(data->mouse, 0, (int)point.x, (int)point.y, 0); SDL_SendMouseMotion(0, (int)point.x, (int)point.y);
break; break;
default: /* just to avoid compiler warnings */ default: /* just to avoid compiler warnings */
break; break;
...@@ -120,9 +107,6 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) ...@@ -120,9 +107,6 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
void void
Cocoa_QuitMouse(_THIS) Cocoa_QuitMouse(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DelMouse(data->mouse);
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -57,8 +57,6 @@ typedef struct SDL_VideoData ...@@ -57,8 +57,6 @@ typedef struct SDL_VideoData
{ {
SInt32 osversion; SInt32 osversion;
unsigned int modifierFlags; unsigned int modifierFlags;
int mouse;
int keyboard;
void *key_layout; void *key_layout;
SDLTranslatorResponder *fieldEdit; SDLTranslatorResponder *fieldEdit;
Uint32 screensaver_activity; Uint32 screensaver_activity;
......
...@@ -126,28 +126,21 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -126,28 +126,21 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)windowDidBecomeKey:(NSNotification *)aNotification - (void)windowDidBecomeKey:(NSNotification *)aNotification
{ {
int index;
/* We're going to get keyboard events, since we're key. */ /* We're going to get keyboard events, since we're key. */
index = _data->videodata->keyboard; SDL_SetKeyboardFocus(_data->window);
SDL_SetKeyboardFocus(index, _data->window);
} }
- (void)windowDidResignKey:(NSNotification *)aNotification - (void)windowDidResignKey:(NSNotification *)aNotification
{ {
int index;
SDL_Mouse *mouse;
/* Some other window will get mouse events, since we're not key. */ /* Some other window will get mouse events, since we're not key. */
index = _data->videodata->mouse; if (SDL_GetMouseFocus() == _data->window) {
mouse = SDL_GetMouse(index); SDL_SetMouseFocus(NULL);
if (mouse->focus == _data->window) {
SDL_SetMouseFocus(index, 0);
} }
/* Some other window will get keyboard events, since we're not key. */ /* Some other window will get keyboard events, since we're not key. */
index = _data->videodata->keyboard; if (SDL_GetKeyboardFocus() == _data->window) {
SDL_SetKeyboardFocus(index, 0); SDL_SetKeyboardFocus(NULL);
}
} }
- (void)windowDidHide:(NSNotification *)aNotification - (void)windowDidHide:(NSNotification *)aNotification
...@@ -162,10 +155,8 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -162,10 +155,8 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)mouseDown:(NSEvent *)theEvent - (void)mouseDown:(NSEvent *)theEvent
{ {
int index;
int button; int button;
index = _data->videodata->mouse;
switch ([theEvent buttonNumber]) { switch ([theEvent buttonNumber]) {
case 0: case 0:
button = SDL_BUTTON_LEFT; button = SDL_BUTTON_LEFT;
...@@ -180,7 +171,7 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -180,7 +171,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
button = [theEvent buttonNumber]; button = [theEvent buttonNumber];
break; break;
} }
SDL_SendMouseButton(index, SDL_PRESSED, button); SDL_SendMouseButton(SDL_PRESSED, button);
} }
- (void)rightMouseDown:(NSEvent *)theEvent - (void)rightMouseDown:(NSEvent *)theEvent
...@@ -195,10 +186,8 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -195,10 +186,8 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)mouseUp:(NSEvent *)theEvent - (void)mouseUp:(NSEvent *)theEvent
{ {
int index;
int button; int button;
index = _data->videodata->mouse;
switch ([theEvent buttonNumber]) { switch ([theEvent buttonNumber]) {
case 0: case 0:
button = SDL_BUTTON_LEFT; button = SDL_BUTTON_LEFT;
...@@ -213,7 +202,7 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -213,7 +202,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
button = [theEvent buttonNumber]; button = [theEvent buttonNumber];
break; break;
} }
SDL_SendMouseButton(index, SDL_RELEASED, button); SDL_SendMouseButton(SDL_RELEASED, button);
} }
- (void)rightMouseUp:(NSEvent *)theEvent - (void)rightMouseUp:(NSEvent *)theEvent
...@@ -229,24 +218,18 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -229,24 +218,18 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)mouseMoved:(NSEvent *)theEvent - (void)mouseMoved:(NSEvent *)theEvent
{ {
SDL_Window *window = _data->window; SDL_Window *window = _data->window;
int index;
SDL_Mouse *mouse;
NSPoint point; NSPoint point;
index = _data->videodata->mouse;
mouse = SDL_GetMouse(index);
point = [theEvent locationInWindow]; point = [theEvent locationInWindow];
point.y = window->h - point.y; point.y = window->h - point.y;
if ( point.x < 0 || point.x >= window->w || if ( point.x < 0 || point.x >= window->w ||
point.y < 0 || point.y >= window->h ) { point.y < 0 || point.y >= window->h ) {
if (mouse->focus != 0) { if (SDL_GetMouseFocus() == window) {
SDL_SetMouseFocus(index, 0); SDL_SetMouseFocus(NULL);
} }
} else { } else {
if (mouse->focus != _data->window) { SDL_SetMouseFocus(_data->window);
SDL_SetMouseFocus(index, _data->window); SDL_SendMouseMotion(0, (int)point.x, (int)point.y);
}
SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0);
} }
} }
...@@ -267,10 +250,7 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -267,10 +250,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)scrollWheel:(NSEvent *)theEvent - (void)scrollWheel:(NSEvent *)theEvent
{ {
int index; SDL_SendMouseWheel((int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
index = _data->videodata->mouse;
SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
} }
@end @end
...@@ -361,9 +341,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created ...@@ -361,9 +341,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
window->flags &= ~SDL_WINDOW_MINIMIZED; window->flags &= ~SDL_WINDOW_MINIMIZED;
} }
if ([nswindow isKeyWindow]) { if ([nswindow isKeyWindow]) {
int index = data->videodata->keyboard;
window->flags |= SDL_WINDOW_INPUT_FOCUS; window->flags |= SDL_WINDOW_INPUT_FOCUS;
SDL_SetKeyboardFocus(index, data->window); SDL_SetKeyboardFocus(data->window);
if (window->flags & SDL_WINDOW_INPUT_GRABBED) { if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
/* FIXME */ /* FIXME */
...@@ -385,8 +364,6 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) ...@@ -385,8 +364,6 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
NSRect rect; NSRect rect;
SDL_Rect bounds; SDL_Rect bounds;
unsigned int style; unsigned int style;
NSString *title;
int status;
Cocoa_GetDisplayBounds(_this, display, &bounds); Cocoa_GetDisplayBounds(_this, display, &bounds);
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
...@@ -452,7 +429,6 @@ Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) ...@@ -452,7 +429,6 @@ Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
NSWindow *nswindow = (NSWindow *) data; NSWindow *nswindow = (NSWindow *) data;
NSString *title; NSString *title;
int status;
pool = [[NSAutoreleasePool alloc] init]; pool = [[NSAutoreleasePool alloc] init];
...@@ -625,7 +601,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window) ...@@ -625,7 +601,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
SDL_bool SDL_bool
Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) 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) { if (info->version.major <= SDL_MAJOR_VERSION) {
//info->window = nswindow; //info->window = nswindow;
......
...@@ -38,8 +38,10 @@ ...@@ -38,8 +38,10 @@
#else #else
@interface SDL_uikitview : UIView { @interface SDL_uikitview : UIView {
#endif #endif
#if FIXME_MULTITOUCH
SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES]; SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
#endif
#if SDL_IPHONE_KEYBOARD #if SDL_IPHONE_KEYBOARD
UITextField *textField; UITextField *textField;
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
[self initializeKeyboard]; [self initializeKeyboard];
#endif #endif
#if FIXME_MULTITOUCH
int i; int i;
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) { for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) {
mice[i].id = i; mice[i].id = i;
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1); SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1);
} }
self.multipleTouchEnabled = YES; self.multipleTouchEnabled = YES;
#endif
return self; return self;
...@@ -64,6 +66,7 @@ ...@@ -64,6 +66,7 @@
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch =(UITouch*)[enumerator nextObject]; UITouch *touch =(UITouch*)[enumerator nextObject];
#if FIXME_MULTITOUCH
/* associate touches with mice, so long as we have slots */ /* associate touches with mice, so long as we have slots */
int i; int i;
int found = 0; int found = 0;
...@@ -104,7 +107,8 @@ ...@@ -104,7 +107,8 @@
/* switch back to our old mouse */ /* switch back to our old mouse */
SDL_SelectMouse(oldMouse); SDL_SelectMouse(oldMouse);
} }
#endif
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
...@@ -112,6 +116,7 @@ ...@@ -112,6 +116,7 @@
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch=nil; UITouch *touch=nil;
#if FIXME_MULTITOUCH
while(touch = (UITouch *)[enumerator nextObject]) { while(touch = (UITouch *)[enumerator nextObject]) {
/* search for the mouse slot associated with this touch */ /* search for the mouse slot associated with this touch */
int i, found = NO; int i, found = NO;
...@@ -127,6 +132,7 @@ ...@@ -127,6 +132,7 @@
} }
} }
} }
#endif
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
...@@ -143,6 +149,7 @@ ...@@ -143,6 +149,7 @@
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch=nil; UITouch *touch=nil;
#if FIXME_MULTITOUCH
while(touch = (UITouch *)[enumerator nextObject]) { while(touch = (UITouch *)[enumerator nextObject]) {
/* try to find the mouse associated with this touch */ /* try to find the mouse associated with this touch */
int i, found = NO; int i, found = NO;
...@@ -157,6 +164,7 @@ ...@@ -157,6 +164,7 @@
} }
} }
} }
#endif
} }
/* /*
......
...@@ -58,12 +58,6 @@ ...@@ -58,12 +58,6 @@
#define WM_INPUT 0x00ff #define WM_INPUT 0x00ff
#endif #endif
extern HCTX *g_hCtx;
extern HANDLE *mice;
extern int total_mice;
extern int tablet;
int pressure = 0; /* the pressure reported by the tablet */
static WPARAM static WPARAM
RemapVKEY(WPARAM wParam, LPARAM lParam) RemapVKEY(WPARAM wParam, LPARAM lParam)
{ {
...@@ -104,8 +98,6 @@ LRESULT CALLBACK ...@@ -104,8 +98,6 @@ LRESULT CALLBACK
WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
SDL_WindowData *data; SDL_WindowData *data;
RAWINPUT *raw;
PACKET packet;
LRESULT returnCode = -1; LRESULT returnCode = -1;
/* Send a SDL_SYSWMEVENT if the application wants them */ /* Send a SDL_SYSWMEVENT if the application wants them */
...@@ -142,35 +134,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -142,35 +134,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
switch (msg) { switch (msg) {
case WT_PACKET:
{
/* if we receive such data we need to update the pressure */
SDL_VideoData *videodata = data->videodata;
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: case WM_SHOWWINDOW:
{ {
if (wParam) { if (wParam) {
...@@ -183,13 +146,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -183,13 +146,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
int index;
SDL_Keyboard *keyboard;
BOOL minimized; BOOL minimized;
minimized = HIWORD(wParam); minimized = HIWORD(wParam);
index = data->videodata->keyboard;
keyboard = SDL_GetKeyboard(index);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
SDL_SendWindowEvent(data->window, SDL_SendWindowEvent(data->window,
...@@ -200,13 +159,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -200,13 +159,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_WINDOWEVENT_MAXIMIZED, 0, 0); SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
} }
#endif #endif
if (keyboard && keyboard->focus != data->window) { if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(index, data->window); SDL_SetKeyboardFocus(data->window);
} }
/* FIXME: Update keyboard state */ /* FIXME: Update keyboard state */
} else { } else {
if (keyboard && keyboard->focus == data->window) { if (SDL_GetKeyboardFocus() == data->window) {
SDL_SetKeyboardFocus(index, 0); SDL_SetKeyboardFocus(NULL);
} }
if (minimized) { if (minimized) {
SDL_SendWindowEvent(data->window, SDL_SendWindowEvent(data->window,
...@@ -217,124 +176,22 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -217,124 +176,22 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
returnCode = 0; returnCode = 0;
break; 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: case WM_MOUSEMOVE:
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); SDL_SendMouseMotion(0, LOWORD(lParam), HIWORD(lParam));
break; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); SDL_SendMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT);
SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0); SDL_SendMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT);
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;
break; break;
#endif /* _WIN32_WCE */
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
{ {
int i; if (SDL_GetMouseFocus() == data->window) {
SDL_SetMouseFocus(NULL);
for (i = 0; i < SDL_GetNumMice(); ++i) {
SDL_Mouse *mouse = SDL_GetMouse(i);
if (mouse->focus == data->window) {
SDL_SetMouseFocus(i, 0);
}
} }
} }
returnCode = 0; returnCode = 0;
...@@ -343,15 +200,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -343,15 +200,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
case WM_KEYDOWN: case WM_KEYDOWN:
{ {
int index;
/* Ignore repeated keys */ /* Ignore repeated keys */
if (lParam & REPEATED_KEYMASK) { if (lParam & REPEATED_KEYMASK) {
returnCode = 0; returnCode = 0;
break; break;
} }
index = data->videodata->keyboard;
wParam = RemapVKEY(wParam, lParam); wParam = RemapVKEY(wParam, lParam);
switch (wParam) { switch (wParam) {
case VK_CONTROL: case VK_CONTROL:
...@@ -388,7 +242,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -388,7 +242,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break; break;
} }
if (wParam < 256) { if (wParam < 256) {
SDL_SendKeyboardKey(index, SDL_PRESSED, SDL_SendKeyboardKey(SDL_PRESSED,
data->videodata->key_layout[wParam]); data->videodata->key_layout[wParam]);
} }
} }
...@@ -398,9 +252,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -398,9 +252,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYUP: case WM_SYSKEYUP:
case WM_KEYUP: case WM_KEYUP:
{ {
int index;
index = data->videodata->keyboard;
wParam = RemapVKEY(wParam, lParam); wParam = RemapVKEY(wParam, lParam);
switch (wParam) { switch (wParam) {
case VK_CONTROL: case VK_CONTROL:
...@@ -441,11 +292,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -441,11 +292,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (wParam == VK_SNAPSHOT if (wParam == VK_SNAPSHOT
&& SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] == && SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
SDL_RELEASED) { SDL_RELEASED) {
SDL_SendKeyboardKey(index, SDL_PRESSED, SDL_SendKeyboardKey(SDL_PRESSED,
data->videodata->key_layout[wParam]); data->videodata->key_layout[wParam]);
} }
if (wParam < 256) { if (wParam < 256) {
SDL_SendKeyboardKey(index, SDL_RELEASED, SDL_SendKeyboardKey(SDL_RELEASED,
data->videodata->key_layout[wParam]); data->videodata->key_layout[wParam]);
} }
} }
...@@ -470,14 +321,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -470,14 +321,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
text[2] = 0x80 | (char) (wParam & 0x3F); text[2] = 0x80 | (char) (wParam & 0x3F);
text[3] = '\0'; text[3] = '\0';
} }
SDL_SendKeyboardText(data->videodata->keyboard, text); SDL_SendKeyboardText(text);
} }
returnCode = 0; returnCode = 0;
break; break;
case WM_INPUTLANGCHANGE: case WM_INPUTLANGCHANGE:
{ {
WIN_UpdateKeymap(data->videodata->keyboard); WIN_UpdateKeymap();
} }
returnCode = 1; returnCode = 1;
break; break;
......
...@@ -50,7 +50,6 @@ void ...@@ -50,7 +50,6 @@ void
WIN_InitKeyboard(_THIS) WIN_InitKeyboard(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Keyboard keyboard;
int i; int i;
/* Make sure the alpha scancodes are correct. T isn't usually remapped */ /* Make sure the alpha scancodes are correct. T isn't usually remapped */
...@@ -82,9 +81,7 @@ WIN_InitKeyboard(_THIS) ...@@ -82,9 +81,7 @@ WIN_InitKeyboard(_THIS)
data->key_layout = win32_scancode_table; data->key_layout = win32_scancode_table;
SDL_zero(keyboard); WIN_UpdateKeymap();
data->keyboard = SDL_AddKeyboard(&keyboard, -1);
WIN_UpdateKeymap(data->keyboard);
SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows"); SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
...@@ -92,7 +89,7 @@ WIN_InitKeyboard(_THIS) ...@@ -92,7 +89,7 @@ WIN_InitKeyboard(_THIS)
} }
void void
WIN_UpdateKeymap(int keyboard) WIN_UpdateKeymap()
{ {
int i; int i;
SDL_scancode scancode; SDL_scancode scancode;
...@@ -117,15 +114,12 @@ WIN_UpdateKeymap(int keyboard) ...@@ -117,15 +114,12 @@ WIN_UpdateKeymap(int keyboard)
keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF); 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 void
WIN_QuitKeyboard(_THIS) WIN_QuitKeyboard(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DelKeyboard(data->keyboard);
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -28,7 +28,7 @@ extern BYTE alpha_scancodes[26]; ...@@ -28,7 +28,7 @@ extern BYTE alpha_scancodes[26];
extern BYTE keypad_scancodes[10]; extern BYTE keypad_scancodes[10];
extern void WIN_InitKeyboard(_THIS); extern void WIN_InitKeyboard(_THIS);
extern void WIN_UpdateKeymap(int keyboard); extern void WIN_UpdateKeymap(void);
extern void WIN_QuitKeyboard(_THIS); extern void WIN_QuitKeyboard(_THIS);
#endif /* _SDL_win32keyboard_h */ #endif /* _SDL_win32keyboard_h */
......
...@@ -160,7 +160,6 @@ WIN_AddDisplay(LPTSTR DeviceName) ...@@ -160,7 +160,6 @@ WIN_AddDisplay(LPTSTR DeviceName)
int int
WIN_InitModes(_THIS) WIN_InitModes(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
DWORD i, j, count; DWORD i, j, count;
DISPLAY_DEVICE device; DISPLAY_DEVICE device;
......
...@@ -31,182 +31,14 @@ ...@@ -31,182 +31,14 @@
#include "SDL_win32video.h" #include "SDL_win32video.h"
#include "../../events/SDL_mouse_c.h"
extern HANDLE *mice;
extern int total_mice;
extern int tablet;
void void
WIN_InitMouse(_THIS) 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, &regtype, 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 void
WIN_QuitMouse(_THIS) 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: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -35,11 +35,6 @@ ...@@ -35,11 +35,6 @@
static int WIN_VideoInit(_THIS); static int WIN_VideoInit(_THIS);
static void WIN_VideoQuit(_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 */ /* WIN32 driver bootstrap functions */
static int static int
...@@ -66,9 +61,6 @@ WIN_DeleteDevice(SDL_VideoDevice * device) ...@@ -66,9 +61,6 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
FreeLibrary(data->ddrawDLL); FreeLibrary(data->ddrawDLL);
} }
#endif #endif
if (data->wintabDLL) {
FreeLibrary(data->wintabDLL);
}
SDL_free(device->driverdata); SDL_free(device->driverdata);
SDL_free(device); SDL_free(device);
} }
...@@ -85,8 +77,10 @@ WIN_CreateDevice(int devindex) ...@@ -85,8 +77,10 @@ WIN_CreateDevice(int devindex)
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device) { if (device) {
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
} else {
data = NULL;
} }
if (!device || !data) { if (!data) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if (device) { if (device) {
SDL_free(device); SDL_free(device);
...@@ -131,32 +125,6 @@ WIN_CreateDevice(int devindex) ...@@ -131,32 +125,6 @@ WIN_CreateDevice(int devindex)
} }
#endif /* SDL_VIDEO_RENDER_DDRAW */ #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 */ /* Set the function pointers */
device->VideoInit = WIN_VideoInit; device->VideoInit = WIN_VideoInit;
device->VideoQuit = WIN_VideoQuit; device->VideoQuit = WIN_VideoQuit;
...@@ -225,7 +193,6 @@ WIN_VideoInit(_THIS) ...@@ -225,7 +193,6 @@ WIN_VideoInit(_THIS)
GAPI_AddRenderDriver(_this); GAPI_AddRenderDriver(_this);
#endif #endif
g_hCtx = SDL_malloc(sizeof(HCTX));
WIN_InitKeyboard(_this); WIN_InitKeyboard(_this);
WIN_InitMouse(_this); WIN_InitMouse(_this);
...@@ -238,7 +205,6 @@ WIN_VideoQuit(_THIS) ...@@ -238,7 +205,6 @@ WIN_VideoQuit(_THIS)
WIN_QuitModes(_this); WIN_QuitModes(_this);
WIN_QuitKeyboard(_this); WIN_QuitKeyboard(_this);
WIN_QuitMouse(_this); WIN_QuitMouse(_this);
SDL_free(g_hCtx);
} }
/* vim: set ts=4 sw=4 expandtab: */ /* vim: set ts=4 sw=4 expandtab: */
...@@ -45,11 +45,6 @@ ...@@ -45,11 +45,6 @@
#include "ddraw.h" #include "ddraw.h"
#endif #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_win32events.h"
#include "SDL_win32gamma.h" #include "SDL_win32gamma.h"
#include "SDL_win32keyboard.h" #include "SDL_win32keyboard.h"
...@@ -79,16 +74,6 @@ typedef struct SDL_VideoData ...@@ -79,16 +74,6 @@ typedef struct SDL_VideoData
IDirectDraw *ddraw; IDirectDraw *ddraw;
#endif #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; const SDL_scancode *key_layout;
} SDL_VideoData; } SDL_VideoData;
......
...@@ -73,9 +73,6 @@ CE_SHFullScreen(HWND hwndRequester, DWORD dwState) ...@@ -73,9 +73,6 @@ CE_SHFullScreen(HWND hwndRequester, DWORD dwState)
#endif #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. */ /* Fake window to help with DirectInput events. */
HWND SDL_HelperWindow = NULL; HWND SDL_HelperWindow = NULL;
static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
...@@ -165,9 +162,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) ...@@ -165,9 +162,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
} }
} }
if (GetFocus() == hwnd) { if (GetFocus() == hwnd) {
int index = data->videodata->keyboard;
window->flags |= SDL_WINDOW_INPUT_FOCUS; window->flags |= SDL_WINDOW_INPUT_FOCUS;
SDL_SetKeyboardFocus(index, data->window); SDL_SetKeyboardFocus(data->window);
if (window->flags & SDL_WINDOW_INPUT_GRABBED) { if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
RECT rect; RECT rect;
...@@ -186,11 +182,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) ...@@ -186,11 +182,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
int int
WIN_CreateWindow(_THIS, SDL_Window * window) WIN_CreateWindow(_THIS, SDL_Window * window)
{ {
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_VideoDisplay *display = window->display; SDL_VideoDisplay *display = window->display;
RAWINPUTDEVICE Rid;
AXIS TabX, TabY;
LOGCONTEXTA lc;
HWND hwnd; HWND hwnd;
HWND top; HWND top;
RECT rect; RECT rect;
...@@ -257,48 +249,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -257,48 +249,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
return -1; 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); WIN_PumpEvents(_this);
if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) { if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
...@@ -620,15 +570,11 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window) ...@@ -620,15 +570,11 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window)
void void
WIN_DestroyWindow(_THIS, SDL_Window * window) WIN_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (data) { if (data) {
ReleaseDC(data->hwnd, data->hdc); ReleaseDC(data->hwnd, data->hdc);
if (data->created) { if (data->created) {
if (videodata->wintabDLL) {
videodata->WTClose(g_hCtx[window->id]);
}
DestroyWindow(data->hwnd); DestroyWindow(data->hwnd);
} }
SDL_free(data); SDL_free(data);
......
/* *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 <PACKETNAME>PACKETDATA and <PACKETNAME>PACKETMODE similar to
2.a. above.
c. Include pktdef.h.
d. The generated structure typedef will be called
<PACKETNAME>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 <PACKETNAME>PACKET<EXTENSION>
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 <PACKETNAME>PACKETDATA and use the
result in the lcPktData field of the LOGCONTEXT structure.
e. If <PACKETNAME>PACKET<EXTENSION> was PKEXT_RELATIVE, OR the
packet mask bit with <PACKETNAME>PACKETMODE and use the result
in the lcPktMode field of the LOGCONTEXT structure.
Example #1. -- single packet format
#include <wintab.h>
#define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/
#define PACKETMODE PK_BUTTONS /@ buttons relative mode @/
#include <pktdef.h>
...
lc.lcPktData = PACKETDATA;
lc.lcPktMode = PACKETMODE;
Example #2. -- multiple formats
#include <wintab.h>
#define PACKETNAME MOE
#define MOEPACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/
#define MOEPACKETMODE PK_BUTTONS /@ buttons relative mode @/
#include <pktdef.h>
#define PACKETNAME LARRY
#define LARRYPACKETDATA PK_Y | PK_Z | PK_BUTTONS /@ y, z, buttons @/
#define LARRYPACKETMODE PK_BUTTONS /@ buttons relative mode @/
#include <pktdef.h>
#define PACKETNAME CURLY
#define CURLYPACKETDATA PK_X | PK_Z | PK_BUTTONS /@ x, z, buttons @/
#define CURLYPACKETMODE PK_BUTTONS /@ buttons relative mode @/
#include <pktdef.h>
...
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 <wintab.h>
#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 <pktdef.h>
...
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 */
/* *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 */
/* *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 */
...@@ -23,12 +23,14 @@ ...@@ -23,12 +23,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <signal.h>
#include <unistd.h> #include <unistd.h>
#include "SDL_x11video.h" #include "SDL_x11video.h"
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_mouse_c.h"
#include "SDL_timer.h"
#include "SDL_syswm.h" #include "SDL_syswm.h"
static void static void
...@@ -93,13 +95,7 @@ X11_DispatchEvent(_THIS) ...@@ -93,13 +95,7 @@ X11_DispatchEvent(_THIS)
if (xevent.xcrossing.mode == NotifyUngrab) if (xevent.xcrossing.mode == NotifyUngrab)
printf("Mode: NotifyUngrab\n"); printf("Mode: NotifyUngrab\n");
#endif #endif
#if 1 SDL_SetMouseFocus(data->window);
/* 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
} }
break; break;
...@@ -116,13 +112,7 @@ X11_DispatchEvent(_THIS) ...@@ -116,13 +112,7 @@ X11_DispatchEvent(_THIS)
printf("Mode: NotifyUngrab\n"); printf("Mode: NotifyUngrab\n");
#endif #endif
if (xevent.xcrossing.detail != NotifyInferior) { if (xevent.xcrossing.detail != NotifyInferior) {
#if 1 SDL_SetMouseFocus(NULL);
/* 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
} }
} }
break; break;
...@@ -132,7 +122,7 @@ X11_DispatchEvent(_THIS) ...@@ -132,7 +122,7 @@ X11_DispatchEvent(_THIS)
#ifdef DEBUG_XEVENTS #ifdef DEBUG_XEVENTS
printf("FocusIn!\n"); printf("FocusIn!\n");
#endif #endif
SDL_SetKeyboardFocus(videodata->keyboard, data->window); SDL_SetKeyboardFocus(data->window);
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
if (data->ic) { if (data->ic) {
XSetICFocus(data->ic); XSetICFocus(data->ic);
...@@ -146,7 +136,7 @@ X11_DispatchEvent(_THIS) ...@@ -146,7 +136,7 @@ X11_DispatchEvent(_THIS)
#ifdef DEBUG_XEVENTS #ifdef DEBUG_XEVENTS
printf("FocusOut!\n"); printf("FocusOut!\n");
#endif #endif
SDL_SetKeyboardFocus(videodata->keyboard, 0); SDL_SetKeyboardFocus(NULL);
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
if (data->ic) { if (data->ic) {
XUnsetICFocus(data->ic); XUnsetICFocus(data->ic);
...@@ -185,8 +175,7 @@ X11_DispatchEvent(_THIS) ...@@ -185,8 +175,7 @@ X11_DispatchEvent(_THIS)
#ifdef DEBUG_XEVENTS #ifdef DEBUG_XEVENTS
printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
#endif #endif
SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED, SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
videodata->key_layout[keycode]);
#if 0 #if 0
if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
int min_keycode, max_keycode; int min_keycode, max_keycode;
...@@ -210,7 +199,7 @@ X11_DispatchEvent(_THIS) ...@@ -210,7 +199,7 @@ X11_DispatchEvent(_THIS)
XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL); XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL);
#endif #endif
if (*text) { if (*text) {
SDL_SendKeyboardText(videodata->keyboard, text); SDL_SendKeyboardText(text);
} }
} }
break; break;
...@@ -222,8 +211,7 @@ X11_DispatchEvent(_THIS) ...@@ -222,8 +211,7 @@ X11_DispatchEvent(_THIS)
#ifdef DEBUG_XEVENTS #ifdef DEBUG_XEVENTS
printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
#endif #endif
SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED, SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]);
videodata->key_layout[keycode]);
} }
break; break;
...@@ -280,79 +268,25 @@ X11_DispatchEvent(_THIS) ...@@ -280,79 +268,25 @@ X11_DispatchEvent(_THIS)
} }
break; break;
default:{ case MotionNotify:{
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;
#ifdef DEBUG_MOTION #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 #endif
SDL_SendMouseMotion(move->deviceid, 0, move->x, move->y, SDL_SendMouseMotion(0, xevent.xmotion.x, xevent.xmotion.y);
move->axis_data[2]); }
return; break;
}
if (xevent.type == data->button_pressed) { case ButtonPress:{
XDeviceButtonPressedEvent *pressed = SDL_SendMouseButton(SDL_PRESSED, xevent.xbutton.button);
(XDeviceButtonPressedEvent *) & xevent; }
SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED, break;
pressed->button);
return; case ButtonRelease:{
} SDL_SendMouseButton(SDL_RELEASED, xevent.xbutton.button);
if (xevent.type == data->button_released) { }
XDeviceButtonReleasedEvent *released = break;
(XDeviceButtonReleasedEvent *) & xevent;
SDL_SendMouseButton(released->deviceid, SDL_RELEASED, default:{
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
}
#ifdef DEBUG_XEVENTS #ifdef DEBUG_XEVENTS
printf("Unhandled event %d\n", xevent.type); printf("Unhandled event %d\n", xevent.type);
#endif #endif
......
...@@ -172,7 +172,6 @@ int ...@@ -172,7 +172,6 @@ int
X11_InitKeyboard(_THIS) X11_InitKeyboard(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Keyboard keyboard;
int i, j; int i, j;
int min_keycode, max_keycode; int min_keycode, max_keycode;
struct { struct {
...@@ -251,8 +250,6 @@ X11_InitKeyboard(_THIS) ...@@ -251,8 +250,6 @@ X11_InitKeyboard(_THIS)
} }
} }
SDL_zero(keyboard);
data->keyboard = SDL_AddKeyboard(&keyboard, -1);
X11_UpdateKeymap(_this); X11_UpdateKeymap(_this);
SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
...@@ -280,15 +277,12 @@ X11_UpdateKeymap(_THIS) ...@@ -280,15 +277,12 @@ X11_UpdateKeymap(_THIS)
keymap[scancode] = X11_KeyCodeToSDLKey(data->display, (KeyCode)i); 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 void
X11_QuitKeyboard(_THIS) X11_QuitKeyboard(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DelKeyboard(data->keyboard);
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -24,139 +24,14 @@ ...@@ -24,139 +24,14 @@
#include "SDL_x11mouse.h" #include "SDL_x11mouse.h"
#include "../../events/SDL_mouse_c.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 void
X11_InitMouse(_THIS) 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 void
X11_QuitMouse(_THIS) 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: */ /* vi: set ts=4 sw=4 expandtab: */
...@@ -67,7 +67,6 @@ typedef struct SDL_VideoData ...@@ -67,7 +67,6 @@ typedef struct SDL_VideoData
int numwindows; int numwindows;
SDL_WindowData **windowlist; SDL_WindowData **windowlist;
int windowlistlength; int windowlistlength;
int keyboard;
Atom WM_DELETE_WINDOW; Atom WM_DELETE_WINDOW;
SDL_scancode key_layout[256]; SDL_scancode key_layout[256];
} SDL_VideoData; } SDL_VideoData;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "SDL_config.h" #include "SDL_config.h"
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_mouse_c.h"
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
#include "SDL_x11opengles.h" #include "SDL_x11opengles.h"
#endif #endif
#include "SDL_timer.h"
#include "SDL_syswm.h" #include "SDL_syswm.h"
#define _NET_WM_STATE_REMOVE 0l #define _NET_WM_STATE_REMOVE 0l
...@@ -67,7 +69,6 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) ...@@ -67,7 +69,6 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
int numwindows = videodata->numwindows; int numwindows = videodata->numwindows;
int windowlistlength = videodata->windowlistlength; int windowlistlength = videodata->windowlistlength;
SDL_WindowData **windowlist = videodata->windowlist; SDL_WindowData **windowlist = videodata->windowlist;
int index;
/* Allocate the window data */ /* Allocate the window data */
data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
...@@ -275,8 +276,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -275,8 +276,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if (visual->class == PseudoColor) { if (visual->class == PseudoColor) {
printf("asking for PseudoColor\n"); printf("asking for PseudoColor\n");
Status status; /* Status status; */
XStandardColormap cmap;
XColor *colorcells; XColor *colorcells;
Colormap colormap; Colormap colormap;
Sint32 pix; Sint32 pix;
...@@ -387,7 +387,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -387,7 +387,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
} else if (visual->class == DirectColor) { } else if (visual->class == DirectColor) {
Status status; Status status;
XStandardColormap cmap;
XColor *colorcells; XColor *colorcells;
Colormap colormap; Colormap colormap;
int i; int i;
...@@ -397,9 +396,9 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -397,9 +396,9 @@ X11_CreateWindow(_THIS, SDL_Window * window)
int rshift, gshift, bshift; int rshift, gshift, bshift;
/* Is the colormap we need already registered in SDL? */ /* Is the colormap we need already registered in SDL? */
if (colormap = if ((colormap =
X11_LookupColormap(data->display, X11_LookupColormap(data->display,
displaydata->screen, visual->visualid)) { displaydata->screen, visual->visualid))) {
xattr.colormap = colormap; xattr.colormap = colormap;
/* printf("found existing colormap\n"); */ /* printf("found existing colormap\n"); */
} else { } else {
...@@ -647,7 +646,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -647,7 +646,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* Tell KDE to keep fullscreen windows on top */ /* Tell KDE to keep fullscreen windows on top */
if (window->flags & SDL_WINDOW_FULLSCREEN) { if (window->flags & SDL_WINDOW_FULLSCREEN) {
XEvent ev; XEvent ev;
long mask;
SDL_zero(ev); SDL_zero(ev);
ev.xclient.type = ClientMessage; ev.xclient.type = ClientMessage;
...@@ -710,32 +708,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -710,32 +708,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
#endif #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; return 0;
} }
...@@ -869,8 +841,6 @@ void ...@@ -869,8 +841,6 @@ void
X11_SetWindowPosition(_THIS, SDL_Window * window) X11_SetWindowPosition(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *displaydata =
(SDL_DisplayData *) window->display->driverdata;
Display *display = data->videodata->display; Display *display = data->videodata->display;
int x, y; int x, y;
......
...@@ -929,45 +929,44 @@ PrintEvent(SDL_Event * event) ...@@ -929,45 +929,44 @@ PrintEvent(SDL_Event * event)
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
fprintf(stderr, fprintf(stderr,
"Keyboard %d: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", "Keyboard: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
event->key.which, event->key.windowID, event->key.windowID,
event->key.keysym.scancode, event->key.keysym.scancode,
SDL_GetScancodeName(event->key.keysym.scancode), SDL_GetScancodeName(event->key.keysym.scancode),
event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
break; break;
case SDL_KEYUP: case SDL_KEYUP:
fprintf(stderr, fprintf(stderr,
"Keyboard %d: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", "Keyboard: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
event->key.which, event->key.windowID, event->key.windowID,
event->key.keysym.scancode, event->key.keysym.scancode,
SDL_GetScancodeName(event->key.keysym.scancode), SDL_GetScancodeName(event->key.keysym.scancode),
event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
break; break;
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d", fprintf(stderr, "Keyboard: text input \"%s\" in window %d",
event->text.which, event->text.text, event->text.windowID); event->text.text, event->text.windowID);
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d", fprintf(stderr, "Mouse: moved to %d,%d (%d,%d) in window %d",
event->motion.which, event->motion.x, event->motion.y, event->motion.x, event->motion.y,
event->motion.xrel, event->motion.yrel, event->motion.xrel, event->motion.yrel,
event->motion.windowID); event->motion.windowID);
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d", fprintf(stderr, "Mouse: button %d pressed at %d,%d in window %d",
event->button.which, event->button.button, event->button.x, event->button.button, event->button.x, event->button.y,
event->button.y, event->button.windowID); event->button.windowID);
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d", fprintf(stderr, "Mouse: button %d released at %d,%d in window %d",
event->button.which, event->button.button, event->button.x, event->button.button, event->button.x, event->button.y,
event->button.y, event->button.windowID); event->button.windowID);
break; break;
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
fprintf(stderr, fprintf(stderr,
"Mouse %d: wheel scrolled %d in x and %d in y in window %d", "Mouse: wheel scrolled %d in x and %d in y in window %d",
event->wheel.which, event->wheel.x, event->wheel.y, event->wheel.x, event->wheel.y, event->wheel.windowID);
event->wheel.windowID);
break; break;
case SDL_JOYBALLMOTION: case SDL_JOYBALLMOTION:
fprintf(stderr, "Joystick %d: ball %d moved by %d,%d", fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",
......
...@@ -279,8 +279,8 @@ int main(int argc, char *argv[]) ...@@ -279,8 +279,8 @@ int main(int argc, char *argv[])
} }
fprintf(stderr, fprintf(stderr,
"Keyboard %d: scancode 0x%08X = %s, keycode 0x%08X = %s\n", "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
event.key.which, event.key.keysym.scancode, event.key.keysym.scancode,
SDL_GetScancodeName(event.key.keysym.scancode), SDL_GetScancodeName(event.key.keysym.scancode),
event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym)); event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
break; break;
...@@ -290,8 +290,7 @@ int main(int argc, char *argv[]) ...@@ -290,8 +290,7 @@ int main(int argc, char *argv[])
markedRect.w < 0) markedRect.w < 0)
break; break;
fprintf(stderr, "Keyboard %d: text input \"%s\"\n", fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text);
event.text.which, event.text.text);
if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
strcpy(text + SDL_strlen(text), event.text.text); strcpy(text + SDL_strlen(text), event.text.text);
......
...@@ -288,20 +288,16 @@ main(int argc, char *argv[]) ...@@ -288,20 +288,16 @@ main(int argc, char *argv[])
CommonEvent(state, &event, &done); CommonEvent(state, &event, &done);
switch (event.type) { switch (event.type) {
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
if (event.button.which == 0) { mouse_begin_x = event.button.x;
mouse_begin_x = event.button.x; mouse_begin_y = event.button.y;
mouse_begin_y = event.button.y;
}
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
if (event.button.which == 0) { if (event.button.button == 3)
if (event.button.button == 3) add_line(mouse_begin_x, mouse_begin_y, event.button.x,
add_line(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
event.button.y); if (event.button.button == 1)
if (event.button.button == 1) add_rect(mouse_begin_x, mouse_begin_y, event.button.x,
add_rect(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
event.button.y);
}
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
switch (event.key.keysym.sym) { switch (event.key.keysym.sym) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment