diff --git a/libultraship/libultraship/ControlDeck.cpp b/libultraship/libultraship/ControlDeck.cpp index 2fbf3d22548..ff7a1d243e5 100644 --- a/libultraship/libultraship/ControlDeck.cpp +++ b/libultraship/libultraship/ControlDeck.cpp @@ -89,15 +89,10 @@ void Ship::ControlDeck::LoadControllerSettings() { profile.Mappings.clear(); profile.Thresholds.clear(); - profile.GyroThresholds.clear(); profile.UseRumble = Config->getBool(NESTED("Rumble.Enabled", "")); - profile.RumbleStrength = Config->getBool(NESTED("Rumble.Strength", "")); + profile.RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", "")); profile.UseGyro = Config->getBool(NESTED("Gyro.Enabled", "")); - for (auto const& val : rawProfile["Gyro"]["Thresholds"].items()) { - profile.GyroThresholds[std::stoi(val.key())] = val.value(); - } - for (auto const& val : rawProfile["Thresholds"].items()) { profile.Thresholds[static_cast(std::stoi(val.key()))] = val.value(); } @@ -135,12 +130,8 @@ void Ship::ControlDeck::SaveControllerSettings() { Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1); } - for (auto const& [key, val] : profile.GyroThresholds) { - Config->setInt(NESTED("Gyro.Thresholds.%d", key), val); - } - for (auto const& [key, val] : profile.Thresholds) { - Config->setInt(NESTED("Thresholds.%d", key), val); + Config->setFloat(NESTED("Thresholds.%d", key), val); } for (auto const& [key, val] : profile.Mappings) { @@ -152,4 +143,4 @@ void Ship::ControlDeck::SaveControllerSettings() { } Config->save(); -} \ No newline at end of file +} diff --git a/libultraship/libultraship/Controller.cpp b/libultraship/libultraship/Controller.cpp index 8c0994a854f..6fc99c5c2cc 100644 --- a/libultraship/libultraship/Controller.cpp +++ b/libultraship/libultraship/Controller.cpp @@ -26,52 +26,45 @@ namespace Ship { pad->button |= dwPressedButtons[slot] & 0xFFFF; // Stick Inputs - if (pad->stick_x == 0) { + if (wStickX == 0) { if (dwPressedButtons[slot] & BTN_STICKLEFT) { pad->stick_x = -128; - } - else if (dwPressedButtons[slot] & BTN_STICKRIGHT) { + } else if (dwPressedButtons[slot] & BTN_STICKRIGHT) { pad->stick_x = 127; } - else { - pad->stick_x = wStickX; - } + } else { + pad->stick_x = wStickX; } - if (pad->stick_y == 0) { + if (wStickY == 0) { if (dwPressedButtons[slot] & BTN_STICKDOWN) { pad->stick_y = -128; - } - else if (dwPressedButtons[slot] & BTN_STICKUP) { + } else if (dwPressedButtons[slot] & BTN_STICKUP) { pad->stick_y = 127; } - else { - pad->stick_y = wStickY; - } + } else { + pad->stick_y = wStickY; } // Stick Inputs - if (pad->cam_x == 0) { + if (wCamX == 0) { if (dwPressedButtons[slot] & BTN_VSTICKLEFT) { pad->cam_x = -128 * 10.0f; - } - else if (dwPressedButtons[slot] & BTN_VSTICKRIGHT) { + } else if (dwPressedButtons[slot] & BTN_VSTICKRIGHT) { pad->cam_x = 127 * 10.0f; } - else { - pad->cam_x = wCamX; - } + } else { + pad->cam_x = wCamX; } - if (pad->cam_y == 0) { + + if (wCamY == 0) { if (dwPressedButtons[slot] & BTN_VSTICKDOWN) { pad->cam_y = -128 * 10.0f; - } - else if (dwPressedButtons[slot] & BTN_VSTICKUP) { + } else if (dwPressedButtons[slot] & BTN_VSTICKUP) { pad->cam_y = 127 * 10.0f; } - else { - pad->cam_y = wCamY; - } + } else { + pad->cam_y = wCamY; } // Gyro diff --git a/libultraship/libultraship/Controller.h b/libultraship/libultraship/Controller.h index ffbeeaabff8..70c339d25a0 100644 --- a/libultraship/libultraship/Controller.h +++ b/libultraship/libultraship/Controller.h @@ -29,8 +29,7 @@ namespace Ship { bool UseRumble = false; bool UseGyro = false; float RumbleStrength = 1.0f; - std::unordered_map Thresholds; - std::unordered_map GyroThresholds; + std::unordered_map Thresholds; std::map Mappings; }; diff --git a/libultraship/libultraship/ControllerHud.cpp b/libultraship/libultraship/ControllerHud.cpp deleted file mode 100644 index e40990b0db5..00000000000 --- a/libultraship/libultraship/ControllerHud.cpp +++ /dev/null @@ -1,277 +0,0 @@ -#include "InputEditor.h" -#include "Controller.h" -#include "Window.h" -#include "Lib/ImGui/imgui.h" -#include "ImGuiImpl.h" -#include "Utils/StringHelper.h" -#include "Lib/ImGui/imgui_internal.h" - -namespace Ship { - - extern "C" uint8_t __enableGameInput; - #define SEPARATION() ImGui::Dummy(ImVec2(0, 5)) - - void InputEditor::Init() { - BtnReading = -1; - } - - std::shared_ptr GetControllerPerSlot(int slot) { - const std::vector vDevices = Window::ControllerApi->virtualDevices; - return Window::ControllerApi->physicalDevices[vDevices[slot]]; - } - - void InputEditor::DrawButton(const char* label, int n64Btn) { - const std::shared_ptr backend = GetControllerPerSlot(CurrentPort); - - float size = 40; - bool readingMode = BtnReading == n64Btn; - bool disabled = BtnReading != -1 && !readingMode || !backend->Connected(); - ImVec2 len = ImGui::CalcTextSize(label); - ImVec2 pos = ImGui::GetCursorPos(); - ImGui::SetCursorPosY(pos.y + len.y / 4); - ImGui::SetCursorPosX(pos.x + abs(len.x - size)); - ImGui::Text("%s", label); - ImGui::SameLine(); - ImGui::SetCursorPosY(pos.y); - - if(disabled) { - ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); - ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); - } - - if(readingMode) { - const int32_t btn = backend->ReadRawPress(); - - if(btn != -1) { - backend->SetButtonMapping(CurrentPort, n64Btn, btn); - BtnReading = -1; - } - } - - const char* BtnName = backend->GetButtonName(CurrentPort, n64Btn); - - if (ImGui::Button(StringHelper::Sprintf("%s##HBTNID_%d", readingMode ? "Press a Key..." : BtnName, n64Btn).c_str())) { - BtnReading = n64Btn; - backend->ClearRawPress(); - } - - if(disabled) { - ImGui::PopItemFlag(); - ImGui::PopStyleVar(); - } - } - - void InputEditor::DrawVirtualStick(const char* label, ImVec2 stick) { - ImGui::SetCursorPos(ImVec2(ImGui::GetCursorPos().x + 5, ImGui::GetCursorPos().y)); - ImGui::BeginChild(label, ImVec2(68, 75), false); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - const ImVec2 p = ImGui::GetCursorScreenPos(); - - float sz = 45.0f; - float rad = sz * 0.5f; - ImVec2 pos = ImVec2(p.x + sz * 0.5f + 12, p.y + sz * 0.5f + 11); - - float stickX = (stick.x / 83.0f) * (rad * 0.5f); - float stickY = -(stick.y / 83.0f) * (rad * 0.5f); - - ImVec4 rect = ImVec4(p.x + 2, p.y + 2, 65, 65); - draw_list->AddRect(ImVec2(rect.x, rect.y), ImVec2(rect.x + rect.z, rect.y + rect.w), ImColor(100, 100, 100, 255), 0.0f, 0, 1.5f); - draw_list->AddCircleFilled(pos, rad, ImColor(130, 130, 130, 255), 8); - draw_list->AddCircleFilled(ImVec2(pos.x + stickX, pos.y + stickY), 5, ImColor(15, 15, 15, 255), 7); - ImGui::EndChild(); - } - - void InputEditor::DrawControllerSchema() { - - const std::vector vDevices = Window::ControllerApi->virtualDevices; - const std::vector> devices = Window::ControllerApi->physicalDevices; - - std::shared_ptr Backend = devices[vDevices[CurrentPort]]; - DeviceProfile& profile =Backend->profiles[CurrentPort]; - float sensitivity = profile.Thresholds[SENSITIVITY]; - bool IsKeyboard = Backend->GetGuid() == "Keyboard" || !Backend->Connected(); - const char* ControllerName = Backend->GetControllerName(); - - if (ControllerName != nullptr && ImGui::BeginCombo("##ControllerEntries", ControllerName)) { - for (uint8_t i = 0; i < devices.size(); i++) { - if (ImGui::Selectable(devices[i]->GetControllerName(), i == vDevices[CurrentPort])) { - Window::ControllerApi->SetPhysicalDevice(CurrentPort, i); - } - } - ImGui::EndCombo(); - } - - ImGui::SameLine(); - - if(ImGui::Button("Refresh")) { - Window::ControllerApi->ScanPhysicalDevices(); - } - - SohImGui::BeginGroupPanel("Buttons", ImVec2(150, 20)); - DrawButton("A", BTN_A); - DrawButton("B", BTN_B); - DrawButton("L", BTN_L); - DrawButton("R", BTN_R); - DrawButton("Z", BTN_Z); - DrawButton("START", BTN_START); - SEPARATION(); - SohImGui::EndGroupPanel(IsKeyboard ? 7.0f : 48.0f); - ImGui::SameLine(); - SohImGui::BeginGroupPanel("Digital Pad", ImVec2(150, 20)); - DrawButton("Up", BTN_DUP); - DrawButton("Down", BTN_DDOWN); - DrawButton("Left", BTN_DLEFT); - DrawButton("Right", BTN_DRIGHT); - SEPARATION(); - SohImGui::EndGroupPanel(IsKeyboard ? 53.0f : 94.0f); - ImGui::SameLine(); - SohImGui::BeginGroupPanel("Analog Stick", ImVec2(150, 20)); - DrawButton("Up", BTN_STICKUP); - DrawButton("Down", BTN_STICKDOWN); - DrawButton("Left", BTN_STICKLEFT); - DrawButton("Right", BTN_STICKRIGHT); - - if (!IsKeyboard) { - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8); - DrawVirtualStick("##MainVirtualStick", ImVec2(Backend->wStickX, Backend->wStickY)); - ImGui::SameLine(); - - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5); - - ImGui::BeginChild("##MSInput", ImVec2(90, 50), false); - ImGui::Text("Deadzone"); - ImGui::PushItemWidth(80); - ImGui::InputInt("##MDZone", &profile.Thresholds[LEFT_STICK]); - ImGui::PopItemWidth(); - ImGui::EndChild(); - } else { - ImGui::Dummy(ImVec2(0, 6)); - } - SohImGui::EndGroupPanel(IsKeyboard ? 52.0f : 24.0f); - ImGui::SameLine(); - - if (!IsKeyboard) { - ImGui::SameLine(); - SohImGui::BeginGroupPanel("Camera Stick", ImVec2(150, 20)); - DrawButton("Up", BTN_VSTICKUP); - DrawButton("Down", BTN_VSTICKDOWN); - DrawButton("Left", BTN_VSTICKLEFT); - DrawButton("Right", BTN_VSTICKRIGHT); - - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8); - DrawVirtualStick("##CameraVirtualStick", ImVec2(Backend->wCamX / sensitivity, Backend->wCamY / sensitivity)); - - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5); - ImGui::BeginChild("##CSInput", ImVec2(90, 85), false); - ImGui::Text("Deadzone"); - ImGui::PushItemWidth(80); - ImGui::InputInt("##MDZone", &profile.Thresholds[RIGHT_STICK]); - ImGui::PopItemWidth(); - ImGui::Text("Sensitivity"); - ImGui::PushItemWidth(80); - ImGui::InputInt("##MSensitivity", &profile.Thresholds[SENSITIVITY]); - ImGui::PopItemWidth(); - ImGui::EndChild(); - SohImGui::EndGroupPanel(14.0f); - } - - if(Backend->CanGyro()) { - ImGui::SameLine(); - - SohImGui::BeginGroupPanel("Gyro Options", ImVec2(175, 20)); - float cursorX = ImGui::GetCursorPosX() + 5; - ImGui::SetCursorPosX(cursorX); - ImGui::Checkbox("Enable Gyro", &profile.UseGyro); - ImGui::SetCursorPosX(cursorX); - ImGui::Text("Gyro Sensitivity: %d%%", profile.Thresholds[GYRO_SENSITIVITY]); - ImGui::PushItemWidth(135.0f); - ImGui::SetCursorPosX(cursorX); - ImGui::SliderInt("##GSensitivity", &profile.Thresholds[GYRO_SENSITIVITY], 0, 100, ""); - ImGui::PopItemWidth(); - ImGui::Dummy(ImVec2(0, 1)); - ImGui::SetCursorPosX(cursorX); - if (ImGui::Button("Recalibrate Gyro##RGyro")) { - profile.Thresholds[DRIFT_X] = 0; - profile.Thresholds[DRIFT_Y] = 0; - } - ImGui::SetCursorPosX(cursorX); - DrawVirtualStick("##GyroPreview", ImVec2(Backend->wGyroX, Backend->wGyroY)); - - ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5); - ImGui::BeginChild("##GyInput", ImVec2(90, 85), false); - ImGui::Text("Drift X"); - ImGui::PushItemWidth(80); - ImGui::InputInt("##GDriftX", &profile.Thresholds[DRIFT_X]); - ImGui::PopItemWidth(); - ImGui::Text("Drift Y"); - ImGui::PushItemWidth(80); - ImGui::InputInt("##GDriftY", &profile.Thresholds[DRIFT_Y]); - ImGui::PopItemWidth(); - ImGui::EndChild(); - SohImGui::EndGroupPanel(14.0f); - } - - ImGui::SameLine(); - - const ImVec2 cursor = ImGui::GetCursorPos(); - - SohImGui::BeginGroupPanel("C-Buttons", ImVec2(158, 20)); - DrawButton("Up", BTN_CUP); - DrawButton("Down", BTN_CDOWN); - DrawButton("Left", BTN_CLEFT); - DrawButton("Right", BTN_CRIGHT); - ImGui::Dummy(ImVec2(0, 5)); - SohImGui::EndGroupPanel(); - - ImGui::SetCursorPosX(cursor.x); - ImGui::SetCursorPosY(cursor.y + 120); - SohImGui::BeginGroupPanel("Options", ImVec2(158, 20)); - float cursorX = ImGui::GetCursorPosX() + 5; - ImGui::SetCursorPosX(cursorX); - ImGui::Checkbox("Rumble Enabled", &profile.UseRumble); - if (Backend->CanRumble()) { - ImGui::SetCursorPosX(cursorX); - ImGui::Text("Rumble Force: %d%%", static_cast(100 * profile.RumbleStrength)); - ImGui::SetCursorPosX(cursorX); - ImGui::PushItemWidth(135.0f); - ImGui::SliderFloat("##RStrength", &profile.RumbleStrength, 0, 1.0f, ""); - ImGui::PopItemWidth(); - } - ImGui::Dummy(ImVec2(0, 5)); - SohImGui::EndGroupPanel(IsKeyboard ? 0.0f : 2.0f); - } - - void InputEditor::DrawHud() { - - __enableGameInput = true; - - if (!this->Opened) { - BtnReading = -1; - return; - } - - ImGui::SetNextWindowSizeConstraints(ImVec2(641, 250), ImVec2(1200, 290)); - //OTRTODO: Disable this stupid workaround ( ReadRawPress() only works when the window is on the main viewport ) - ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID); - ImGui::Begin("Controller Configuration", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize); - - ImGui::BeginTabBar("##Controllers"); - - for (int i = 0; i < 4; i++) { - if (ImGui::BeginTabItem(StringHelper::Sprintf("Port %d", i + 1).c_str())) { - CurrentPort = i; - ImGui::EndTabItem(); - } - } - - ImGui::EndTabBar(); - - // Draw current cfg - - DrawControllerSchema(); - - ImGui::End(); - } -} diff --git a/libultraship/libultraship/InputEditor.cpp b/libultraship/libultraship/InputEditor.cpp index e40990b0db5..0d170e305e8 100644 --- a/libultraship/libultraship/InputEditor.cpp +++ b/libultraship/libultraship/InputEditor.cpp @@ -141,7 +141,7 @@ namespace Ship { ImGui::BeginChild("##MSInput", ImVec2(90, 50), false); ImGui::Text("Deadzone"); ImGui::PushItemWidth(80); - ImGui::InputInt("##MDZone", &profile.Thresholds[LEFT_STICK]); + ImGui::InputFloat("##MDZone", &profile.Thresholds[LEFT_STICK], 1.0f, 0.0f, "%.0f"); ImGui::PopItemWidth(); ImGui::EndChild(); } else { @@ -166,11 +166,11 @@ namespace Ship { ImGui::BeginChild("##CSInput", ImVec2(90, 85), false); ImGui::Text("Deadzone"); ImGui::PushItemWidth(80); - ImGui::InputInt("##MDZone", &profile.Thresholds[RIGHT_STICK]); + ImGui::InputFloat("##MDZone", &profile.Thresholds[RIGHT_STICK], 1.0f, 0.0f, "%.0f"); ImGui::PopItemWidth(); ImGui::Text("Sensitivity"); ImGui::PushItemWidth(80); - ImGui::InputInt("##MSensitivity", &profile.Thresholds[SENSITIVITY]); + ImGui::InputFloat("##MSensitivity", &profile.Thresholds[SENSITIVITY], 1.0f, 0.0f, "%.0f"); ImGui::PopItemWidth(); ImGui::EndChild(); SohImGui::EndGroupPanel(14.0f); @@ -184,30 +184,30 @@ namespace Ship { ImGui::SetCursorPosX(cursorX); ImGui::Checkbox("Enable Gyro", &profile.UseGyro); ImGui::SetCursorPosX(cursorX); - ImGui::Text("Gyro Sensitivity: %d%%", profile.Thresholds[GYRO_SENSITIVITY]); + ImGui::Text("Gyro Sensitivity: %d%%", static_cast(100.0f * profile.Thresholds[GYRO_SENSITIVITY])); ImGui::PushItemWidth(135.0f); ImGui::SetCursorPosX(cursorX); - ImGui::SliderInt("##GSensitivity", &profile.Thresholds[GYRO_SENSITIVITY], 0, 100, ""); + ImGui::SliderFloat("##GSensitivity", &profile.Thresholds[GYRO_SENSITIVITY], 0.0f, 1.0f, ""); ImGui::PopItemWidth(); ImGui::Dummy(ImVec2(0, 1)); ImGui::SetCursorPosX(cursorX); if (ImGui::Button("Recalibrate Gyro##RGyro")) { - profile.Thresholds[DRIFT_X] = 0; - profile.Thresholds[DRIFT_Y] = 0; + profile.Thresholds[DRIFT_X] = 0.0f; + profile.Thresholds[DRIFT_Y] = 0.0f; } ImGui::SetCursorPosX(cursorX); - DrawVirtualStick("##GyroPreview", ImVec2(Backend->wGyroX, Backend->wGyroY)); + DrawVirtualStick("##GyroPreview", ImVec2(-10.0f * Backend->wGyroY, 10.0f * Backend->wGyroX)); ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5); ImGui::BeginChild("##GyInput", ImVec2(90, 85), false); ImGui::Text("Drift X"); ImGui::PushItemWidth(80); - ImGui::InputInt("##GDriftX", &profile.Thresholds[DRIFT_X]); + ImGui::InputFloat("##GDriftX", &profile.Thresholds[DRIFT_X], 1.0f, 0.0f, "%.1f"); ImGui::PopItemWidth(); ImGui::Text("Drift Y"); ImGui::PushItemWidth(80); - ImGui::InputInt("##GDriftY", &profile.Thresholds[DRIFT_Y]); + ImGui::InputFloat("##GDriftY", &profile.Thresholds[DRIFT_Y], 1.0f, 0.0f, "%.1f"); ImGui::PopItemWidth(); ImGui::EndChild(); SohImGui::EndGroupPanel(14.0f); @@ -233,10 +233,10 @@ namespace Ship { ImGui::Checkbox("Rumble Enabled", &profile.UseRumble); if (Backend->CanRumble()) { ImGui::SetCursorPosX(cursorX); - ImGui::Text("Rumble Force: %d%%", static_cast(100 * profile.RumbleStrength)); + ImGui::Text("Rumble Force: %d%%", static_cast(100.0f * profile.RumbleStrength)); ImGui::SetCursorPosX(cursorX); ImGui::PushItemWidth(135.0f); - ImGui::SliderFloat("##RStrength", &profile.RumbleStrength, 0, 1.0f, ""); + ImGui::SliderFloat("##RStrength", &profile.RumbleStrength, 0.0f, 1.0f, ""); ImGui::PopItemWidth(); } ImGui::Dummy(ImVec2(0, 5)); diff --git a/libultraship/libultraship/Resource.h b/libultraship/libultraship/Resource.h index 4e4d73b29d7..6bdae983eb4 100644 --- a/libultraship/libultraship/Resource.h +++ b/libultraship/libultraship/Resource.h @@ -63,8 +63,7 @@ namespace Ship Deckard = 0, Roy = 1, Rachael = 2, - Leon = 3, - Zhora = 4, + Zhora = 3, // ... }; diff --git a/libultraship/libultraship/SDLController.cpp b/libultraship/libultraship/SDLController.cpp index fc813dd661f..3d02a861436 100644 --- a/libultraship/libultraship/SDLController.cpp +++ b/libultraship/libultraship/SDLController.cpp @@ -100,13 +100,13 @@ namespace Ship { for (int32_t i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) { const auto Axis = static_cast(i); - const auto AxisValue = SDL_GameControllerGetAxis(Cont, Axis) / 32767; + const auto AxisValue = SDL_GameControllerGetAxis(Cont, Axis) / 32767.0f; - if(AxisValue < 0) { + if (AxisValue < -0.7f) { return -(Axis + AXIS_SCANCODE_BIT); } - if (AxisValue > 0) { + if (AxisValue > 0.7f) { return (Axis + AXIS_SCANCODE_BIT); } } @@ -153,9 +153,9 @@ namespace Ship { float gyroData[3]; SDL_GameControllerGetSensorData(Cont, SDL_SENSOR_GYRO, gyroData, 3); - float gyro_drift_x = profile.GyroThresholds[DRIFT_X] / 100.0f; - float gyro_drift_y = profile.GyroThresholds[DRIFT_Y] / 100.0f; - const float gyro_sensitivity = profile.GyroThresholds[SENSITIVITY] / 100.0f; + float gyro_drift_x = profile.Thresholds[DRIFT_X] / 100.0f; + float gyro_drift_y = profile.Thresholds[DRIFT_Y] / 100.0f; + const float gyro_sensitivity = profile.Thresholds[GYRO_SENSITIVITY]; if (gyro_drift_x == 0) { gyro_drift_x = gyroData[0]; @@ -165,8 +165,8 @@ namespace Ship { gyro_drift_y = gyroData[1]; } - profile.GyroThresholds[DRIFT_X] = (int) gyro_drift_x * 100; - profile.GyroThresholds[DRIFT_Y] = (int) gyro_drift_y * 100; + profile.Thresholds[DRIFT_X] = gyro_drift_x * 100.0f; + profile.Thresholds[DRIFT_Y] = gyro_drift_y * 100.0f; wGyroX = gyroData[0] - gyro_drift_x; wGyroY = gyroData[1] - gyro_drift_y; @@ -175,6 +175,8 @@ namespace Ship { wGyroY *= gyro_sensitivity; } + dwPressedButtons[slot] = 0; + for (int32_t i = SDL_CONTROLLER_BUTTON_A; i < SDL_CONTROLLER_BUTTON_MAX; i++) { if (profile.Mappings.contains(i)) { if (SDL_GameControllerGetButton(Cont, static_cast(i))) { @@ -198,7 +200,7 @@ namespace Ship { const auto Axis = static_cast(i); const auto PosScancode = i + AXIS_SCANCODE_BIT; const auto NegScancode = -PosScancode; - const auto AxisThreshold = profile.Thresholds[SDLAxisToThreshold(i)]; + const auto AxisThreshold = static_cast(profile.Thresholds[SDLAxisToThreshold(i)]); const auto PosButton = profile.Mappings[PosScancode]; const auto NegButton = profile.Mappings[NegScancode]; const auto AxisValue = SDL_GameControllerGetAxis(Cont, Axis); @@ -467,10 +469,13 @@ namespace Ship { profile.Mappings[-(SDL_CONTROLLER_AXIS_LEFTX + AXIS_SCANCODE_BIT)] = BTN_STICKLEFT; profile.Mappings[SDL_CONTROLLER_AXIS_LEFTY + AXIS_SCANCODE_BIT] = BTN_STICKDOWN; profile.Mappings[-(SDL_CONTROLLER_AXIS_LEFTY + AXIS_SCANCODE_BIT)] = BTN_STICKUP; - profile.Thresholds[LEFT_STICK] = 16.0; - profile.Thresholds[RIGHT_STICK] = 16.0; + profile.Thresholds[LEFT_STICK] = 16.0f; + profile.Thresholds[RIGHT_STICK] = 16.0f; profile.Thresholds[LEFT_TRIGGER] = 0x1E00; profile.Thresholds[RIGHT_TRIGGER] = 0x1E00; - profile.Thresholds[SENSITIVITY] = 16.0; + profile.Thresholds[DRIFT_X] = 0.0f; + profile.Thresholds[DRIFT_Y] = 0.0f; + profile.Thresholds[SENSITIVITY] = 16.0f; + profile.Thresholds[GYRO_SENSITIVITY] = 1.0f; } } diff --git a/libultraship/libultraship/libultraship.vcxproj b/libultraship/libultraship/libultraship.vcxproj index 964f51f5123..27e868afaab 100644 --- a/libultraship/libultraship/libultraship.vcxproj +++ b/libultraship/libultraship/libultraship.vcxproj @@ -38,38 +38,38 @@ StaticLibrary true - v143 + v142 Unicode StaticLibrary true - v143 + v142 Unicode StaticLibrary false - v143 + v142 true Unicode StaticLibrary true - v143 + v142 Unicode StaticLibrary true - v143 + v142 Unicode StaticLibrary false - v143 + v142 true Unicode diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index 3be124ca305..037539b2a6f 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -942,6 +942,7 @@ + diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 4bb4efd19ec..eb2b02b115e 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -521,7 +521,7 @@ void DebugConsole_LoadLegacyCVars() { } } - fs::remove("cvars.cfg"); + fs::remove(cvarsConfig); } } diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index a936b65671f..e14cf502dd1 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -7,6 +7,9 @@ // #include #include #include +#define NOGDI +#define WIN32_LEAN_AND_MEAN +#include #define TICKS_PER_SEC 268123480.0 @@ -18,7 +21,7 @@ void RandoMain::GenerateRando(std::unordered_map cvarS // std::string settingsFileName = "./randomizer/latest_settings.json"; // CVar_SetString("gLoadedPreset", settingsFileName.c_str()); - std::string fileName = GenerateRandomizer(cvarSettings); + std::string fileName = Ship::GlobalCtx2::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings).c_str()); CVar_SetString("gSpoilerLog", fileName.c_str()); Game::SaveSettings(); diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 24662f1d7b0..5deea408823 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -26,6 +26,10 @@ #include #include +#define NOGDI +#define WIN32_LEAN_AND_MEAN +#include "GlobalCtx2.h" + using json = nlohmann::json; json jsonData; @@ -721,12 +725,13 @@ const char* SpoilerLog_Write(int language) { //WriteShuffledEntrances(spoilerLog); WriteAllLocations(language); - if (!std::filesystem::exists("./Randomizer")) { - std::filesystem::create_directory("./Randomizer"); + if (!std::filesystem::exists(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"))) { + std::filesystem::create_directory(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer")); } std::string jsonString = jsonData.dump(4); - std::ofstream jsonFile("./Randomizer/" + Settings::seed + ".json"); + std::ofstream jsonFile(Ship::GlobalCtx2::GetPathRelativeToAppDirectory( + (std::string("Randomizer/") + std::string(Settings::seed) + std::string(".json")).c_str())); jsonFile << std::setw(4) << jsonString << std::endl; jsonFile.close(); diff --git a/soh/src/boot/build.c b/soh/src/boot/build.c index 94d142020e7..84a73076d3d 100644 --- a/soh/src/boot/build.c +++ b/soh/src/boot/build.c @@ -1,4 +1,4 @@ -const char gBuildVersion[] = "ROY ALFA (2.0.0)"; +const char gBuildVersion[] = "RACHAEL ALFA (3.0.0)"; const char gBuildTeam[] = "github.com/harbourmasters"; const char gBuildDate[] = __DATE__ " " __TIME__; const char gBuildMakeOption[] = "";