include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 07 Jun 2006 16:10:28 +0000
branchSDL-1.3
changeset 1670 eef792d31de8
parent 1668 4da1ee79c9af
child 1671 89f7510fe17a
permissions -rw-r--r--
Work 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@1670
    48
/* \fn int SDL_GetNumMice(void)
slouken@1670
    49
 *
slouken@1670
    50
 * \brief Get the number of mouse input devices available.
slouken@1670
    51
 *
slouken@1670
    52
 * \sa SDL_SelectMouse()
slouken@1670
    53
 */
slouken@1670
    54
extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
slouken@1670
    55
slouken@1670
    56
/* \fn int SDL_SelectMouse(int index)
slouken@1670
    57
 *
slouken@1670
    58
 * \brief Set the index of the currently selected mouse.
slouken@1670
    59
 *
slouken@1670
    60
 * \return The index of the currently selected mouse.
slouken@1670
    61
 *
slouken@1670
    62
 * \note You can query the currently selected mouse by passing an index of -1.
slouken@1670
    63
 *
slouken@1670
    64
 * \sa SDL_GetNumMice()
slouken@1670
    65
 */
slouken@1670
    66
extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
slouken@1670
    67
slouken@1670
    68
/* \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
slouken@1670
    69
 *
slouken@1670
    70
 * \brief Get the window which currently has focus for the currently selected mouse.
slouken@1670
    71
 */
slouken@1670
    72
extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void);
slouken@1670
    73
slouken@0
    74
/*
slouken@1670
    75
 * \fn Uint8 SDL_GetMouseState(int *x, int *y)
slouken@1670
    76
 *
slouken@1670
    77
 * \brief Retrieve the current state of the mouse.
slouken@1670
    78
 *
slouken@0
    79
 * The current button state is returned as a button bitmask, which can
slouken@0
    80
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@1670
    81
 * mouse cursor position relative to the focus window for the currently
slouken@1670
    82
 * selected mouse.  You can pass NULL for either x or y.
slouken@0
    83
 */
slouken@1668
    84
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
slouken@0
    85
slouken@0
    86
/*
slouken@1670
    87
 * \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
slouken@1670
    88
 *
slouken@1670
    89
 * \brief Retrieve the current state of the mouse.
slouken@1670
    90
 *
slouken@0
    91
 * The current button state is returned as a button bitmask, which can
slouken@0
    92
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    93
 * mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@0
    94
 */
slouken@1668
    95
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
slouken@0
    96
slouken@0
    97
/*
slouken@1670
    98
 * \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
slouken@1670
    99
 *
slouken@1670
   100
 * \brief Moves the currently selected mouse to the given position within the window.
slouken@1670
   101
 *
slouken@1670
   102
 * \param windowID The window to move the mouse into, or 0 for the current mouse focus
slouken@1670
   103
 * \param x The x coordinate within the window
slouken@1670
   104
 * \param y The y coordinate within the window
slouken@1670
   105
 *
slouken@1670
   106
 * \note This function generates a mouse motion event
slouken@0
   107
 */
slouken@1670
   108
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
slouken@1670
   109
                                                   int x, int y);
slouken@0
   110
slouken@0
   111
/*
slouken@0
   112
 * Create a cursor using the specified data and mask (in MSB format).
slouken@0
   113
 * The cursor width must be a multiple of 8 bits.
slouken@0
   114
 *
slouken@0
   115
 * The cursor is created in black and white according to the following:
slouken@0
   116
 * data  mask    resulting pixel on screen
slouken@0
   117
 *  0     1       White
slouken@0
   118
 *  1     1       Black
slouken@0
   119
 *  0     0       Transparent
slouken@0
   120
 *  1     0       Inverted color if possible, black if not.
slouken@0
   121
 *
slouken@0
   122
 * Cursors created with this function must be freed with SDL_FreeCursor().
slouken@0
   123
 */
slouken@1662
   124
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor
slouken@1662
   125
    (Uint8 * data, Uint8 * mask, int w, int h, int hot_x, int hot_y);
slouken@0
   126
slouken@0
   127
/*
slouken@0
   128
 * Set the currently active cursor to the specified one.
slouken@0
   129
 * If the cursor is currently visible, the change will be immediately 
slouken@0
   130
 * represented on the display.
slouken@0
   131
 */
slouken@1668
   132
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
slouken@0
   133
slouken@0
   134
/*
slouken@0
   135
 * Returns the currently active cursor.
slouken@0
   136
 */
slouken@1668
   137
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
slouken@0
   138
slouken@0
   139
/*
slouken@0
   140
 * Deallocates a cursor created with SDL_CreateCursor().
slouken@0
   141
 */
slouken@1668
   142
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
slouken@0
   143
slouken@0
   144
/*
slouken@0
   145
 * Toggle whether or not the cursor is shown on the screen.
slouken@0
   146
 * The cursor start off displayed, but can be turned off.
slouken@0
   147
 * SDL_ShowCursor() returns 1 if the cursor was being displayed
slouken@0
   148
 * before the call, or 0 if it was not.  You can query the current
slouken@0
   149
 * state by passing a 'toggle' value of -1.
slouken@0
   150
 */
slouken@1668
   151
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
slouken@0
   152
slouken@0
   153
/* Used as a mask when testing buttons in buttonstate
slouken@0
   154
   Button 1:	Left mouse button
slouken@0
   155
   Button 2:	Middle mouse button
slouken@0
   156
   Button 3:	Right mouse button
slouken@451
   157
   Button 4:	Mouse wheel up	 (may also be a real button)
slouken@451
   158
   Button 5:	Mouse wheel down (may also be a real button)
slouken@0
   159
 */
slouken@1330
   160
#define SDL_BUTTON(X)		(1 << ((X)-1))
slouken@0
   161
#define SDL_BUTTON_LEFT		1
slouken@0
   162
#define SDL_BUTTON_MIDDLE	2
slouken@0
   163
#define SDL_BUTTON_RIGHT	3
slouken@451
   164
#define SDL_BUTTON_WHEELUP	4
slouken@451
   165
#define SDL_BUTTON_WHEELDOWN	5
slouken@0
   166
#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@0
   167
#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@0
   168
#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@0
   169
slouken@0
   170
slouken@0
   171
/* Ends C function definitions when using C++ */
slouken@0
   172
#ifdef __cplusplus
slouken@1662
   173
/* *INDENT-OFF* */
slouken@0
   174
}
slouken@1662
   175
/* *INDENT-ON* */
slouken@0
   176
#endif
slouken@0
   177
#include "close_code.h"
slouken@0
   178
slouken@0
   179
#endif /* _SDL_mouse_h */
slouken@1662
   180
slouken@1662
   181
/* vi: set ts=4 sw=4 expandtab: */