Skip to main content

Overview

The IProtocol interface is the base class for all protocol plugins. Protocols are responsible for transmitting tracking data from OpenTrack to games and applications using various communication methods.

Interface Definition

Methods

initialize()

Initializes the protocol and prepares for data transmission.
module_status
Returns status_ok() on success, or error(message) on failure.
Description:
  • Called once when the protocol is started
  • Open network connections, shared memory, or other resources
  • Validate configuration settings
  • Register with game interfaces
  • Return error if initialization fails
Example implementations:

pose()

Transmits filtered and raw tracking data to the target application.
const double*
Filtered pose data as array: [TX, TY, TZ, Yaw, Pitch, Roll] in degrees/cm
const double*
Raw pose data (before filtering) in same format as pose
This method is called 250 times per second. Keep it fast and avoid blocking operations.
Description:
  • Called at 250Hz from the tracking pipeline thread
  • Transform data to target format
  • Send data via network, shared memory, or other IPC
  • Use background threads for expensive operations
  • Don’t block the calling thread
Data format:
  • pose[TX] / raw[TX]: X translation in centimeters
  • pose[TY] / raw[TY]: Y translation in centimeters
  • pose[TZ] / raw[TZ]: Z translation in centimeters
  • pose[Yaw] / raw[Yaw]: Yaw rotation in degrees
  • pose[Pitch] / raw[Pitch]: Pitch rotation in degrees
  • pose[Roll] / raw[Roll]: Roll rotation in degrees
Example implementation:

game_name()

Returns the name of the currently connected game or application.
QString
Name of connected game, or placeholder text if none detected
Description:
  • Called periodically from UI thread
  • Return actual game name if detected
  • Return generic text like “Game” if unknown
  • Use mutex protection if name is updated from pose()
Example implementations:

Dialog Interface

register_protocol()

Receives a pointer to the active protocol instance.
IProtocol*
Pointer to the running protocol instance
Description:
  • Called from UI thread when protocol starts
  • Store pointer for runtime interaction (optional)
  • Can query protocol state or display status
  • Often implemented as empty function
Example:

unregister_protocol()

Called when protocol is about to be destroyed. Description:
  • Clear any stored protocol pointers
  • Stop accessing protocol data
  • Clean up any UI state

Complete Example

Communication Patterns

Used by FreeTrack/TrackIR protocols for low-latency local communication.
Simple datagram-based protocol for network transmission.
Emulate joystick or other input device.

Performance Considerations

The pose() method is called 250 times per second. Optimize carefully.

Best Practices

  1. Use non-blocking I/O
  2. Minimize allocations
  3. Batch updates if needed
  4. Use atomic operations for shared memory

See Also