Skip to content

Overview


The Gamepad SDK is a gamepad event listener library based on UDP communication, responsible for receiving gamepad operation data broadcast by the mobile App via UDP. Developers can use this SDK to obtain physical button trigger information and joystick values in real time for robot remote control scenarios.

The Gamepad SDK serves as the user input layer in the Lite3 development ecosystem, with the following responsibilities:

  • Receiving button and joystick data from the gamepad App via UDP
  • Parsing protocol frames (frame header, device ID, CRC16 checksum)
  • Converting raw data into structured button states and normalized joystick values
  • Supporting both Retroid (Lite3) and Skydroid gamepads

Upper-layer applications (e.g., lite3_transfer) reference the Gamepad SDK to obtain user gamepad input and publish it to ROS2 topics.

Retroid Gamepad

gamepad/
├── include/
│ ├── gamepad.h # Gamepad template base class
│ ├── gamepad_keys.h # Button/joystick data type definitions and protocol frame structure
│ ├── retroid_gamepad.h # Retroid gamepad subclass interface
│ ├── skydroid_gamepad.h # Skydroid gamepad subclass interface
│ └── udp_receiver.h # UDP receiver
├── src/
│ ├── gamepad.cpp # Gamepad base class implementation
│ ├── retroid_gamepad.cpp # Retroid gamepad data parsing implementation
│ ├── skydroid_gamepad.cpp # Skydroid gamepad data parsing implementation
│ └── udp_receiver.cpp # UDP receiver implementation
├── example/
│ ├── fmt/ # fmt formatting library (git submodule)
│ ├── example_retroid.cpp # Retroid gamepad example program
│ ├── example_skydroid.cpp # Skydroid gamepad example program
│ └── CMakeLists.txt # Example build configuration
├── doc/ # Documentation images
├── CMakeLists.txt # Build configuration
├── LICENSE
└── controlapp.apk # Mobile gamepad App

The Gamepad SDK uses a UDP unidirectional receive model, where the mobile App acts as the sender and the SDK host acts as the receiver:

graph LR
A["Gamepad App (Mobile)"] -->|"UDP Broadcast"| B["SDK (Development Host)"]
DirectionPortDescription
App → SDK12121 (default, customizable)App broadcasts gamepad data to this port

Each UDP data packet sent by the gamepad App follows a unified frame format:

FieldSizeDescription
stx2 bytesFrame header, fixed at 0x55 0x66
ctrl1 byteControl byte
data_len2 bytesData area length
seq2 bytesSequence number for packet loss detection
id1 byteDevice ID: 1 = Retroid, 2 = Skydroid
crc162 bytesCRC-16 checksum (data area accumulation)
dataVariableButton + joystick raw data

The SDK performs three-level verification on each received data packet:

  1. Frame header verification: Check stx[0] == 0x55 and stx[1] == 0x66
  2. Device ID verification: Check if the id field matches the target gamepad type
  3. CRC-16 verification: Accumulate bytes in the data area and compare with the crc16 field

Only data packets that pass all three levels of verification are parsed as valid button data.

ResourceDescription
gamepadGamepad SDK repository