Update to spice2x-26-02-17 (pre-apply)
> broken commit
This commit is contained in:
+41
-18
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "piuio.h"
|
||||
#include "touch.h"
|
||||
#include "acio/mdxf/mdxf_poll.h"
|
||||
|
||||
extern "C" {
|
||||
#include "external/usbhidusage/usb-hid-usage.h"
|
||||
@@ -347,40 +348,38 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
|
||||
if (hid_handle != INVALID_HANDLE_VALUE) {
|
||||
|
||||
// check manufacturer string
|
||||
std::wstring man_ws;
|
||||
std::string man_ws;
|
||||
wchar_t man_str_buffer[256] {};
|
||||
if (HidD_GetManufacturerString(hid_handle, man_str_buffer, sizeof(man_str_buffer))) {
|
||||
man_ws = std::wstring(man_str_buffer);
|
||||
man_ws = wchar_to_u8(man_str_buffer);
|
||||
}
|
||||
|
||||
// get product string
|
||||
std::wstring prod_ws;
|
||||
std::string prod_ws;
|
||||
wchar_t prod_str_buffer[256] {};
|
||||
if (HidD_GetProductString(hid_handle, prod_str_buffer, sizeof(prod_str_buffer))) {
|
||||
prod_ws = std::wstring(prod_str_buffer);
|
||||
prod_ws = wchar_to_u8(prod_str_buffer);
|
||||
}
|
||||
|
||||
// For Bluetooth LE HID devices (e.g., newer Xbox controllers) HidD_GetProductString
|
||||
// and HidD_GetManufacturerString will return blank strings.
|
||||
// https://docs.microsoft.com/en-us/answers/questions/401236/hidd-getproductstring-with-ble-hid-device.html
|
||||
if (man_ws.empty() && prod_ws.empty()) {
|
||||
prod_ws = s2ws(device_description);
|
||||
prod_ws = device_description;
|
||||
}
|
||||
|
||||
// build desc string
|
||||
std::wstring desc_ws;
|
||||
std::string desc_ws;
|
||||
if (string_begins_with(prod_ws, man_ws)) {
|
||||
desc_ws = prod_ws;
|
||||
} else {
|
||||
desc_ws = man_ws;
|
||||
if (!man_ws.empty() && !prod_ws.empty()) {
|
||||
desc_ws += L" ";
|
||||
desc_ws += " ";
|
||||
}
|
||||
desc_ws += prod_ws;
|
||||
}
|
||||
|
||||
// convert to normal string
|
||||
new_device.desc = ws2s(desc_ws);
|
||||
new_device.desc = desc_ws;
|
||||
|
||||
// get attributes
|
||||
if (!HidD_GetAttributes(hid_handle, &hid_attributes)) {
|
||||
@@ -1148,7 +1147,7 @@ std::string rawinput::RawInputManager::rawinput_get_device_description(const raw
|
||||
|
||||
// get property
|
||||
DWORD desc_size = 0;
|
||||
if (SetupDiGetDeviceRegistryProperty(
|
||||
if (SetupDiGetDeviceRegistryPropertyW(
|
||||
devinfo, &devinfo_data, SPDRP_DEVICEDESC, nullptr, nullptr, 0, &desc_size))
|
||||
{
|
||||
continue;
|
||||
@@ -1160,14 +1159,32 @@ std::string rawinput::RawInputManager::rawinput_get_device_description(const raw
|
||||
// allocate buffer
|
||||
auto desc_data = std::make_unique<BYTE[]>(desc_size);
|
||||
|
||||
if (!SetupDiGetDeviceRegistryProperty(
|
||||
if (!SetupDiGetDeviceRegistryPropertyW(
|
||||
devinfo, &devinfo_data, SPDRP_DEVICEDESC, nullptr, desc_data.get(), desc_size, nullptr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// kthxbye
|
||||
device_description = std::string(reinterpret_cast<char *>(desc_data.get()));
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1499,7 +1516,7 @@ LRESULT CALLBACK rawinput::RawInputManager::input_wnd_proc(
|
||||
}
|
||||
|
||||
// get input time
|
||||
double input_time = get_performance_seconds();
|
||||
const auto input_time = get_performance_seconds();
|
||||
|
||||
// lock device
|
||||
device.mutex->lock();
|
||||
@@ -1827,7 +1844,13 @@ LRESULT CALLBACK rawinput::RawInputManager::input_wnd_proc(
|
||||
|
||||
// free device
|
||||
device.mutex->unlock();
|
||||
|
||||
// don't iterate through the other devices
|
||||
break;
|
||||
}
|
||||
|
||||
// update controller state ring buffers (DDR/MDXF)
|
||||
mdxf_poll(true);
|
||||
|
||||
// call the default window handler for cleanup
|
||||
DefWindowProc(hWnd, msg, wparam, lParam);
|
||||
@@ -1922,7 +1945,7 @@ void CALLBACK rawinput::RawInputManager::input_midi_proc(HMIDIIN hMidiIn, UINT w
|
||||
}
|
||||
|
||||
// get input time
|
||||
auto input_time = get_performance_seconds();
|
||||
const auto input_time = get_performance_seconds();
|
||||
|
||||
// lock device
|
||||
std::lock_guard<std::mutex> lock(*device.mutex);
|
||||
@@ -1963,7 +1986,7 @@ void CALLBACK rawinput::RawInputManager::input_midi_proc(HMIDIIN hMidiIn, UINT w
|
||||
device.midiInfo->v2_last_off_time[midi_index] = get_performance_milliseconds();
|
||||
device.updated = true;
|
||||
}
|
||||
// for v2_drum, NOTE ON is ignored
|
||||
// for v2_drum, NOTE OFF is ignored
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2812,4 +2835,4 @@ void rawinput::RawInputManager::remove_callback_midi(void * data, const std::fun
|
||||
[data, callback](MidiCallback const &cb) {
|
||||
return cb.data == data && cb.f.target<void>() == callback.target<void>();
|
||||
}), this->callback_midi.end());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user