15#ifdef MAYAFLUX_PLATFORM_MACOS
18 : m_registrations(std::make_shared<const RegistrationList>())
21#ifdef MAYAFLUX_PLATFORM_MACOS
22 for (
auto& hp : m_hazard_ptrs) {
28 "InputManager created");
37#ifdef MAYAFLUX_PLATFORM_MACOS
50 "InputManager already running");
60 "InputManager requires InputService but service not registered");
70 "InputManager started");
103 "Input queue full, dropping oldest event");
115 bool any_pushed =
false;
116 for (
const auto& value : values) {
121 "Input queue full during batch, dropping oldest events");
136 const std::shared_ptr<Nodes::Input::InputNode>& node,
145 "VID/PID binding requires InputService but service not registered");
155 "No device found for VID/PID");
163 "Device ID binding requires InputService but service not registered");
172#ifdef MAYAFLUX_PLATFORM_MACOS
175 new_list->push_back({ .node = node, .binding = binding });
177 retire_list(old_list);
180 auto new_list = std::make_shared<RegistrationList>(*current_list);
181 new_list->push_back({ .node = node, .binding = binding });
188 "Registered InputNode for backend {} device {}",
194 const std::vector<InputDeviceInfo>& devices)
const
196 for (
const auto& dev : devices) {
197 if (dev.backend_type != binding.
backend)
203 if (vid_match && pid_match) {
223#ifdef MAYAFLUX_PLATFORM_MACOS
228 std::remove_if(new_list->begin(), new_list->end(),
230 auto locked = reg.node.lock();
231 return !locked || locked == node;
236 retire_list(old_list);
239 auto new_list = std::make_shared<RegistrationList>(*current_list);
242 std::remove_if(new_list->begin(), new_list->end(),
244 auto locked = reg.node.lock();
245 return !locked || locked == node;
257 "Unregistered InputNode");
264#ifdef MAYAFLUX_PLATFORM_MACOS
267 retire_list(old_list);
275 "Unregistered all InputNodes (Registry swapped to empty)");
280#ifdef MAYAFLUX_PLATFORM_MACOS
282 size_t slot = m_hazard_counter.fetch_add(1) % MAX_READERS;
286 m_hazard_ptrs[slot].store(current);
289 size_t count = current->size();
290 m_hazard_ptrs[slot].store(
nullptr);
299 return m_queue.snapshot().size();
309 "Processing thread started");
314 while (
auto value =
m_queue.pop()) {
328 "Processing thread exiting");
333#ifdef MAYAFLUX_PLATFORM_MACOS
335 size_t slot = m_hazard_counter.fetch_add(1) % MAX_READERS;
340 m_hazard_ptrs[slot].store(current_regs);
344 for (
const auto& reg : *current_regs) {
345 auto node = reg.node.lock();
350 node->process_input(value);
355 m_hazard_ptrs[slot].store(
nullptr);
359 for (
const auto& reg : *current_regs) {
360 auto node = reg.node.lock();
365 node->process_input(value);
384 const auto& midi = value.
as_midi();
403 const auto& osc = value.
as_osc();
418#ifdef MAYAFLUX_PLATFORM_MACOS
419void InputManager::retire_list(
const RegistrationList* list)
422 for (
const auto& hp : m_hazard_ptrs) {
423 if (hp.load() == list) {
447 "OSC bridge requested but NetworkService not available");
457 ep.
label =
"osc_input";
463 "Failed to open UDP endpoint for OSC on port {}",
469 [
this](uint64_t,
const uint8_t* data,
size_t size, std::string_view) {
477 "OSC bridge active on port {}", osc_config.
receive_port);
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
static std::optional< InputValue > parse(const uint8_t *data, size_t size, uint32_t device_id=0)
Parse a single OSC message from raw bytes.
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.
NetworkTransport transport
std::string remote_address
Describes one logical send/receive endpoint managed by a backend.
uint16_t receive_port
UDP port to listen on.
std::string send_address
Default send address.
bool enabled
Enable OSC backend.
uint16_t send_port
Default UDP port to send to.
OSC backend configuration.
std::function< uint64_t(const Core::EndpointInfo &info)> open_endpoint
Open a network endpoint on the appropriate backend.
std::function< void(uint64_t endpoint_id, std::function< void(uint64_t, const uint8_t *, size_t, std::string_view)> callback)> set_endpoint_receive_callback
Register a per-endpoint receive callback.
std::function< void(uint64_t endpoint_id)> close_endpoint
Close an endpoint.
Backend network transport service interface.