include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 25 Aug 2008 06:33:00 +0000
changeset 2710 44e49d3fa6cf
parent 2284 545fbf461c5b
child 2718 abacf2555bb4
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 
    23 /**
    24  * \file SDL_mouse.h
    25  *
    26  * Include file for SDL mouse event handling
    27  */
    28 
    29 #ifndef _SDL_mouse_h
    30 #define _SDL_mouse_h
    31 
    32 #include "SDL_stdinc.h"
    33 #include "SDL_error.h"
    34 #include "SDL_video.h"
    35 
    36 #include "begin_code.h"
    37 /* Set up for C function definitions, even when using C++ */
    38 #ifdef __cplusplus
    39 /* *INDENT-OFF* */
    40 extern "C" {
    41 /* *INDENT-ON* */
    42 #endif
    43 
    44 typedef struct SDL_Cursor SDL_Cursor;   /* Implementation dependent */
    45 
    46 /* Function prototypes */
    47 
    48 /**
    49  * \fn int SDL_GetNumMice(void)
    50  *
    51  * \brief Get the number of mouse input devices available.
    52  *
    53  * \sa SDL_SelectMouse()
    54  */
    55 extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
    56 
    57 /**
    58  * \fn int SDL_SelectMouse(int index)
    59  *
    60  * \brief Set the index of the currently selected mouse.
    61  *
    62  * \return The index of the previously selected mouse.
    63  *
    64  * \note You can query the currently selected mouse by passing an index of -1.
    65  *
    66  * \sa SDL_GetNumMice()
    67  */
    68 extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
    69 
    70 /**
    71  * \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
    72  *
    73  * \brief Get the window which currently has focus for the currently selected mouse.
    74  */
    75 extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(int index);
    76 
    77 /**
    78  * \fn int SDL_SetRelativeMouseMode(SDL_bool enabled)
    79  *
    80  * \brief Set relative mouse mode for the currently selected mouse.
    81  *
    82  * \param enabled Whether or not to enable relative mode
    83  *
    84  * \return 0 on success, or -1 if relative mode is not supported.
    85  *
    86  * While the mouse is in relative mode, the cursor is hidden, and the
    87  * driver will try to report continuous motion in the current window.
    88  * Only relative motion events will be delivered, the mouse position
    89  * will not change.
    90  *
    91  * \note This function will flush any pending mouse motion.
    92  *
    93  * \sa SDL_GetRelativeMouseMode()
    94  */
    95 extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(int index,
    96                                                      SDL_bool enabled);
    97 
    98 /**
    99  * \fn SDL_bool SDL_GetRelativeMouseMode()
   100  *
   101  * \brief Query whether relative mouse mode is enabled for the currently selected mouse.
   102  *
   103  * \sa SDL_SetRelativeMouseMode()
   104  */
   105 extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(int index);
   106 
   107 /**
   108  * \fn Uint8 SDL_GetMouseState(int *x, int *y)
   109  *
   110  * \brief Retrieve the current state of the currently selected mouse.
   111  *
   112  * The current button state is returned as a button bitmask, which can
   113  * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
   114  * mouse cursor position relative to the focus window for the currently
   115  * selected mouse.  You can pass NULL for either x or y.
   116  */
   117 extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int index, int *x, int *y);
   118 
   119 /**
   120  * \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
   121  *
   122  * \brief Retrieve the state of the currently selected mouse.
   123  *
   124  * The current button state is returned as a button bitmask, which can
   125  * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
   126  * mouse deltas since the last call to SDL_GetRelativeMouseState().
   127  */
   128 extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int index, int *x,
   129                                                         int *y);
   130 
   131 /**
   132  * \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
   133  *
   134  * \brief Moves the currently selected mouse to the given position within the window.
   135  *
   136  * \param windowID The window to move the mouse into, or 0 for the current mouse focus
   137  * \param x The x coordinate within the window
   138  * \param y The y coordinate within the window
   139  *
   140  * \note This function generates a mouse motion event
   141  */
   142 extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
   143                                                    int x, int y);
   144 
   145 /**
   146  * \fn SDL_Cursor *SDL_CreateCursor (const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y)
   147  *
   148  * \brief Create a cursor for the currently selected mouse, using the
   149  *        specified bitmap data and mask (in MSB format).
   150  *
   151  * The cursor width must be a multiple of 8 bits.
   152  *
   153  * The cursor is created in black and white according to the following:
   154  * data  mask    resulting pixel on screen
   155  *  0     1       White
   156  *  1     1       Black
   157  *  0     0       Transparent
   158  *  1     0       Inverted color if possible, black if not.
   159  *
   160  * \sa SDL_FreeCursor()
   161  */
   162 extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
   163                                                      const Uint8 * mask,
   164                                                      int w, int h, int hot_x,
   165                                                      int hot_y);
   166 
   167 /**
   168  * \fn void SDL_SetCursor(SDL_Cursor * cursor)
   169  *
   170  * \brief Set the active cursor for the currently selected mouse.
   171  *
   172  * \note The cursor must have been created for the selected mouse.
   173  */
   174 extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
   175 
   176 /**
   177  * \fn SDL_Cursor *SDL_GetCursor(void)
   178  *
   179  * \brief Return the active cursor for the currently selected mouse.
   180  */
   181 extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
   182 
   183 /**
   184  * \fn void SDL_FreeCursor(SDL_Cursor * cursor)
   185  *
   186  * \brief Frees a cursor created with SDL_CreateCursor().
   187  *
   188  * \sa SDL_CreateCursor()
   189  */
   190 extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
   191 
   192 /**
   193  * \fn int SDL_ShowCursor(int toggle)
   194  *
   195  * \brief Toggle whether or not the cursor is shown for the currently selected mouse.
   196  *
   197  * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current state.
   198  *
   199  * \return 1 if the cursor is shown, or 0 if the cursor is hidden.
   200  */
   201 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
   202 
   203 /* Used as a mask when testing buttons in buttonstate
   204    Button 1:	Left mouse button
   205    Button 2:	Middle mouse button
   206    Button 3:	Right mouse button
   207  */
   208 
   209 /* FIXME: Where do these functions go in this header?
   210           Also, add doxygen documentation for these...
   211 */
   212 extern DECLSPEC char *SDLCALL SDL_GetMouseName(int index);
   213 
   214 extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index);
   215 
   216 extern DECLSPEC int SDLCALL SDL_GetCurrentCursor(int index);
   217 
   218 #define SDL_BUTTON(X)		(1 << ((X)-1))
   219 #define SDL_BUTTON_LEFT		1
   220 #define SDL_BUTTON_MIDDLE	2
   221 #define SDL_BUTTON_RIGHT	3
   222 #define SDL_BUTTON_X1		4
   223 #define SDL_BUTTON_X2		5
   224 #define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
   225 #define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
   226 #define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
   227 #define SDL_BUTTON_X1MASK	SDL_BUTTON(SDL_BUTTON_X1)
   228 #define SDL_BUTTON_X2MASK	SDL_BUTTON(SDL_BUTTON_X2)
   229 
   230 
   231 /* Ends C function definitions when using C++ */
   232 #ifdef __cplusplus
   233 /* *INDENT-OFF* */
   234 }
   235 /* *INDENT-ON* */
   236 #endif
   237 #include "close_code.h"
   238 
   239 #endif /* _SDL_mouse_h */
   240 
   241 /* vi: set ts=4 sw=4 expandtab: */