Merged changes from the main SDL codebase
--HG-- rename : VisualC/SDL/SDL.vcproj => VisualC/SDL/SDL_VS2005.vcproj rename : VisualC/SDL.sln => VisualC/SDL_VS2005.sln rename : VisualC/SDLmain/SDLmain.vcproj => VisualC/SDLmain/SDLmain_VS2005.vcproj
This commit is contained in:
commit
22a37911dd
150 changed files with 6377 additions and 3337 deletions
47
src/events/SDL_clipboardevents.c
Normal file
47
src/events/SDL_clipboardevents.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Clipboard event handling code for SDL */
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_clipboardevents_c.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_SendClipboardUpdate(void)
|
||||
{
|
||||
int posted;
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_CLIPBOARDUPDATE;
|
||||
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return (posted);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
31
src/events/SDL_clipboardevents_c.h
Normal file
31
src/events/SDL_clipboardevents_c.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_clipboardevents_c_h
|
||||
#define _SDL_clipboardevents_c_h
|
||||
|
||||
extern int SDL_SendClipboardUpdate(void);
|
||||
|
||||
#endif /* _SDL_clipboardevents_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -30,9 +30,19 @@
|
|||
|
||||
|
||||
/* Global keyboard information */
|
||||
static int SDL_num_keyboards;
|
||||
static int SDL_current_keyboard;
|
||||
static SDL_Keyboard **SDL_keyboards;
|
||||
|
||||
typedef struct SDL_Keyboard SDL_Keyboard;
|
||||
|
||||
struct SDL_Keyboard
|
||||
{
|
||||
/* Data common to all keyboards */
|
||||
SDL_Window *focus;
|
||||
Uint16 modstate;
|
||||
Uint8 keystate[SDL_NUM_SCANCODES];
|
||||
SDLKey keymap[SDL_NUM_SCANCODES];
|
||||
};
|
||||
|
||||
static SDL_Keyboard SDL_keyboard;
|
||||
|
||||
static const SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = {
|
||||
0, 0, 0, 0,
|
||||
|
@ -541,78 +551,22 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
|
|||
int
|
||||
SDL_KeyboardInit(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
/* Set the default keymap */
|
||||
SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
|
||||
return (0);
|
||||
}
|
||||
|
||||
SDL_Keyboard *
|
||||
SDL_GetKeyboard(int index)
|
||||
{
|
||||
if (index < 0 || index >= SDL_num_keyboards) {
|
||||
return NULL;
|
||||
}
|
||||
return SDL_keyboards[index];
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index)
|
||||
{
|
||||
SDL_Keyboard **keyboards;
|
||||
|
||||
/* Add the keyboard to the list of keyboards */
|
||||
if (index < 0 || index >= SDL_num_keyboards || SDL_keyboards[index]) {
|
||||
keyboards =
|
||||
(SDL_Keyboard **) SDL_realloc(SDL_keyboards,
|
||||
(SDL_num_keyboards +
|
||||
1) * sizeof(*keyboards));
|
||||
if (!keyboards) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_keyboards = keyboards;
|
||||
index = SDL_num_keyboards++;
|
||||
}
|
||||
SDL_keyboards[index] =
|
||||
(SDL_Keyboard *) SDL_malloc(sizeof(*SDL_keyboards[index]));
|
||||
if (!SDL_keyboards[index]) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
*SDL_keyboards[index] = *keyboard;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DelKeyboard(int index)
|
||||
SDL_ResetKeyboard(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyboard->FreeKeyboard) {
|
||||
keyboard->FreeKeyboard(keyboard);
|
||||
}
|
||||
SDL_free(keyboard);
|
||||
|
||||
SDL_keyboards[index] = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ResetKeyboard(int index)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
SDL_scancode scancode;
|
||||
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||
if (keyboard->keystate[scancode] == SDL_PRESSED) {
|
||||
SDL_SendKeyboardKey(index, SDL_RELEASED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,13 +578,9 @@ SDL_GetDefaultKeymap(SDLKey * keymap)
|
|||
}
|
||||
|
||||
void
|
||||
SDL_SetKeymap(int index, int start, SDLKey * keys, int length)
|
||||
SDL_SetKeymap(int start, SDLKey * keys, int length)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (start < 0 || start + length > SDL_NUM_SCANCODES) {
|
||||
return;
|
||||
|
@ -645,33 +595,23 @@ SDL_SetScancodeName(SDL_scancode scancode, const char *name)
|
|||
SDL_scancode_names[scancode] = name;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetKeyboardFocus(int index, SDL_Window * window)
|
||||
SDL_Window *
|
||||
SDL_GetKeyboardFocus(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
int i;
|
||||
SDL_bool focus;
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
return keyboard->focus;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetKeyboardFocus(SDL_Window * window)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
/* See if the current window has lost focus */
|
||||
if (keyboard->focus && keyboard->focus != window) {
|
||||
focus = SDL_FALSE;
|
||||
for (i = 0; i < SDL_num_keyboards; ++i) {
|
||||
if (i != index) {
|
||||
SDL_Keyboard *check = SDL_GetKeyboard(i);
|
||||
if (check && check->focus == keyboard->focus) {
|
||||
focus = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!focus) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
|
||||
0, 0);
|
||||
}
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
keyboard->focus = window;
|
||||
|
@ -687,14 +627,14 @@ SDL_SetKeyboardFocus(int index, SDL_Window * window)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
Uint16 modstate;
|
||||
Uint32 type;
|
||||
|
||||
if (!keyboard || !scancode) {
|
||||
if (!scancode) {
|
||||
return 0;
|
||||
}
|
||||
#if 0
|
||||
|
@ -807,7 +747,6 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
|
|||
if (SDL_GetEventState(type) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.key.type = type;
|
||||
event.key.which = (Uint8) index;
|
||||
event.key.state = state;
|
||||
event.key.keysym.scancode = scancode;
|
||||
event.key.keysym.sym = keyboard->keymap[scancode];
|
||||
|
@ -820,22 +759,17 @@ SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardText(int index, const char *text)
|
||||
SDL_SendKeyboardText(const char *text)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
|
||||
if (!keyboard) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.text.type = SDL_TEXTINPUT;
|
||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.text.which = (Uint8) index;
|
||||
SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
|
||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
|
@ -844,22 +778,17 @@ SDL_SendKeyboardText(int index, const char *text)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_SendEditingText(int index, const char *text, int start, int length)
|
||||
SDL_SendEditingText(const char *text, int start, int length)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
|
||||
if (!keyboard) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.edit.type = SDL_TEXTEDITING;
|
||||
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.text.which = (Uint8) index;
|
||||
event.edit.start = start;
|
||||
event.edit.length = length;
|
||||
SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
|
||||
|
@ -871,93 +800,49 @@ SDL_SendEditingText(int index, const char *text, int start, int length)
|
|||
void
|
||||
SDL_KeyboardQuit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SDL_num_keyboards; ++i) {
|
||||
SDL_DelKeyboard(i);
|
||||
}
|
||||
SDL_num_keyboards = 0;
|
||||
SDL_current_keyboard = 0;
|
||||
|
||||
if (SDL_keyboards) {
|
||||
SDL_free(SDL_keyboards);
|
||||
SDL_keyboards = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetNumKeyboards(void)
|
||||
{
|
||||
return SDL_num_keyboards;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SelectKeyboard(int index)
|
||||
{
|
||||
if (index >= 0 && index < SDL_num_keyboards) {
|
||||
SDL_current_keyboard = index;
|
||||
}
|
||||
return SDL_current_keyboard;
|
||||
}
|
||||
|
||||
Uint8 *
|
||||
SDL_GetKeyboardState(int *numkeys)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (numkeys != (int *) 0) {
|
||||
*numkeys = SDL_NUM_SCANCODES;
|
||||
}
|
||||
|
||||
if (!keyboard) {
|
||||
return NULL;
|
||||
}
|
||||
return keyboard->keystate;
|
||||
}
|
||||
|
||||
SDLMod
|
||||
SDL_GetModState(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (!keyboard) {
|
||||
return KMOD_NONE;
|
||||
}
|
||||
return keyboard->modstate;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetModState(SDLMod modstate)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
keyboard->modstate = modstate;
|
||||
}
|
||||
|
||||
SDLKey
|
||||
SDL_GetKeyFromScancode(SDL_scancode scancode)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (!keyboard) {
|
||||
return SDLK_UNKNOWN;
|
||||
}
|
||||
return keyboard->keymap[scancode];
|
||||
}
|
||||
|
||||
SDL_scancode
|
||||
SDL_GetScancodeFromKey(SDLKey key)
|
||||
{
|
||||
SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard);
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
SDL_scancode scancode;
|
||||
|
||||
if (!keyboard) {
|
||||
return SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
|
||||
++scancode) {
|
||||
if (keyboard->keymap[scancode] == key) {
|
||||
|
|
|
@ -27,44 +27,17 @@
|
|||
#include "SDL_keysym.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
typedef struct SDL_Keyboard SDL_Keyboard;
|
||||
|
||||
struct SDL_Keyboard
|
||||
{
|
||||
/* Free the keyboard when it's time */
|
||||
void (*FreeKeyboard) (SDL_Keyboard * keyboard);
|
||||
|
||||
/* Data common to all keyboards */
|
||||
SDL_Window *focus;
|
||||
Uint16 modstate;
|
||||
Uint8 keystate[SDL_NUM_SCANCODES];
|
||||
SDLKey keymap[SDL_NUM_SCANCODES];
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Initialize the keyboard subsystem */
|
||||
extern int SDL_KeyboardInit(void);
|
||||
|
||||
/* Get the keyboard at an index */
|
||||
extern SDL_Keyboard *SDL_GetKeyboard(int index);
|
||||
|
||||
/* Add a keyboard, possibly reattaching at a particular index (or -1),
|
||||
returning the index of the keyboard, or -1 if there was an error.
|
||||
*/
|
||||
extern int SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index);
|
||||
|
||||
/* Remove a keyboard at an index, clearing the slot for later */
|
||||
extern void SDL_DelKeyboard(int index);
|
||||
|
||||
/* Clear the state of a keyboard at an index */
|
||||
extern void SDL_ResetKeyboard(int index);
|
||||
/* Clear the state of the keyboard */
|
||||
extern void SDL_ResetKeyboard(void);
|
||||
|
||||
/* Get the default keymap */
|
||||
extern void SDL_GetDefaultKeymap(SDLKey * keymap);
|
||||
|
||||
/* Set the mapping of scancode to key codes for this keyboard */
|
||||
extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length);
|
||||
/* Set the mapping of scancode to key codes */
|
||||
extern void SDL_SetKeymap(int start, SDLKey * keys, int length);
|
||||
|
||||
/* Set a platform-dependent key name, overriding the default platform-agnostic
|
||||
name. Encoded as UTF-8. The string is not copied, thus the pointer given to
|
||||
|
@ -73,16 +46,16 @@ extern void SDL_SetKeymap(int index, int start, SDLKey * keys, int length);
|
|||
extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
|
||||
|
||||
/* Set the keyboard focus window */
|
||||
extern void SDL_SetKeyboardFocus(int index, SDL_Window * window);
|
||||
extern void SDL_SetKeyboardFocus(SDL_Window * window);
|
||||
|
||||
/* Send a keyboard event for a keyboard at an index */
|
||||
extern int SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode);
|
||||
/* Send a keyboard key event */
|
||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
|
||||
|
||||
/* Send keyboard text input for a keyboard at an index */
|
||||
extern int SDL_SendKeyboardText(int index, const char *text);
|
||||
/* Send keyboard text input */
|
||||
extern int SDL_SendKeyboardText(const char *text);
|
||||
|
||||
/* Send editing text for selected range from start to end */
|
||||
extern int SDL_SendEditingText(int index, const char *text, int start, int end);
|
||||
extern int SDL_SendEditingText(const char *text, int start, int end);
|
||||
|
||||
/* Shutdown the keyboard subsystem */
|
||||
extern void SDL_KeyboardQuit(void);
|
||||
|
|
|
@ -29,9 +29,44 @@
|
|||
#include "../video/SDL_sysvideo.h"
|
||||
|
||||
|
||||
static int SDL_num_mice = 0;
|
||||
static int SDL_current_mouse = -1;
|
||||
static SDL_Mouse **SDL_mice = NULL;
|
||||
/* Global mouse information */
|
||||
|
||||
typedef struct SDL_Mouse SDL_Mouse;
|
||||
|
||||
struct SDL_Mouse
|
||||
{
|
||||
/* Create a cursor from a surface */
|
||||
SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
|
||||
|
||||
/* Show the specified cursor, or hide if cursor is NULL */
|
||||
int (*ShowCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* This is called when a mouse motion event occurs */
|
||||
void (*MoveCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* Free a window manager cursor */
|
||||
void (*FreeCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* Warp the mouse to (x,y) */
|
||||
void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y);
|
||||
|
||||
/* Data common to all mice */
|
||||
SDL_Window *focus;
|
||||
int x;
|
||||
int y;
|
||||
int xdelta;
|
||||
int ydelta;
|
||||
int last_x, last_y; /* the last reported x and y coordinates */
|
||||
Uint8 buttonstate;
|
||||
SDL_bool relative_mode;
|
||||
|
||||
SDL_Cursor *cursors;
|
||||
SDL_Cursor *def_cursor;
|
||||
SDL_Cursor *cur_cursor;
|
||||
SDL_bool cursor_shown;
|
||||
};
|
||||
|
||||
static SDL_Mouse SDL_mouse;
|
||||
|
||||
|
||||
/* Public functions */
|
||||
|
@ -41,368 +76,52 @@ SDL_MouseInit(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
SDL_Mouse *
|
||||
SDL_GetMouse(int index)
|
||||
{
|
||||
if (index < 0 || index >= SDL_num_mice) {
|
||||
return NULL;
|
||||
}
|
||||
return SDL_mice[index];
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_GetMouseIndexId(int id)
|
||||
{
|
||||
int index;
|
||||
SDL_Mouse *mouse;
|
||||
|
||||
for (index = 0; index < SDL_num_mice; ++index) {
|
||||
mouse = SDL_GetMouse(index);
|
||||
if (mouse->id == id) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddMouse(const SDL_Mouse * mouse, char *name, int pressure_max,
|
||||
int pressure_min, int ends)
|
||||
{
|
||||
SDL_Mouse **mice;
|
||||
int selected_mouse;
|
||||
int index;
|
||||
size_t length;
|
||||
|
||||
if (SDL_GetMouseIndexId(mouse->id) != -1) {
|
||||
SDL_SetError("Mouse ID already in use");
|
||||
}
|
||||
|
||||
/* Add the mouse to the list of mice */
|
||||
mice = (SDL_Mouse **) SDL_realloc(SDL_mice,
|
||||
(SDL_num_mice + 1) * sizeof(*mice));
|
||||
if (!mice) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_mice = mice;
|
||||
index = SDL_num_mice++;
|
||||
|
||||
SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index]));
|
||||
if (!SDL_mice[index]) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
*SDL_mice[index] = *mouse;
|
||||
|
||||
/* we're setting the mouse properties */
|
||||
length = 0;
|
||||
length = SDL_strlen(name);
|
||||
SDL_mice[index]->focus = 0;
|
||||
SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char));
|
||||
SDL_strlcpy(SDL_mice[index]->name, name, length + 1);
|
||||
SDL_mice[index]->pressure_max = pressure_max;
|
||||
SDL_mice[index]->pressure_min = pressure_min;
|
||||
SDL_mice[index]->cursor_shown = SDL_TRUE;
|
||||
selected_mouse = SDL_SelectMouse(index);
|
||||
SDL_mice[index]->cur_cursor = NULL;
|
||||
SDL_mice[index]->def_cursor =
|
||||
SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH,
|
||||
DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
|
||||
SDL_SetCursor(SDL_mice[index]->def_cursor);
|
||||
/* we're assuming that all mice are in the computer sensing zone */
|
||||
SDL_mice[index]->proximity = SDL_TRUE;
|
||||
/* we're assuming that all mice are working in the absolute position mode
|
||||
thanx to that, the users that don't want to use many mice don't have to
|
||||
worry about anything */
|
||||
SDL_mice[index]->relative_mode = SDL_FALSE;
|
||||
SDL_mice[index]->current_end = 0;
|
||||
SDL_mice[index]->total_ends = ends;
|
||||
SDL_SelectMouse(selected_mouse);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DelMouse(int index)
|
||||
SDL_ResetMouse(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
mouse->def_cursor = NULL;
|
||||
SDL_free(mouse->name);
|
||||
while (mouse->cursors) {
|
||||
SDL_FreeCursor(mouse->cursors);
|
||||
}
|
||||
|
||||
if (mouse->FreeMouse) {
|
||||
mouse->FreeMouse(mouse);
|
||||
}
|
||||
SDL_free(mouse);
|
||||
|
||||
SDL_mice[index] = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ResetMouse(int index)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
}
|
||||
|
||||
void
|
||||
SDL_MouseQuit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SDL_num_mice; ++i) {
|
||||
SDL_DelMouse(i);
|
||||
}
|
||||
SDL_num_mice = 0;
|
||||
SDL_current_mouse = -1;
|
||||
|
||||
if (SDL_mice) {
|
||||
SDL_free(SDL_mice);
|
||||
SDL_mice = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetNumMice(void)
|
||||
{
|
||||
return SDL_num_mice;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SelectMouse(int index)
|
||||
{
|
||||
if (index >= 0 && index < SDL_num_mice) {
|
||||
SDL_current_mouse = index;
|
||||
}
|
||||
return SDL_current_mouse;
|
||||
}
|
||||
|
||||
SDL_Window *
|
||||
SDL_GetMouseFocusWindow(int index)
|
||||
SDL_GetMouseFocus(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
if (!mouse) {
|
||||
return 0;
|
||||
}
|
||||
return mouse->focus;
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
FlushMouseMotion(void *param, SDL_Event * event)
|
||||
{
|
||||
if (event->type == SDL_MOUSEMOTION
|
||||
&& event->motion.which == (Uint8) SDL_current_mouse) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetRelativeMouseMode(int index, SDL_bool enabled)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Flush pending mouse motion */
|
||||
mouse->flush_motion = SDL_TRUE;
|
||||
SDL_PumpEvents();
|
||||
mouse->flush_motion = SDL_FALSE;
|
||||
SDL_FilterEvents(FlushMouseMotion, mouse);
|
||||
|
||||
/* Set the relative mode */
|
||||
mouse->relative_mode = enabled;
|
||||
|
||||
/* Update cursor visibility */
|
||||
SDL_SetCursor(NULL);
|
||||
|
||||
if (!enabled) {
|
||||
/* Restore the expected mouse position */
|
||||
SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_GetRelativeMouseMode(int index)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return mouse->relative_mode;
|
||||
}
|
||||
|
||||
Uint8
|
||||
SDL_GetMouseState(int *x, int *y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
|
||||
|
||||
if (!mouse) {
|
||||
if (x) {
|
||||
*x = 0;
|
||||
}
|
||||
if (y) {
|
||||
*y = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (x) {
|
||||
*x = mouse->x;
|
||||
}
|
||||
if (y) {
|
||||
*y = mouse->y;
|
||||
}
|
||||
return mouse->buttonstate;
|
||||
}
|
||||
|
||||
Uint8
|
||||
SDL_GetRelativeMouseState(int index, int *x, int *y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
if (x) {
|
||||
*x = 0;
|
||||
}
|
||||
if (y) {
|
||||
*y = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (x) {
|
||||
*x = mouse->xdelta;
|
||||
}
|
||||
if (y) {
|
||||
*y = mouse->ydelta;
|
||||
}
|
||||
mouse->xdelta = 0;
|
||||
mouse->ydelta = 0;
|
||||
return mouse->buttonstate;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetMouseFocus(int id, SDL_Window * window)
|
||||
SDL_SetMouseFocus(SDL_Window * window)
|
||||
{
|
||||
int index = SDL_GetMouseIndexId(id);
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
int i;
|
||||
SDL_bool focus;
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
if (!mouse || (mouse->focus == window)) {
|
||||
if (mouse->focus == window) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* See if the current window has lost focus */
|
||||
if (mouse->focus) {
|
||||
focus = SDL_FALSE;
|
||||
for (i = 0; i < SDL_num_mice; ++i) {
|
||||
SDL_Mouse *check;
|
||||
if (i != index) {
|
||||
check = SDL_GetMouse(i);
|
||||
if (check && check->focus == mouse->focus) {
|
||||
focus = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!focus) {
|
||||
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
}
|
||||
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
}
|
||||
|
||||
mouse->focus = window;
|
||||
|
||||
if (mouse->focus) {
|
||||
focus = SDL_FALSE;
|
||||
for (i = 0; i < SDL_num_mice; ++i) {
|
||||
SDL_Mouse *check;
|
||||
if (i != index) {
|
||||
check = SDL_GetMouse(i);
|
||||
if (check && check->focus == mouse->focus) {
|
||||
focus = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!focus) {
|
||||
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
}
|
||||
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendProximity(int id, int x, int y, int type)
|
||||
SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
|
||||
{
|
||||
int index = SDL_GetMouseIndexId(id);
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
int posted = 0;
|
||||
|
||||
if (!mouse) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
mouse->last_x = x;
|
||||
mouse->last_y = y;
|
||||
if (SDL_GetEventState(type) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.proximity.which = (Uint8) index;
|
||||
event.proximity.x = x;
|
||||
event.proximity.y = y;
|
||||
event.proximity.cursor = mouse->current_end;
|
||||
event.proximity.type = type;
|
||||
/* FIXME: is this right? */
|
||||
event.proximity.windowID = mouse->focus ? mouse->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
if (type == SDL_PROXIMITYIN) {
|
||||
mouse->proximity = SDL_TRUE;
|
||||
} else {
|
||||
mouse->proximity = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
return posted;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
|
||||
{
|
||||
int index = SDL_GetMouseIndexId(id);
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
int posted;
|
||||
int xrel;
|
||||
int yrel;
|
||||
int x_max = 0, y_max = 0;
|
||||
|
||||
if (!mouse || mouse->flush_motion) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if the mouse is out of proximity we don't to want to have any motion from it */
|
||||
if (mouse->proximity == SDL_FALSE) {
|
||||
mouse->last_x = x;
|
||||
mouse->last_y = y;
|
||||
return 0;
|
||||
if (window) {
|
||||
SDL_SetMouseFocus(window);
|
||||
}
|
||||
|
||||
/* the relative motion is calculated regarding the system cursor last position */
|
||||
|
@ -451,35 +170,26 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
|
|||
|
||||
mouse->xdelta += xrel;
|
||||
mouse->ydelta += yrel;
|
||||
mouse->pressure = pressure;
|
||||
|
||||
#if 0 /* FIXME */
|
||||
/* Move the mouse cursor, if needed */
|
||||
if (mouse->cursor_shown && !mouse->relative_mode &&
|
||||
mouse->MoveCursor && mouse->cur_cursor) {
|
||||
mouse->MoveCursor(mouse->cur_cursor);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE &&
|
||||
mouse->proximity == SDL_TRUE) {
|
||||
if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.motion.type = SDL_MOUSEMOTION;
|
||||
event.motion.which = (Uint8) index;
|
||||
event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
|
||||
event.motion.state = mouse->buttonstate;
|
||||
event.motion.x = mouse->x;
|
||||
event.motion.y = mouse->y;
|
||||
event.motion.z = mouse->z;
|
||||
event.motion.pressure = mouse->pressure;
|
||||
event.motion.pressure_max = mouse->pressure_max;
|
||||
event.motion.pressure_min = mouse->pressure_min;
|
||||
event.motion.rotation = 0;
|
||||
event.motion.tilt_x = 0;
|
||||
event.motion.tilt_y = 0;
|
||||
event.motion.cursor = mouse->current_end;
|
||||
event.motion.xrel = xrel;
|
||||
event.motion.yrel = yrel;
|
||||
event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
mouse->last_x = mouse->x;
|
||||
|
@ -488,15 +198,14 @@ SDL_SendMouseMotion(int id, int relative, int x, int y, int pressure)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
|
||||
SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
|
||||
{
|
||||
int index = SDL_GetMouseIndexId(id);
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
int posted;
|
||||
Uint32 type;
|
||||
|
||||
if (!mouse) {
|
||||
return 0;
|
||||
if (window) {
|
||||
SDL_SetMouseFocus(window);
|
||||
}
|
||||
|
||||
/* Figure out which event to perform */
|
||||
|
@ -527,7 +236,6 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
|
|||
if (SDL_GetEventState(type) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = type;
|
||||
event.button.which = (Uint8) index;
|
||||
event.button.state = state;
|
||||
event.button.button = button;
|
||||
event.button.x = mouse->x;
|
||||
|
@ -539,12 +247,16 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_SendMouseWheel(int index, int x, int y)
|
||||
SDL_SendMouseWheel(SDL_Window * window, int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
int posted;
|
||||
|
||||
if (!mouse || (!x && !y)) {
|
||||
if (window) {
|
||||
SDL_SetMouseFocus(window);
|
||||
}
|
||||
|
||||
if (!x && !y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -553,53 +265,107 @@ SDL_SendMouseWheel(int index, int x, int y)
|
|||
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_MOUSEWHEEL;
|
||||
event.wheel.which = (Uint8) index;
|
||||
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
|
||||
event.wheel.x = x;
|
||||
event.wheel.y = y;
|
||||
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return posted;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_MouseQuit(void)
|
||||
{
|
||||
}
|
||||
|
||||
Uint8
|
||||
SDL_GetMouseState(int *x, int *y)
|
||||
{
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
if (x) {
|
||||
*x = mouse->x;
|
||||
}
|
||||
if (y) {
|
||||
*y = mouse->y;
|
||||
}
|
||||
return mouse->buttonstate;
|
||||
}
|
||||
|
||||
Uint8
|
||||
SDL_GetRelativeMouseState(int *x, int *y)
|
||||
{
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
if (x) {
|
||||
*x = mouse->xdelta;
|
||||
}
|
||||
if (y) {
|
||||
*y = mouse->ydelta;
|
||||
}
|
||||
mouse->xdelta = 0;
|
||||
mouse->ydelta = 0;
|
||||
return mouse->buttonstate;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
|
||||
|
||||
if (!mouse) {
|
||||
return;
|
||||
}
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
if (mouse->WarpMouse) {
|
||||
mouse->WarpMouse(mouse, window, x, y);
|
||||
} else {
|
||||
SDL_SetMouseFocus(SDL_current_mouse, window);
|
||||
SDL_SendMouseMotion(SDL_current_mouse, 0, x, y, 0);
|
||||
SDL_SendMouseMotion(window, 0, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
/* Flush pending mouse motion */
|
||||
SDL_FlushEvent(SDL_MOUSEMOTION);
|
||||
|
||||
/* Set the relative mode */
|
||||
mouse->relative_mode = enabled;
|
||||
|
||||
if (!enabled) {
|
||||
/* Restore the expected mouse position */
|
||||
SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
|
||||
}
|
||||
|
||||
/* Update cursor visibility */
|
||||
SDL_SetCursor(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_GetRelativeMouseMode()
|
||||
{
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
return mouse->relative_mode;
|
||||
}
|
||||
|
||||
SDL_Cursor *
|
||||
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
|
||||
int w, int h, int hot_x, int hot_y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
SDL_Surface *surface;
|
||||
SDL_Cursor *cursor;
|
||||
int x, y;
|
||||
Uint32 *pixel;
|
||||
Uint8 datab, maskb;
|
||||
Uint8 datab = 0, maskb = 0;
|
||||
const Uint32 black = 0xFF000000;
|
||||
const Uint32 white = 0xFFFFFFFF;
|
||||
const Uint32 transparent = 0x00000000;
|
||||
|
||||
if (!mouse) {
|
||||
SDL_SetError("No mice are initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!mouse->CreateCursor) {
|
||||
SDL_SetError("Current mouse doesn't have cursor support");
|
||||
SDL_SetError("Cursors are not currently supported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -638,7 +404,6 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
|
|||
|
||||
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
|
||||
if (cursor) {
|
||||
cursor->mouse = mouse;
|
||||
cursor->next = mouse->cursors;
|
||||
mouse->cursors = cursor;
|
||||
}
|
||||
|
@ -655,12 +420,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
|
|||
void
|
||||
SDL_SetCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
|
||||
|
||||
if (!mouse) {
|
||||
SDL_SetError("No mice are initialized");
|
||||
return;
|
||||
}
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
/* Set the new cursor */
|
||||
if (cursor) {
|
||||
|
@ -694,7 +454,7 @@ SDL_SetCursor(SDL_Cursor * cursor)
|
|||
SDL_Cursor *
|
||||
SDL_GetCursor(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
|
||||
if (!mouse) {
|
||||
return NULL;
|
||||
|
@ -705,13 +465,12 @@ SDL_GetCursor(void)
|
|||
void
|
||||
SDL_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
SDL_Mouse *mouse;
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
SDL_Cursor *curr, *prev;
|
||||
|
||||
if (!cursor) {
|
||||
return;
|
||||
}
|
||||
mouse = cursor->mouse;
|
||||
|
||||
if (cursor == mouse->def_cursor) {
|
||||
return;
|
||||
|
@ -740,7 +499,7 @@ SDL_FreeCursor(SDL_Cursor * cursor)
|
|||
int
|
||||
SDL_ShowCursor(int toggle)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
|
||||
SDL_Mouse *mouse = &SDL_mouse;
|
||||
SDL_bool shown;
|
||||
|
||||
if (!mouse) {
|
||||
|
@ -761,47 +520,4 @@ SDL_ShowCursor(int toggle)
|
|||
return shown;
|
||||
}
|
||||
|
||||
char *
|
||||
SDL_GetMouseName(int index)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
if (!mouse) {
|
||||
return NULL;
|
||||
}
|
||||
return mouse->name;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ChangeEnd(int id, int end)
|
||||
{
|
||||
int index = SDL_GetMouseIndexId(id);
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (mouse) {
|
||||
mouse->current_end = end;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetCursorsNumber(int index)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
return -1;
|
||||
}
|
||||
return mouse->total_ends;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetCurrentCursor(int index)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse(index);
|
||||
|
||||
if (!mouse) {
|
||||
return -1;
|
||||
}
|
||||
return mouse->current_end;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -24,108 +24,33 @@
|
|||
#ifndef _SDL_mouse_c_h
|
||||
#define _SDL_mouse_c_h
|
||||
|
||||
typedef struct SDL_Mouse SDL_Mouse;
|
||||
|
||||
struct SDL_Cursor
|
||||
{
|
||||
SDL_Mouse *mouse;
|
||||
SDL_Cursor *next;
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
struct SDL_Mouse
|
||||
{
|
||||
/* Create a cursor from a surface */
|
||||
SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
|
||||
|
||||
/* Show the specified cursor, or hide if cursor is NULL */
|
||||
int (*ShowCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* This is called when a mouse motion event occurs */
|
||||
void (*MoveCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* Free a window manager cursor */
|
||||
void (*FreeCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* Warp the mouse to (x,y) */
|
||||
void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x,
|
||||
int y);
|
||||
|
||||
/* Free the mouse when it's time */
|
||||
void (*FreeMouse) (SDL_Mouse * mouse);
|
||||
|
||||
/* data common for tablets */
|
||||
int pressure;
|
||||
int pressure_max;
|
||||
int pressure_min;
|
||||
int tilt; /* for future use */
|
||||
int rotation; /* for future use */
|
||||
int total_ends;
|
||||
int current_end;
|
||||
|
||||
/* Data common to all mice */
|
||||
int id;
|
||||
SDL_Window *focus;
|
||||
int which;
|
||||
int x;
|
||||
int y;
|
||||
int z; /* for future use */
|
||||
int xdelta;
|
||||
int ydelta;
|
||||
int last_x, last_y; /* the last reported x and y coordinates */
|
||||
char *name;
|
||||
Uint8 buttonstate;
|
||||
SDL_bool relative_mode;
|
||||
SDL_bool proximity;
|
||||
SDL_bool flush_motion;
|
||||
|
||||
SDL_Cursor *cursors;
|
||||
SDL_Cursor *def_cursor;
|
||||
SDL_Cursor *cur_cursor;
|
||||
SDL_bool cursor_shown;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Initialize the mouse subsystem */
|
||||
extern int SDL_MouseInit(void);
|
||||
|
||||
/* Get the mouse at an index */
|
||||
extern SDL_Mouse *SDL_GetMouse(int index);
|
||||
|
||||
/* Add a mouse, possibly reattaching at a particular index (or -1),
|
||||
returning the index of the mouse, or -1 if there was an error.
|
||||
*/
|
||||
extern int SDL_AddMouse(const SDL_Mouse * mouse, char *name,
|
||||
int pressure_max, int pressure_min, int ends);
|
||||
|
||||
/* Remove a mouse at an index, clearing the slot for later */
|
||||
extern void SDL_DelMouse(int index);
|
||||
|
||||
/* Clear the button state of a mouse at an index */
|
||||
extern void SDL_ResetMouse(int index);
|
||||
/* Clear the mouse state */
|
||||
extern void SDL_ResetMouse(void);
|
||||
|
||||
/* Set the mouse focus window */
|
||||
extern void SDL_SetMouseFocus(int id, SDL_Window * window);
|
||||
extern void SDL_SetMouseFocus(SDL_Window * window);
|
||||
|
||||
/* Send a mouse motion event for a mouse */
|
||||
extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z);
|
||||
/* Send a mouse motion event */
|
||||
extern int SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y);
|
||||
|
||||
/* Send a mouse button event for a mouse */
|
||||
extern int SDL_SendMouseButton(int id, Uint8 state, Uint8 button);
|
||||
/* Send a mouse button event */
|
||||
extern int SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button);
|
||||
|
||||
/* Send a mouse wheel event for a mouse */
|
||||
extern int SDL_SendMouseWheel(int id, int x, int y);
|
||||
|
||||
/* Send a proximity event for a mouse */
|
||||
extern int SDL_SendProximity(int id, int x, int y, int type);
|
||||
/* Send a mouse wheel event */
|
||||
extern int SDL_SendMouseWheel(SDL_Window * window, int x, int y);
|
||||
|
||||
/* Shutdown the mouse subsystem */
|
||||
extern void SDL_MouseQuit(void);
|
||||
|
||||
/* FIXME: Where do these functions go in this header? */
|
||||
extern void SDL_ChangeEnd(int id, int end);
|
||||
|
||||
#endif /* _SDL_mouse_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue