MayaFlux 0.2.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 132 of file InputManager.cpp.

135{
136 if (!node)
137 return;
138
139 if (binding.hid_vendor_id || binding.hid_product_id) {
140 if (!m_input_service) {
142 "VID/PID binding requires InputService but service not registered");
143 return;
144 }
145
146 auto devices = m_input_service->get_all_devices();
147 auto resolved = resolve_vid_pid(binding, devices);
148 if (resolved) {
149 binding = *resolved;
150 } else {
152 "No device found for VID/PID");
153 return;
154 }
155 }
156
157 if (binding.device_id != 0) {
158 if (!m_input_service) {
160 "Device ID binding requires InputService but service not registered");
161 return;
162 }
163
164 m_input_service->open_device(binding.backend, binding.device_id);
165 }
166
167 {
168 std::lock_guard lock(m_registry_mutex);
169#ifdef MAYAFLUX_PLATFORM_MACOS
170 auto* old_list = m_registrations.load();
171 auto* new_list = new RegistrationList(*old_list);
172 new_list->push_back({ .node = node, .binding = binding });
173 m_registrations.store(new_list);
174 retire_list(old_list);
175#else
176 auto current_list = m_registrations.load();
177 auto new_list = std::make_shared<RegistrationList>(*current_list);
178 new_list->push_back({ .node = node, .binding = binding });
179 m_registrations.store(new_list);
180#endif
181 m_tracked_nodes.push_back(node);
182 }
183
185 "Registered InputNode for backend {} device {}",
186 static_cast<int>(binding.backend), binding.device_id);
187}
#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: