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

◆ register_node()

void MayaFlux::Core::InputManager::register_node ( const std::shared_ptr< Nodes::Input::InputNode > &  node,
InputBinding  binding 
)

Register a node to receive input.

Parameters
nodeThe InputNode to register
bindingSpecifies what input the node wants

Thread-safe. Can be called while processing is active.

Definition at line 135 of file InputManager.cpp.

138{
139 if (!node)
140 return;
141
142 if (binding.hid_vendor_id || binding.hid_product_id) {
143 if (!m_input_service) {
145 "VID/PID binding requires InputService but service not registered");
146 return;
147 }
148
149 auto devices = m_input_service->get_all_devices();
150 auto resolved = resolve_vid_pid(binding, devices);
151 if (resolved) {
152 binding = *resolved;
153 } else {
155 "No device found for VID/PID");
156 return;
157 }
158 }
159
160 if (binding.device_id != 0) {
161 if (!m_input_service) {
163 "Device ID binding requires InputService but service not registered");
164 return;
165 }
166
167 m_input_service->open_device(binding.backend, binding.device_id);
168 }
169
170 {
171 std::lock_guard lock(m_registry_mutex);
172#ifdef MAYAFLUX_PLATFORM_MACOS
173 auto* old_list = m_registrations.load();
174 auto* new_list = new RegistrationList(*old_list);
175 new_list->push_back({ .node = node, .binding = binding });
176 m_registrations.store(new_list);
177 retire_list(old_list);
178#else
179 auto current_list = m_registrations.load();
180 auto new_list = std::make_shared<RegistrationList>(*current_list);
181 new_list->push_back({ .node = node, .binding = binding });
182 m_registrations.store(new_list);
183#endif
184 m_tracked_nodes.push_back(node);
185 }
186
188 "Registered InputNode for backend {} device {}",
189 static_cast<int>(binding.backend), binding.device_id);
190}
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::vector< NodeRegistration > RegistrationList
std::atomic< std::shared_ptr< const RegistrationList > > m_registrations
Registry::Service::InputService * m_input_service
std::optional< InputBinding > resolve_vid_pid(const InputBinding &binding, const std::vector< InputDeviceInfo > &devices) const
std::vector< std::shared_ptr< Nodes::Input::InputNode > > m_tracked_nodes
To keep nodes alive.
@ InputManagement
Input management (Core::InputManager)
@ Core
Core engine, backend, subsystems.
std::function< std::vector< Core::InputDeviceInfo >()> get_all_devices
Query all available input devices across all backends.
std::function< bool(Core::InputType, uint32_t)> open_device
Open a specific input device.

References MayaFlux::Core::InputBinding::backend, MayaFlux::Journal::Core, MayaFlux::Core::InputBinding::device_id, MayaFlux::Registry::Service::InputService::get_all_devices, MayaFlux::Core::InputBinding::hid_product_id, MayaFlux::Core::InputBinding::hid_vendor_id, MayaFlux::Journal::InputManagement, m_input_service, m_registrations, m_registry_mutex, m_tracked_nodes, MF_DEBUG, MF_WARN, MayaFlux::Registry::Service::InputService::open_device, and resolve_vid_pid().

Referenced by MayaFlux::register_input_node().

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