Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
briaguya-ai committed Jan 19, 2025
1 parent 7d7a2cb commit d14fdb7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ RumbleMappingFactory::CreateDefaultSDLRumbleMappings(PhysicalDeviceType physical
// ->GetDeviceIndexMappingManager()
// ->GetDeviceIndexMappingFromShipDeviceIndex(physicalDeviceType));
// if (sdlIndexMapping == nullptr) {
return std::vector<std::shared_ptr<ControllerRumbleMapping>>();
return std::vector<std::shared_ptr<ControllerRumbleMapping>>();
// }

// std::vector<std::shared_ptr<ControllerRumbleMapping>> mappings = { std::make_shared<SDLRumbleMapping>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ void SDLAxisDirectionToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons)

int32_t axisThresholdPercentage = 25;
if (AxisIsStick()) {
axisThresholdPercentage = Ship::Context::GetInstance()->GetControlDeck()->GetGlobalSDLDeviceSettings()->GetStickAxisThresholdPercentage();
axisThresholdPercentage = Ship::Context::GetInstance()
->GetControlDeck()
->GetGlobalSDLDeviceSettings()
->GetStickAxisThresholdPercentage();
} else if (AxisIsTrigger()) {
axisThresholdPercentage = Ship::Context::GetInstance()->GetControlDeck()->GetGlobalSDLDeviceSettings()->GetTriggerAxisThresholdPercentage();
axisThresholdPercentage = Ship::Context::GetInstance()
->GetControlDeck()
->GetGlobalSDLDeviceSettings()
->GetTriggerAxisThresholdPercentage();
}

for (const auto& [instanceId, gamepad] :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ void SDLLEDMapping::SetLEDColor(Color_RGB8 color) {
if (mColorSource == LED_COLOR_SOURCE_SET) {
color = mSavedColor;
}

for (const auto& [instanceId, gamepad] :
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(mPortIndex))
{
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadsForPort(
mPortIndex)) {
if (!SDL_GameControllerHasLED(gamepad)) {
continue;
}
Expand Down
8 changes: 6 additions & 2 deletions src/controller/physicaldevice/GlobalSDLDeviceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ namespace Ship {
GlobalSDLDeviceSettings::GlobalSDLDeviceSettings() {
const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".GlobalSDLDeviceSettings";
const int32_t defaultAxisThresholdPercentage = 25;
mStickAxisThresholdPercentage = CVarGetInteger(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), defaultAxisThresholdPercentage);
mTriggerAxisThresholdPercentage = CVarGetInteger(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(), defaultAxisThresholdPercentage);
mStickAxisThresholdPercentage =
CVarGetInteger(StringHelper::Sprintf("%s.StickAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(),
defaultAxisThresholdPercentage);
mTriggerAxisThresholdPercentage =
CVarGetInteger(StringHelper::Sprintf("%s.TriggerAxisThresholdPercentage", mappingCvarKey.c_str()).c_str(),
defaultAxisThresholdPercentage);
}

GlobalSDLDeviceSettings::~GlobalSDLDeviceSettings() {
Expand Down
14 changes: 8 additions & 6 deletions src/window/gui/InputEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ void InputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, CONTROLLER
ImGui::SetNextItemWidth(SCALE_IMGUI_SIZE(160.0f));
if (ImGui::SliderInt(StringHelper::Sprintf("##Stick Axis Threshold%s", id.c_str()).c_str(),
&stickAxisThreshold, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp)) {
globalSettings->SetStickAxisThresholdPercentage(stickAxisThreshold);
globalSettings->SaveToConfig();
globalSettings->SetStickAxisThresholdPercentage(stickAxisThreshold);
globalSettings->SaveToConfig();
}
ImGui::SameLine(0.0f, 0.0f);
if (stickAxisThreshold == 100) {
Expand Down Expand Up @@ -372,8 +372,8 @@ void InputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, CONTROLLER
ImGui::SetNextItemWidth(SCALE_IMGUI_SIZE(160.0f));
if (ImGui::SliderInt(StringHelper::Sprintf("##Trigger Axis Threshold%s", id.c_str()).c_str(),
&triggerAxisThreshold, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp)) {
globalSettings->SetTriggerAxisThresholdPercentage(triggerAxisThreshold);
globalSettings->SaveToConfig();
globalSettings->SetTriggerAxisThresholdPercentage(triggerAxisThreshold);
globalSettings->SaveToConfig();
}
ImGui::SameLine(0.0f, 0.0f);
if (triggerAxisThreshold == 100) {
Expand Down Expand Up @@ -1186,7 +1186,8 @@ void InputEditorWindow::DrawDeviceNameButtons() {
ImGui::PopStyleColor();
ImGui::PopStyleColor();

for (const auto& name : Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadNames()) {
for (const auto& name :
Context::GetInstance()->GetControlDeck()->GetConnectedPhysicalDeviceManager()->GetConnectedSDLGamepadNames()) {
auto buttonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button);
auto buttonHoveredColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered);
GetButtonColorsForPhysicalDeviceType(PhysicalDeviceType::SDLGamepad, buttonColor, buttonHoveredColor);
Expand Down Expand Up @@ -1348,7 +1349,8 @@ void InputEditorWindow::DrawSetDefaultsButton(uint8_t portIndex) {
ImGui::PopStyleColor();
ImGui::PopStyleColor();
if (ImGui::BeginPopupModal("Set Defaults for Gamepad (SDL)", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("This will clear all existing mappings for\nGamepad (SDL) on port %d.\n\nContinue?", portIndex + 1);
ImGui::Text("This will clear all existing mappings for\nGamepad (SDL) on port %d.\n\nContinue?",
portIndex + 1);
if (ImGui::Button("Cancel")) {
shouldClose = true;
ImGui::CloseCurrentPopup();
Expand Down

0 comments on commit d14fdb7

Please sign in to comment.