mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-02-07 02:40:30 -05:00
Fixed PS5 gyro & Added GUI calibration button (#78)
* Fixed PS5 gyro & Added GUI calibration button * Change PS4/PS5 LED to the tunic color
This commit is contained in:
parent
6aa8894125
commit
98ddacef01
@ -30,7 +30,9 @@ struct SoHConfigType {
|
||||
float gyro_sensitivity = 1.0f;
|
||||
float rumble_strength = 1.0f;
|
||||
float input_scale = 1.0f;
|
||||
bool input_enabled = false;
|
||||
float gyroDriftX = 0.0f;
|
||||
float gyroDriftY = 0.0f;
|
||||
bool input_enabled = false;
|
||||
} controller;
|
||||
|
||||
// Cheats
|
||||
|
@ -7,12 +7,8 @@
|
||||
#include "Window.h"
|
||||
|
||||
extern "C" uint8_t __osMaxControllers;
|
||||
float gyroDriftX;
|
||||
float gyroDriftY;
|
||||
|
||||
namespace Ship {
|
||||
|
||||
|
||||
SDLController::SDLController(int32_t dwControllerNumber) : Controller(dwControllerNumber), Cont(nullptr), guid(INVALID_SDL_CONTROLLER_GUID) {
|
||||
|
||||
}
|
||||
@ -186,31 +182,31 @@ namespace Ship {
|
||||
SDL_GameControllerGetSensorData(Cont, SDL_SENSOR_GYRO, gyroData, 3);
|
||||
|
||||
const char* contName = SDL_GameControllerName(Cont);
|
||||
const int isSpecialController = strcmp("PS5 Controller", contName);
|
||||
const int isSpecialController = !strcmp("PS5 Controller", contName);
|
||||
const float gyroSensitivity = Game::Settings.controller.gyro_sensitivity;
|
||||
|
||||
if (gyroDriftX == 0) {
|
||||
if (isSpecialController == 0) {
|
||||
gyroDriftX = gyroData[2];
|
||||
if (Game::Settings.controller.gyroDriftX == 0) {
|
||||
Game::Settings.controller.gyroDriftX = gyroData[0];
|
||||
}
|
||||
|
||||
if (Game::Settings.controller.gyroDriftY == 0) {
|
||||
if (isSpecialController == 1) {
|
||||
Game::Settings.controller.gyroDriftY = gyroData[2];
|
||||
}
|
||||
else {
|
||||
gyroDriftX = gyroData[0];
|
||||
Game::Settings.controller.gyroDriftY = gyroData[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (gyroDriftY == 0) {
|
||||
gyroDriftY = gyroData[1];
|
||||
}
|
||||
|
||||
if (isSpecialController == 0) {
|
||||
wGyroX = gyroData[2] - gyroDriftX;
|
||||
if (isSpecialController == 1) {
|
||||
wGyroX = gyroData[0] - Game::Settings.controller.gyroDriftX;
|
||||
wGyroY = -gyroData[2] - Game::Settings.controller.gyroDriftY;
|
||||
}
|
||||
else {
|
||||
wGyroX = gyroData[0] - gyroDriftX;
|
||||
wGyroX = gyroData[0] - Game::Settings.controller.gyroDriftX;
|
||||
wGyroY = gyroData[1] - Game::Settings.controller.gyroDriftY;
|
||||
}
|
||||
|
||||
wGyroY = gyroData[1] - gyroDriftY;
|
||||
|
||||
wGyroX *= gyroSensitivity;
|
||||
wGyroY *= gyroSensitivity;
|
||||
}
|
||||
@ -340,11 +336,19 @@ namespace Ship {
|
||||
}
|
||||
|
||||
if (SDL_GameControllerHasLED(Cont)) {
|
||||
if (controller->ledColor == 1) {
|
||||
switch (controller->ledColor) {
|
||||
case 0:
|
||||
SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 255, 0, 0);
|
||||
}
|
||||
else {
|
||||
SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0, 255, 0);
|
||||
break;
|
||||
case 1:
|
||||
SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0x1E, 0x69, 0x1B);
|
||||
break;
|
||||
case 2:
|
||||
SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0x64, 0x14, 0x00);
|
||||
break;
|
||||
case 3:
|
||||
SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0x00, 0x3C, 0x64);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,6 +306,14 @@ namespace SohImGui {
|
||||
if (ImGui::SliderFloat("##GYROSCOPE", &Game::Settings.controller.gyro_sensitivity, 0.0f, 1.0f, "")) {
|
||||
needs_save = true;
|
||||
}
|
||||
|
||||
if (ImGui::Button("Recalibrate Gyro")) {
|
||||
Game::Settings.controller.gyroDriftX = 0;
|
||||
Game::Settings.controller.gyroDriftY = 0;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Rumble Strength: %d %%", static_cast<int>(100 * Game::Settings.controller.rumble_strength));
|
||||
if (ImGui::SliderFloat("##RUMBLE", &Game::Settings.controller.rumble_strength, 0.0f, 1.0f, "")) {
|
||||
needs_save = true;
|
||||
|
@ -272,9 +272,19 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) {
|
||||
controllerCallback.rumble = padMgr->rumbleEnable[0] > 0 ? 1 : 0;
|
||||
|
||||
if (HealthMeter_IsCritical()) {
|
||||
controllerCallback.ledColor = 1;
|
||||
} else {
|
||||
controllerCallback.ledColor = 0;
|
||||
} else if (gGlobalCtx) {
|
||||
switch (CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1) {
|
||||
case PLAYER_TUNIC_KOKIRI:
|
||||
controllerCallback.ledColor = 1;
|
||||
break;
|
||||
case PLAYER_TUNIC_GORON:
|
||||
controllerCallback.ledColor = 2;
|
||||
break;
|
||||
case PLAYER_TUNIC_ZORA:
|
||||
controllerCallback.ledColor = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OTRControllerCallback(&controllerCallback);
|
||||
|
Loading…
Reference in New Issue
Block a user