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

◆ poll_device()

void MayaFlux::Core::HIDBackend::poll_device ( uint32_t  device_id,
HIDDeviceState state 
)
private

Definition at line 410 of file HIDBackend.cpp.

411{
412 int bytes_read = hid_read_timeout(
413 state.handle, state.read_buffer.data(),
414 state.read_buffer.size(), m_config.poll_timeout_ms);
415
416 if (bytes_read > 0) {
417 std::span<const uint8_t> report(state.read_buffer.data(), bytes_read);
418 InputValue value = parse_hid_report(device_id, report);
419 notify_input(value);
420 } else if (bytes_read < 0) {
422 "HID read error on device {}", device_id);
423 state.active.store(false);
424 }
425 // bytes_read == 0 means timeout (no data), which is normal
426}
#define MF_WARN(comp, ctx,...)
void notify_input(const InputValue &value)
InputValue parse_hid_report(uint32_t device_id, std::span< const uint8_t > report)
@ InputBackend
Input device backend (HID, MIDI, OSC)
@ Core
Core engine, backend, subsystems.
int poll_timeout_ms
Timeout for hid_read_timeout.

References MayaFlux::Core::HIDDeviceState::active, MayaFlux::Journal::Core, MayaFlux::Core::HIDDeviceState::handle, MayaFlux::Journal::InputBackend, m_config, MF_WARN, notify_input(), parse_hid_report(), MayaFlux::Core::HIDBackend::Config::poll_timeout_ms, and MayaFlux::Core::HIDDeviceState::read_buffer.

Referenced by poll_thread_func().

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