First step towards configurable keyboard mappings (#464)

* Configurable keyboard mappings

* Cleanup

* Cleanup

* Biggest mistake of my career

* format

* Fix naming convention

---------

Co-authored-by: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com>
This commit is contained in:
Paris Oplopoios 2024-03-21 15:54:18 +02:00 committed by GitHub
parent 5488e9ca7c
commit 3270cfe602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 162 additions and 126 deletions

View file

@ -0,0 +1,22 @@
#pragma once
#include <unordered_map>
#include "helpers.hpp"
#include "services/hid.hpp"
struct InputMappings {
using Scancode = u32;
using Container = std::unordered_map<Scancode, u32>;
u32 getMapping(Scancode scancode) const {
auto it = container.find(scancode);
return it != container.end() ? it->second : HID::Keys::Null;
}
void setMapping(Scancode scancode, u32 key) { container[scancode] = key; }
static InputMappings defaultKeyboardMappings();
private:
Container container;
};