DS4: add ZEROPLUS Brook Mars controller

This commit is contained in:
Megamouse 2021-03-30 10:58:11 +02:00
parent 7df7ac57cc
commit 877dd1f98d
5 changed files with 22 additions and 18 deletions

View File

@ -41,11 +41,10 @@ struct ds3_output_report
constexpr u8 battery_capacity[] = {0, 1, 25, 50, 75, 100}; constexpr u8 battery_capacity[] = {0, 1, 25, 50, 75, 100};
constexpr u16 DS3_VID = 0x054C; constexpr id_pair SONY_DS3_ID_0 = {0x054C, 0x0268};
constexpr u16 DS3_PID = 0x0268;
ds3_pad_handler::ds3_pad_handler() 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 = button_list =
{ {

View File

@ -4,10 +4,11 @@
LOG_CHANNEL(ds4_log, "DS4"); LOG_CHANNEL(ds4_log, "DS4");
constexpr u16 DS4_VID = 0x054C; constexpr id_pair SONY_DS4_ID_0 = {0x054C, 0xBA0};
constexpr u16 DS4_PID_0 = 0xBA0; constexpr id_pair SONY_DS4_ID_1 = {0x054C, 0x5C4};
constexpr u16 DS4_PID_1 = 0x5C4; constexpr id_pair SONY_DS4_ID_2 = {0x054C, 0x09CC};
constexpr u16 DS4_PID_2 = 0x09CC;
constexpr id_pair ZEROPLUS_ID_0 = {0x0C12, 0x0E20};
namespace namespace
{ {
@ -71,7 +72,7 @@ namespace
} }
ds4_pad_handler::ds4_pad_handler() ds4_pad_handler::ds4_pad_handler()
: hid_pad_handler<DS4Device>(pad_handler::ds4, DS4_VID, {DS4_PID_0, DS4_PID_1, DS4_PID_2}) : hid_pad_handler<DS4Device>(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 // Unique names for the config files and our pad settings dialog
button_list = button_list =

View File

@ -29,8 +29,7 @@ namespace
constexpr u32 DUALSENSE_COMMON_REPORT_SIZE = 47; constexpr u32 DUALSENSE_COMMON_REPORT_SIZE = 47;
constexpr u32 DUALSENSE_INPUT_REPORT_GYRO_X_OFFSET = 15; constexpr u32 DUALSENSE_INPUT_REPORT_GYRO_X_OFFSET = 15;
constexpr u16 DUALSENSE_VID = 0x054C; constexpr id_pair SONY_DUALSENSE_ID_0 = {0x054C, 0x0CE6};
constexpr u16 DUALSENSE_PID = 0x0CE6;
enum enum
{ {
@ -90,7 +89,7 @@ namespace
} }
dualsense_pad_handler::dualsense_pad_handler() dualsense_pad_handler::dualsense_pad_handler()
: hid_pad_handler<DualSenseDevice>(pad_handler::dualsense, DUALSENSE_VID, {DUALSENSE_PID}) : hid_pad_handler<DualSenseDevice>(pad_handler::dualsense, {SONY_DUALSENSE_ID_0})
{ {
// Unique names for the config files and our pad settings dialog // Unique names for the config files and our pad settings dialog
button_list = button_list =

View File

@ -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}; static u8 s_hid_instances{0};
template <class Device> template <class Device>
hid_pad_handler<Device>::hid_pad_handler(pad_handler type, u16 vid, std::vector<u16> pids) hid_pad_handler<Device>::hid_pad_handler(pad_handler type, std::vector<id_pair> ids)
: PadHandlerBase(type), m_vid(vid), m_pids(std::move(pids)) : PadHandlerBase(type), m_ids(std::move(ids))
{ {
std::scoped_lock lock(s_hid_mutex); std::scoped_lock lock(s_hid_mutex);
ensure(s_hid_instances++ < 255); ensure(s_hid_instances++ < 255);
@ -100,9 +100,9 @@ void hid_pad_handler<Device>::enumerate_devices()
std::set<std::string> device_paths; std::set<std::string> device_paths;
std::map<std::string, std::wstring_view> serials; std::map<std::string, std::wstring_view> 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; hid_device_info* head = dev_info;
while (dev_info) while (dev_info)
{ {

View File

@ -44,11 +44,17 @@ public:
u8 cable_state{0}; u8 cable_state{0};
}; };
struct id_pair
{
u16 m_vid = 0;
u16 m_pid = 0;
};
template <class Device> template <class Device>
class hid_pad_handler : public PadHandlerBase class hid_pad_handler : public PadHandlerBase
{ {
public: public:
hid_pad_handler(pad_handler type, u16 vid, std::vector<u16> pids); hid_pad_handler(pad_handler type, std::vector<id_pair> ids);
~hid_pad_handler(); ~hid_pad_handler();
bool Init() override; bool Init() override;
@ -65,8 +71,7 @@ protected:
CRCPP::CRC::Table<u32, 32> crcTable{CRCPP::CRC::CRC_32()}; CRCPP::CRC::Table<u32, 32> crcTable{CRCPP::CRC::CRC_32()};
u16 m_vid; std::vector<id_pair> m_ids;
std::vector<u16> m_pids;
// pseudo 'controller id' to keep track of unique controllers // pseudo 'controller id' to keep track of unique controllers
std::map<std::string, std::shared_ptr<Device>> m_controllers; std::map<std::string, std::shared_ptr<Device>> m_controllers;