|
godot-cpp-utils
A collection of utility classes, functions and macros for use with Godot and GDExtension.
|
An event-driven input observer. More...
#include <player_input.hpp>
Classes | |
| struct | Listener |
| A PlayerInput action listener. More... | |
Public Member Functions | |
| virtual void | _enter_tree () override |
| virtual void | _exit_tree () override |
| virtual void | _unhandled_input (gd::Ref< gd::InputEvent > const &event) override |
| virtual void | _process (double deltaTime) override |
| void | listen_to (Listener const &listener) |
| Start listening for action. | |
| void | listen_to (gd::String action, gd::Callable callable) |
| Start listening for action. | |
| void | listen_to (gd::String negative, gd::String positive, gd::Callable callable) |
| Start listening for action. | |
| void | stop_listening (Node *node) |
| Remove any listeners related to node. | |
| void | stop_listening (Listener const &listener) |
| Remove listeners exactly equal to listener. | |
| void | clear_listeners () |
| Remove all listeners. | |
| void | set_device (int id) |
| set the device observe events from. | |
Static Public Member Functions | |
| static gd::Vector2 | get_last_mouse_motion () |
| Returns the last stored mouse delta. | |
Static Private Member Functions | |
| static void | _bind_methods () |
Private Attributes | |
| bool | isPrimary {false} |
| Is this the primary instance. | |
| int | device {-1} |
| which device to observe events from. | |
| gd::Vector< Listener > | listeners {} |
| current listeners for this instance | |
Static Private Attributes | |
| static gd::Vector2 | lastMouseMotion {0.f, 0.f} |
| The last mouse motion, updated by the primary instance. | |
| static bool | primaryExists {false} |
| Does a primary instance exist. | |
An event-driven input observer.
Listen for events with listen_to, registering godot input action names to callbacks. It's possible to register an "axis" by registering a listener with a positive and negative action.
| void utils::PlayerInput::listen_to | ( | gd::String | action, |
| gd::Callable | callable | ||
| ) |
Start listening for action.
Shorthand for listen_to(Listener(action, callable)).
| void utils::PlayerInput::listen_to | ( | gd::String | negative, |
| gd::String | positive, | ||
| gd::Callable | callable | ||
| ) |
Start listening for action.
Shorthand for listen_to(Listener(negative, positive, callable)).
|
private |
Is this the primary instance.
The primary instance is responsible for updating static variables like lastMouseMotion.