include/SDL_mouse.h
author Patrice Mandin <patmandin@gmail.com>
Fri, 01 Apr 2005 15:19:26 +0000
changeset 1045 63b8e93a3a52
parent 911 04a403e4ccf5
child 1046 f09d5edfc7a3
permissions -rw-r--r--
Release CPU when waiting
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@769
     3
    Copyright (C) 1997-2004 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 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@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
/* Include file for SDL mouse event handling */
slouken@0
    29
slouken@0
    30
#ifndef _SDL_mouse_h
slouken@0
    31
#define _SDL_mouse_h
slouken@0
    32
slouken@0
    33
#include "SDL_types.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@0
    39
extern "C" {
slouken@0
    40
#endif
slouken@0
    41
slouken@0
    42
typedef struct WMcursor WMcursor;	/* Implementation dependent */
slouken@911
    43
typedef struct SDL_Cursor {
slouken@0
    44
	SDL_Rect area;			/* The area of the mouse cursor */
slouken@0
    45
	Sint16 hot_x, hot_y;		/* The "tip" of the cursor */
slouken@0
    46
	Uint8 *data;			/* B/W cursor data */
slouken@0
    47
	Uint8 *mask;			/* B/W cursor mask */
slouken@0
    48
	Uint8 *save[2];			/* Place to save cursor area */
slouken@0
    49
	WMcursor *wm_cursor;		/* Window-manager cursor */
slouken@0
    50
} SDL_Cursor;
slouken@0
    51
slouken@0
    52
/* Function prototypes */
slouken@0
    53
/*
slouken@0
    54
 * Retrieve the current state of the mouse.
slouken@0
    55
 * The current button state is returned as a button bitmask, which can
slouken@0
    56
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    57
 * current mouse cursor position.  You can pass NULL for either x or y.
slouken@0
    58
 */
slouken@337
    59
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
slouken@0
    60
slouken@0
    61
/*
slouken@0
    62
 * Retrieve the current state of the mouse.
slouken@0
    63
 * The current button state is returned as a button bitmask, which can
slouken@0
    64
 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
slouken@0
    65
 * mouse deltas since the last call to SDL_GetRelativeMouseState().
slouken@0
    66
 */
slouken@337
    67
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
slouken@0
    68
slouken@0
    69
/*
slouken@0
    70
 * Set the position of the mouse cursor (generates a mouse motion event)
slouken@0
    71
 */
slouken@337
    72
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
slouken@0
    73
slouken@0
    74
/*
slouken@0
    75
 * Create a cursor using the specified data and mask (in MSB format).
slouken@0
    76
 * The cursor width must be a multiple of 8 bits.
slouken@0
    77
 *
slouken@0
    78
 * The cursor is created in black and white according to the following:
slouken@0
    79
 * data  mask    resulting pixel on screen
slouken@0
    80
 *  0     1       White
slouken@0
    81
 *  1     1       Black
slouken@0
    82
 *  0     0       Transparent
slouken@0
    83
 *  1     0       Inverted color if possible, black if not.
slouken@0
    84
 *
slouken@0
    85
 * Cursors created with this function must be freed with SDL_FreeCursor().
slouken@0
    86
 */
slouken@337
    87
extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor
slouken@0
    88
		(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
slouken@0
    89
slouken@0
    90
/*
slouken@0
    91
 * Set the currently active cursor to the specified one.
slouken@0
    92
 * If the cursor is currently visible, the change will be immediately 
slouken@0
    93
 * represented on the display.
slouken@0
    94
 */
slouken@337
    95
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
slouken@0
    96
slouken@0
    97
/*
slouken@0
    98
 * Returns the currently active cursor.
slouken@0
    99
 */
slouken@337
   100
extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
slouken@0
   101
slouken@0
   102
/*
slouken@0
   103
 * Deallocates a cursor created with SDL_CreateCursor().
slouken@0
   104
 */
slouken@337
   105
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor);
slouken@0
   106
slouken@0
   107
/*
slouken@0
   108
 * Toggle whether or not the cursor is shown on the screen.
slouken@0
   109
 * The cursor start off displayed, but can be turned off.
slouken@0
   110
 * SDL_ShowCursor() returns 1 if the cursor was being displayed
slouken@0
   111
 * before the call, or 0 if it was not.  You can query the current
slouken@0
   112
 * state by passing a 'toggle' value of -1.
slouken@0
   113
 */
slouken@337
   114
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
slouken@0
   115
slouken@0
   116
/* Used as a mask when testing buttons in buttonstate
slouken@0
   117
   Button 1:	Left mouse button
slouken@0
   118
   Button 2:	Middle mouse button
slouken@0
   119
   Button 3:	Right mouse button
slouken@451
   120
   Button 4:	Mouse wheel up	 (may also be a real button)
slouken@451
   121
   Button 5:	Mouse wheel down (may also be a real button)
slouken@0
   122
 */
slouken@0
   123
#define SDL_BUTTON(X)		(SDL_PRESSED<<(X-1))
slouken@0
   124
#define SDL_BUTTON_LEFT		1
slouken@0
   125
#define SDL_BUTTON_MIDDLE	2
slouken@0
   126
#define SDL_BUTTON_RIGHT	3
slouken@451
   127
#define SDL_BUTTON_WHEELUP	4
slouken@451
   128
#define SDL_BUTTON_WHEELDOWN	5
slouken@0
   129
#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
slouken@0
   130
#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
slouken@0
   131
#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
slouken@0
   132
slouken@0
   133
slouken@0
   134
/* Ends C function definitions when using C++ */
slouken@0
   135
#ifdef __cplusplus
slouken@0
   136
}
slouken@0
   137
#endif
slouken@0
   138
#include "close_code.h"
slouken@0
   139
slouken@0
   140
#endif /* _SDL_mouse_h */