zenilib: zenilib/jni/external/sdl/src/events/SDL_mouse.c File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
SDL_mouse.c File Reference
`#include "SDL_config.h"`
`#include "SDL_assert.h"`
`#include "SDL_events.h"`
`#include "SDL_events_c.h"`
`#include "default_cursor.h"`
`#include "../video/SDL_sysvideo.h"`

Go to the source code of this file.

## Functions

SDL_Cursor * | SDL_CreateColorCursor (SDL_Surface *surface, int hot_x, int hot_y)
| Create a color cursor. More...
SDL_Cursor * | 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). More...
SDL_Cursor * | SDL_CreateSystemCursor (SDL_SystemCursor id)
| Create a system cursor. More...
void | SDL_FreeCursor (SDL_Cursor *cursor)
| Frees a cursor created with SDL_CreateCursor(). More...
SDL_Cursor * | SDL_GetCursor (void)
| Return the active cursor. More...
SDL_Cursor * | SDL_GetDefaultCursor (void)
| Return the default cursor. More...
SDL_Mouse * | SDL_GetMouse (void)
SDL_Window * | SDL_GetMouseFocus (void)
| Get the window which currently has mouse focus. More...
Uint32 | SDL_GetMouseState (int *x, int *y)
| Retrieve the current state of the mouse. More...
SDL_bool | SDL_GetRelativeMouseMode ()
| Query whether relative mouse mode is enabled. More...
Uint32 | SDL_GetRelativeMouseState (int *x, int *y)
| Retrieve the relative state of the mouse. More...
int | SDL_MouseInit (void)
void | SDL_MouseQuit (void)
static int | SDL_PrivateSendMouseMotion (SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
void | SDL_ResetMouse (void)
int | SDL_SendMouseButton (SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
int | SDL_SendMouseMotion (SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
int | SDL_SendMouseWheel (SDL_Window *window, SDL_MouseID mouseID, int x, int y)
void | SDL_SetCursor (SDL_Cursor *cursor)
| Set the active cursor. More...
void | SDL_SetDefaultCursor (SDL_Cursor *cursor)
void | SDL_SetMouseFocus (SDL_Window *window)
int | SDL_SetRelativeMouseMode (SDL_bool enabled)
| Set relative mouse mode. More...
int | SDL_ShowCursor (int toggle)
| Toggle whether or not the cursor is shown. More...
static SDL_bool | SDL_UpdateMouseFocus (SDL_Window *window, int x, int y, Uint32 buttonstate)
void | SDL_WarpMouseInWindow (SDL_Window *window, int x, int y)
| Moves the mouse to the given position within the window. More...

## Variables

static SDL_Mouse | SDL_mouse

## Function Documentation

SDL_Cursor* SDL_CreateColorCursor | ( | SDL_Surface * | surface,
|  | int | hot_x,
|  | int | hot_y
| ) |  |

Create a color cursor.

See Also
  SDL_FreeCursor()

Definition at line 535 of file SDL_mouse.c.

References SDL_Mouse::CreateCursor, SDL_Mouse::cursors, SDL_Surface::format, SDL_PixelFormat::format, SDL_Surface::h, SDL_Cursor::next, NULL, SDL_ConvertSurfaceFormat(), SDL_FreeSurface(), SDL_GetMouse(), SDL_PIXELFORMAT_ARGB8888, SDL_SetError(), and SDL_Surface::w.

Referenced by SDL_CreateCursor().

SDL_Cursor* 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()

Definition at line 486 of file SDL_mouse.c.

References NULL, SDL_Surface::pitch, SDL_Surface::pixels, SDL_CreateColorCursor(), SDL_CreateRGBSurface(), and SDL_FreeSurface().

SDL_Cursor* SDL_CreateSystemCursor | ( | SDL_SystemCursor | id | ) |

Create a system cursor.

See Also
  SDL_FreeCursor()

Definition at line 578 of file SDL_mouse.c.

References SDL_Mouse::CreateSystemCursor, SDL_Mouse::cursors, SDL_Cursor::next, NULL, SDL_GetMouse(), and SDL_SetError().

void SDL_FreeCursor | ( | SDL_Cursor * | cursor | ) |

Frees a cursor created with SDL_CreateCursor().

See Also
  SDL_CreateCursor()

Definition at line 664 of file SDL_mouse.c.

References SDL_Mouse::cur_cursor, SDL_Mouse::cursors, SDL_Mouse::def_cursor, SDL_Mouse::FreeCursor, SDL_Cursor::next, NULL, SDL_GetMouse(), and SDL_SetCursor().

Referenced by SDL_MouseQuit().

SDL_Cursor* SDL_GetCursor | ( | void |  | ) |

Return the active cursor.

Definition at line 642 of file SDL_mouse.c.

References SDL_Mouse::cur_cursor, NULL, and SDL_GetMouse().

SDL_Cursor* SDL_GetDefaultCursor | ( | void |  | ) |

Return the default cursor.

Definition at line 653 of file SDL_mouse.c.

References SDL_Mouse::def_cursor, NULL, and SDL_GetMouse().

SDL_Mouse* SDL_GetMouse | ( | void |  | ) |

Definition at line 62 of file SDL_mouse.c.

References SDL_mouse.

Referenced by SDL_CreateColorCursor(), SDL_CreateSystemCursor(), SDL_FreeCursor(), SDL_GetCursor(), SDL_GetDefaultCursor(), SDL_GetMouseFocus(), SDL_GetMouseState(), SDL_GetRelativeMouseMode(), SDL_GetRelativeMouseState(), SDL_MouseInit(), SDL_MouseQuit(), SDL_OnWindowFocusGained(), SDL_PrivateSendMouseMotion(), SDL_ResetMouse(), SDL_SendMouseButton(), SDL_SendMouseMotion(), SDL_SendMouseWheel(), SDL_SetCursor(), SDL_SetDefaultCursor(), SDL_SetMouseFocus(), SDL_SetRelativeMouseMode(), SDL_ShowCursor(), SDL_UpdateMouseFocus(), and SDL_WarpMouseInWindow().

SDL_Window* SDL_GetMouseFocus | ( | void |  | ) |

Get the window which currently has mouse focus.

Definition at line 68 of file SDL_mouse.c.

References SDL_Mouse::focus, and SDL_GetMouse().

Referenced by SDL_DestroyWindow(), and SDL_RestoreMousePosition().

Uint32 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.

Definition at line 382 of file SDL_mouse.c.

References SDL_Mouse::buttonstate, SDL_GetMouse(), SDL_Mouse::x, and SDL_Mouse::y.

Referenced by Zeni::Game::run(), and SDL_RestoreMousePosition().

SDL_bool SDL_GetRelativeMouseMode | ( | void |  | ) |

Query whether relative mouse mode is enabled.

See Also
  SDL_SetRelativeMouseMode()

Definition at line 478 of file SDL_mouse.c.

References SDL_Mouse::relative_mode, and SDL_GetMouse().

Referenced by Zeni::Window::get_mouse_state(), SDL_ShowMessageBox(), and SDLTest_CommonEvent().

Uint32 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().

Definition at line 396 of file SDL_mouse.c.

References SDL_Mouse::buttonstate, SDL_GetMouse(), SDL_Mouse::xdelta, and SDL_Mouse::ydelta.

int SDL_MouseInit | ( | void |  | ) |

Definition at line 41 of file SDL_mouse.c.

References SDL_Mouse::cursor_shown, SDL_GetMouse(), and SDL_TRUE.

Referenced by SDL_VideoInit().

void SDL_MouseQuit | ( | void |  | ) |

Definition at line 360 of file SDL_mouse.c.

References SDL_Mouse::cursors, SDL_Mouse::def_cursor, SDL_Mouse::FreeCursor, SDL_Cursor::next, SDL_FreeCursor(), SDL_GetMouse(), SDL_ShowCursor(), and SDL_zerop.

Referenced by SDL_VideoQuit().

static int SDL_PrivateSendMouseMotion | ( | SDL_Window * | window,
|  | SDL_MouseID | mouseID,
|  | int | relative,
|  | int | x,
|  | int | y
| ) |  |

static

Definition at line 191 of file SDL_mouse.c.

References SDL_Mouse::buttonstate, SDL_Mouse::cur_cursor, SDL_Mouse::cursor_shown, SDL_Mouse::focus, SDL_Window::id, SDL_Mouse::last_x, SDL_Mouse::last_y, SDL_Mouse::MoveCursor, SDL_Mouse::relative_mode, SDL_ENABLE, SDL_FALSE, SDL_GetEventState, SDL_GetMouse(), SDL_GetWindowSize(), SDL_MOUSEMOTION, SDL_PushEvent(), SDL_Mouse::x, SDL_Mouse::xdelta, SDL_Mouse::y, and SDL_Mouse::ydelta.

Referenced by SDL_SendMouseMotion(), and SDL_UpdateMouseFocus().

void SDL_ResetMouse | ( | void |  | ) |

Definition at line 76 of file SDL_mouse.c.

References SDL_Mouse::buttonstate, SDL_Mouse::focus, i, SDL_Mouse::mouseID, SDL_assert, SDL_BUTTON, SDL_GetMouse(), SDL_RELEASED, and SDL_SendMouseButton().

Referenced by SDL_SetMouseFocus().

int SDL_SendMouseButton | ( | SDL_Window * | window,
|  | SDL_MouseID | mouseID,
|  | Uint8 | state,
|  | Uint8 | button
| ) |  |

Definition at line 276 of file SDL_mouse.c.

References SDL_Mouse::buttonstate, SDL_Mouse::focus, SDL_Window::id, SDL_BUTTON, SDL_ENABLE, SDL_GetEventState, SDL_GetMouse(), SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_PRESSED, SDL_PushEvent(), SDL_RELEASED, SDL_UpdateMouseFocus(), SDL_Mouse::x, and SDL_Mouse::y.

Referenced by SDL_ResetMouse().

int SDL_SendMouseMotion | ( | SDL_Window * | window,
|  | SDL_MouseID | mouseID,
|  | int | relative,
|  | int | x,
|  | int | y
| ) |  |

Definition at line 178 of file SDL_mouse.c.

References SDL_Mouse::buttonstate, SDL_GetMouse(), SDL_PrivateSendMouseMotion(), and SDL_UpdateMouseFocus().

Referenced by SDL_WarpMouseInWindow().

int SDL_SendMouseWheel | ( | SDL_Window * | window,
|  | SDL_MouseID | mouseID,
|  | int | x,
|  | int | y
| ) |  |

Definition at line 332 of file SDL_mouse.c.

References SDL_Mouse::focus, SDL_Window::id, SDL_ENABLE, SDL_GetEventState, SDL_GetMouse(), SDL_MOUSEWHEEL, SDL_PushEvent(), and SDL_SetMouseFocus().

void SDL_SetCursor | ( | SDL_Cursor * | cursor | ) |

Set the active cursor.

Definition at line 602 of file SDL_mouse.c.

References SDL_Mouse::cur_cursor, SDL_Mouse::cursor_shown, SDL_Mouse::cursors, SDL_Mouse::def_cursor, SDL_Mouse::focus, SDL_Cursor::next, NULL, SDL_Mouse::relative_mode, SDL_GetMouse(), SDL_SetError(), and SDL_Mouse::ShowCursor.

Referenced by SDL_FreeCursor(), SDL_SetDefaultCursor(), SDL_SetMouseFocus(), SDL_SetRelativeMouseMode(), and SDL_ShowCursor().

void SDL_SetDefaultCursor | ( | SDL_Cursor * | cursor | ) |

Definition at line 51 of file SDL_mouse.c.

References SDL_Mouse::cur_cursor, SDL_Mouse::def_cursor, SDL_GetMouse(), and SDL_SetCursor().

void SDL_SetMouseFocus | ( | SDL_Window * | window | ) |

Definition at line 93 of file SDL_mouse.c.

References SDL_Mouse::focus, NULL, SDL_GetMouse(), SDL_ResetMouse(), SDL_SendWindowEvent(), SDL_SetCursor(), SDL_WINDOWEVENT_ENTER, and SDL_WINDOWEVENT_LEAVE.

Referenced by SDL_DestroyWindow(), SDL_OnWindowFocusGained(), SDL_SendMouseWheel(), SDL_SetRelativeMouseMode(), and SDL_UpdateMouseFocus().

int SDL_SetRelativeMouseMode | ( | SDL_bool | enabled | ) |

Set relative mouse mode.

Parameters

  enabled | Whether 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()

Definition at line 430 of file SDL_mouse.c.

References SDL_Mouse::focus, SDL_Window::h, NULL, SDL_Mouse::original_x, SDL_Mouse::original_y, SDL_Mouse::relative_mode, SDL_FlushEvent(), SDL_GetKeyboardFocus(), SDL_GetMouse(), SDL_MOUSEMOTION, SDL_SetCursor(), SDL_SetMouseFocus(), SDL_Unsupported, SDL_WarpMouseInWindow(), SDL_Mouse::SetRelativeMouseMode, SDL_Window::w, SDL_Mouse::x, and SDL_Mouse::y.

Referenced by SDL_ShowMessageBox(), SDLTest_CommonEvent(), and Zeni::Window::set_mouse_state().

int SDL_ShowCursor | ( | int | toggle | ) |

Toggle whether or not the cursor is shown.

Parameters

  toggle | 1 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.

Definition at line 698 of file SDL_mouse.c.

References SDL_Mouse::cursor_shown, NULL, SDL_FALSE, SDL_GetMouse(), SDL_SetCursor(), and SDL_TRUE.

Referenced by Zeni::Window::get_mouse_state(), SDL_MouseQuit(), SDL_ShowMessageBox(), and Zeni::Window::set_mouse_state().

static SDL_bool SDL_UpdateMouseFocus | ( | SDL_Window * | window,
|  | int | x,
|  | int | y,
|  | Uint32 | buttonstate
| ) |  |

static

Definition at line 130 of file SDL_mouse.c.

References SDL_Mouse::focus, SDL_Mouse::mouseID, NULL, SDL_FALSE, SDL_GetMouse(), SDL_GetWindowSize(), SDL_PrivateSendMouseMotion(), SDL_SetMouseFocus(), and SDL_TRUE.

Referenced by SDL_SendMouseButton(), and SDL_SendMouseMotion().

void SDL_WarpMouseInWindow | ( | SDL_Window * | window,
|  | int | x,
|  | int | y
| ) |  |

Moves the mouse to the given position within the window.

Parameters

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

Note
  This function generates a mouse motion event

Definition at line 412 of file SDL_mouse.c.

References SDL_Mouse::focus, SDL_Mouse::mouseID, NULL, SDL_GetMouse(), SDL_SendMouseMotion(), and SDL_Mouse::WarpMouse.

Referenced by Zeni::Game::run(), SDL_OnWindowFocusGained(), SDL_RestoreMousePosition(), and SDL_SetRelativeMouseMode().

## Variable Documentation

SDL_Mouse SDL_mouse

static

Definition at line 34 of file SDL_mouse.c.

Referenced by SDL_GetMouse().