module lib.sdl2.mouse

Code Map

module lib.sdl2.mouse;


enum SDL_SYSTEM_CURSOR_ARROW;
enum SDL_SYSTEM_CURSOR_IBEAM;
enum SDL_SYSTEM_CURSOR_WAIT;
enum SDL_SYSTEM_CURSOR_CROSSHAIR;
enum SDL_SYSTEM_CURSOR_WAITARROW;
enum SDL_SYSTEM_CURSOR_SIZENWSE;
enum SDL_SYSTEM_CURSOR_SIZENESW;
enum SDL_SYSTEM_CURSOR_SIZEWE;
enum SDL_SYSTEM_CURSOR_SIZENS;
enum SDL_SYSTEM_CURSOR_SIZEALL;
enum SDL_SYSTEM_CURSOR_NO;
enum SDL_SYSTEM_CURSOR_HAND;
enum SDL_NUM_SYSTEM_CURSORS;
//! Used as a mask when testing buttons in buttonstate.
enum SDL_BUTTON_LEFT;
enum SDL_BUTTON_MIDDLE;
enum SDL_BUTTON_RIGHT;
enum SDL_BUTTON_X1;
enum SDL_BUTTON_X2;
enum SDL_BUTTON_LMASK;
enum SDL_BUTTON_MMASK;
enum SDL_BUTTON_RMASK;
enum SDL_BUTTON_X1MASK;
enum SDL_BUTTON_X2MASK;

//! \brief Cursor types for SDL_CreateSystemCursor.
alias SDL_SystemCursor = i32;

struct SDL_Cursor
{
}

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

\brief Cursor types for SDL_CreateSystemCursor.

fn SDL_GetMouseFocus() SDL_Window*

\brief Get the window which currently has mouse focus.

fn SDL_GetMouseState(x: i32*, y: i32*) Uint32

\brief 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.

fn SDL_GetRelativeMouseState(x: i32*, y: i32*) Uint32

\brief 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().

fn SDL_WarpMouseInWindow(window: SDL_Window*, x: i32, y: i32)

\brief Moves the mouse to the given position within the window.

\param window The window to move the mouse into, or NULL for the current mouse focus \param x The x coordinate within the window \param y The y coordinate within the window

\note This function generates a mouse motion event

fn SDL_SetRelativeMouseMode(enabled: SDL_bool) i32

\brief Set relative mouse mode.

\param enabled Whether or not to enable relative mode

\return 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.

\sa SDL_GetRelativeMouseMode()

fn SDL_GetRelativeMouseMode() SDL_bool

\brief Query whether relative mouse mode is enabled.

\sa SDL_SetRelativeMouseMode()

fn SDL_CreateCursor(data: const(const(Uint8)*), mask: const(const(Uint8)*), w: i32, h: i32, hot_x: i32, hot_y: i32) SDL_Cursor*

\brief 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.

\sa SDL_FreeCursor()

fn SDL_CreateColorCursor(surface: SDL_Surface*, hot_x: i32, hot_y: i32) SDL_Cursor*

\brief Create a color cursor.

\sa SDL_FreeCursor()

fn SDL_CreateSystemCursor(id: SDL_SystemCursor) SDL_Cursor*

\brief Create a system cursor.

\sa SDL_FreeCursor()

fn SDL_SetCursor(cursor: SDL_Cursor*)

\brief Set the active cursor.

fn SDL_GetCursor() SDL_Cursor*

\brief Return the active cursor.

fn SDL_GetDefaultCursor() SDL_Cursor*

\brief Return the default cursor.

fn SDL_FreeCursor(cursor: SDL_Cursor*)

\brief Frees a cursor created with SDL_CreateCursor().

\sa SDL_CreateCursor()

fn SDL_ShowCursor(toggle: i32) i32

\brief Toggle whether or not the cursor is shown.

\param toggle 1 to show the cursor, 0 to hide it, -1 to query the current state.

\return 1 if the cursor is shown, or 0 if the cursor is hidden.

enum SDL_BUTTON_LEFT

Used as a mask when testing buttons in buttonstate.

  • Button 1: Left mouse button
  • Button 2: Middle mouse button
  • Button 3: Right mouse button