godot-cpp-utils
A collection of utility classes, functions and macros for use with Godot and GDExtension.
utils::PlayerInput::Listener Struct Reference

A PlayerInput action listener. More...

#include <player_input.hpp>

Public Member Functions

bool has_changed (gd::Ref< gd::InputEvent > const &event)
 Check if this event has any chance to result in a trigger.
 
float evaluate (gd::Ref< gd::InputEvent > const &event)
 evaluate the event for changes to either actionPositive or actionNegative
 

Private Attributes

gd::String actionNegative {""}
 Negative action on axis, evaluates to -1.
 
gd::String actionPositive {""}
 Positive action on axis, evaluates to +1.
 
float lastCached {0.f}
 The last cached action.
 
gd::Callable callable
 The listening function.
 
bool isMouseEvent {false}
 If either actionNegative or actionPositive is a mouse event this will be true.
 

Detailed Description

A PlayerInput action listener.

A listener is a combination of a positive and negative action and a callable. The expected callable signature is void (godot::Ref<godot::InputEvent> event, float value) actions can also be "special" actions prefixed with _. Special actions include _mouse_up, _mouse_down, _mouse_left, and _mouse_right.

Member Function Documentation

◆ has_changed()

bool utils::PlayerInput::Listener::has_changed ( gd::Ref< gd::InputEvent > const &  event)

Check if this event has any chance to result in a trigger.

Does not evaluate the event or poll current input state

Member Data Documentation

◆ lastCached

float utils::PlayerInput::Listener::lastCached {0.f}
private

The last cached action.

If the newest result matches this, the event will be considered duplicate and ignored (not passed to listener)


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