controller menu cleanup (#1166)

This commit is contained in:
briaguya 2022-08-15 17:02:45 -04:00 committed by GitHub
parent 7a9160ed78
commit a31256d956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View File

@ -93,10 +93,11 @@ namespace Ship {
if (ImGui::BeginCombo("##ControllerEntries", ControllerName.c_str())) { if (ImGui::BeginCombo("##ControllerEntries", ControllerName.c_str())) {
for (uint8_t i = 0; i < controlDeck->GetNumPhysicalDevices(); i++) { for (uint8_t i = 0; i < controlDeck->GetNumPhysicalDevices(); i++) {
if (ControllerName != "Keyboard" && ControllerName != "Auto") { std::string DeviceName = controlDeck->GetPhysicalDevice(i)->GetControllerName();
ControllerName += "##"+std::to_string(i); if (DeviceName != "Keyboard" && DeviceName != "Auto") {
DeviceName += "##"+std::to_string(i);
} }
if (ImGui::Selectable(ControllerName.c_str(), i == controlDeck->GetVirtualDevice(CurrentPort))) { if (ImGui::Selectable(DeviceName.c_str(), i == controlDeck->GetVirtualDevice(CurrentPort))) {
controlDeck->SetPhysicalDevice(CurrentPort, i); controlDeck->SetPhysicalDevice(CurrentPort, i);
} }
} }
@ -151,7 +152,7 @@ namespace Ship {
#ifdef __WIIU__ #ifdef __WIIU__
ImGui::BeginChild("##MSInput", ImVec2(90 * 2, 50 * 2), false); ImGui::BeginChild("##MSInput", ImVec2(90 * 2, 50 * 2), false);
#else #else
ImGui::BeginChild("##MSInput", ImVec2(90 , 50), false); ImGui::BeginChild("##MSInput", ImVec2(90, 50), false);
#endif #endif
ImGui::Text("Deadzone"); ImGui::Text("Deadzone");
#ifdef __WIIU__ #ifdef __WIIU__
@ -159,7 +160,12 @@ namespace Ship {
#else #else
ImGui::PushItemWidth(80); ImGui::PushItemWidth(80);
#endif #endif
ImGui::InputFloat("##MDZone", &profile->AxisDeadzones[0] /* This is the SDL value for left stick X axis */, 1.0f, 0.0f, "%.0f"); // The window has deadzone per stick, so we need to
// set the deadzone for both left stick axes here
// SDL_CONTROLLER_AXIS_LEFTX: 0
// SDL_CONTROLLER_AXIS_LEFTY: 1
ImGui::InputFloat("##MDZone", &profile->AxisDeadzones[0], 1.0f, 0.0f, "%.0f");
profile->AxisDeadzones[1] = profile->AxisDeadzones[0];
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::EndChild(); ImGui::EndChild();
} else { } else {
@ -198,7 +204,12 @@ namespace Ship {
#else #else
ImGui::PushItemWidth(80); ImGui::PushItemWidth(80);
#endif #endif
ImGui::InputFloat("##MDZone", &profile->AxisDeadzones[2] /* This is the SDL value for right stick X axis */, 1.0f, 0.0f, "%.0f"); // The window has deadzone per stick, so we need to
// set the deadzone for both right stick axes here
// SDL_CONTROLLER_AXIS_RIGHTX: 2
// SDL_CONTROLLER_AXIS_RIGHTY: 3
ImGui::InputFloat("##MDZone", &profile->AxisDeadzones[2], 1.0f, 0.0f, "%.0f");
profile->AxisDeadzones[3] = profile->AxisDeadzones[2];
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::Text("Sensitivity"); ImGui::Text("Sensitivity");
#ifdef __WIIU__ #ifdef __WIIU__
@ -206,7 +217,11 @@ namespace Ship {
#else #else
ImGui::PushItemWidth(80); ImGui::PushItemWidth(80);
#endif #endif
ImGui::InputFloat("##MSensitivity", &profile->AxisSensitivities[2] /* This is the SDL value for right stick X axis */, 1.0f, 0.0f, "%.0f"); // The window has sensitivity per stick, so we need to
// set the sensitivity for both right stick axes here
// SDL_CONTROLLER_AXIS_RIGHTX: 2
// SDL_CONTROLLER_AXIS_RIGHTY: 3
ImGui::InputFloat("##MSensitivity", &profile->AxisSensitivities[2], 1.0f, 0.0f, "%.0f");
profile->AxisSensitivities[3] = profile->AxisSensitivities[2]; profile->AxisSensitivities[3] = profile->AxisSensitivities[2];
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::EndChild(); ImGui::EndChild();

View File

@ -21,6 +21,7 @@ namespace Ship {
return false; return false;
} }
supportsGyro = false;
if (SDL_GameControllerHasSensor(NewCont, SDL_SENSOR_GYRO)) { if (SDL_GameControllerHasSensor(NewCont, SDL_SENSOR_GYRO)) {
SDL_GameControllerSetSensorEnabled(NewCont, SDL_SENSOR_GYRO, SDL_TRUE); SDL_GameControllerSetSensorEnabled(NewCont, SDL_SENSOR_GYRO, SDL_TRUE);
supportsGyro = true; supportsGyro = true;