mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 10:02:49 +01:00
Gamepad: rename identifier to serial number
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
typedef struct FFGamepadDevice
|
||||
{
|
||||
FFstrbuf identifier;
|
||||
FFstrbuf serial;
|
||||
FFstrbuf name;
|
||||
uint8_t battery; // 0-100%
|
||||
} FFGamepadDevice;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
static void enumSet(IOHIDDeviceRef value, FFlist* results)
|
||||
{
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(results);
|
||||
ffStrbufInit(&device->identifier);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -18,9 +18,9 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results)
|
||||
CFStringRef product = IOHIDDeviceGetProperty(value, CFSTR(kIOHIDProductKey));
|
||||
if (device->name.length)
|
||||
{
|
||||
ffCfStrGetString(product, &device->identifier);
|
||||
ffCfStrGetString(product, &device->serial);
|
||||
ffStrbufAppendC(&device->name, ' ');
|
||||
ffStrbufAppend(&device->name, &device->identifier);
|
||||
ffStrbufAppend(&device->name, &device->serial);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -28,7 +28,7 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results)
|
||||
}
|
||||
|
||||
CFStringRef serialNumber = IOHIDDeviceGetProperty(value, CFSTR(kIOHIDSerialNumberKey));
|
||||
ffCfStrGetString(serialNumber, &device->identifier);
|
||||
ffCfStrGetString(serialNumber, &device->serial);
|
||||
}
|
||||
|
||||
const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
|
||||
|
||||
@@ -42,7 +42,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
|
||||
if (ioctl(fd, USB_GET_DEVICEINFO, &di) != -1)
|
||||
{
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
ffStrbufInitS(&device->identifier, di.udi_serial);
|
||||
ffStrbufInitS(&device->serial, di.udi_serial);
|
||||
ffStrbufInitF(&device->name, "%s %s", di.udi_vendor, di.udi_product);
|
||||
device->battery = 0;
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path)
|
||||
{
|
||||
uint32_t baseLen = path->length;
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
ffStrbufInit(&device->identifier);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInitMove(&device->name, name);
|
||||
device->battery = 0;
|
||||
|
||||
ffStrbufAppendS(path, "uniq");
|
||||
if (ffAppendFileBuffer(path->chars, &device->identifier))
|
||||
ffStrbufTrimRightSpace(&device->identifier);
|
||||
if (ffAppendFileBuffer(path->chars, &device->serial))
|
||||
ffStrbufTrimRightSpace(&device->serial);
|
||||
|
||||
ffStrbufSubstrBefore(path, baseLen);
|
||||
ffStrbufAppendS(path, "device/power_supply/"); // /sys/class/input/jsX/device/device/power_supply
|
||||
|
||||
@@ -96,7 +96,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
|
||||
continue;
|
||||
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
ffStrbufInit(&device->identifier);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -142,14 +142,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
|
||||
|
||||
wchar_t serialNumber[127] = L"";
|
||||
if (HidD_GetSerialNumberString(hHidFile, serialNumber, sizeof(serialNumber)))
|
||||
ffStrbufSetWS(&device->identifier, serialNumber);
|
||||
else if (caps.FeatureReportByteLength >= 6)
|
||||
{
|
||||
uint8_t* featureBuffer = malloc(caps.FeatureReportByteLength);
|
||||
featureBuffer[0] = 18;
|
||||
if (HidD_GetFeature(hHidFile, featureBuffer, caps.FeatureReportByteLength))
|
||||
ffStrbufSetF(&device->identifier, "%02X:%02X:%02X:%02X:%02X:%02X", featureBuffer[0], featureBuffer[1], featureBuffer[2], featureBuffer[3], featureBuffer[4], featureBuffer[5]);
|
||||
}
|
||||
ffStrbufSetWS(&device->serial, serialNumber);
|
||||
|
||||
if (
|
||||
(rdi.hid.dwVendorId == 0x054C && (
|
||||
|
||||
Reference in New Issue
Block a user