From 83aa907b1374e5b121a358d3e6e79447a12ffbaf Mon Sep 17 00:00:00 2001 From: llm96 Date: Wed, 17 Dec 2025 23:03:16 +0000 Subject: [PATCH] rawinput: append HID product string to description (#458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- src/spice2x/rawinput/rawinput.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/spice2x/rawinput/rawinput.cpp b/src/spice2x/rawinput/rawinput.cpp index 79a595f..336a231 100644 --- a/src/spice2x/rawinput/rawinput.cpp +++ b/src/spice2x/rawinput/rawinput.cpp @@ -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(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); + } } } }