accept 🎮 in mod bindings
This commit is contained in:
parent
323364f0af
commit
a6ac154b94
@ -29,12 +29,16 @@ local function getMods(key)
|
|||||||
if bindMods[1] then return bindMods end
|
if bindMods[1] then return bindMods end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function finishBind(type, value)
|
local function finishBind(a, b)
|
||||||
widget.blur("snare")
|
widget.blur("snare")
|
||||||
snared = false
|
snared = false
|
||||||
snareFinished{ type = type, value = value, mods = getMods(value) }
|
if (type(a) == "table") then
|
||||||
for i, mod in ipairs(mods) do
|
snareFinished(a)
|
||||||
mod.active = false
|
else
|
||||||
|
snareFinished{ type = a, value = b, mods = getMods(value) }
|
||||||
|
for i, mod in ipairs(mods) do
|
||||||
|
mod.active = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,6 +54,8 @@ local function scanInputEvents()
|
|||||||
return finishBind("key", data.key)
|
return finishBind("key", data.key)
|
||||||
elseif type == "MouseButtonDown" then
|
elseif type == "MouseButtonDown" then
|
||||||
return finishBind("mouse", data.mouseButton)
|
return finishBind("mouse", data.mouseButton)
|
||||||
|
elseif type == "ControllerButtonDown" then
|
||||||
|
return finishBind{ type = "controller", value = data.controllerButton, controller = data.controller }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -127,9 +133,9 @@ function bindsToString(binds)
|
|||||||
str = str .. v .. " + "
|
str = str .. v .. " + "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if bind.type == "key" then
|
if bind.type == "controller" then
|
||||||
str = str .. bind.value
|
str = str .. "🎮 " .. bind.value
|
||||||
elseif bind.type == "mouse" then
|
else
|
||||||
str = str .. bind.value
|
str = str .. bind.value
|
||||||
end
|
end
|
||||||
local _i = (i - 1) * 2
|
local _i = (i - 1) * 2
|
||||||
@ -362,7 +368,7 @@ local function initCallbacks()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
--log = sb.logInfo
|
--log = chat and chat.addMessage or sb.logInfo
|
||||||
|
|
||||||
widget.clearListItems(CATEGORY_LIST_WIDGET)
|
widget.clearListItems(CATEGORY_LIST_WIDGET)
|
||||||
initCallbacks()
|
initCallbacks()
|
||||||
|
@ -301,20 +301,19 @@ void ClientApplication::processInput(InputEvent const& event) {
|
|||||||
m_controllerRightStick[1] = cAxis->controllerAxisValue;
|
m_controllerRightStick[1] = cAxis->controllerAxisValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_errorScreen->accepted() && m_errorScreen->handleInputEvent(event))
|
bool processed = !m_errorScreen->accepted() && m_errorScreen->handleInputEvent(event);
|
||||||
return;
|
|
||||||
|
|
||||||
bool processed = false;
|
if (!processed) {
|
||||||
|
if (m_state == MainAppState::Splash) {
|
||||||
|
processed = m_cinematicOverlay->handleInputEvent(event);
|
||||||
|
} else if (m_state == MainAppState::Title) {
|
||||||
|
if (!(processed = m_cinematicOverlay->handleInputEvent(event)))
|
||||||
|
processed = m_titleScreen->handleInputEvent(event);
|
||||||
|
|
||||||
if (m_state == MainAppState::Splash) {
|
} else if (m_state == MainAppState::SinglePlayer || m_state == MainAppState::MultiPlayer) {
|
||||||
processed = m_cinematicOverlay->handleInputEvent(event);
|
if (!(processed = m_cinematicOverlay->handleInputEvent(event)))
|
||||||
} else if (m_state == MainAppState::Title) {
|
processed = m_mainInterface->handleInputEvent(event);
|
||||||
if (!(processed = m_cinematicOverlay->handleInputEvent(event)))
|
}
|
||||||
processed = m_titleScreen->handleInputEvent(event);
|
|
||||||
|
|
||||||
} else if (m_state == MainAppState::SinglePlayer || m_state == MainAppState::MultiPlayer) {
|
|
||||||
if (!(processed = m_cinematicOverlay->handleInputEvent(event)))
|
|
||||||
processed = m_mainInterface->handleInputEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_input->handleInput(event, processed);
|
m_input->handleInput(event, processed);
|
||||||
|
@ -122,6 +122,22 @@ Json Input::inputEventToJson(InputEvent const& input) {
|
|||||||
{"mouseMove", jsonFromVec2I(mouseMove->mouseMove)},
|
{"mouseMove", jsonFromVec2I(mouseMove->mouseMove)},
|
||||||
{"mousePosition", jsonFromVec2I(mouseMove->mousePosition)}
|
{"mousePosition", jsonFromVec2I(mouseMove->mousePosition)}
|
||||||
};
|
};
|
||||||
|
} else if (auto controllerDown = input.ptr<ControllerButtonDownEvent>()) {
|
||||||
|
type = "ControllerButtonDown";
|
||||||
|
data = JsonObject{
|
||||||
|
{"controllerButton", ControllerButtonNames.getRight(controllerDown->controllerButton)},
|
||||||
|
{"controller", controllerDown->controller}};
|
||||||
|
} else if (auto controllerUp = input.ptr<ControllerButtonUpEvent>()) {
|
||||||
|
type = "ControllerButtonUp";
|
||||||
|
data = JsonObject{
|
||||||
|
{"controllerButton", ControllerButtonNames.getRight(controllerUp->controllerButton)},
|
||||||
|
{"controller", controllerUp->controller}};
|
||||||
|
} else if (auto controllerAxis = input.ptr<ControllerAxisEvent>()) {
|
||||||
|
type = "ControllerAxis";
|
||||||
|
data = JsonObject{
|
||||||
|
{"controllerAxis", ControllerAxisNames.getRight(controllerAxis->controllerAxis)},
|
||||||
|
{"controllerAxisValue", controllerAxis->controllerAxisValue},
|
||||||
|
{"controller", controllerAxis->controller}};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -186,7 +202,8 @@ Json Input::bindToJson(Bind const& bind) {
|
|||||||
else if (auto controllerBind = bind.ptr<ControllerBind>()) {
|
else if (auto controllerBind = bind.ptr<ControllerBind>()) {
|
||||||
return JsonObject{
|
return JsonObject{
|
||||||
{"type", "controller"},
|
{"type", "controller"},
|
||||||
{"value", ControllerButtonNames.getRight(controllerBind->button)}
|
{"value", ControllerButtonNames.getRight(controllerBind->button)},
|
||||||
|
{"controller", controllerBind->controller}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +409,8 @@ bool Input::handleInput(InputEvent const& input, bool gameProcessed) {
|
|||||||
m_bindStates[bind].press();
|
m_bindStates[bind].press();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (auto keyUp = input.ptr<KeyUpEvent>()) {
|
}
|
||||||
|
else if (auto keyUp = input.ptr<KeyUpEvent>()) {
|
||||||
auto keyToMod = KeysToMods.rightPtr(keyUp->key);
|
auto keyToMod = KeysToMods.rightPtr(keyUp->key);
|
||||||
if (keyToMod)
|
if (keyToMod)
|
||||||
m_pressedMods &= ~*keyToMod;
|
m_pressedMods &= ~*keyToMod;
|
||||||
@ -410,7 +428,8 @@ bool Input::handleInput(InputEvent const& input, bool gameProcessed) {
|
|||||||
state->release();
|
state->release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (auto mouseDown = input.ptr<MouseButtonDownEvent>()) {
|
}
|
||||||
|
else if (auto mouseDown = input.ptr<MouseButtonDownEvent>()) {
|
||||||
m_mousePosition = mouseDown->mousePosition;
|
m_mousePosition = mouseDown->mousePosition;
|
||||||
if (!gameProcessed) {
|
if (!gameProcessed) {
|
||||||
auto& state = m_mouseStates[mouseDown->mouseButton];
|
auto& state = m_mouseStates[mouseDown->mouseButton];
|
||||||
@ -422,7 +441,8 @@ bool Input::handleInput(InputEvent const& input, bool gameProcessed) {
|
|||||||
m_bindStates[bind].press();
|
m_bindStates[bind].press();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (auto mouseUp = input.ptr<MouseButtonUpEvent>()) {
|
}
|
||||||
|
else if (auto mouseUp = input.ptr<MouseButtonUpEvent>()) {
|
||||||
m_mousePosition = mouseUp->mousePosition;
|
m_mousePosition = mouseUp->mousePosition;
|
||||||
if (auto state = m_mouseStates.ptr(mouseUp->mouseButton)) {
|
if (auto state = m_mouseStates.ptr(mouseUp->mouseButton)) {
|
||||||
state->releasePositions.append(mouseUp->mousePosition);
|
state->releasePositions.append(mouseUp->mousePosition);
|
||||||
@ -439,6 +459,28 @@ bool Input::handleInput(InputEvent const& input, bool gameProcessed) {
|
|||||||
else if (auto mouseMove = input.ptr<MouseMoveEvent>()) {
|
else if (auto mouseMove = input.ptr<MouseMoveEvent>()) {
|
||||||
m_mousePosition = mouseMove->mousePosition;
|
m_mousePosition = mouseMove->mousePosition;
|
||||||
}
|
}
|
||||||
|
else if (auto controllerDown = input.ptr<ControllerButtonDownEvent>()) {
|
||||||
|
if (!gameProcessed) {
|
||||||
|
auto& state = m_controllerStates[controllerDown->controllerButton];
|
||||||
|
state.press();
|
||||||
|
|
||||||
|
if (auto binds = m_bindMappings.ptr(controllerDown->controllerButton)) {
|
||||||
|
for (auto bind : filterBindEntries(*binds, m_pressedMods))
|
||||||
|
m_bindStates[bind].press();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (auto controllerUp = input.ptr<ControllerButtonUpEvent>()) {
|
||||||
|
if (auto state = m_controllerStates.ptr(controllerUp->controllerButton))
|
||||||
|
state->release();
|
||||||
|
|
||||||
|
if (auto binds = m_bindMappings.ptr(controllerUp->controllerButton)) {
|
||||||
|
for (auto& bind : *binds) {
|
||||||
|
if (auto state = m_bindStates.ptr(bind.entry))
|
||||||
|
state->release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user