Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/HarbourMasters/Shipwright
Browse files Browse the repository at this point in the history
…into rando-custom-messages
  • Loading branch information
leggettc18 committed Jul 14, 2022
2 parents cd096ce + 8417db6 commit 9c57ed6
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 353 deletions.
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

0 comments on commit 9c57ed6

Please sign in to comment.