|
MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
|
HIDAPI-based HID input backend. More...
#include <HIDBackend.hpp>
Inheritance diagram for MayaFlux::Core::HIDBackend:
Collaboration diagram for MayaFlux::Core::HIDBackend:Classes | |
| struct | Config |
| Configuration for HID backend. More... | |
Public Member Functions | |
| HIDBackend () | |
| HIDBackend (Config config) | |
| ~HIDBackend () override | |
| HIDBackend (const HIDBackend &)=delete | |
| HIDBackend & | operator= (const HIDBackend &)=delete |
| HIDBackend (HIDBackend &&)=delete | |
| HIDBackend & | operator= (HIDBackend &&)=delete |
| bool | initialize () override |
| Initialize the input backend. | |
| void | start () override |
| Start listening for input events. | |
| void | stop () override |
| Stop listening for input events. | |
| void | shutdown () override |
| Shutdown and release all resources. | |
| bool | is_initialized () const override |
| Check if backend is initialized. | |
| bool | is_running () const override |
| Check if backend is actively listening. | |
| std::vector< InputDeviceInfo > | get_devices () const override |
| Get list of available devices. | |
| size_t | refresh_devices () override |
| Refresh the device list. | |
| bool | open_device (uint32_t device_id) override |
| Open a device for input. | |
| void | close_device (uint32_t device_id) override |
| Close a previously opened device. | |
| bool | is_device_open (uint32_t device_id) const override |
| Check if a device is currently open. | |
| std::vector< uint32_t > | get_open_devices () const override |
| Get list of currently open device IDs. | |
| void | set_input_callback (InputCallback callback) override |
| Register callback for input values. | |
| void | set_device_callback (DeviceCallback callback) override |
| Register callback for device connect/disconnect events. | |
| InputType | get_type () const override |
| Get backend type. | |
| std::string | get_name () const override |
| Get backend name/identifier string. | |
| std::string | get_version () const override |
| Get backend version string. | |
| void | add_device_filter (const HIDDeviceFilter &filter) |
| Add a device filter for enumeration. | |
| void | clear_device_filters () |
| Clear all device filters. | |
| std::optional< HIDDeviceInfoExt > | get_device_info_ext (uint32_t device_id) const |
| Get extended HID device info. | |
| int | send_feature_report (uint32_t device_id, std::span< const uint8_t > data) |
| Send a feature report to a device. | |
| int | get_feature_report (uint32_t device_id, uint8_t report_id, std::span< uint8_t > buffer) |
| Get a feature report from a device. | |
| int | write (uint32_t device_id, std::span< const uint8_t > data) |
| Send an output report to a device. | |
Public Member Functions inherited from MayaFlux::Core::IInputBackend | |
| virtual | ~IInputBackend ()=default |
Private Member Functions | |
| void | poll_thread_func () |
| void | poll_device (uint32_t device_id, HIDDeviceState &state) |
| bool | matches_any_filter (uint16_t vid, uint16_t pid, uint16_t usage_page, uint16_t usage) const |
| uint32_t | find_or_assign_device_id (const std::string &path) |
| void | notify_input (const InputValue &value) |
| void | notify_device_change (const InputDeviceInfo &info, bool connected) |
| InputValue | parse_hid_report (uint32_t device_id, std::span< const uint8_t > report) |
Private Attributes | |
| Config | m_config |
| std::atomic< bool > | m_initialized { false } |
| std::atomic< bool > | m_running { false } |
| std::atomic< bool > | m_stop_requested { false } |
| std::mutex | m_devices_mutex |
| std::unordered_map< uint32_t, HIDDeviceInfoExt > | m_enumerated_devices |
| std::unordered_map< uint32_t, std::shared_ptr< HIDDeviceState > > | m_open_devices |
| uint32_t | m_next_device_id { 1 } |
| std::thread | m_poll_thread |
| InputCallback | m_input_callback |
| DeviceCallback | m_device_callback |
| std::mutex | m_callback_mutex |
HIDAPI-based HID input backend.
Provides access to generic HID devices including:
Uses HIDAPI for cross-platform HID communication.
Threading model:
Example usage:
Definition at line 66 of file HIDBackend.hpp.