include/SDL_mouse.h
author Szymon Wilczek <kazeuser@gmail.com>
Mon, 25 Aug 2008 18:02:14 +0000
changeset 2718 abacf2555bb4
parent 2710 44e49d3fa6cf
child 2765 f55c87ae336b
permissions -rw-r--r--
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@1895
    23
/**
slouken@1895
    24
 * \file SDL_mouse.h
slouken@1895
    25
 *
slouken@1895
    26
 * Include file for SDL mouse event handling
slouken@1895
    27
 */
slouken@0
    28
slouken@0
    29
#ifndef _SDL_mouse_h
slouken@0
    30
#define _SDL_mouse_h
slouken@0
    31
slouken@1356
    32
#include "SDL_stdinc.h"
slouken@1358
    33
#include "SDL_error.h"
slouken@0
    34
#include "SDL_video.h"
slouken@0
    35
slouken@0
    36
#include "begin_code.h"
slouken@0
    37
/* Set up for C function definitions, even when using C++ */
slouken@0
    38
#ifdef __cplusplus
slouken@1895
    39
/* *INDENT-OFF* */
slouken@0
    40
extern "C" {
slouken@1895
    41
/* *INDENT-ON* */
slouken@0
    42
#endif
slouken@0
    43
slouken@1895
    44
typedef struct SDL_Cursor SDL_Cursor;   /* Implementation dependent */
slouken@0
    45
slouken@0
    46
/* Function prototypes */
slouken@1895
    47
slouken@1895
    48
/**
slouken@1895
    49
 * \fn int SDL_GetNumMice(void)
slouken@1895
    50
 *
slouken@1895
    51
 * \brief Get the number of mouse input devices available.
slouken@1895
    52
 *
slouken@1895
    53
 * \sa SDL_SelectMouse()
slouken@1895
    54
 */
slouken@1895
    55
extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
slouken@1895
    56
slouken@1895
    57
/**
kazeuser@2718
    58
 * \fn char* SDL_GetMouseName(int index)
kazeuser@2718
    59
 *
kazeuser@2718
    60
 * \brief Gets the name of a mouse with the given index.
kazeuser@2718
    61
 *
kazeuser@2718
    62
 * \param index is the index of the mouse, which name is to be returned.
kazeuser@2718
    63
 *
kazeuser@2718
    64
 * \return the name of the mouse with the specified index
kazeuser@2718
    65
 */
kazeuser@2718
    66
extern DECLSPEC char *SDLCALL SDL_GetMouseName(int index);
kazeuser@2718
    67
kazeuser@2718
    68
/**
slouken@1895
    69
 * \fn int SDL_SelectMouse(int index)
slouken@1895
    70
 *
slouken@1895
    71
 * \brief Set the index of the currently selected mouse.
slouken@1895
    72
 *
slouken@1895
    73
 * \return The index of the previously selected mouse.
slouken@1895
    74
 *
slouken@1895
    75
 * \note You can query the currently selected mouse by passing an index of -1.
slouken@1895
    76
 *
slouken@1895
    77
 * \sa SDL_GetNumMice()
slouken@1895
    78
 */
slouken@1895
    79
extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
slouken@1895
    80
slouken@1895
    81
/**
slouken@1895
    82
 * \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
slouken@1895
    83
 *
slouken@1895
    84
 * \brief Get the window which currently has focus for the currently selected mouse.
slouken@1895
    85
 */
slouken@2710
    86
extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(int index);
slouken@1895
    87
slouken@1895
    88
/**
slouken@1895
    89
 * \fn int SDL_SetRelativeMouseMode(SDL_bool enabled)
slouken@1895
    90
 *
slouken@1895
    91
 * \brief Set relative mouse mode for the currently selected mouse.
slouken@1895
    92
 *
slouken@1895
    93
 * \param enabled Whether or not to enable relative mode
slouken@1895
    94
 *
slouken@1895
    95
 * \return 0 on success, or -1 if relative mode is not supported.
slouken@1895
    96
 *
slouken@1895
    97
 * While the mouse is in relative mode, the cursor is hidden, and the
slouken@1895
    98
 * driver will try to report continuous motion in the current window.
slouken@1895
    99
 * Only relative motion events will be delivered, the mouse position
slouken@1895
   100
 * will not change.
slouken@1895
   101
 *
slouken@1895
   102
 * \note This function will flush any pending mouse motion.
slouken@1895
   103
 *
slouken@1895
   104
 * \sa SDL_GetRelativeMouseMode()
slouken@1895
   105
 */
slouken@2710
   106
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(int index,
slouken@2710
   107
                                                     SDL_bool enabled);
slouken@1895
   108
slouken@1895
   109
/**
slouken@1895
   110
 * \fn SDL_bool SDL_GetRelativeMouseMode()
slouken@1895
   111
 *
slouken@1895
   112
 * \brief Query whether relative mouse mode is enabled for the currently selected mouse.
slouken@1895
   113
 *
slouken@1895
   114
 * \sa SDL_SetRelativeMouseMode()
slouken@1895
   115
 */
slouken@2710
   116
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(int index);
slouken@1895
   117
slouken@1895
   118
/**
slouken@1895
   119
 * \fn Uint8 SDL_GetMouseState(int *x, int *y)
slouken@1895
   120
 *
slouken@1895
   121
 * \brief Retrieve the current state of the currently selected mouse.
slouken@1895
   122
 *
slouken@0
   123
 * The current button state is returned as a button bitmask, which can
slouken@0
   124
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@1895
   125
 * mouse cursor position relative to the focus window for the currently
slouken@1895
   126
 * selected mouse.  You can pass NULL for either x or y.
slouken@0
   127
 */
slouken@2710
   128
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int index, int *x, int *y);
slouken@0
   129
slouken@1895
   130
/**
slouken@1895
   131
 * \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
slouken@1895
   132
 *
slouken@1895
   133
 * \brief Retrieve the state of the currently selected mouse.
slouken@1895
   134
 *
slouken@0
   135
 * The current button state is returned as a button bitmask, which can
slouken@0
   136
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
   137
 * mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@0
   138
 */
slouken@2710
   139
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int index, int *x,
slouken@2710
   140
                                                        int *y);
slouken@0
   141
slouken@1895
   142
/**
slouken@1895
   143
 * \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
slouken@1895
   144
 *
slouken@1895
   145
 * \brief Moves the currently selected mouse to the given position within the window.
slouken@1895
   146
 *
slouken@1895
   147
 * \param windowID The window to move the mouse into, or 0 for the current mouse focus
slouken@1895
   148
 * \param x The x coordinate within the window
slouken@1895
   149
 * \param y The y coordinate within the window
slouken@1895
   150
 *
slouken@1895
   151
 * \note This function generates a mouse motion event
slouken@0
   152
 */
slouken@1895
   153
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
slouken@1895
   154
                                                   int x, int y);
slouken@0
   155
slouken@1895
   156
/**
slouken@1895
   157
 * \fn SDL_Cursor *SDL_CreateCursor (const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y)
slouken@1895
   158
 *
slouken@1895
   159
 * \brief Create a cursor for the currently selected mouse, using the
slouken@1895
   160
 *        specified bitmap data and mask (in MSB format).
slouken@1895
   161
 *
slouken@0
   162
 * The cursor width must be a multiple of 8 bits.
slouken@0
   163
 *
slouken@0
   164
 * The cursor is created in black and white according to the following:
slouken@0
   165
 * data  mask    resulting pixel on screen
slouken@0
   166
 *  0     1       White
slouken@0
   167
 *  1     1       Black
slouken@0
   168
 *  0     0       Transparent
slouken@0
   169
 *  1     0       Inverted color if possible, black if not.
slouken@0
   170
 *
slouken@1895
   171
 * \sa SDL_FreeCursor()
slouken@0
   172
 */
slouken@1895
   173
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
slouken@1895
   174
                                                     const Uint8 * mask,
slouken@1895
   175
                                                     int w, int h, int hot_x,
slouken@1895
   176
                                                     int hot_y);
slouken@0
   177
slouken@1895
   178
/**
slouken@1895
   179
 * \fn void SDL_SetCursor(SDL_Cursor * cursor)
slouken@1895
   180
 *
slouken@1895
   181
 * \brief Set the active cursor for the currently selected mouse.
slouken@1895
   182
 *
slouken@1895
   183
 * \note The cursor must have been created for the selected mouse.
slouken@0
   184
 */
slouken@1895
   185
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
slouken@0
   186
slouken@1895
   187
/**
slouken@1895
   188
 * \fn SDL_Cursor *SDL_GetCursor(void)
slouken@1895
   189
 *
slouken@1895
   190
 * \brief Return the active cursor for the currently selected mouse.
slouken@0
   191
 */
slouken@1895
   192
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
slouken@0
   193
slouken@1895
   194
/**
slouken@1895
   195
 * \fn void SDL_FreeCursor(SDL_Cursor * cursor)
slouken@1895
   196
 *
slouken@1895
   197
 * \brief Frees a cursor created with SDL_CreateCursor().
slouken@1895
   198
 *
slouken@1895
   199
 * \sa SDL_CreateCursor()
slouken@0
   200
 */
slouken@1895
   201
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
slouken@0
   202
slouken@1895
   203
/**
slouken@1895
   204
 * \fn int SDL_ShowCursor(int toggle)
slouken@1895
   205
 *
slouken@1895
   206
 * \brief Toggle whether or not the cursor is shown for the currently selected mouse.
slouken@1895
   207
 *
slouken@1895
   208
 * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current state.
slouken@1895
   209
 *
slouken@1895
   210
 * \return 1 if the cursor is shown, or 0 if the cursor is hidden.
slouken@0
   211
 */
slouken@337
   212
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
slouken@0
   213
slouken@0
   214
/* Used as a mask when testing buttons in buttonstate
slouken@0
   215
   Button 1:	Left mouse button
slouken@0
   216
   Button 2:	Middle mouse button
slouken@0
   217
   Button 3:	Right mouse button
slouken@0
   218
 */
slouken@2710
   219
kazeuser@2718
   220
/**
kazeuser@2718
   221
 * \fn int SDL_GetCursorsNumber(int index)
kazeuser@2718
   222
 *
kazeuser@2718
   223
 * \brief Gets the number of cursors a pointing device supports.
kazeuser@2718
   224
 * Useful for tablet users. Useful only under Windows.
kazeuser@2718
   225
 *
kazeuser@2718
   226
 * \param index is the index of the pointing device, which number of cursors we
kazeuser@2718
   227
 * want to receive.
kazeuser@2718
   228
 *
kazeuser@2718
   229
 * \return the number of cursors supported by the pointing device. On Windows
kazeuser@2718
   230
 * if a device is a tablet it returns a number >=1. Normal mice always return 1.
kazeuser@2718
   231
 * On Linux every device reports one cursor.
kazeuser@2718
   232
 */
slouken@2710
   233
extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index);
slouken@2710
   234
kazeuser@2718
   235
/**
kazeuser@2718
   236
 * \fn int SDL_GetCurrentCursor(int index)
kazeuser@2718
   237
 *
kazeuser@2718
   238
 * \brief Returns the index of the current cursor used by a specific pointing
kazeuser@2718
   239
 * device. Useful only under Windows.
kazeuser@2718
   240
 *
kazeuser@2718
   241
 * \param index is the index of the pointing device, which cursor index we want
kazeuser@2718
   242
 * to receive.
kazeuser@2718
   243
 *
kazeuser@2718
   244
 * \return the index of the cursor currently used by a specific pointing device.
kazeuser@2718
   245
 * Always 0 under Linux. On Windows if the device isn't a tablet it returns 0.
kazeuser@2718
   246
 * If the device is the tablet it returns the cursor index.
kazeuser@2718
   247
 * 0 - stylus, 1 - eraser, 2 - cursor.
kazeuser@2718
   248
 */
slouken@2710
   249
extern DECLSPEC int SDLCALL SDL_GetCurrentCursor(int index);
slouken@2710
   250
slouken@1330
   251
#define SDL_BUTTON(X)		(1 << ((X)-1))
slouken@0
   252
#define SDL_BUTTON_LEFT		1
slouken@0
   253
#define SDL_BUTTON_MIDDLE	2
slouken@0
   254
#define SDL_BUTTON_RIGHT	3
slouken@2284
   255
#define SDL_BUTTON_X1		4
slouken@2284
   256
#define SDL_BUTTON_X2		5
slouken@0
   257
#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@0
   258
#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@0
   259
#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@2284
   260
#define SDL_BUTTON_X1MASK	SDL_BUTTON(SDL_BUTTON_X1)
slouken@2284
   261
#define SDL_BUTTON_X2MASK	SDL_BUTTON(SDL_BUTTON_X2)
slouken@0
   262
slouken@0
   263
slouken@0
   264
/* Ends C function definitions when using C++ */
slouken@0
   265
#ifdef __cplusplus
slouken@1895
   266
/* *INDENT-OFF* */
slouken@0
   267
}
slouken@1895
   268
/* *INDENT-ON* */
slouken@0
   269
#endif
slouken@0
   270
#include "close_code.h"
slouken@0
   271
slouken@0
   272
#endif /* _SDL_mouse_h */
slouken@1895
   273
slouken@1895
   274
/* vi: set ts=4 sw=4 expandtab: */