32 lines
967 B
C++
32 lines
967 B
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
// Mapeig id → SDL_Scancode carregat des de data/input/keys.yaml. Consumit
|
|
// per GlobalInputs i (en el futur) per menús de remapat. No té cap cost
|
|
// global: si la clau no existeix, retorna SDL_SCANCODE_UNKNOWN i GlobalInputs
|
|
// ignora l'acció. D'aquesta manera podem afegir nous bindings al YAML sense
|
|
// tocar codi mentre els handlers continuen funcionant.
|
|
class KeyConfig {
|
|
public:
|
|
static auto get() -> KeyConfig&;
|
|
|
|
KeyConfig(const KeyConfig&) = delete;
|
|
KeyConfig(KeyConfig&&) = delete;
|
|
auto operator=(const KeyConfig&) -> KeyConfig& = delete;
|
|
auto operator=(KeyConfig&&) -> KeyConfig& = delete;
|
|
|
|
void load(const std::string& file_path);
|
|
|
|
[[nodiscard]] auto scancode(const std::string& id) const -> SDL_Scancode;
|
|
|
|
private:
|
|
KeyConfig() = default;
|
|
~KeyConfig() = default;
|
|
|
|
std::unordered_map<std::string, SDL_Scancode> bindings_;
|
|
};
|