fix issues

fix timeout loop, fixed drift issues, fixed infinite rumble, fixed gamecube controller adapter taking over all ports, require assigning a virtual controller port specifically to the gamecube controller adapter, and block inputs from gamecube controller while settings menu (f10 menu) is open
This commit is contained in:
GalaxisBeast
2026-08-26 20:12:15 -04:00
parent f1c2b60df1
commit 251529d66e
8 changed files with 161 additions and 77 deletions
+66 -24
View File
@@ -312,6 +312,34 @@ void ApplyConfiguredMappings() {
}
}
void DrawGameCubeAdapterInfo() {
ImGui::Separator();
if (!ImGui::BeginMenu("GameCube adapter info")) return;
const auto adapter = Wup028Adapter::GetInfo();
const char* state = adapter.state == Wup028Adapter::ConnectionState::Connected
? "Connected"
: adapter.state == Wup028Adapter::ConnectionState::DriverError ? "Driver error"
: "Searching";
ImGui::Text("Status: %s", state);
if (!adapter.deviceName.empty()) {
ImGui::Text("Device: %s", adapter.deviceName.c_str());
}
ImGui::TextWrapped("%s", adapter.detail.c_str());
if (adapter.state == Wup028Adapter::ConnectionState::Connected) {
ImGui::Text("Poll rate: %.1f reports/s", adapter.pollRateHz);
ImGui::Text("Endpoints: IN 0x%02X, OUT 0x%02X", adapter.inputEndpoint, adapter.outputEndpoint);
for (size_t port = 0; port < adapter.ports.size(); ++port) {
const uint8_t type = adapter.portStatus[port] & 0x30;
const char* typeName = type == 0x10 ? "wired" : type == 0x20 ? "wireless" : "none";
ImGui::Text("Adapter port %u: %s (type %s, raw 0x%02X)", static_cast<unsigned>(port + 1),
adapter.ports[port] ? "Controller connected" : "Empty", typeName,
adapter.portStatus[port]);
}
}
ImGui::EndMenu();
}
void DrawControllerSettings() {
for (int port = 0; port < PAD_MAX_CONTROLLERS; ++port) {
const std::string label = "Port " + std::to_string(port + 1);
@@ -322,47 +350,60 @@ void DrawControllerSettings() {
}
ImGui::Separator();
if (ImGui::BeginMenu("GameCube controller adapter")) {
const auto adapter = Wup028Adapter::GetInfo();
const char* state = adapter.state == Wup028Adapter::ConnectionState::Connected
? "Connected"
: adapter.state == Wup028Adapter::ConnectionState::DriverError ? "Driver error"
: "Searching";
ImGui::Text("Status: %s", state);
if (!adapter.deviceName.empty()) {
ImGui::Text("Device: %s", adapter.deviceName.c_str());
const uint32_t selectedGamePort = static_cast<uint32_t>(g_controllerPort);
const int adapterAssignment = Wup028Adapter::GetPortAssignment(selectedGamePort);
if (adapterAssignment >= 0) {
ImGui::Text("Assigned: GameCube adapter port %d", adapterAssignment + 1);
} else {
const char* currentName = PADGetName(selectedGamePort);
ImGui::Text("Assigned: %s", currentName != nullptr ? currentName : "None");
}
if (ImGui::BeginMenu("Assign GameCube adapter port")) {
if (ImGui::MenuItem("None", nullptr, adapterAssignment < 0)) {
Wup028Adapter::SetPortAssignment(selectedGamePort, -1);
RuntimeConfigFile::SetGameCubeAdapterPort(selectedGamePort, -1);
}
ImGui::TextWrapped("%s", adapter.detail.c_str());
if (adapter.state == Wup028Adapter::ConnectionState::Connected) {
ImGui::Text("Poll rate: %.1f reports/s", adapter.pollRateHz);
ImGui::Text("Endpoints: IN 0x%02X, OUT 0x%02X", adapter.inputEndpoint, adapter.outputEndpoint);
for (size_t port = 0; port < adapter.ports.size(); ++port) {
const uint8_t type = adapter.portStatus[port] & 0x30;
const char* typeName = type == 0x10 ? "wired" : type == 0x20 ? "wireless" : "none";
ImGui::Text("Adapter port %u: %s (type %s, raw 0x%02X)",
static_cast<unsigned>(port + 1),
adapter.ports[port] ? "Controller connected" : "Empty", typeName,
adapter.portStatus[port]);
const auto adapter = Wup028Adapter::GetInfo();
for (int physicalPort = 0; physicalPort < PAD_CHANMAX; ++physicalPort) {
const std::string label = "Adapter port " + std::to_string(physicalPort + 1) +
(adapter.ports[static_cast<size_t>(physicalPort)] ? " (connected)" : " (empty)");
if (ImGui::MenuItem(label.c_str(), nullptr, adapterAssignment == physicalPort)) {
for (uint32_t gamePort = 0; gamePort < PAD_CHANMAX; ++gamePort) {
if (gamePort != selectedGamePort && Wup028Adapter::GetPortAssignment(gamePort) == physicalPort) {
RuntimeConfigFile::SetGameCubeAdapterPort(gamePort, -1);
}
}
PADClearPort(selectedGamePort);
Wup028Adapter::SetPortAssignment(selectedGamePort, physicalPort);
RuntimeConfigFile::SetGameCubeAdapterPort(selectedGamePort, physicalPort);
g_configuredControllerIndices.fill(std::numeric_limits<int32_t>::min());
}
}
ImGui::EndMenu();
}
if (ImGui::MenuItem("Unassign controller")) {
PADClearPort(selectedGamePort);
Wup028Adapter::SetPortAssignment(selectedGamePort, -1);
RuntimeConfigFile::SetGameCubeAdapterPort(selectedGamePort, -1);
g_configuredControllerIndices.fill(std::numeric_limits<int32_t>::min());
}
ImGui::Separator();
controller_mapping_wizard::DrawSetupList();
const uint32_t controllerCount = PADCount();
if (controllerCount == 0) {
ImGui::TextDisabled("No controller connected");
DrawGameCubeAdapterInfo();
return;
}
const char* currentName = PADGetName(static_cast<uint32_t>(g_controllerPort));
ImGui::Text("Assigned: %s", currentName != nullptr ? currentName : "None");
if (ImGui::BeginMenu("Assign connected controller")) {
for (uint32_t index = 0; index < controllerCount; ++index) {
const char* name = PADGetNameForControllerIndex(index);
ImGui::PushID(static_cast<int>(index));
if (ImGui::MenuItem(name != nullptr ? name : "Unknown controller")) {
PADSetPortForIndex(index, static_cast<uint32_t>(g_controllerPort));
Wup028Adapter::SetPortAssignment(selectedGamePort, -1);
RuntimeConfigFile::SetGameCubeAdapterPort(selectedGamePort, -1);
PADSetPortForIndex(index, selectedGamePort);
g_configuredControllerIndices.fill(std::numeric_limits<int32_t>::min());
ApplyConfiguredMappings();
}
@@ -375,6 +416,7 @@ void DrawControllerSettings() {
PADButtonMapping* mappings = PADGetButtonMappings(static_cast<uint32_t>(g_controllerPort), &mappingCount);
if (mappings == nullptr || mappingCount != PAD_BUTTON_COUNT) {
ImGui::TextDisabled("Assign a controller to edit its buttons");
DrawGameCubeAdapterInfo();
return;
}
@@ -514,7 +556,7 @@ void DrawControllerSettings() {
ImGui::TextUnformatted(kControllerButtons[i].label);
ImGui::PopID();
}
DrawGameCubeAdapterInfo();
}
void DrawAudioSettings() {