Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various controller fixes #771

Merged
merged 8 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions libultraship/libultraship/ControlDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ControllerThresholds>(std::stoi(val.key()))] = val.value();
}
Expand Down Expand Up @@ -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) {
Expand All @@ -152,4 +143,4 @@ void Ship::ControlDeck::SaveControllerSettings() {
}

Config->save();
}
}
41 changes: 17 additions & 24 deletions libultraship/libultraship/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions libultraship/libultraship/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ namespace Ship {
bool UseRumble = false;
bool UseGyro = false;
float RumbleStrength = 1.0f;
std::unordered_map<ControllerThresholds, int32_t> Thresholds;
std::unordered_map<int32_t, int32_t> GyroThresholds;
std::unordered_map<ControllerThresholds, float> Thresholds;
std::map<int32_t, int32_t> Mappings;
};

Expand Down
277 changes: 0 additions & 277 deletions libultraship/libultraship/ControllerHud.cpp

This file was deleted.

Loading