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.
This commit is contained in:
parent
566b0f4d36
commit
ac7577b4df
@ -90,23 +90,23 @@ Maybe<Key> keyFromSdlKeyCode(SDL_Keycode sym) {
|
||||
{SDLK_y, Key::Y},
|
||||
{SDLK_z, Key::Z},
|
||||
{SDLK_DELETE, Key::Delete},
|
||||
{SDLK_KP_0, Key::Kp0},
|
||||
{SDLK_KP_1, Key::Kp1},
|
||||
{SDLK_KP_2, Key::Kp2},
|
||||
{SDLK_KP_3, Key::Kp3},
|
||||
{SDLK_KP_4, Key::Kp4},
|
||||
{SDLK_KP_5, Key::Kp5},
|
||||
{SDLK_KP_6, Key::Kp6},
|
||||
{SDLK_KP_7, Key::Kp7},
|
||||
{SDLK_KP_8, Key::Kp8},
|
||||
{SDLK_KP_9, Key::Kp9},
|
||||
{SDLK_KP_PERIOD, Key::Kp_period},
|
||||
{SDLK_KP_DIVIDE, Key::Kp_divide},
|
||||
{SDLK_KP_MULTIPLY, Key::Kp_multiply},
|
||||
{SDLK_KP_MINUS, Key::Kp_minus},
|
||||
{SDLK_KP_PLUS, Key::Kp_plus},
|
||||
{SDLK_KP_ENTER, Key::Kp_enter},
|
||||
{SDLK_KP_EQUALS, Key::Kp_equals},
|
||||
{SDLK_KP_0, Key::Keypad0},
|
||||
{SDLK_KP_1, Key::Keypad1},
|
||||
{SDLK_KP_2, Key::Keypad2},
|
||||
{SDLK_KP_3, Key::Keypad3},
|
||||
{SDLK_KP_4, Key::Keypad4},
|
||||
{SDLK_KP_5, Key::Keypad5},
|
||||
{SDLK_KP_6, Key::Keypad6},
|
||||
{SDLK_KP_7, Key::Keypad7},
|
||||
{SDLK_KP_8, Key::Keypad8},
|
||||
{SDLK_KP_9, Key::Keypad9},
|
||||
{SDLK_KP_PERIOD, Key::KeypadPeriod},
|
||||
{SDLK_KP_DIVIDE, Key::KeypadDivide},
|
||||
{SDLK_KP_MULTIPLY, Key::KeypadMultiply},
|
||||
{SDLK_KP_MINUS, Key::KeypadMinus},
|
||||
{SDLK_KP_PLUS, Key::KeypadPlus},
|
||||
{SDLK_KP_ENTER, Key::KeypadEnter},
|
||||
{SDLK_KP_EQUALS, Key::KeypadEquals},
|
||||
{SDLK_UP, Key::Up},
|
||||
{SDLK_DOWN, Key::Down},
|
||||
{SDLK_RIGHT, Key::Right},
|
||||
|
@ -73,23 +73,23 @@ EnumMap<Key> const KeyNames{
|
||||
{Key::Y, "Y"},
|
||||
{Key::Z, "Z"},
|
||||
{Key::Delete, "Del"},
|
||||
{Key::Kp0, "Kp0"},
|
||||
{Key::Kp1, "Kp1"},
|
||||
{Key::Kp2, "Kp2"},
|
||||
{Key::Kp3, "Kp3"},
|
||||
{Key::Kp4, "Kp4"},
|
||||
{Key::Kp5, "Kp5"},
|
||||
{Key::Kp6, "Kp6"},
|
||||
{Key::Kp7, "Kp7"},
|
||||
{Key::Kp8, "Kp8"},
|
||||
{Key::Kp9, "Kp9"},
|
||||
{Key::Kp_period, "Kp_period"},
|
||||
{Key::Kp_divide, "Kp_divide"},
|
||||
{Key::Kp_multiply, "Kp_multiply"},
|
||||
{Key::Kp_minus, "Kp_minus"},
|
||||
{Key::Kp_plus, "Kp_plus"},
|
||||
{Key::Kp_enter, "Kp_enter"},
|
||||
{Key::Kp_equals, "Kp_equals"},
|
||||
{Key::Keypad0, "Keypad 0"},
|
||||
{Key::Keypad1, "Keypad 1"},
|
||||
{Key::Keypad2, "Keypad 2"},
|
||||
{Key::Keypad3, "Keypad 3"},
|
||||
{Key::Keypad4, "Keypad 4"},
|
||||
{Key::Keypad5, "Keypad 5"},
|
||||
{Key::Keypad6, "Keypad 6"},
|
||||
{Key::Keypad7, "Keypad 7"},
|
||||
{Key::Keypad8, "Keypad 8"},
|
||||
{Key::Keypad9, "Keypad 9"},
|
||||
{Key::KeypadPeriod, "Keypad ."},
|
||||
{Key::KeypadDivide, "Keypad /"},
|
||||
{Key::KeypadMultiply, "Keypad *"},
|
||||
{Key::KeypadMinus, "Keypad -"},
|
||||
{Key::KeypadPlus, "Keypad +"},
|
||||
{Key::KeypadEnter, "Keypad Enter"},
|
||||
{Key::KeypadEquals, "Keypad ="},
|
||||
{Key::Up, "Up"},
|
||||
{Key::Down, "Down"},
|
||||
{Key::Right, "Right"},
|
||||
|
@ -78,23 +78,23 @@ enum class Key : uint16_t {
|
||||
Y,
|
||||
Z,
|
||||
Delete,
|
||||
Kp0,
|
||||
Kp1,
|
||||
Kp2,
|
||||
Kp3,
|
||||
Kp4,
|
||||
Kp5,
|
||||
Kp6,
|
||||
Kp7,
|
||||
Kp8,
|
||||
Kp9,
|
||||
Kp_period,
|
||||
Kp_divide,
|
||||
Kp_multiply,
|
||||
Kp_minus,
|
||||
Kp_plus,
|
||||
Kp_enter,
|
||||
Kp_equals,
|
||||
Keypad0,
|
||||
Keypad1,
|
||||
Keypad2,
|
||||
Keypad3,
|
||||
Keypad4,
|
||||
Keypad5,
|
||||
Keypad6,
|
||||
Keypad7,
|
||||
Keypad8,
|
||||
Keypad9,
|
||||
KeypadPeriod,
|
||||
KeypadDivide,
|
||||
KeypadMultiply,
|
||||
KeypadMinus,
|
||||
KeypadPlus,
|
||||
KeypadEnter,
|
||||
KeypadEquals,
|
||||
Up,
|
||||
Down,
|
||||
Right,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -229,6 +229,10 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) {
|
||||
return luaTupleReturn(HumanoidEmoteNames.getRight(currentEmote.first), currentEmote.second);
|
||||
});
|
||||
|
||||
callbacks.registerCallback("currentState", [player]() {
|
||||
return Player::StateNames.getRight(player->currentState());
|
||||
});
|
||||
|
||||
callbacks.registerCallback("aimPosition", [player]() { return player->aimPosition(); });
|
||||
|
||||
callbacks.registerCallback("id", [player]() { return player->entityId(); });
|
||||
|
@ -284,7 +284,7 @@ bool TextBoxWidget::innerSendEvent(InputEvent const& event) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (keyDown->key == Key::Return || keyDown->key == Key::Kp_enter) {
|
||||
if (keyDown->key == Key::Return || keyDown->key == Key::KeypadEnter) {
|
||||
if (m_onEnterKey) {
|
||||
m_onEnterKey(this);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user