Module: SDL2::Mouse
- Defined in:
- mouse.c,
mouse.c
Overview
This module has mouse input handling functions.
Defined Under Namespace
Class Method Summary collapse
-
.focused_window ⇒ SDL2::Window?
Get the window which has mouse focus.
-
.global_state ⇒ SDL2::Mouse::State
Get the current mouse state in relation to the desktop.
-
.relative_mode=(bool) ⇒ Boolean
Set relative mouse mode.
-
.relative_mode? ⇒ Boolean
Return true if relative mouse mode is enabled.
-
.relative_state ⇒ SDL2::Mouse::State
Get the relative state of the mouse.
-
.state ⇒ SDL2::Mouse::State
Get the current state of the mouse.
Class Method Details
.focused_window ⇒ SDL2::Window?
Get the window which has mouse focus.
154 155 156 157 158 159 160 161 |
# File 'mouse.c', line 154
static VALUE Mouse_s_focused_window(VALUE self)
{
SDL_Window* window = SDL_GetMouseFocus();
if (!window)
return Qnil;
else
return find_window_by_id(SDL_GetWindowID(window));
}
|
.global_state ⇒ SDL2::Mouse::State
This module function is available since SDL 2.0.4.
Get the current mouse state in relation to the desktop.
The return value contains the x and y coordinates of the cursor relative to the desktop and the state of mouse buttons.
83 84 85 86 |
# File 'mouse.c', line 83
static VALUE Mouse_s_global_state(VALUE self)
{
return mouse_state(SDL_GetGlobalMouseState);
}
|
.relative_mode=(bool) ⇒ Boolean
This function will flush any pending mouse motion.
Set relative mouse mode.
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.
128 129 130 131 132 |
# File 'mouse.c', line 128
static VALUE Mouse_s_set_relative_mode(VALUE self, VALUE enabled)
{
HANDLE_ERROR(SDL_SetRelativeMouseMode(RTEST(enabled)));
return enabled;
}
|
.relative_mode? ⇒ Boolean
Return true if relative mouse mode is enabled.
107 108 109 110 |
# File 'mouse.c', line 107
static VALUE Mouse_s_relative_mode_p(VALUE self)
{
return INT2BOOL(SDL_GetRelativeMouseMode());
}
|
.relative_state ⇒ SDL2::Mouse::State
Get the relative state of the mouse.
The button state is same as state and x and y of the returned object are set to the mouse deltas since the last call to this method.
143 144 145 146 |
# File 'mouse.c', line 143
static VALUE Mouse_s_relative_state(VALUE self)
{
return mouse_state(SDL_GetRelativeMouseState);
}
|
.state ⇒ SDL2::Mouse::State
Get the current state of the mouse.
The return value contains the x and y coordinates of the cursor and the state of mouse buttons.
97 98 99 100 |
# File 'mouse.c', line 97
static VALUE Mouse_s_state(VALUE self)
{
return mouse_state(SDL_GetMouseState);
}
|