Skip to content

Commit 8919ef6

Browse files
committed
Swap buttons in-game and prevent inputs when settings is open
1 parent 29de0dc commit 8919ef6

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/hooking/controls.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,17 +733,19 @@ void CemuHooks::hook_InjectXRInput(PPCInterpreter_t* hCPU) {
733733
if (inventoryLongPress) {
734734
inputs.inGame.inventoryState.longFired_actedUpon = false;
735735
isMenuOpen = !isMenuOpen;
736+
}
737+
738+
// allow the gamepad inputs to control the imgui overlay
739+
imguiOverlay->ProcessInputs(inputs);
736740

737-
// ignore stick input when the help menu is open
741+
// ignore stick input when the help menu is open
742+
if (isMenuOpen) {
738743
leftStickSource.currentState = { 0.0f, 0.0f };
739744
rightStickSource.currentState = { 0.0f, 0.0f };
740745
leftJoystickDir = Direction::None;
741746
rightJoystickDir = Direction::None;
742747
}
743748

744-
// allow the gamepad inputs to control the imgui overlay
745-
imguiOverlay->ProcessInputs(inputs);
746-
747749
//Log::print<INFO>("last_weapon_held_hand : {}", gameState.last_weapon_held_hand);
748750
//Log::print<INFO>("Is weapon held : {}", gameState.is_weapon_or_object_held);
749751
//Log::print<INFO>("Weapon Type : {}", (int)gameState.left_weapon_type);

src/rendering/vulkan_imgui.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ RND_Renderer::ImGuiOverlay::ImGuiOverlay(VkCommandBuffer cb, VkExtent2D fbRes, V
210210
page3.push_back(createHelpImage(BOTWcontrolScheme_Whistle, sizeof(BOTWcontrolScheme_Whistle)));
211211
m_helpImagePages.push_back(page3);
212212

213-
214213
VulkanUtils::DebugPipelineBarrier(cb);
215214

216215
// start the first frame right away
@@ -245,7 +244,6 @@ RND_Renderer::ImGuiOverlay::~ImGuiOverlay() {
245244
}
246245
}
247246

248-
249247
if (m_sampler != VK_NULL_HANDLE)
250248
VRManager::instance().VK->GetDeviceDispatch()->DestroySampler(VRManager::instance().VK->GetDevice(), m_sampler, nullptr);
251249
if (m_renderPass != VK_NULL_HANDLE)
@@ -306,9 +304,9 @@ void RND_Renderer::ImGuiOverlay::Update() {
306304
p.y = p.y - blackBarHeight;
307305

308306
// update mouse controls and keyboard input
309-
bool isWindowFocused = CemuHooks::m_cemuTopWindow == GetForegroundWindow() || true;
307+
bool isWindowFocused = CemuHooks::m_cemuTopWindow == GetForegroundWindow();
310308

311-
ImGui::GetIO().AddFocusEvent(isWindowFocused);
309+
//ImGui::GetIO().AddFocusEvent(true);
312310
if (isWindowFocused) {
313311
// update mouse state depending on if the window is focused
314312
ImGui::GetIO().AddMousePosEvent((float)p.x / uiScaleFactor, (float)p.y / uiScaleFactor);
@@ -414,13 +412,14 @@ void RND_Renderer::ImGuiOverlay::ProcessInputs(OpenXR::InputState& inputs) {
414412
auto& io = ImGui::GetIO();
415413
bool inGame = inputs.inGame.in_game;
416414

417-
bool backDown = false;
418-
bool confirmDown = false;
415+
bool backDown;
416+
bool confirmDown;
419417
XrActionStateVector2f stick;
420418
if (inputs.inGame.in_game) {
421419
stick = inputs.inGame.move;
422-
backDown = inputs.inGame.run_interact_cancel.currentState;
423-
confirmDown = inputs.inGame.jump.currentState;
420+
backDown = inputs.inGame.jump.currentState;
421+
confirmDown = inputs.inGame.run_interact_cancel.currentState;
422+
Log::print<INFO>("backDown = {}, confirmDown = {}", backDown, confirmDown);
424423
}
425424
else {
426425
stick = inputs.inMenu.navigate;
@@ -484,9 +483,9 @@ void RND_Renderer::ImGuiOverlay::ProcessInputs(OpenXR::InputState& inputs) {
484483
// if no inputs or popup is open, allow closing the menu using the cancel/back button
485484
bool shouldClose = false;
486485
if (inGame) {
487-
if (inputs.inGame.run_interact_cancel.changedSinceLastSync && inputs.inGame.run_interact_cancel.currentState) {
486+
if (inputs.inGame.jump.changedSinceLastSync && inputs.inGame.jump.currentState) {
488487
shouldClose = true;
489-
inputs.inGame.run_interact_cancel.currentState = XR_FALSE;
488+
inputs.inGame.jump.currentState = XR_FALSE;
490489
}
491490
}
492491
else {
@@ -574,11 +573,11 @@ void RND_Renderer::ImGuiOverlay::DrawHelpMenu() {
574573
changed = true;
575574
}
576575

577-
bool leftHanded = settings.leftHanded;
578-
if (ImGui::Checkbox("Left Handed Mode", &leftHanded)) {
579-
settings.leftHanded = leftHanded ? 1 : 0;
580-
changed = true;
581-
}
576+
//bool leftHanded = settings.leftHanded;
577+
//if (ImGui::Checkbox("Left Handed Mode", &leftHanded)) {
578+
// settings.leftHanded = leftHanded ? 1 : 0;
579+
// changed = true;
580+
//}
582581
}
583582

584583
ImGui::Spacing();

0 commit comments

Comments
 (0)