12#include <glm/gtc/quaternion.hpp>
13#include <nlohmann/json_fwd.hpp>
15#include "core/reflect.h"
17#include "platform/input/input_command.h"
18#include "platform/input/input_handle.h"
20namespace Vkm::Engine {
36 inline constexpr const char*
UI_CLICK =
"UI/Click";
45enum class InputSource : uint8_t {
57 InputSource source = InputSource::Key;
82 ~InputMap() =
default;
84 InputMap(
const InputMap& other) =
delete;
85 InputMap& operator=(
const InputMap& other) =
delete;
87 InputMap(InputMap && other) =
delete;
88 InputMap& operator=(InputMap && other) =
delete;
142 const std::vector<InputBinding>&
bindings(std::string_view action)
const;
209 void setView(
const glm::quat& view) { m_view = view; }
253 bool held(std::string_view action)
const;
277 float axis(std::string_view action)
const;
335 const glm::vec2&
pointer()
const {
return m_pointer; }
353 float wheel()
const {
return m_wheel; }
372 std::u32string_view
text()
const {
return m_text; }
383 bool typed(
int key)
const {
return key >= 0 && key <= MAX_KEY && m_typed[static_cast<size_t>(key)]; }
393 const std::optional<InputBinding>&
struck()
const {
return m_struck; }
416 std::vector<InputBinding> bindings;
417 std::vector<InputBinding> defaults;
421 bool wasActive =
false;
428 enum class Holder : uint8_t {
448 void defineEngineActions();
456 const Action* find(std::string_view action)
const;
466 Action& mutableAction(std::string_view action);
474 void assignSlot(Action& entry, std::string_view action);
490 bool heldElsewhere(
const InputBinding& binding,
bool down,
bool hostHas,
bool uiHas,
bool forUI);
498 std::map<std::string, Action, std::less<>> m_actions;
500 std::map<std::string, std::vector<InputBinding>, std::less<>> m_saved;
502 glm::vec2 m_pointer{0.0f};
503 glm::vec2 m_pointerDelta{0.0f};
504 float m_wheel = 0.0f;
505 float m_uiWheel = 0.0f;
507 std::u32string m_text;
508 std::bitset<MAX_KEY + 1> m_typed;
509 std::optional<InputBinding> m_struck;
511 InputCommand m_command;
512 glm::quat m_view{1.0f, 0.0f, 0.0f, 0.0f};
513 std::array<uint8_t, MAX_COMMAND_PAYLOAD> m_payload{};
514 uint8_t m_payloadSize = 0;
515 uint32_t m_pendingPressed = 0;
516 uint32_t m_pendingReleased = 0;
517 uint32_t m_nextSequence = 1;
518 uint32_t m_nextSlot = 0;
520 bool m_pointerOverUI =
false;
527 std::vector<HeldPress> m_heldPresses;
532VKM_ENUM_NAMES(::Vkm::Engine::InputSource,
"Key",
"MouseButton")
What an authoring host tells the engine about the frame it draws over.
Definition host_chrome.h:18