include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 09 Mar 2014 11:06:11 -0700
changeset 8582 c3e9a2b93517
parent 7191 75360622e65f
child 8149 681eb46b8ac4
permissions -rw-r--r--
Fixed line endings on WinRT source code
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_mouse.h
slouken@7191
    24
 *
slouken@3407
    25
 *  Include file for SDL mouse event handling.
slouken@1895
    26
 */
slouken@0
    27
slouken@0
    28
#ifndef _SDL_mouse_h
slouken@0
    29
#define _SDL_mouse_h
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1358
    32
#include "SDL_error.h"
slouken@0
    33
#include "SDL_video.h"
slouken@0
    34
slouken@0
    35
#include "begin_code.h"
slouken@0
    36
/* Set up for C function definitions, even when using C++ */
slouken@0
    37
#ifdef __cplusplus
slouken@0
    38
extern "C" {
slouken@0
    39
#endif
slouken@0
    40
slouken@1895
    41
typedef struct SDL_Cursor SDL_Cursor;   /* Implementation dependent */
slouken@0
    42
mikesart@6675
    43
/**
mikesart@6675
    44
 * \brief Cursor types for SDL_CreateSystemCursor.
mikesart@6675
    45
 */
mikesart@6675
    46
typedef enum
mikesart@6675
    47
{
icculus@7067
    48
    SDL_SYSTEM_CURSOR_ARROW,     /**< Arrow */
icculus@7067
    49
    SDL_SYSTEM_CURSOR_IBEAM,     /**< I-beam */
icculus@7067
    50
    SDL_SYSTEM_CURSOR_WAIT,      /**< Wait */
icculus@7067
    51
    SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */
icculus@7067
    52
    SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */
icculus@7067
    53
    SDL_SYSTEM_CURSOR_SIZENWSE,  /**< Double arrow pointing northwest and southeast */
icculus@7067
    54
    SDL_SYSTEM_CURSOR_SIZENESW,  /**< Double arrow pointing northeast and southwest */
icculus@7067
    55
    SDL_SYSTEM_CURSOR_SIZEWE,    /**< Double arrow pointing west and east */
icculus@7067
    56
    SDL_SYSTEM_CURSOR_SIZENS,    /**< Double arrow pointing north and south */
icculus@7067
    57
    SDL_SYSTEM_CURSOR_SIZEALL,   /**< Four pointed arrow pointing north, south, east, and west */
icculus@7067
    58
    SDL_SYSTEM_CURSOR_NO,        /**< Slashed circle or crossbones */
icculus@7067
    59
    SDL_SYSTEM_CURSOR_HAND,      /**< Hand */
slouken@6677
    60
    SDL_NUM_SYSTEM_CURSORS
mikesart@6675
    61
} SDL_SystemCursor;
slouken@4465
    62
slouken@0
    63
/* Function prototypes */
slouken@1895
    64
slouken@1895
    65
/**
slouken@4465
    66
 *  \brief Get the window which currently has mouse focus.
slouken@1895
    67
 */
slouken@4465
    68
extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
slouken@1895
    69
slouken@1895
    70
/**
slouken@4465
    71
 *  \brief Retrieve the current state of the mouse.
slouken@7191
    72
 *
slouken@4465
    73
 *  The current button state is returned as a button bitmask, which can
slouken@4465
    74
 *  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@4465
    75
 *  mouse cursor position relative to the focus window for the currently
slouken@4465
    76
 *  selected mouse.  You can pass NULL for either x or y.
kazeuser@2718
    77
 */
slouken@6673
    78
extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
kazeuser@2718
    79
kazeuser@2718
    80
/**
slouken@4465
    81
 *  \brief Retrieve the relative state of the mouse.
slouken@4465
    82
 *
slouken@4465
    83
 *  The current button state is returned as a button bitmask, which can
slouken@4465
    84
 *  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@4465
    85
 *  mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@1895
    86
 */
slouken@6673
    87
extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
slouken@1895
    88
slouken@1895
    89
/**
slouken@4465
    90
 *  \brief Moves the mouse to the given position within the window.
slouken@7191
    91
 *
slouken@4465
    92
 *  \param window The window to move the mouse into, or NULL for the current mouse focus
slouken@4465
    93
 *  \param x The x coordinate within the window
slouken@4465
    94
 *  \param y The y coordinate within the window
slouken@7191
    95
 *
slouken@4465
    96
 *  \note This function generates a mouse motion event
slouken@1895
    97
 */
slouken@4465
    98
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
slouken@4465
    99
                                                   int x, int y);
slouken@1895
   100
slouken@1895
   101
/**
slouken@4465
   102
 *  \brief Set relative mouse mode.
slouken@7191
   103
 *
slouken@3407
   104
 *  \param enabled Whether or not to enable relative mode
slouken@4465
   105
 *
slouken@3407
   106
 *  \return 0 on success, or -1 if relative mode is not supported.
slouken@7191
   107
 *
slouken@3407
   108
 *  While the mouse is in relative mode, the cursor is hidden, and the
slouken@3407
   109
 *  driver will try to report continuous motion in the current window.
slouken@3407
   110
 *  Only relative motion events will be delivered, the mouse position
slouken@3407
   111
 *  will not change.
slouken@7191
   112
 *
slouken@3407
   113
 *  \note This function will flush any pending mouse motion.
slouken@7191
   114
 *
slouken@3407
   115
 *  \sa SDL_GetRelativeMouseMode()
slouken@1895
   116
 */
slouken@4465
   117
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
slouken@1895
   118
slouken@1895
   119
/**
slouken@4465
   120
 *  \brief Query whether relative mouse mode is enabled.
slouken@7191
   121
 *
slouken@3407
   122
 *  \sa SDL_SetRelativeMouseMode()
slouken@1895
   123
 */
slouken@4465
   124
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
slouken@1895
   125
slouken@1895
   126
/**
slouken@4465
   127
 *  \brief Create a cursor, using the specified bitmap data and
slouken@4465
   128
 *         mask (in MSB format).
slouken@7191
   129
 *
slouken@3407
   130
 *  The cursor width must be a multiple of 8 bits.
slouken@7191
   131
 *
slouken@3407
   132
 *  The cursor is created in black and white according to the following:
slouken@3407
   133
 *  <table>
slouken@3407
   134
 *  <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
slouken@3407
   135
 *  <tr><td>  0   </td><td>  1   </td><td> White </td></tr>
slouken@3407
   136
 *  <tr><td>  1   </td><td>  1   </td><td> Black </td></tr>
slouken@3407
   137
 *  <tr><td>  0   </td><td>  0   </td><td> Transparent </td></tr>
slouken@7191
   138
 *  <tr><td>  1   </td><td>  0   </td><td> Inverted color if possible, black
slouken@4465
   139
 *                                         if not. </td></tr>
slouken@3407
   140
 *  </table>
slouken@7191
   141
 *
slouken@3407
   142
 *  \sa SDL_FreeCursor()
slouken@0
   143
 */
slouken@1895
   144
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
slouken@1895
   145
                                                     const Uint8 * mask,
slouken@1895
   146
                                                     int w, int h, int hot_x,
slouken@1895
   147
                                                     int hot_y);
slouken@0
   148
slouken@1895
   149
/**
slouken@5473
   150
 *  \brief Create a color cursor.
slouken@7191
   151
 *
slouken@5473
   152
 *  \sa SDL_FreeCursor()
slouken@5473
   153
 */
slouken@5473
   154
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
slouken@5473
   155
                                                          int hot_x,
slouken@5473
   156
                                                          int hot_y);
slouken@5473
   157
slouken@5473
   158
/**
mikesart@6675
   159
 *  \brief Create a system cursor.
mikesart@6675
   160
 *
mikesart@6675
   161
 *  \sa SDL_FreeCursor()
mikesart@6675
   162
 */
mikesart@6675
   163
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
mikesart@6675
   164
mikesart@6675
   165
/**
slouken@4465
   166
 *  \brief Set the active cursor.
slouken@0
   167
 */
slouken@1895
   168
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
slouken@0
   169
slouken@1895
   170
/**
slouken@4465
   171
 *  \brief Return the active cursor.
slouken@0
   172
 */
slouken@1895
   173
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
slouken@0
   174
slouken@1895
   175
/**
jorgen@7104
   176
 *  \brief Return the default cursor.
jorgen@7104
   177
 */
jorgen@7104
   178
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
jorgen@7104
   179
jorgen@7104
   180
/**
slouken@3407
   181
 *  \brief Frees a cursor created with SDL_CreateCursor().
slouken@7191
   182
 *
slouken@3407
   183
 *  \sa SDL_CreateCursor()
slouken@0
   184
 */
slouken@1895
   185
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
slouken@0
   186
slouken@1895
   187
/**
slouken@4465
   188
 *  \brief Toggle whether or not the cursor is shown.
slouken@7191
   189
 *
slouken@7191
   190
 *  \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current
slouken@3407
   191
 *                state.
slouken@7191
   192
 *
slouken@3407
   193
 *  \return 1 if the cursor is shown, or 0 if the cursor is hidden.
slouken@0
   194
 */
slouken@337
   195
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
slouken@0
   196
kazeuser@2718
   197
/**
slouken@3407
   198
 *  Used as a mask when testing buttons in buttonstate.
slouken@3407
   199
 *   - Button 1:  Left mouse button
slouken@3407
   200
 *   - Button 2:  Middle mouse button
slouken@3407
   201
 *   - Button 3:  Right mouse button
slouken@3407
   202
 */
slouken@7191
   203
#define SDL_BUTTON(X)       (1 << ((X)-1))
slouken@7191
   204
#define SDL_BUTTON_LEFT     1
slouken@7191
   205
#define SDL_BUTTON_MIDDLE   2
slouken@7191
   206
#define SDL_BUTTON_RIGHT    3
slouken@7191
   207
#define SDL_BUTTON_X1       4
slouken@7191
   208
#define SDL_BUTTON_X2       5
slouken@7191
   209
#define SDL_BUTTON_LMASK    SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@7191
   210
#define SDL_BUTTON_MMASK    SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@7191
   211
#define SDL_BUTTON_RMASK    SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@7191
   212
#define SDL_BUTTON_X1MASK   SDL_BUTTON(SDL_BUTTON_X1)
slouken@7191
   213
#define SDL_BUTTON_X2MASK   SDL_BUTTON(SDL_BUTTON_X2)
slouken@0
   214
slouken@0
   215
slouken@0
   216
/* Ends C function definitions when using C++ */
slouken@0
   217
#ifdef __cplusplus
slouken@0
   218
}
slouken@0
   219
#endif
slouken@0
   220
#include "close_code.h"
slouken@0
   221
slouken@0
   222
#endif /* _SDL_mouse_h */
slouken@1895
   223
slouken@1895
   224
/* vi: set ts=4 sw=4 expandtab: */