Cleans up InputEditor class.

This commit is contained in:
Kenix3 2022-08-23 20:00:24 -04:00
parent 927ffd0b8b
commit 3792b03a7d
4 changed files with 35 additions and 9 deletions

View File

@ -165,7 +165,13 @@ namespace SohImGui {
} else {
console->Close();
}
SohImGui::controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0);
if (CVar_GetS32("gControllerConfigurationEnabled", 0)) {
controller->Open();
} else {
controller->Close();
}
UpdateAudio();
});
}
@ -1096,7 +1102,11 @@ namespace SohImGui {
bool currentValue = CVar_GetS32("gControllerConfigurationEnabled", 0);
CVar_SetS32("gControllerConfigurationEnabled", !currentValue);
needs_save = true;
controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0);
if (CVar_GetS32("gControllerConfigurationEnabled", 0)) {
controller->Open();
} else {
controller->Close();
}
}
ImGui::PopStyleColor(1);
ImGui::PopStyleVar(3);

View File

@ -20,7 +20,7 @@ namespace Ship {
return controlDeck->GetPhysicalDeviceFromVirtualSlot(slot);
}
void InputEditor::DrawButton(const char* label, int n64Btn) {
void InputEditor::DrawButton(const char* label, int32_t n64Btn) {
const std::shared_ptr<Controller> backend = GetControllerPerSlot(CurrentPort);
float size = 40;
@ -357,4 +357,16 @@ namespace Ship {
ImGui::End();
}
bool InputEditor::IsOpened() {
return Opened;
}
void InputEditor::Open() {
Opened = true;
}
void InputEditor::Close() {
Opened = false;
}
}

View File

@ -1,18 +1,22 @@
#pragma once
#include "stdint.h"
#include "Lib/ImGui/imgui.h"
namespace Ship {
class InputEditor {
int CurrentPort = 0;
int BtnReading = -1;
public:
int32_t CurrentPort = 0;
int32_t BtnReading = -1;
bool Opened = false;
public:
void Init();
void DrawButton(const char* label, int n64Btn);
void DrawButton(const char* label, int32_t n64Btn);
void DrawVirtualStick(const char* label, ImVec2 stick);
void DrawControllerSchema();
void DrawHud();
bool IsOpened();
void Open();
void Close();
};
}

View File

@ -86,7 +86,7 @@ extern "C" {
pad->gyro_x = 0;
pad->gyro_y = 0;
if (SohImGui::controller->Opened) return;
if (SohImGui::controller->IsOpened()) return;
Ship::Window::GetInstance()->GetControlDeck()->WriteToPad(pad);
Ship::ExecuteHooks<Ship::ControllerRead>(pad);