Manages initialization and shutdown of the input system.
More...
|
static std::string | id_to_char (Button btn) |
| Returns the character (as a UTF-8 encoded string) that a button usually produces. More...
|
|
static Button | char_to_id (std::string ch) |
| Returns the button that has to be pressed to produce the given character (as a UTF-8 encoded string), or NO_BUTTON. More...
|
|
static std::string | button_name (Button btn) |
| Returns the name for the given button, provided it is a Gosu::KB_{constant} Returns the empty string if nothing can be found. More...
|
|
static std::string | gamepad_name (int index) |
| Returns the name for the given gamepad. More...
|
|
static bool | down (Button btn) |
| Returns true if a button is currently pressed. More...
|
|
static double | axis (Button btn) |
| Returns the value of a gamepad stick in the range -1.0 through +1.0, or a trigger in the range 0.0 through +1.0. More...
|
|
Manages initialization and shutdown of the input system.
Only one Input instance can exist per application.
Definition at line 27 of file Input.hpp.
◆ Input()
Gosu::Input::Input |
( |
void * |
window | ) |
|
|
explicit |
◆ ~Input()
◆ accelerometer_x()
Accelerometer positions in all three dimensions (smoothened).
Note: Not really deprecated, but temporarily defunct.
◆ accelerometer_y()
◆ accelerometer_z()
◆ axis()
static double Gosu::Input::axis |
( |
Button |
btn | ) |
|
|
static |
Returns the value of a gamepad stick in the range -1.0 through +1.0, or a trigger in the range 0.0 through +1.0.
Updated every tick.
◆ button_name()
static std::string Gosu::Input::button_name |
( |
Button |
btn | ) |
|
|
static |
Returns the name for the given button, provided it is a Gosu::KB_{constant} Returns the empty string if nothing can be found.
◆ char_to_id()
static Button Gosu::Input::char_to_id |
( |
std::string |
ch | ) |
|
|
static |
Returns the button that has to be pressed to produce the given character (as a UTF-8 encoded string), or NO_BUTTON.
◆ current_touches()
const Touches& Gosu::Input::current_touches |
( |
| ) |
const |
◆ down()
static bool Gosu::Input::down |
( |
Button |
btn | ) |
|
|
static |
Returns true if a button is currently pressed.
Updated every tick.
◆ feed_sdl_event()
bool Gosu::Input::feed_sdl_event |
( |
void * |
event | ) |
|
◆ gamepad_name()
static std::string Gosu::Input::gamepad_name |
( |
int |
index | ) |
|
|
static |
Returns the name for the given gamepad.
Returns an empty string if there is no gamepad in the slot index.
◆ id_to_char()
static std::string Gosu::Input::id_to_char |
( |
Button |
btn | ) |
|
|
static |
Returns the character (as a UTF-8 encoded string) that a button usually produces.
Returns the empty string if nothing can be found.
◆ mouse_x()
double Gosu::Input::mouse_x |
( |
| ) |
const |
Returns the horizontal position of the mouse relative to the top left corner of the window given to Input's constructor.
◆ mouse_y()
double Gosu::Input::mouse_y |
( |
| ) |
const |
◆ set_mouse_factors()
void Gosu::Input::set_mouse_factors |
( |
double |
factor_x, |
|
|
double |
factor_y, |
|
|
double |
offset_x = 0 , |
|
|
double |
offset_y = 0 |
|
) |
| |
◆ set_mouse_position()
void Gosu::Input::set_mouse_position |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Immediately moves the mouse as far towards the desired position as possible.
x and y are relative to the window, just as in mouse_x() and mouse_y(), so (0, 0) is the top left corner of the window..
◆ set_text_input()
void Gosu::Input::set_text_input |
( |
TextInput * |
input | ) |
|
Sets the currently active TextInput, or resets it to the nullptr.
◆ text_input()
Returns the currently active TextInput instance, or nullptr.
◆ update()
void Gosu::Input::update |
( |
| ) |
|
Collects new information about which buttons are pressed, where the mouse is and calls on_button_up/on_button_down, if assigned.
◆ on_button_down
std::function<void (Button)> Gosu::Input::on_button_down |
Assignable events that are called by update.
You can bind these to your own functions. If you use the Window class, it will assign these to its own methods.
Definition at line 97 of file Input.hpp.
◆ on_button_up
std::function<void (Button)> Gosu::Input::on_button_up |
◆ on_gamepad_connected
std::function<void (int)> Gosu::Input::on_gamepad_connected |
◆ on_gamepad_disconnected
std::function<void (int)> Gosu::Input::on_gamepad_disconnected |
◆ on_touch_began
std::function<void (Touch)> Gosu::Input::on_touch_began |
Assignable events that are called by update.
You can bind these to your own functions. If you use the Window class, it will assign these to its own methods.
Definition at line 103 of file Input.hpp.
◆ on_touch_cancelled
std::function<void (Touch)> Gosu::Input::on_touch_cancelled |
◆ on_touch_ended
std::function<void (Touch)> Gosu::Input::on_touch_ended |
◆ on_touch_moved
std::function<void (Touch)> Gosu::Input::on_touch_moved |
The documentation for this class was generated from the following file: