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);
......
This diff is collapsed.
...@@ -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: */
This diff is collapsed.
...@@ -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
} }
/* /*
......
This diff is collapsed.
...@@ -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 */
This diff is collapsed.
/* *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