SDL standard library

Dependents:   H261_encoder

Embed: (wiki syntax)

« Back to documentation index

SDL_mouse.h File Reference

SDL_mouse.h File Reference

Include file for SDL mouse event handling. More...

Go to the source code of this file.

Enumerations

enum  SDL_SystemCursor {
  SDL_SYSTEM_CURSOR_ARROW, SDL_SYSTEM_CURSOR_IBEAM, SDL_SYSTEM_CURSOR_WAIT, SDL_SYSTEM_CURSOR_CROSSHAIR,
  SDL_SYSTEM_CURSOR_WAITARROW, SDL_SYSTEM_CURSOR_SIZENWSE, SDL_SYSTEM_CURSOR_SIZENESW, SDL_SYSTEM_CURSOR_SIZEWE,
  SDL_SYSTEM_CURSOR_SIZENS, SDL_SYSTEM_CURSOR_SIZEALL, SDL_SYSTEM_CURSOR_NO, SDL_SYSTEM_CURSOR_HAND
}
 

Cursor types for SDL_CreateSystemCursor.

More...

Functions

DECLSPEC SDL_Window *SDLCALL SDL_GetMouseFocus (void)
 Get the window which currently has mouse focus.
DECLSPEC Uint32 SDLCALL SDL_GetMouseState (int *x, int *y)
 Retrieve the current state of the mouse.
DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState (int *x, int *y)
 Retrieve the relative state of the mouse.
DECLSPEC void SDLCALL SDL_WarpMouseInWindow (SDL_Window *window, int x, int y)
 Moves the mouse to the given position within the window.
DECLSPEC int SDLCALL SDL_SetRelativeMouseMode (SDL_bool enabled)
 Set relative mouse mode.
DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode (void)
 Query whether relative mouse mode is enabled.
DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor (const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y)
 Create a cursor, using the specified bitmap data and mask (in MSB format).
DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor (SDL_Surface *surface, int hot_x, int hot_y)
 Create a color cursor.
DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor (SDL_SystemCursor id)
 Create a system cursor.
DECLSPEC void SDLCALL SDL_SetCursor (SDL_Cursor *cursor)
 Set the active cursor.
DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor (void)
 Return the active cursor.
DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor (void)
 Return the default cursor.
DECLSPEC void SDLCALL SDL_FreeCursor (SDL_Cursor *cursor)
 Frees a cursor created with SDL_CreateCursor().
DECLSPEC int SDLCALL SDL_ShowCursor (int toggle)
 Toggle whether or not the cursor is shown.

Detailed Description

Include file for SDL mouse event handling.

Definition in file SDL_mouse.h.


Enumeration Type Documentation

Cursor types for SDL_CreateSystemCursor.

Enumerator:
SDL_SYSTEM_CURSOR_ARROW 

Arrow.

SDL_SYSTEM_CURSOR_IBEAM 

I-beam.

SDL_SYSTEM_CURSOR_WAIT 

Wait.

SDL_SYSTEM_CURSOR_CROSSHAIR 

Crosshair.

SDL_SYSTEM_CURSOR_WAITARROW 

Small wait cursor (or Wait if not available)

SDL_SYSTEM_CURSOR_SIZENWSE 

Double arrow pointing northwest and southeast.

SDL_SYSTEM_CURSOR_SIZENESW 

Double arrow pointing northeast and southwest.

SDL_SYSTEM_CURSOR_SIZEWE 

Double arrow pointing west and east.

SDL_SYSTEM_CURSOR_SIZENS 

Double arrow pointing north and south.

SDL_SYSTEM_CURSOR_SIZEALL 

Four pointed arrow pointing north, south, east, and west.

SDL_SYSTEM_CURSOR_NO 

Slashed circle or crossbones.

SDL_SYSTEM_CURSOR_HAND 

Hand.

Definition at line 46 of file SDL_mouse.h.


Function Documentation

DECLSPEC SDL_Cursor* SDLCALL SDL_CreateColorCursor ( SDL_Surface surface,
int  hot_x,
int  hot_y 
)

Create a color cursor.

See also:
SDL_FreeCursor()
DECLSPEC SDL_Cursor* SDLCALL SDL_CreateCursor ( const Uint8 data,
const Uint8 mask,
int  w,
int  h,
int  hot_x,
int  hot_y 
)

Create a cursor, using the specified bitmap data and mask (in MSB format).

The cursor width must be a multiple of 8 bits.

The cursor is created in black and white according to the following:

data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black if not.
See also:
SDL_FreeCursor()
DECLSPEC SDL_Cursor* SDLCALL SDL_CreateSystemCursor ( SDL_SystemCursor  id )

Create a system cursor.

See also:
SDL_FreeCursor()
DECLSPEC void SDLCALL SDL_FreeCursor ( SDL_Cursor *  cursor )

Frees a cursor created with SDL_CreateCursor().

See also:
SDL_CreateCursor()
DECLSPEC SDL_Cursor* SDLCALL SDL_GetCursor ( void   )

Return the active cursor.

DECLSPEC SDL_Cursor* SDLCALL SDL_GetDefaultCursor ( void   )

Return the default cursor.

DECLSPEC SDL_Window* SDLCALL SDL_GetMouseFocus ( void   )

Get the window which currently has mouse focus.

DECLSPEC Uint32 SDLCALL SDL_GetMouseState ( int *  x,
int *  y 
)

Retrieve the current state of the mouse.

The current button state is returned as a button bitmask, which can be tested using the SDL_BUTTON(X) macros, and x and y are set to the mouse cursor position relative to the focus window for the currently selected mouse. You can pass NULL for either x or y.

DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode ( void   )

Query whether relative mouse mode is enabled.

See also:
SDL_SetRelativeMouseMode()
DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState ( int *  x,
int *  y 
)

Retrieve the relative state of the mouse.

The current button state is returned as a button bitmask, which can be tested using the SDL_BUTTON(X) macros, and x and y are set to the mouse deltas since the last call to SDL_GetRelativeMouseState().

DECLSPEC void SDLCALL SDL_SetCursor ( SDL_Cursor *  cursor )

Set the active cursor.

DECLSPEC int SDLCALL SDL_SetRelativeMouseMode ( SDL_bool  enabled )

Set relative mouse mode.

Parameters:
enabledWhether or not to enable relative mode
Returns:
0 on success, or -1 if relative mode is not supported.

While the mouse is in relative mode, the cursor is hidden, and the driver will try to report continuous motion in the current window. Only relative motion events will be delivered, the mouse position will not change.

Note:
This function will flush any pending mouse motion.
See also:
SDL_GetRelativeMouseMode()
DECLSPEC int SDLCALL SDL_ShowCursor ( int  toggle )

Toggle whether or not the cursor is shown.

Parameters:
toggle1 to show the cursor, 0 to hide it, -1 to query the current state.
Returns:
1 if the cursor is shown, or 0 if the cursor is hidden.
DECLSPEC void SDLCALL SDL_WarpMouseInWindow ( SDL_Window window,
int  x,
int  y 
)

Moves the mouse to the given position within the window.

Parameters:
windowThe window to move the mouse into, or NULL for the current mouse focus
xThe x coordinate within the window
yThe y coordinate within the window
Note:
This function generates a mouse motion event