Skip to content

Networking

Twometer edited this page May 23, 2020 · 13 revisions

This page describes the technical implementation details of the communication between the controllers, the service and the SteamVR driver.

Server Discovery

The controllers must discover the server to push their metadata to. This is solved using a UDP broadcast. The controller broadcasts the (randomly chosen) 4-byte discovery sequence 0x79 0x65 0x65 0x74 to all devices on the subnet on port 12743. The server listens for theses sequences and if one is received, returns its local IP address as a NUL-terminated ASCII string to the controller. The controller then starts streaming motion and button data via UDP to the server on port 12742.

Protocol Controller ⇄ Service

The protocol that is used between the TwometerVR Service (TVR.Service) and the individual hand controllers. This synchronizes button presses, controller states and most importantly pose data with the PC. Rotation data is transmitted as quaternions.

ControllerInfoPacket

[byte controllerId][byte buttonPressCount][byte[] buttonPresses][float qx][float qy][float qz][float qw]

StatusPacket

Used to notify the server about the state of the controller

The 0xFF is used to indicate that this is a status message.

[0xFF][byte status]

Available status codes

  • 0x00: Connected
  • 0x01: Begin calibration mode
  • 0x02: Begin calibrating magnetometer
  • 0x03: Exit calibration mode
  • 0x04: Begin calculating offsets
  • 0x05: Controller ready

Protocol Service ⇄ Driver

The protocol that is used for the communication between the service and the driver. The service regularly pushes updates to the driver, including controller pose data (position & rotation) and button states

DriverPacket

[int16 length][byte controllerStateCount][ControllerState[] controllerStates]

ControllerState

[byte ctrlId][float posX][float posY][float posZ][float rotX][float rotY][float rotZ][float rotW][byte buttonCount][ButtonState[] states]

ButtonState

[byte btnId][bool pressed]