MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ refresh_devices()

size_t MayaFlux::Core::TabletBackend::refresh_devices ( )
overridevirtual

Refresh the device list.

Returns
Number of devices found

Re-enumerates available devices. May trigger device callbacks for newly connected or disconnected devices.

Implements MayaFlux::Core::IInputBackend.

Definition at line 569 of file TabletBackend.cpp.

570{
571 if (!m_initialized.load()) {
572 return 0;
573 }
574
575 hid_device_info* devs = hid_enumerate(0x0, 0x0);
576
577 for (hid_device_info* cur = devs; cur != nullptr; cur = cur->next) {
579 && cur->usage_page != k_page_digitizer
580 && cur->usage_page != 0)
581 continue;
582
583 std::string path(cur->path);
584
585 {
586 std::lock_guard lock(m_devices_mutex);
587 if (m_devices.find(path) != m_devices.end())
588 continue;
589 }
590
591 std::string name = wide_to_utf8(cur->product_string);
592 if (name.empty())
593 name = "Tablet";
594
595 adopt_device(path, cur->vendor_id, cur->product_id, std::move(name));
596 }
597
598 hid_free_enumeration(devs);
599
600 std::lock_guard lock(m_devices_mutex);
601 return m_tools.size();
602}
std::string name
Definition VKDevice.cpp:123
std::atomic< bool > m_initialized
std::unordered_map< std::string, std::shared_ptr< TabletDevice > > m_devices
std::unordered_map< uint32_t, TabletToolInfo > m_tools
bool adopt_device(const std::string &path, uint16_t vid, uint16_t pid, std::string name)
MAYAFLUX_API std::string wide_to_utf8(const wchar_t *ws)
Encode a null-terminated wide string as UTF-8.
bool probe_all_devices
Read every HID descriptor rather than trusting enumeration.

References adopt_device(), m_config, m_devices, m_devices_mutex, m_initialized, m_tools, name, MayaFlux::Core::TabletBackend::Config::probe_all_devices, and MayaFlux::Core::wide_to_utf8().

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: