7#include "keyboard_key.hpp"
9#include "../architecture.hpp"
10#include "../command.hpp"
11#include "../subsystem.hpp"
12#include <unordered_map>
35 void add_system_command(command cmd)
noexcept {
36 ttlet i =
std::find(system.cbegin(), system.cend(), cmd);
37 if (i == system.cend()) {
38 system.push_back(cmd);
43 void add_ignored_command(command cmd)
noexcept {
45 if (i == ignored.
cend()) {
51 void add_user_command(command cmd)
noexcept {
53 if (i == user.
cend()) {
59 void update_cache()
noexcept {
60 cache.
reserve(std::ssize(system) + std::ssize(user));
62 for (ttlet cmd: system) {
64 if (i == cache.
cend()) {
69 for (ttlet cmd: ignored) {
71 if (i != cache.
cend()) {
76 for (ttlet cmd: user) {
78 if (i == cache.
cend()) {
93 void add_system_binding(
keyboard_key key, command command)
noexcept {
94 bindings[key].add_system_command(command);
97 void add_ignored_binding(
keyboard_key key, command command)
noexcept {
98 bindings[key].add_ignored_command(command);
101 void add_user_binding(
keyboard_key key, command command)
noexcept {
102 bindings[key].add_user_command(command);
110 ttlet i = bindings.
find(key);
111 if (i != bindings.
cend()) {
112 return i->second.get_commands();
114 return empty_commands;
Definition keyboard_bindings.hpp:17
void clear() noexcept
Clear all bindings.
Definition keyboard_bindings.hpp:123
void load_bindings(URL url, bool system_binding=false)
Load bindings from a JSON file.
std::vector< command > const & translate(keyboard_key key) const noexcept
translate a key press in the empty-context to a command.
Definition keyboard_bindings.hpp:107
A key in combination with modifiers.
Definition keyboard_key.hpp:20