How freespacenav/spacenavd works
spacenavd is a user-space driver daemon for six-degree-of-freedom input devices. Its main workflow is to discover and read device input, normalize and transform events, apply configuration-driven mappings and actions, then dispatch events to applications over the spacenav Unix-socket protocol or the legacy Magellan X11 protocol. Clients can also query devices and change settings through the Unix protocol. The README documents compatibility and configuration capabilities; some subsystem links below rely on that documentation because their implementation was not sampled.
Main entry points: spnavd.c Daemon loop · dev.c Device manager · proto_unix.c Unix socket protocol · proto_x11.c Magellan X11 protocol
Components 19
Daemon control
- Daemon loop
src/spnavd.c - Logging
src/logger.c
Device input
- Device manager
src/dev.c - Serial backend
src/dev_serial.c - Linux USB backend
src/dev_usb_linux.c - FreeBSD USB backend
src/dev_usb_freebsd.c - Platform hotplug
src/hotplug.h
Event processing
- Device event queue
src/event.c - Mapping and actions
src/event.c - Keyboard emulation
src/kbemu.c
Client protocols
- Unix socket protocol
src/proto_unix.c - Magellan X11 protocol
src/proto_x11.c - Client registry
src/client.c - Unix wire format
src/proto.h - X display detection
src/xdetect.h
Configuration
- Settings and persistence
src/cfgfile.c
Other components
- Client applications
- 6-DOF device
- Configuration file
Connections 25
- Client applications → Unix socket protocol: connects
- Client applications → Magellan X11 protocol: uses legacy protocol
- 6-DOF device → Device manager: provides input
- Configuration file → Settings and persistence: loads and saves
- Daemon loop → Settings and persistence: loads settings
- Daemon loop → Device manager: manages devices
- Daemon loop → Platform hotplug: handles changes
- Daemon loop → Device event queue: processes queued input
- Daemon loop → Unix socket protocol: runs service
- Daemon loop → Magellan X11 protocol: runs compatibility service
- Device manager → Serial backend: reads serial input
- Device manager → Linux USB backend: reads USB input
- Device manager → FreeBSD USB backend: reads USB input
- Device manager → Device event queue: queues input
- Device event queue → Mapping and actions: supplies input events
- Mapping and actions → Keyboard emulation: emits mapped keys
- Mapping and actions → Unix socket protocol: broadcasts events
- Mapping and actions → Magellan X11 protocol: broadcasts events
- Unix socket protocol → Client registry: registers clients
- Magellan X11 protocol → Client registry: registers clients
- Unix socket protocol → Unix wire format: encodes requests
- Unix socket protocol → Settings and persistence: reads and changes settings
- Unix socket protocol → Device manager: queries devices
- Magellan X11 protocol → X display detection: detects display
- Daemon loop → Logging: records status