rawinput: append HID product string to description (#458)

## Link to GitHub Issue, if one exists
N/A

## Description of change
Append product strings to descriptions. Useful for differentiating
devices in the analog binding dialog.

Before | After
------ | ------

![0](https://github.com/user-attachments/assets/803c5a69-2ed9-40f8-a147-f1b4f3a7e220)
|
![1](https://github.com/user-attachments/assets/7407a3cc-eebb-4529-be43-2eb177645bb7)

## Testing
`spice64 -iidx -cfg` ⟶ Analogs ⟶ Bind
This commit is contained in:
llm96
2025-12-17 23:03:16 +00:00
committed by GitHub
parent 71b144918c
commit 83aa907b13
+19 -1
View File
@@ -1165,8 +1165,26 @@ std::string rawinput::RawInputManager::rawinput_get_device_description(const raw
continue;
}
// kthxbye
// base description
device_description = wchar_to_u8(reinterpret_cast<PWCHAR>(desc_data.get()));
// append HID product string if available
HANDLE hid_handle = CreateFile(
device_path.c_str(), 0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
OPEN_EXISTING,
0, nullptr);
if (hid_handle != INVALID_HANDLE_VALUE) {
wchar_t product_buffer[126] {};
if (HidD_GetProductString(hid_handle, product_buffer, sizeof(product_buffer))) {
auto const product_str = wchar_to_u8(product_buffer);
if (!product_str.empty() && device_description != product_str) {
device_description += " - " + product_str;
}
}
CloseHandle(hid_handle);
}
}
}
}