Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarInput.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-09-02 22:17:26 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-09-02 22:17:26 +1000
commitac7577b4df91fbf31541f203e88eccb64b98365a (patch)
treebc69420c0cab776c49b27deeb93d9d2ffaff75c7 /source/game/StarInput.cpp
parent566b0f4d362fb2858fe76dca805c4d2930da0f27 (diff)
Rename Keypad enums
noticed keypad binds were named like this in SE (probably due to using the names given by SDL there) and it's nicer anyway. better do this sooner than later.
Diffstat (limited to 'source/game/StarInput.cpp')
-rw-r--r--source/game/StarInput.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/game/StarInput.cpp b/source/game/StarInput.cpp
index 2400207..7869b52 100644
--- a/source/game/StarInput.cpp
+++ b/source/game/StarInput.cpp
@@ -160,19 +160,28 @@ Input::Bind Input::bindFromJson(Json const& json) {
if (type == "key") {
KeyBind keyBind;
- keyBind.key = KeyNames.getLeft(value.toString());
+ if (auto key = KeyNames.maybeLeft(value.toString()))
+ keyBind.key = *key;
+ else
+ return bind;
keyBind.mods = keyModsFromJson(json.getArray("mods", {}), &keyBind.priority);
bind = std::move(keyBind);
}
else if (type == "mouse") {
MouseBind mouseBind;
- mouseBind.button = MouseButtonNames.getLeft(value.toString());
+ if (auto button = MouseButtonNames.maybeLeft(value.toString()))
+ mouseBind.button = *button;
+ else
+ return bind;
mouseBind.mods = keyModsFromJson(json.getArray("mods", {}), &mouseBind.priority);
bind = std::move(mouseBind);
}
else if (type == "controller") {
ControllerBind controllerBind;
- controllerBind.button = ControllerButtonNames.getLeft(value.toString());
+ if (auto button = ControllerButtonNames.maybeLeft(value.toString()))
+ controllerBind.button = *button;
+ else
+ return bind;
controllerBind.controller = json.getUInt("controller", 0);
bind = std::move(controllerBind);
}