src/events/SDL_mouse_c.h
author Szymon Wilczek
Thu, 03 Jul 2008 22:03:58 +0000
branchgsoc2008_manymouse
changeset 3764 2970fcfbdd54
parent 3760 64f346a83ed3
child 3765 ed9b7fe8f902
permissions -rw-r--r--
Relative mode for tablets. Info on wiki.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_mouse_c_h
    25 #define _SDL_mouse_c_h
    26 
    27 typedef struct SDL_Mouse SDL_Mouse;
    28 
    29 struct SDL_Cursor
    30 {
    31     SDL_Mouse *mouse;
    32 
    33     SDL_Cursor *next;
    34 
    35     void *driverdata;
    36 };
    37 
    38 struct SDL_Mouse
    39 {
    40     /* Create a cursor from a surface */
    41     SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
    42 
    43     /* Show the specified cursor, or hide if cursor is NULL */
    44     int (*ShowCursor) (SDL_Cursor * cursor);
    45 
    46     /* This is called when a mouse motion event occurs */
    47     void (*MoveCursor) (SDL_Cursor * cursor);
    48 
    49     /* Free a window manager cursor */
    50     void (*FreeCursor) (SDL_Cursor * cursor);
    51 
    52     /* Warp the mouse to (x,y) */
    53     void (*WarpMouse) (SDL_Mouse * mouse, SDL_WindowID windowID, int x,
    54                        int y);
    55 
    56     /* Free the mouse when it's time */
    57     void (*FreeMouse) (SDL_Mouse * mouse);
    58 
    59     /* Data common to all mice */
    60     SDL_WindowID focus;
    61     int which;
    62     int x;
    63     int y;
    64     int z;
    65     int xdelta;
    66     int ydelta;
    67     char* name;
    68     Uint8 buttonstate;
    69     SDL_bool relative_mode;
    70     SDL_bool proximity;
    71     SDL_bool flush_motion;
    72 
    73     SDL_Cursor *cursors;
    74     SDL_Cursor *def_cursor;
    75     SDL_Cursor *cur_cursor;
    76     SDL_bool cursor_shown;
    77 
    78     void *driverdata;
    79 };
    80 
    81 
    82 /* Initialize the mouse subsystem */
    83 extern int SDL_MouseInit(void);
    84 
    85 /* Get the mouse at an index */
    86 extern SDL_Mouse *SDL_GetMouse(int index);
    87 
    88 /* Add a mouse, possibly reattaching at a particular index (or -1),
    89    returning the index of the mouse, or -1 if there was an error.
    90  */
    91 extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name);
    92 
    93 /* Remove a mouse at an index, clearing the slot for later */
    94 extern void SDL_DelMouse(int index);
    95 
    96 /* Clear the button state of a mouse at an index */
    97 extern void SDL_ResetMouse(int index);
    98 
    99 /* Set the mouse focus window */
   100 extern void SDL_SetMouseFocus(int index, SDL_WindowID windowID);
   101 
   102 /* Send a mouse motion event for a mouse at an index */
   103 extern int SDL_SendMouseMotion(int index, int relative, int x, int y, int z);
   104 
   105 /* Send a mouse button event for a mouse at an index */
   106 extern int SDL_SendMouseButton(int index, Uint8 state, Uint8 button);
   107 
   108 /* Send a mouse wheel event for a mouse at an index */
   109 extern int SDL_SendMouseWheel(int index, int x, int y);
   110 
   111 /* Shutdown the mouse subsystem */
   112 extern void SDL_MouseQuit(void);
   113 
   114 extern int SDL_GetIndexById(int id);
   115 
   116 extern void SDL_SetIndexId(int id, int index);
   117 
   118 extern int SDL_GetNumOfMice(void);
   119 
   120 extern char* SDL_GetMouseName(int index);
   121 
   122 extern void SDL_UpdateCoordinates(int x, int y);
   123 
   124 #endif /* _SDL_mouse_c_h */
   125 
   126 /* vi: set ts=4 sw=4 expandtab: */