include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 10 Jun 2006 09:11:59 +0000
branchSDL-1.3
changeset 1673 624e1412fbba
parent 1671 89f7510fe17a
child 1722 5daa04d862f1
permissions -rw-r--r--
Keyboard code update in progress
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@1662
    23
/**
slouken@1662
    24
 * \file SDL_mouse.h
slouken@1662
    25
 *
slouken@1662
    26
 * Include file for SDL mouse event handling
slouken@1662
    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@1662
    39
/* *INDENT-OFF* */
slouken@0
    40
extern "C" {
slouken@1662
    41
/* *INDENT-ON* */
slouken@0
    42
#endif
slouken@0
    43
slouken@1670
    44
typedef struct SDL_Cursor SDL_Cursor;   /* Implementation dependent */
slouken@0
    45
slouken@0
    46
/* Function prototypes */
slouken@1670
    47
slouken@1673
    48
/**
slouken@1673
    49
 * \fn int SDL_GetNumMice(void)
slouken@1670
    50
 *
slouken@1670
    51
 * \brief Get the number of mouse input devices available.
slouken@1670
    52
 *
slouken@1670
    53
 * \sa SDL_SelectMouse()
slouken@1670
    54
 */
slouken@1670
    55
extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
slouken@1670
    56
slouken@1673
    57
/**
slouken@1673
    58
 * \fn int SDL_SelectMouse(int index)
slouken@1670
    59
 *
slouken@1670
    60
 * \brief Set the index of the currently selected mouse.
slouken@1670
    61
 *
slouken@1671
    62
 * \return The index of the previously selected mouse.
slouken@1670
    63
 *
slouken@1670
    64
 * \note You can query the currently selected mouse by passing an index of -1.
slouken@1670
    65
 *
slouken@1670
    66
 * \sa SDL_GetNumMice()
slouken@1670
    67
 */
slouken@1670
    68
extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
slouken@1670
    69
slouken@1673
    70
/**
slouken@1673
    71
 * \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
slouken@1670
    72
 *
slouken@1670
    73
 * \brief Get the window which currently has focus for the currently selected mouse.
slouken@1670
    74
 */
slouken@1670
    75
extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void);
slouken@1670
    76
slouken@1673
    77
/**
slouken@1670
    78
 * \fn Uint8 SDL_GetMouseState(int *x, int *y)
slouken@1670
    79
 *
slouken@1670
    80
 * \brief Retrieve the current state of the mouse.
slouken@1670
    81
 *
slouken@0
    82
 * The current button state is returned as a button bitmask, which can
slouken@0
    83
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@1670
    84
 * mouse cursor position relative to the focus window for the currently
slouken@1670
    85
 * selected mouse.  You can pass NULL for either x or y.
slouken@0
    86
 */
slouken@1668
    87
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
slouken@0
    88
slouken@1673
    89
/**
slouken@1670
    90
 * \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
slouken@1670
    91
 *
slouken@1670
    92
 * \brief Retrieve the current state of the mouse.
slouken@1670
    93
 *
slouken@0
    94
 * The current button state is returned as a button bitmask, which can
slouken@0
    95
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    96
 * mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@0
    97
 */
slouken@1668
    98
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
slouken@0
    99
slouken@1673
   100
/**
slouken@1670
   101
 * \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
slouken@1670
   102
 *
slouken@1670
   103
 * \brief Moves the currently selected mouse to the given position within the window.
slouken@1670
   104
 *
slouken@1670
   105
 * \param windowID The window to move the mouse into, or 0 for the current mouse focus
slouken@1670
   106
 * \param x The x coordinate within the window
slouken@1670
   107
 * \param y The y coordinate within the window
slouken@1670
   108
 *
slouken@1670
   109
 * \note This function generates a mouse motion event
slouken@0
   110
 */
slouken@1670
   111
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
slouken@1670
   112
                                                   int x, int y);
slouken@0
   113
slouken@1673
   114
/**
slouken@1671
   115
 * \fn SDL_Cursor *SDL_CreateCursor (const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y)
slouken@1671
   116
 *
slouken@1671
   117
 * \brief Create a cursor for the currently selected mouse, using the
slouken@1671
   118
 *        specified bitmap data and mask (in MSB format).
slouken@1671
   119
 *
slouken@0
   120
 * The cursor width must be a multiple of 8 bits.
slouken@0
   121
 *
slouken@0
   122
 * The cursor is created in black and white according to the following:
slouken@0
   123
 * data  mask    resulting pixel on screen
slouken@0
   124
 *  0     1       White
slouken@0
   125
 *  1     1       Black
slouken@0
   126
 *  0     0       Transparent
slouken@0
   127
 *  1     0       Inverted color if possible, black if not.
slouken@0
   128
 *
slouken@1671
   129
 * \sa SDL_FreeCursor()
slouken@0
   130
 */
slouken@1671
   131
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
slouken@1671
   132
                                                     const Uint8 * mask,
slouken@1671
   133
                                                     int w, int h, int hot_x,
slouken@1671
   134
                                                     int hot_y);
slouken@0
   135
slouken@1673
   136
/**
slouken@1671
   137
 * \fn void SDL_SetCursor(SDL_Cursor * cursor)
slouken@1671
   138
 *
slouken@1671
   139
 * \brief Set the active cursor for the currently selected mouse.
slouken@1671
   140
 *
slouken@1671
   141
 * \note The cursor must have been created for the selected mouse.
slouken@0
   142
 */
slouken@1668
   143
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
slouken@0
   144
slouken@1673
   145
/**
slouken@1671
   146
 * \fn SDL_Cursor *SDL_GetCursor(void)
slouken@1671
   147
 *
slouken@1671
   148
 * \brief Return the active cursor for the currently selected mouse.
slouken@0
   149
 */
slouken@1668
   150
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
slouken@0
   151
slouken@1673
   152
/**
slouken@1671
   153
 * \fn void SDL_FreeCursor(SDL_Cursor * cursor)
slouken@1671
   154
 *
slouken@1671
   155
 * \brief Frees a cursor created with SDL_CreateCursor().
slouken@1671
   156
 *
slouken@1671
   157
 * \sa SDL_CreateCursor()
slouken@0
   158
 */
slouken@1668
   159
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
slouken@0
   160
slouken@1673
   161
/**
slouken@1671
   162
 * \fn int SDL_ShowCursor(int toggle)
slouken@1671
   163
 *
slouken@1671
   164
 * \brief Toggle whether or not the cursor is shown for the currently selected mouse.
slouken@1671
   165
 *
slouken@1671
   166
 * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current state.
slouken@1671
   167
 *
slouken@1671
   168
 * \return 1 if the cursor is shown, or 0 if the cursor is hidden.
slouken@0
   169
 */
slouken@1668
   170
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
slouken@0
   171
slouken@0
   172
/* Used as a mask when testing buttons in buttonstate
slouken@0
   173
   Button 1:	Left mouse button
slouken@0
   174
   Button 2:	Middle mouse button
slouken@0
   175
   Button 3:	Right mouse button
slouken@451
   176
   Button 4:	Mouse wheel up	 (may also be a real button)
slouken@451
   177
   Button 5:	Mouse wheel down (may also be a real button)
slouken@0
   178
 */
slouken@1330
   179
#define SDL_BUTTON(X)		(1 << ((X)-1))
slouken@0
   180
#define SDL_BUTTON_LEFT		1
slouken@0
   181
#define SDL_BUTTON_MIDDLE	2
slouken@0
   182
#define SDL_BUTTON_RIGHT	3
slouken@451
   183
#define SDL_BUTTON_WHEELUP	4
slouken@451
   184
#define SDL_BUTTON_WHEELDOWN	5
slouken@0
   185
#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@0
   186
#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@0
   187
#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@0
   188
slouken@0
   189
slouken@0
   190
/* Ends C function definitions when using C++ */
slouken@0
   191
#ifdef __cplusplus
slouken@1662
   192
/* *INDENT-OFF* */
slouken@0
   193
}
slouken@1662
   194
/* *INDENT-ON* */
slouken@0
   195
#endif
slouken@0
   196
#include "close_code.h"
slouken@0
   197
slouken@0
   198
#endif /* _SDL_mouse_h */
slouken@1662
   199
slouken@1662
   200
/* vi: set ts=4 sw=4 expandtab: */