include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 28 May 2006 13:04:16 +0000
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1358 c71e05b4dc2e
child 1668 4da1ee79c9af
permissions -rw-r--r--
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.

WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.

The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce

The headers are being converted to automatically generate doxygen documentation.
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@1662
    44
typedef struct WMcursor WMcursor;       /* Implementation dependent */
slouken@1662
    45
typedef struct SDL_Cursor
slouken@1662
    46
{
slouken@1662
    47
    SDL_Rect area;              /* The area of the mouse cursor */
slouken@1662
    48
    Sint16 hot_x, hot_y;        /* The "tip" of the cursor */
slouken@1662
    49
    Uint8 *data;                /* B/W cursor data */
slouken@1662
    50
    Uint8 *mask;                /* B/W cursor mask */
slouken@1662
    51
    Uint8 *save[2];             /* Place to save cursor area */
slouken@1662
    52
    WMcursor *wm_cursor;        /* Window-manager cursor */
slouken@0
    53
} SDL_Cursor;
slouken@0
    54
slouken@0
    55
/* Function prototypes */
slouken@0
    56
/*
slouken@0
    57
 * Retrieve the current state of the mouse.
slouken@0
    58
 * The current button state is returned as a button bitmask, which can
slouken@0
    59
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    60
 * current mouse cursor position.  You can pass NULL for either x or y.
slouken@0
    61
 */
slouken@1662
    62
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState (int *x, int *y);
slouken@0
    63
slouken@0
    64
/*
slouken@0
    65
 * Retrieve the current state of the mouse.
slouken@0
    66
 * The current button state is returned as a button bitmask, which can
slouken@0
    67
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    68
 * mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@0
    69
 */
slouken@1662
    70
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState (int *x, int *y);
slouken@0
    71
slouken@0
    72
/*
slouken@0
    73
 * Set the position of the mouse cursor (generates a mouse motion event)
slouken@0
    74
 */
slouken@1662
    75
extern DECLSPEC void SDLCALL SDL_WarpMouse (Uint16 x, Uint16 y);
slouken@0
    76
slouken@0
    77
/*
slouken@0
    78
 * Create a cursor using the specified data and mask (in MSB format).
slouken@0
    79
 * The cursor width must be a multiple of 8 bits.
slouken@0
    80
 *
slouken@0
    81
 * The cursor is created in black and white according to the following:
slouken@0
    82
 * data  mask    resulting pixel on screen
slouken@0
    83
 *  0     1       White
slouken@0
    84
 *  1     1       Black
slouken@0
    85
 *  0     0       Transparent
slouken@0
    86
 *  1     0       Inverted color if possible, black if not.
slouken@0
    87
 *
slouken@0
    88
 * Cursors created with this function must be freed with SDL_FreeCursor().
slouken@0
    89
 */
slouken@1662
    90
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor
slouken@1662
    91
    (Uint8 * data, Uint8 * mask, int w, int h, int hot_x, int hot_y);
slouken@0
    92
slouken@0
    93
/*
slouken@0
    94
 * Set the currently active cursor to the specified one.
slouken@0
    95
 * If the cursor is currently visible, the change will be immediately 
slouken@0
    96
 * represented on the display.
slouken@0
    97
 */
slouken@1662
    98
extern DECLSPEC void SDLCALL SDL_SetCursor (SDL_Cursor * cursor);
slouken@0
    99
slouken@0
   100
/*
slouken@0
   101
 * Returns the currently active cursor.
slouken@0
   102
 */
slouken@1662
   103
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor (void);
slouken@0
   104
slouken@0
   105
/*
slouken@0
   106
 * Deallocates a cursor created with SDL_CreateCursor().
slouken@0
   107
 */
slouken@1662
   108
extern DECLSPEC void SDLCALL SDL_FreeCursor (SDL_Cursor * cursor);
slouken@0
   109
slouken@0
   110
/*
slouken@0
   111
 * Toggle whether or not the cursor is shown on the screen.
slouken@0
   112
 * The cursor start off displayed, but can be turned off.
slouken@0
   113
 * SDL_ShowCursor() returns 1 if the cursor was being displayed
slouken@0
   114
 * before the call, or 0 if it was not.  You can query the current
slouken@0
   115
 * state by passing a 'toggle' value of -1.
slouken@0
   116
 */
slouken@1662
   117
extern DECLSPEC int SDLCALL SDL_ShowCursor (int toggle);
slouken@0
   118
slouken@0
   119
/* Used as a mask when testing buttons in buttonstate
slouken@0
   120
   Button 1:	Left mouse button
slouken@0
   121
   Button 2:	Middle mouse button
slouken@0
   122
   Button 3:	Right mouse button
slouken@451
   123
   Button 4:	Mouse wheel up	 (may also be a real button)
slouken@451
   124
   Button 5:	Mouse wheel down (may also be a real button)
slouken@0
   125
 */
slouken@1330
   126
#define SDL_BUTTON(X)		(1 << ((X)-1))
slouken@0
   127
#define SDL_BUTTON_LEFT		1
slouken@0
   128
#define SDL_BUTTON_MIDDLE	2
slouken@0
   129
#define SDL_BUTTON_RIGHT	3
slouken@451
   130
#define SDL_BUTTON_WHEELUP	4
slouken@451
   131
#define SDL_BUTTON_WHEELDOWN	5
slouken@0
   132
#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@0
   133
#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@0
   134
#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@0
   135
slouken@0
   136
slouken@0
   137
/* Ends C function definitions when using C++ */
slouken@0
   138
#ifdef __cplusplus
slouken@1662
   139
/* *INDENT-OFF* */
slouken@0
   140
}
slouken@1662
   141
/* *INDENT-ON* */
slouken@0
   142
#endif
slouken@0
   143
#include "close_code.h"
slouken@0
   144
slouken@0
   145
#endif /* _SDL_mouse_h */
slouken@1662
   146
slouken@1662
   147
/* vi: set ts=4 sw=4 expandtab: */