godot-cpp-utils
A collection of utility classes, functions and macros for use with Godot and GDExtension.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
utils::PlayerInput Class Reference

An event-driven input observer. More...

#include <player_input.hpp>

Inheritance diagram for utils::PlayerInput:

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< Listenerlisteners {}
 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.
 

Detailed Description

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.

Member Function Documentation

◆ listen_to() [1/2]

void utils::PlayerInput::listen_to ( gd::String  action,
gd::Callable  callable 
)

Start listening for action.

Shorthand for listen_to(Listener(action, callable)).

◆ listen_to() [2/2]

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

Member Data Documentation

◆ isPrimary

bool utils::PlayerInput::isPrimary {false}
private

Is this the primary instance.

The primary instance is responsible for updating static variables like lastMouseMotion.


The documentation for this class was generated from the following files: