mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-19 18:04:56 +00:00
Now lightbar overwrite works on dualsense while using it on bluetooth (#2481)
This commit is contained in:
parent
cc583b6189
commit
2af20b0d83
1 changed files with 29 additions and 3 deletions
|
@ -97,6 +97,7 @@ void SDLInputEngine::Init() {
|
||||||
SDL_CloseGamepad(m_gamepad);
|
SDL_CloseGamepad(m_gamepad);
|
||||||
m_gamepad = nullptr;
|
m_gamepad = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gamepad_count;
|
int gamepad_count;
|
||||||
SDL_JoystickID* gamepads = SDL_GetGamepads(&gamepad_count);
|
SDL_JoystickID* gamepads = SDL_GetGamepads(&gamepad_count);
|
||||||
if (!gamepads) {
|
if (!gamepads) {
|
||||||
|
@ -108,12 +109,26 @@ void SDLInputEngine::Init() {
|
||||||
SDL_free(gamepads);
|
SDL_free(gamepads);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Input, "Got {} gamepads. Opening the first one.", gamepad_count);
|
LOG_INFO(Input, "Got {} gamepads. Opening the first one.", gamepad_count);
|
||||||
if (!(m_gamepad = SDL_OpenGamepad(gamepads[0]))) {
|
m_gamepad = SDL_OpenGamepad(gamepads[0]);
|
||||||
|
if (!m_gamepad) {
|
||||||
LOG_ERROR(Input, "Failed to open gamepad 0: {}", SDL_GetError());
|
LOG_ERROR(Input, "Failed to open gamepad 0: {}", SDL_GetError());
|
||||||
SDL_free(gamepads);
|
SDL_free(gamepads);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Joystick* joystick = SDL_GetGamepadJoystick(m_gamepad);
|
||||||
|
Uint16 vendor = SDL_GetJoystickVendor(joystick);
|
||||||
|
Uint16 product = SDL_GetJoystickProduct(joystick);
|
||||||
|
|
||||||
|
bool isDualSense = (vendor == 0x054C && product == 0x0CE6);
|
||||||
|
|
||||||
|
LOG_INFO(Input, "Gamepad Vendor: {:04X}, Product: {:04X}", vendor, product);
|
||||||
|
if (isDualSense) {
|
||||||
|
LOG_INFO(Input, "Detected DualSense Controller");
|
||||||
|
}
|
||||||
|
|
||||||
if (Config::getIsMotionControlsEnabled()) {
|
if (Config::getIsMotionControlsEnabled()) {
|
||||||
if (SDL_SetGamepadSensorEnabled(m_gamepad, SDL_SENSOR_GYRO, true)) {
|
if (SDL_SetGamepadSensorEnabled(m_gamepad, SDL_SENSOR_GYRO, true)) {
|
||||||
m_gyro_poll_rate = SDL_GetGamepadSensorDataRate(m_gamepad, SDL_SENSOR_GYRO);
|
m_gyro_poll_rate = SDL_GetGamepadSensorDataRate(m_gamepad, SDL_SENSOR_GYRO);
|
||||||
|
@ -126,12 +141,23 @@ void SDLInputEngine::Init() {
|
||||||
LOG_INFO(Input, "Accel initialized, poll rate: {}", m_accel_poll_rate);
|
LOG_INFO(Input, "Accel initialized, poll rate: {}", m_accel_poll_rate);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Input, "Failed to initialize accel controls for gamepad");
|
LOG_ERROR(Input, "Failed to initialize accel controls for gamepad");
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SDL_free(gamepads);
|
SDL_free(gamepads);
|
||||||
|
|
||||||
int* rgb = Config::GetControllerCustomColor();
|
int* rgb = Config::GetControllerCustomColor();
|
||||||
|
|
||||||
|
if (isDualSense) {
|
||||||
|
if (SDL_SetJoystickLED(joystick, rgb[0], rgb[1], rgb[2]) == 0) {
|
||||||
|
LOG_INFO(Input, "Set DualSense LED to R:{} G:{} B:{}", rgb[0], rgb[1], rgb[2]);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Input, "Failed to set DualSense LED: {}", SDL_GetError());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
SetLightBarRGB(rgb[0], rgb[1], rgb[2]);
|
SetLightBarRGB(rgb[0], rgb[1], rgb[2]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SDLInputEngine::SetLightBarRGB(u8 r, u8 g, u8 b) {
|
void SDLInputEngine::SetLightBarRGB(u8 r, u8 g, u8 b) {
|
||||||
if (m_gamepad) {
|
if (m_gamepad) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue