Fill in serial field for all HID controllers using hidapi

This commit is contained in:
Adam Honse
2020-12-03 00:01:42 -06:00
parent 92dc8411d6
commit d19baf1365
101 changed files with 446 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ RGBController_SonyDS4::RGBController_SonyDS4(SonyDS4Controller* dualshock)
type = DEVICE_TYPE_GAMEPAD;
description = "Sony DualShock 4 Device";
location = dualshock->GetLocation();
serial = dualshock->GetSerialString();
mode Direct;
Direct.value = 0;

View File

@@ -36,6 +36,17 @@ std::string SonyDS4Controller::GetLocation()
return("HID: " + location);
}
std::string SonyDS4Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(device_handle, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void SonyDS4Controller::SetColors(unsigned char red, unsigned char green, unsigned char blue)
{
if(is_bluetooth)

View File

@@ -16,6 +16,7 @@ public:
SonyDS4Controller(hid_device * device_handle, const char * device_path);
std::string GetLocation();
std::string GetSerialString();
void SetColors(unsigned char red, unsigned char green, unsigned char blue);