controls.json -> controls.toml
This commit is contained in:
@@ -40,6 +40,25 @@ static std::unordered_map<std::string, int> mousecodes {
|
||||
{"middle", GLFW_MOUSE_BUTTON_3},
|
||||
};
|
||||
|
||||
static std::unordered_map<int, std::string> keynames {};
|
||||
|
||||
std::string input_util::get_name(mousecode code) {
|
||||
switch (code) {
|
||||
case mousecode::BUTTON_1: return "left";
|
||||
case mousecode::BUTTON_2: return "right";
|
||||
case mousecode::BUTTON_3: return "middle";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
std::string input_util::get_name(keycode code) {
|
||||
auto found = keynames.find(static_cast<int>(code));
|
||||
if (found == keynames.end()) {
|
||||
return "unknown";
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
|
||||
void Binding::reset(inputtype type, int code) {
|
||||
this->type = type;
|
||||
this->code = code;
|
||||
@@ -63,6 +82,9 @@ void input_util::initialize() {
|
||||
for (char i = 'a'; i <= 'z'; i++) {
|
||||
keycodes[std::string({i})] = GLFW_KEY_A-'a'+i;
|
||||
}
|
||||
for (const auto& entry : keycodes) {
|
||||
keynames[entry.second] = entry.first;
|
||||
}
|
||||
}
|
||||
|
||||
keycode input_util::keycode_from(const std::string& name) {
|
||||
|
||||
Reference in New Issue
Block a user