include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 06 Jul 2007 13:39:03 +0000
branchSDL-1.2
changeset 4011 f5794774970d
parent 4009 1146681dbb74
child 4113 82dab719502e
permissions -rw-r--r--
Reverted mousewheel support in 1.2, since it breaks binary compatibility.
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@0
    23
/* Include file for SDL mouse event handling */
slouken@0
    24
slouken@0
    25
#ifndef _SDL_mouse_h
slouken@0
    26
#define _SDL_mouse_h
slouken@0
    27
slouken@1356
    28
#include "SDL_stdinc.h"
slouken@1358
    29
#include "SDL_error.h"
slouken@0
    30
#include "SDL_video.h"
slouken@0
    31
slouken@0
    32
#include "begin_code.h"
slouken@0
    33
/* Set up for C function definitions, even when using C++ */
slouken@0
    34
#ifdef __cplusplus
slouken@0
    35
extern "C" {
slouken@0
    36
#endif
slouken@0
    37
slouken@0
    38
typedef struct WMcursor WMcursor;	/* Implementation dependent */
slouken@911
    39
typedef struct SDL_Cursor {
slouken@0
    40
	SDL_Rect area;			/* The area of the mouse cursor */
slouken@0
    41
	Sint16 hot_x, hot_y;		/* The "tip" of the cursor */
slouken@0
    42
	Uint8 *data;			/* B/W cursor data */
slouken@0
    43
	Uint8 *mask;			/* B/W cursor mask */
slouken@0
    44
	Uint8 *save[2];			/* Place to save cursor area */
slouken@0
    45
	WMcursor *wm_cursor;		/* Window-manager cursor */
slouken@0
    46
} SDL_Cursor;
slouken@0
    47
slouken@0
    48
/* Function prototypes */
slouken@0
    49
/*
slouken@0
    50
 * Retrieve the current state of the mouse.
slouken@0
    51
 * The current button state is returned as a button bitmask, which can
slouken@0
    52
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    53
 * current mouse cursor position.  You can pass NULL for either x or y.
slouken@0
    54
 */
slouken@337
    55
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
slouken@0
    56
slouken@0
    57
/*
slouken@0
    58
 * Retrieve the current state of the mouse.
slouken@0
    59
 * The current button state is returned as a button bitmask, which can
slouken@0
    60
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    61
 * mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@0
    62
 */
slouken@337
    63
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
slouken@0
    64
slouken@0
    65
/*
slouken@0
    66
 * Set the position of the mouse cursor (generates a mouse motion event)
slouken@0
    67
 */
slouken@337
    68
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
slouken@0
    69
slouken@0
    70
/*
slouken@0
    71
 * Create a cursor using the specified data and mask (in MSB format).
slouken@0
    72
 * The cursor width must be a multiple of 8 bits.
slouken@0
    73
 *
slouken@0
    74
 * The cursor is created in black and white according to the following:
slouken@0
    75
 * data  mask    resulting pixel on screen
slouken@0
    76
 *  0     1       White
slouken@0
    77
 *  1     1       Black
slouken@0
    78
 *  0     0       Transparent
slouken@0
    79
 *  1     0       Inverted color if possible, black if not.
slouken@0
    80
 *
slouken@0
    81
 * Cursors created with this function must be freed with SDL_FreeCursor().
slouken@0
    82
 */
slouken@337
    83
extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor
slouken@0
    84
		(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
slouken@0
    85
slouken@0
    86
/*
slouken@0
    87
 * Set the currently active cursor to the specified one.
slouken@0
    88
 * If the cursor is currently visible, the change will be immediately 
slouken@0
    89
 * represented on the display.
slouken@0
    90
 */
slouken@337
    91
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
slouken@0
    92
slouken@0
    93
/*
slouken@0
    94
 * Returns the currently active cursor.
slouken@0
    95
 */
slouken@337
    96
extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
slouken@0
    97
slouken@0
    98
/*
slouken@0
    99
 * Deallocates a cursor created with SDL_CreateCursor().
slouken@0
   100
 */
slouken@337
   101
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor);
slouken@0
   102
slouken@0
   103
/*
slouken@0
   104
 * Toggle whether or not the cursor is shown on the screen.
slouken@0
   105
 * The cursor start off displayed, but can be turned off.
slouken@0
   106
 * SDL_ShowCursor() returns 1 if the cursor was being displayed
slouken@0
   107
 * before the call, or 0 if it was not.  You can query the current
slouken@0
   108
 * state by passing a 'toggle' value of -1.
slouken@0
   109
 */
slouken@337
   110
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
slouken@0
   111
slouken@0
   112
/* Used as a mask when testing buttons in buttonstate
slouken@0
   113
   Button 1:	Left mouse button
slouken@0
   114
   Button 2:	Middle mouse button
slouken@0
   115
   Button 3:	Right mouse button
slouken@451
   116
   Button 4:	Mouse wheel up	 (may also be a real button)
slouken@451
   117
   Button 5:	Mouse wheel down (may also be a real button)
slouken@0
   118
 */
slouken@1330
   119
#define SDL_BUTTON(X)		(1 << ((X)-1))
slouken@0
   120
#define SDL_BUTTON_LEFT		1
slouken@0
   121
#define SDL_BUTTON_MIDDLE	2
slouken@0
   122
#define SDL_BUTTON_RIGHT	3
slouken@451
   123
#define SDL_BUTTON_WHEELUP	4
slouken@451
   124
#define SDL_BUTTON_WHEELDOWN	5
slouken@0
   125
#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@0
   126
#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@0
   127
#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@0
   128
slouken@0
   129
slouken@0
   130
/* Ends C function definitions when using C++ */
slouken@0
   131
#ifdef __cplusplus
slouken@0
   132
}
slouken@0
   133
#endif
slouken@0
   134
#include "close_code.h"
slouken@0
   135
slouken@0
   136
#endif /* _SDL_mouse_h */