Changed input disable to only be forced on switch (#941)

* Changed input disable to only be forced on switch

* Inverted if

* Finally fixed validation

* Removed enhancement if its a switch build

* Input now only gets blocked when the device is not a keyboard or its on switch

* Input gets blocked when the controller view is opened

* gControlNav is enabled by default on switch

* Fixed compilation issues
This commit is contained in:
KiritoDev 2022-08-08 18:53:43 -05:00 committed by GitHub
parent a8fea61bda
commit a4334ecb02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 19 deletions

View File

@ -6,6 +6,7 @@
#include "KeyboardController.h" #include "KeyboardController.h"
#include "SDLController.h" #include "SDLController.h"
#include <Utils/StringHelper.h> #include <Utils/StringHelper.h>
#include "Cvar.h"
namespace Ship { namespace Ship {
uint8_t* controllerBits; uint8_t* controllerBits;
@ -51,18 +52,31 @@ namespace Ship {
*controllerBits |= (backend->Connected()) << slot; *controllerBits |= (backend->Connected()) << slot;
} }
void ControlDeck::WriteToPad(OSContPad* pad) const { void ControlDeck::WriteToPad(OSContPad* pad) const {
for (size_t i = 0; i < virtualDevices.size(); i++) {
const std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]]; #ifdef __SWITCH__
if (backend->GetGuid() == "Auto") { bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0);
for (const auto& device : physicalDevices) { #else
device->Read(&pad[i], i); bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0);
} #endif
continue;
} for (size_t i = 0; i < virtualDevices.size(); i++) {
backend->Read(&pad[i], i); const std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
} if (backend->GetGuid() == "Auto") {
} for (const auto& device : physicalDevices) {
if(shouldBlockGameInput && device->GetGuid() != "Keyboard") {
continue;
}
device->Read(&pad[i], i);
}
continue;
}
if(shouldBlockGameInput && backend->GetGuid() != "Keyboard") {
continue;
}
backend->Read(&pad[i], i);
}
}
#define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), slot, __VA_ARGS__) #define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), slot, __VA_ARGS__)

View File

@ -822,7 +822,12 @@ namespace SohImGui {
GlobalCtx2::GetInstance()->GetWindow()->SetMenuBar(menu_bar); GlobalCtx2::GetInstance()->GetWindow()->SetMenuBar(menu_bar);
ShowCursor(menu_bar, Dialogues::dMenubar); ShowCursor(menu_bar, Dialogues::dMenubar);
GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->SaveControllerSettings(); GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->SaveControllerSettings();
if (CVar_GetS32("gControlNav", 0)) { #ifdef __SWITCH__
bool enableControllerNavigation = true;
#else
bool enableControllerNavigation = CVar_GetS32("gControlNav", 0);
#endif
if (enableControllerNavigation) {
if (CVar_GetS32("gOpenMenuBar", 0)) { if (CVar_GetS32("gOpenMenuBar", 0)) {
io->ConfigFlags |=ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard; io->ConfigFlags |=ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard;
} else { } else {
@ -892,9 +897,11 @@ namespace SohImGui {
if (ImGui::BeginMenu("Controller")) if (ImGui::BeginMenu("Controller"))
{ {
#ifndef __SWITCH__
EnhancementCheckbox("Use Controller Navigation", "gControlNav"); EnhancementCheckbox("Use Controller Navigation", "gControlNav");
Tooltip("Allows controller navigation of the menu bar\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); Tooltip("Allows controller navigation of the menu bar\nD-pad to move between items, A to select, and X to grab focus on the menu bar");
#endif
EnhancementCheckbox("Controller Configuration", "gControllerConfigurationEnabled"); EnhancementCheckbox("Controller Configuration", "gControllerConfigurationEnabled");
controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0); controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0);
@ -1365,7 +1372,7 @@ namespace SohImGui {
{ {
val = 20; val = 20;
} }
CVar_SetS32(fps_cvar, val); CVar_SetS32(fps_cvar, val);
needs_save = true; needs_save = true;
} }

View File

@ -19,7 +19,7 @@
#include <string> #include <string>
#include <chrono> #include <chrono>
#include "Console.h" #include "Console.h"
#include "Cvar.h" #include "ImGuiImpl.h"
#include <iostream> #include <iostream>
@ -67,10 +67,9 @@ extern "C" {
pad->gyro_x = 0; pad->gyro_x = 0;
pad->gyro_y = 0; pad->gyro_y = 0;
if (!CVar_GetS32("gOpenMenuBar", 0)) { if (SohImGui::controller->Opened) return;
Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->WriteToPad(pad);
}
Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->WriteToPad(pad);
Ship::ExecuteHooks<Ship::ControllerRead>(pad); Ship::ExecuteHooks<Ship::ControllerRead>(pad);
} }