MayaFlux 0.5.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 560 of file TabletBackend.cpp.

561{
562 if (!m_initialized.load()) {
563 return 0;
564 }
565
566 hid_device_info* devs = hid_enumerate(0x0, 0x0);
567
568 for (hid_device_info* cur = devs; cur != nullptr; cur = cur->next) {
570 && cur->usage_page != k_page_digitizer
571 && cur->usage_page != 0)
572 continue;
573
574 std::string path(cur->path);
575
576 {
577 std::lock_guard lock(m_devices_mutex);
578 if (m_devices.find(path) != m_devices.end())
579 continue;
580 }
581
582 std::string name = widen_to_narrow(cur->product_string);
583 if (name.empty())
584 name = "Tablet";
585
586 adopt_device(path, cur->vendor_id, cur->product_id, std::move(name));
587 }
588
589 hid_free_enumeration(devs);
590
591 std::lock_guard lock(m_devices_mutex);
592 return m_tools.size();
593}
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)
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, and MayaFlux::Core::TabletBackend::Config::probe_all_devices.

Referenced by initialize().

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