diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index a1cf83a3cd..e81008fba3 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -606,8 +606,8 @@ int ds4_pad_handler::send_output_report(const std::shared_ptr& device if (!device) return -2; - auto p_profile = device->config; - if (p_profile == nullptr) + auto config = device->config; + if (config == nullptr) return -2; // hid_write and hid_write_control return -1 on error std::array outputBuf{0}; @@ -619,9 +619,9 @@ int ds4_pad_handler::send_output_report(const std::shared_ptr& device outputBuf[3] = 0x07; outputBuf[6] = device->smallVibrate; outputBuf[7] = device->largeVibrate; - outputBuf[8] = p_profile->colorR; // red - outputBuf[9] = p_profile->colorG; // green - outputBuf[10] = p_profile->colorB; // blue + outputBuf[8] = config->colorR; // red + outputBuf[9] = config->colorG; // green + outputBuf[10] = config->colorB; // blue // alternating blink states with values 0-255: only setting both to zero disables blinking // 255 is roughly 2 seconds, so setting both values to 255 results in a 4 second interval @@ -646,9 +646,9 @@ int ds4_pad_handler::send_output_report(const std::shared_ptr& device outputBuf[1] = 0x07; outputBuf[4] = device->smallVibrate; outputBuf[5] = device->largeVibrate; - outputBuf[6] = p_profile->colorR; // red - outputBuf[7] = p_profile->colorG; // green - outputBuf[8] = p_profile->colorB; // blue + outputBuf[6] = config->colorR; // red + outputBuf[7] = config->colorG; // green + outputBuf[8] = config->colorB; // blue outputBuf[9] = device->led_delay_on; outputBuf[10] = device->led_delay_off; diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index 2a1f194857..7768edb1d9 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -14,6 +14,15 @@ namespace const u32 DUALSENSE_COMMON_REPORT_SIZE = 47; const u32 DUALSENSE_INPUT_REPORT_GYRO_X_OFFSET = 15; + enum + { + VALID_FLAG_0_COMPATIBLE_VIBRATION = 0x1, + VALID_FLAG_0_HAPTICS_SELECT = 0x2, + VALID_FLAG_1_LIGHTBAR_CONTROL_ENABLE = 0x4, + VALID_FLAG_1_RELEASE_LEDS = 0x8, + VALID_FLAG_2_LIGHTBAR_SETUP_CONTROL_ENABLE = 0x2, + LIGHTBAR_SETUP_LIGHT_OUT = 0x2, + }; struct output_report_common { @@ -115,7 +124,7 @@ dualsense_pad_handler::dualsense_pad_handler() b_has_config = true; b_has_rumble = true; b_has_deadzones = true; - b_has_led = false; + b_has_led = true; b_has_battery = false; m_name_string = "DualSense Pad #"; @@ -911,11 +920,29 @@ int dualsense_pad_handler::send_output_report(const std::shared_ptrlargeVibrate; common.motor_right = device->smallVibrate; + if (device->init_lightbar) + { + device->init_lightbar = false; + + common.valid_flag_2 = VALID_FLAG_2_LIGHTBAR_SETUP_CONTROL_ENABLE; + common.lightbar_setup = LIGHTBAR_SETUP_LIGHT_OUT; // Fade light out. + } + + if (device->update_lightbar) + { + device->update_lightbar = false; + + common.valid_flag_1 |= VALID_FLAG_1_LIGHTBAR_CONTROL_ENABLE; + common.lightbar_r = config->colorR; // red + common.lightbar_g = config->colorG; // green + common.lightbar_b = config->colorB; // blue + } + if (device->btCon) { const u8 seq_tag = (device->bt_sequence << 4) | 0x0; @@ -1002,13 +1029,13 @@ void dualsense_pad_handler::SetPadData(const std::string& padId, u32 largeMotor, } } - // TODO: Set new LED color (see ds4_pad_handler) - + // Set new LED color (see ds4_pad_handler) if (r >= 0 && g >= 0 && b >= 0 && r <= 255 && g <= 255 && b <= 255) { device->config->colorR.set(r); device->config->colorG.set(g); device->config->colorB.set(b); + device->update_lightbar = true; } // Start/Stop the engines :) diff --git a/rpcs3/Input/dualsense_pad_handler.h b/rpcs3/Input/dualsense_pad_handler.h index 15af274a93..429f2d8712 100644 --- a/rpcs3/Input/dualsense_pad_handler.h +++ b/rpcs3/Input/dualsense_pad_handler.h @@ -90,6 +90,8 @@ class dualsense_pad_handler final : public PadHandlerBase bool newVibrateData{true}; u8 largeVibrate{0}; u8 smallVibrate{0}; + bool init_lightbar{true}; + bool update_lightbar{true}; }; const u16 DUALSENSE_VID = 0x054C;