Fixed detection for Dualsense

This commit is contained in:
Flora Aubry 2023-03-01 18:06:00 +00:00 committed by Adam Honse
parent a4f86032a5
commit c02d401b1d
3 changed files with 6 additions and 13 deletions

View file

@ -10,19 +10,11 @@
#include <hidapi/hidapi.h>
#include "SonyDualSenseController.h"
SonyDualSenseController::SonyDualSenseController(hid_device * device_handle, const char * device_path)
SonyDualSenseController::SonyDualSenseController(hid_device * device_handle, const char * device_path, bool is_bluetooth)
{
dev = device_handle;
location = device_path;
unsigned char usb_buf[SONY_DUALSENSE_BT_PACKET_SIZE];
memset(usb_buf, 0x00, SONY_DUALSENSE_BT_PACKET_SIZE);
usb_buf[0] = 0x31;
int bytes = hid_write(dev, usb_buf, SONY_DUALSENSE_BT_PACKET_SIZE);
is_bluetooth = bytes > 0;
this->is_bluetooth = is_bluetooth;
}
SonyDualSenseController::~SonyDualSenseController()

View file

@ -31,7 +31,7 @@ enum
class SonyDualSenseController
{
public:
SonyDualSenseController(hid_device * device_handle, const char * device_path);
SonyDualSenseController(hid_device * device_handle, const char * device_path, bool is_bluetooth);
~SonyDualSenseController();
std::string GetLocation();

View file

@ -37,7 +37,8 @@ void DetectSonyDualSenseControllers(hid_device_info* info, const std::string&)
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SonyDualSenseController* controller = new SonyDualSenseController(dev, info->path);
bool is_bluetooth = info->interface_number == -1;
SonyDualSenseController* controller = new SonyDualSenseController(dev, info->path, is_bluetooth);
RGBController_SonyDualSense* rgb_controller = new RGBController_SonyDualSense(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
@ -47,4 +48,4 @@ void DetectSonyDualSenseControllers(hid_device_info* info, const std::string&)
REGISTER_HID_DETECTOR("Sony DualShock 4", DetectSonyDS4Controllers, SONY_VID, SONY_DS4_V1_PID);
REGISTER_HID_DETECTOR("Sony DualShock 4", DetectSonyDS4Controllers, SONY_VID, SONY_DS4_V2_PID);
REGISTER_HID_DETECTOR("Sony DualShock 4", DetectSonyDS4Controllers, SONY_VID, SONY_DS4_RECEIVER_PID);
REGISTER_HID_DETECTOR("Sony DualSense" , DetectSonyDualSenseControllers, SONY_VID, SONY_DUALSENSE_PID);
REGISTER_HID_DETECTOR("Sony DualSense", DetectSonyDualSenseControllers, SONY_VID, SONY_DUALSENSE_PID);