Toast Engine
Loading...
Searching...
No Matches
player_controller.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "box.hpp"
12#include "icontroller.hpp"
13
14#include <cstdint>
15#include <string>
16#include <string_view>
18#include <unordered_set>
19#include <vector>
20
21namespace event {
22struct InputEvent;
23struct SetInputLayout;
24struct SetInputLayer;
25struct PlayHaptic;
26}
27
28namespace input {
29
33class [[ToastNode]] TOAST_API PlayerController : public input::IController {
34public:
39 [[Reflect]]
40 void setLayout(std::string_view layout);
41
46 [[Reflect]]
47 void setLayer(std::string_view layer);
48
53 [[Reflect]]
55
59 [[Reflect]]
60 void setMouseLocked(bool locked);
61
62 // NOLINTNEXTLINE(modernize-use-nodiscard) refgen would copy [[nodiscard]] into the reflected metadata
63 [[Reflect]]
64 auto isMouseLocked() const -> bool;
65
66 [[Reflect, ReadOnly]]
67 std::string active_layout;
68
69 [[Reflect, ReadOnly]]
70 std::string active_layer;
71
72 [[Reflect]]
73 std::string default_layout;
74
75 [[Reflect]]
76 std::string default_layer;
77
78 [[Reflect]]
79 std::vector<assets::Handle<assets::InputLayout>> layouts;
80
81 [[Reflect]]
82 bool use_settings = false;
83
84 [[Reflect]]
85 std::string settings_name;
86
88 [[Reflect]]
89 uint32_t controller_id = 0;
90
91private:
92 void updateInspectorMessages() override;
93 void init();
94 void end();
95
96 void rebuildEnabledActions();
97
98 void dispatchToParent(const event::InputEvent& event);
99
100 [[nodiscard]]
101 auto matchesTarget(std::string_view target) const -> bool;
102
103 std::unordered_set<uint64_t> m_enabled_actions;
105 bool m_holds_mouse_lock = false;
106};
107
108}
pseudo shared pointer for Nodes
Type-safe smart pointer for assets.
Definition core_types.hpp:149
Definition icontroller.hpp:22
Controller driven by a human player.
Definition player_controller.hpp:33
void setMouseLocked(bool locked)
Locks the mouse to the game.
Definition player_controller.cpp:114
uint32_t controller_id
SDL_JoystickID of the controller this player drives; 0 = first/active gamepad.
Definition player_controller.hpp:89
void setLayer(std::string_view layer)
Switches the active layer by name and recomputes the enabled action set.
Definition player_controller.cpp:105
void playHaptic(assets::Handle< assets::Haptic > haptic) const
Plays a haptic effect on this controller's physical gamepad.
Definition player_controller.cpp:110
void setLayout(std::string_view layout)
Switches the active layout by name and recomputes the enabled action set.
Definition player_controller.cpp:100
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Hidden base node for every input controller.
Sent whenever an input action fires.
Definition input_events.hpp:28
Requests that a controller play a haptic effect.
Definition input_events.hpp:77
Requests that a controller switch its active layer.
Definition input_events.hpp:62
Requests that a controller switch its active layout.
Definition input_events.hpp:52
Concrete asset types for the Toast engine.