Fix hid_pad_handler

This commit is contained in:
RipleyTom 2023-03-10 14:05:08 +01:00 committed by Megamouse
parent 1b7b59466d
commit ec8cb1668c
2 changed files with 4 additions and 4 deletions

View file

@ -126,7 +126,7 @@ void hid_pad_handler<Device>::enumerate_devices()
{ {
Timer timer; Timer timer;
std::set<std::string> device_paths; std::set<std::string> device_paths;
std::map<std::string, std::wstring_view> serials; std::map<std::string, std::wstring> serials;
for (const auto& [vid, pid] : m_ids) for (const auto& [vid, pid] : m_ids)
{ {
@ -140,7 +140,7 @@ void hid_pad_handler<Device>::enumerate_devices()
continue; continue;
} }
device_paths.insert(dev_info->path); device_paths.insert(dev_info->path);
serials[dev_info->path] = dev_info->serial_number ? std::wstring_view(dev_info->serial_number) : std::wstring_view{}; serials[dev_info->path] = dev_info->serial_number ? std::wstring(dev_info->serial_number) : std::wstring();
dev_info = dev_info->next; dev_info = dev_info->next;
} }
hid_free_enumeration(head); hid_free_enumeration(head);
@ -149,7 +149,7 @@ void hid_pad_handler<Device>::enumerate_devices()
std::lock_guard lock(m_enumeration_mutex); std::lock_guard lock(m_enumeration_mutex);
m_new_enumerated_devices = device_paths; m_new_enumerated_devices = device_paths;
m_enumerated_serials = serials; m_enumerated_serials = std::move(serials);
} }
template <class Device> template <class Device>

View file

@ -78,7 +78,7 @@ protected:
std::set<std::string> m_last_enumerated_devices; std::set<std::string> m_last_enumerated_devices;
std::set<std::string> m_new_enumerated_devices; std::set<std::string> m_new_enumerated_devices;
std::map<std::string, std::wstring_view> m_enumerated_serials; std::map<std::string, std::wstring> m_enumerated_serials;
std::mutex m_enumeration_mutex; std::mutex m_enumeration_mutex;
std::unique_ptr<named_thread<std::function<void()>>> m_enumeration_thread; std::unique_ptr<named_thread<std::function<void()>>> m_enumeration_thread;