Unravel Engine C++ Reference
Loading...
Searching...
No Matches
keyboard_action_map.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "action_id.hpp"
4#include "key.hpp"
5#include "keyboard.hpp"
6#include <map>
7#include <vector>
8
9namespace input
10{
12{
13public:
14
15 struct key_entry
16 {
18
19 std::vector<key_code> modifiers{};
20 // Analog value used when key is down
21 float analog_value{};
22
23 friend auto operator==(const key_entry& lhs, const key_entry& rhs) -> bool = default;
24 };
25
26 std::map<action_id_t, std::vector<key_entry>> entries_by_action_id_;
27
28 auto get_analog_value(const action_id_t& action, const keyboard& device) const -> float;
29 auto get_digital_value(const action_id_t& action, const keyboard& device) const -> bool;
30 auto is_pressed(const action_id_t& action, const keyboard& device) const -> bool;
31 auto is_released(const action_id_t& action, const keyboard& device) const -> bool;
32 auto is_down(const action_id_t& action, const keyboard& device) const -> bool;
33
34 void map(const action_id_t& action, key_code key, float analog_value = 1.0f);
35 void map(const action_id_t& action, key_code key, const std::vector<key_code>& modifiers, float analog_value = 1.0f);
36
37 friend auto operator==(const keyboard_action_map& lhs, const keyboard_action_map& rhs) -> bool = default;
38};
39} // namespace input
auto get_analog_value(const action_id_t &action, const keyboard &device) const -> float
friend auto operator==(const keyboard_action_map &lhs, const keyboard_action_map &rhs) -> bool=default
auto is_pressed(const action_id_t &action, const keyboard &device) const -> bool
std::map< action_id_t, std::vector< key_entry > > entries_by_action_id_
auto is_down(const action_id_t &action, const keyboard &device) const -> bool
auto get_digital_value(const action_id_t &action, const keyboard &device) const -> bool
auto is_released(const action_id_t &action, const keyboard &device) const -> bool
void map(const action_id_t &action, key_code key, float analog_value=1.0f)
key_code
Definition key.hpp:6
std::string action_id_t
Definition action_id.hpp:6
float analog_value
key_code key
friend auto operator==(const key_entry &lhs, const key_entry &rhs) -> bool=default
std::vector< key_code > modifiers