39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#ifndef PLAYER_INPUT_HPP
|
|
#define PLAYER_INPUT_HPP
|
|
|
|
#include <vector>
|
|
#include "godot_cpp/classes/input.hpp"
|
|
#include "godot_cpp/classes/input_event.hpp"
|
|
#include "godot_cpp/classes/node.hpp"
|
|
|
|
namespace godot {
|
|
class PlayerInput : public Node {
|
|
GDCLASS(PlayerInput, Node)
|
|
static void _bind_methods();
|
|
public:
|
|
struct Listener {
|
|
String actionNegative{""};
|
|
String actionPositive{""};
|
|
float lastCached{0.f};
|
|
String methodName{""};
|
|
Node *object;
|
|
|
|
Listener(String positive, String negative, Node *object, String method);
|
|
bool has_changed(Ref<InputEvent> const &event);
|
|
float evaluate(Ref<InputEvent> const &event);
|
|
bool operator==(godot::PlayerInput::Listener const& b);
|
|
};
|
|
private:
|
|
std::vector<Listener> listeners{};
|
|
public:
|
|
virtual void _unhandled_input(Ref<InputEvent> const &event) override;
|
|
|
|
void listen_to(Listener const& listener);
|
|
void stop_listening(Node *node);
|
|
void stop_listening(Listener const& listener);
|
|
};
|
|
}
|
|
|
|
|
|
#endif // !PLAYER_INPUT_HPP
|