src/events/SDL_mouse_c.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 25 Aug 2008 06:33:00 +0000
changeset 2710 44e49d3fa6cf
parent 2152 003c1b5b07da
child 2712 c4e697245676
permissions -rw-r--r--
Final merge of Google Summer of Code 2008 work...

Many-mouse and tablet support
by Szymon Wilczek, mentored by Ryan C. Gordon

Everything concerning the project is noted on the wiki:
http://wilku.ravenlord.ws/doku.php?id=start
     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     SDL_Cursor *next;
    33     void *driverdata;
    34 };
    35 
    36 struct SDL_Mouse
    37 {
    38     /* Create a cursor from a surface */
    39     SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
    40 
    41     /* Show the specified cursor, or hide if cursor is NULL */
    42     int (*ShowCursor) (SDL_Cursor * cursor);
    43 
    44     /* This is called when a mouse motion event occurs */
    45     void (*MoveCursor) (SDL_Cursor * cursor);
    46 
    47     /* Free a window manager cursor */
    48     void (*FreeCursor) (SDL_Cursor * cursor);
    49 
    50     /* Warp the mouse to (x,y) */
    51     void (*WarpMouse) (SDL_Mouse * mouse, SDL_WindowID windowID, int x,
    52                        int y);
    53 
    54     /* Free the mouse when it's time */
    55     void (*FreeMouse) (SDL_Mouse * mouse);
    56 
    57     /* data common for tablets */
    58     int pressure;
    59     int pressure_max;
    60     int pressure_min;
    61     int tilt;                   /* for future use */
    62     int rotation;               /* for future use */
    63     int total_ends;
    64     int current_end;
    65 
    66     /* Data common to all mice */
    67     SDL_WindowID focus;
    68     int which;
    69     int x;
    70     int y;
    71     int z;                      /* for future use */
    72     int xdelta;
    73     int ydelta;
    74     char *name;
    75     Uint8 buttonstate;
    76     SDL_bool relative_mode;
    77     SDL_bool proximity;
    78     SDL_bool flush_motion;
    79 
    80     SDL_Cursor *cursors;
    81     SDL_Cursor *def_cursor;
    82     SDL_Cursor *cur_cursor;
    83     SDL_bool cursor_shown;
    84 
    85     void *driverdata;
    86 };
    87 
    88 /* Initialize the mouse subsystem */
    89 extern int SDL_MouseInit(void);
    90 
    91 /* Get the mouse at an index */
    92 extern SDL_Mouse *SDL_GetMouse(int index);
    93 
    94 /* Assign an id to a mouse at an index */
    95 extern int SDL_SetMouseIndexId(int id, int index);
    96 
    97 /* Get the mouse by id */
    98 extern SDL_Mouse *SDL_GetMouseByID(int id);
    99 
   100 /* Add a mouse, possibly reattaching at a particular index (or -1),
   101    returning the index of the mouse, or -1 if there was an error.
   102  */
   103 extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char *name,
   104                         int pressure_max, int pressure_min, int ends);
   105 
   106 /* Remove a mouse at an index, clearing the slot for later */
   107 extern void SDL_DelMouse(int index);
   108 
   109 /* Clear the button state of a mouse at an index */
   110 extern void SDL_ResetMouse(int index);
   111 
   112 /* Set the mouse focus window */
   113 extern void SDL_SetMouseFocus(int id, SDL_WindowID windowID);
   114 
   115 /* Send a mouse motion event for a mouse at an index */
   116 extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z);
   117 
   118 /* Send a mouse button event for a mouse at an index */
   119 extern int SDL_SendMouseButton(int id, Uint8 state, Uint8 button);
   120 
   121 /* Send a mouse wheel event for a mouse at an index */
   122 extern int SDL_SendMouseWheel(int id, int x, int y);
   123 
   124 /* Shutdown the mouse subsystem */
   125 extern void SDL_MouseQuit(void);
   126 
   127 /* FIXME: Where do these functions go in this header? */
   128 extern void SDL_UpdateCoordinates(int x, int y);
   129 extern void SDL_ChangeEnd(int id, int end);
   130 
   131 #endif /* _SDL_mouse_c_h */
   132 
   133 /* vi: set ts=4 sw=4 expandtab: */