include/SDL_mouse.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 26 Sep 2009 23:17:08 +0000
branchSDL-1.2
changeset 4246 8b8314cc34a6
parent 4217 4c4113c2162c
child 6137 4720145f848b
permissions -rw-r--r--
Fixed bug #810

Lauri Kenttä 2009-09-26 06:42:23 PDT

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