12#ifdef MAYAFLUX_PLATFORM_MACOS
15 : m_registrations(std::make_shared<const RegistrationList>())
18#ifdef MAYAFLUX_PLATFORM_MACOS
19 for (
auto& hp : m_hazard_ptrs) {
25 "InputManager created");
34#ifdef MAYAFLUX_PLATFORM_MACOS
47 "InputManager already running");
57 "InputManager requires InputService but service not registered");
67 "InputManager started");
100 "Input queue full, dropping oldest event");
112 bool any_pushed =
false;
113 for (
const auto& value : values) {
118 "Input queue full during batch, dropping oldest events");
133 const std::shared_ptr<Nodes::Input::InputNode>& node,
142 "VID/PID binding requires InputService but service not registered");
152 "No device found for VID/PID");
160 "Device ID binding requires InputService but service not registered");
169#ifdef MAYAFLUX_PLATFORM_MACOS
172 new_list->push_back({ .node = node, .binding = binding });
174 retire_list(old_list);
177 auto new_list = std::make_shared<RegistrationList>(*current_list);
178 new_list->push_back({ .node = node, .binding = binding });
185 "Registered InputNode for backend {} device {}",
191 const std::vector<InputDeviceInfo>& devices)
const
193 for (
const auto& dev : devices) {
194 if (dev.backend_type != binding.
backend)
200 if (vid_match && pid_match) {
220#ifdef MAYAFLUX_PLATFORM_MACOS
225 std::remove_if(new_list->begin(), new_list->end(),
227 auto locked = reg.node.lock();
228 return !locked || locked == node;
233 retire_list(old_list);
236 auto new_list = std::make_shared<RegistrationList>(*current_list);
239 std::remove_if(new_list->begin(), new_list->end(),
241 auto locked = reg.node.lock();
242 return !locked || locked == node;
254 "Unregistered InputNode");
261#ifdef MAYAFLUX_PLATFORM_MACOS
264 retire_list(old_list);
272 "Unregistered all InputNodes (Registry swapped to empty)");
277#ifdef MAYAFLUX_PLATFORM_MACOS
279 size_t slot = m_hazard_counter.fetch_add(1) % MAX_READERS;
283 m_hazard_ptrs[slot].store(current);
286 size_t count = current->size();
287 m_hazard_ptrs[slot].store(
nullptr);
296 return m_queue.snapshot().size();
306 "Processing thread started");
311 while (
auto value =
m_queue.pop()) {
325 "Processing thread exiting");
330#ifdef MAYAFLUX_PLATFORM_MACOS
332 size_t slot = m_hazard_counter.fetch_add(1) % MAX_READERS;
337 m_hazard_ptrs[slot].store(current_regs);
341 for (
const auto& reg : *current_regs) {
342 auto node = reg.node.lock();
347 node->process_input(value);
352 m_hazard_ptrs[slot].store(
nullptr);
356 for (
const auto& reg : *current_regs) {
357 auto node = reg.node.lock();
362 node->process_input(value);
381 const auto& midi = value.
as_midi();
400 const auto& osc = value.
as_osc();
415#ifdef MAYAFLUX_PLATFORM_MACOS
416void InputManager::retire_list(
const RegistrationList* list)
419 for (
const auto& hp : m_hazard_ptrs) {
420 if (hp.load() == list) {
#define MF_INFO(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
@ OSC
Open Sound Control (network)
@ MIDI
MIDI controllers and instruments.
@ InputManagement
Input management (Core::InputManager)
@ Init
Engine/subsystem initialization.
@ AsyncIO
Async I/O operations ( network, streaming)
@ Core
Core engine, backend, subsystems.