#ifndef PLAYER_INPUT_HPP #define PLAYER_INPUT_HPP #include #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 { friend class PlayerInput; private: String actionNegative{""}; String actionPositive{""}; float lastCached{0.f}; String methodName{""}; Node *object{nullptr}; bool isMouseEvent{false}; public: Listener(String positive, String negative, Node *object, String method); static float evaluate_event(Ref const &event, String const &action); bool has_changed(Ref const &event); float evaluate(Ref const &event); bool operator==(godot::PlayerInput::Listener const& b); }; private: std::vector listeners{}; public: virtual void _unhandled_input(Ref const &event) override; void listen_to(Listener const& listener); void stop_listening(Node *node); void stop_listening(Listener const& listener); }; } #endif // !PLAYER_INPUT_HPP