From 877dd1f98d0865b753e86dda51cf2cff0f5897cb Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 30 Mar 2021 10:58:11 +0200 Subject: [PATCH] DS4: add ZEROPLUS Brook Mars controller --- rpcs3/Input/ds3_pad_handler.cpp | 5 ++--- rpcs3/Input/ds4_pad_handler.cpp | 11 ++++++----- rpcs3/Input/dualsense_pad_handler.cpp | 5 ++--- rpcs3/Input/hid_pad_handler.cpp | 8 ++++---- rpcs3/Input/hid_pad_handler.h | 11 ++++++++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/rpcs3/Input/ds3_pad_handler.cpp b/rpcs3/Input/ds3_pad_handler.cpp index cc1aa85d10..0423d543d7 100644 --- a/rpcs3/Input/ds3_pad_handler.cpp +++ b/rpcs3/Input/ds3_pad_handler.cpp @@ -41,11 +41,10 @@ struct ds3_output_report constexpr u8 battery_capacity[] = {0, 1, 25, 50, 75, 100}; -constexpr u16 DS3_VID = 0x054C; -constexpr u16 DS3_PID = 0x0268; +constexpr id_pair SONY_DS3_ID_0 = {0x054C, 0x0268}; ds3_pad_handler::ds3_pad_handler() - : hid_pad_handler(pad_handler::ds3, DS3_VID, {DS3_PID}) + : hid_pad_handler(pad_handler::ds3, {SONY_DS3_ID_0}) { button_list = { diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index 85ea745613..d255fa8505 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -4,10 +4,11 @@ LOG_CHANNEL(ds4_log, "DS4"); -constexpr u16 DS4_VID = 0x054C; -constexpr u16 DS4_PID_0 = 0xBA0; -constexpr u16 DS4_PID_1 = 0x5C4; -constexpr u16 DS4_PID_2 = 0x09CC; +constexpr id_pair SONY_DS4_ID_0 = {0x054C, 0xBA0}; +constexpr id_pair SONY_DS4_ID_1 = {0x054C, 0x5C4}; +constexpr id_pair SONY_DS4_ID_2 = {0x054C, 0x09CC}; + +constexpr id_pair ZEROPLUS_ID_0 = {0x0C12, 0x0E20}; namespace { @@ -71,7 +72,7 @@ namespace } ds4_pad_handler::ds4_pad_handler() - : hid_pad_handler(pad_handler::ds4, DS4_VID, {DS4_PID_0, DS4_PID_1, DS4_PID_2}) + : hid_pad_handler(pad_handler::ds4, {SONY_DS4_ID_0, SONY_DS4_ID_1, SONY_DS4_ID_2, ZEROPLUS_ID_0}) { // Unique names for the config files and our pad settings dialog button_list = diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index 241b4f8aba..93a90b00af 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -29,8 +29,7 @@ namespace constexpr u32 DUALSENSE_COMMON_REPORT_SIZE = 47; constexpr u32 DUALSENSE_INPUT_REPORT_GYRO_X_OFFSET = 15; - constexpr u16 DUALSENSE_VID = 0x054C; - constexpr u16 DUALSENSE_PID = 0x0CE6; + constexpr id_pair SONY_DUALSENSE_ID_0 = {0x054C, 0x0CE6}; enum { @@ -90,7 +89,7 @@ namespace } dualsense_pad_handler::dualsense_pad_handler() - : hid_pad_handler(pad_handler::dualsense, DUALSENSE_VID, {DUALSENSE_PID}) + : hid_pad_handler(pad_handler::dualsense, {SONY_DUALSENSE_ID_0}) { // Unique names for the config files and our pad settings dialog button_list = diff --git a/rpcs3/Input/hid_pad_handler.cpp b/rpcs3/Input/hid_pad_handler.cpp index 7b7c4aa911..80be86eea6 100644 --- a/rpcs3/Input/hid_pad_handler.cpp +++ b/rpcs3/Input/hid_pad_handler.cpp @@ -13,8 +13,8 @@ static std::mutex s_hid_mutex; // hid_pad_handler is created by pad_thread and p static u8 s_hid_instances{0}; template -hid_pad_handler::hid_pad_handler(pad_handler type, u16 vid, std::vector pids) - : PadHandlerBase(type), m_vid(vid), m_pids(std::move(pids)) +hid_pad_handler::hid_pad_handler(pad_handler type, std::vector ids) + : PadHandlerBase(type), m_ids(std::move(ids)) { std::scoped_lock lock(s_hid_mutex); ensure(s_hid_instances++ < 255); @@ -100,9 +100,9 @@ void hid_pad_handler::enumerate_devices() std::set device_paths; std::map serials; - for (const auto& pid : m_pids) + for (const auto& [vid, pid] : m_ids) { - hid_device_info* dev_info = hid_enumerate(m_vid, pid); + hid_device_info* dev_info = hid_enumerate(vid, pid); hid_device_info* head = dev_info; while (dev_info) { diff --git a/rpcs3/Input/hid_pad_handler.h b/rpcs3/Input/hid_pad_handler.h index c27a638d7a..2ef0f9613e 100644 --- a/rpcs3/Input/hid_pad_handler.h +++ b/rpcs3/Input/hid_pad_handler.h @@ -44,11 +44,17 @@ public: u8 cable_state{0}; }; +struct id_pair +{ + u16 m_vid = 0; + u16 m_pid = 0; +}; + template class hid_pad_handler : public PadHandlerBase { public: - hid_pad_handler(pad_handler type, u16 vid, std::vector pids); + hid_pad_handler(pad_handler type, std::vector ids); ~hid_pad_handler(); bool Init() override; @@ -65,8 +71,7 @@ protected: CRCPP::CRC::Table crcTable{CRCPP::CRC::CRC_32()}; - u16 m_vid; - std::vector m_pids; + std::vector m_ids; // pseudo 'controller id' to keep track of unique controllers std::map> m_controllers;