Gamepad State Example
This example demonstrates how to read gamepad button and joystick input states.
Gamepad SDK Example
Section titled “Gamepad SDK Example”example/example_retroid.cpp demonstrates how to receive and display all Retroid gamepad button and joystick states in real time.
Program Initialization
Section titled “Program Initialization”RetroidGamepad rc(12121); ///< Create gamepad instance, listening on port 12121InitialRetroidKeys(rc); ///< Initialize button state display stringsrc.StartDataThread(); ///< Start UDP data receiving threadRegister Callback
Section titled “Register Callback”rc.updateCallback_ = [&](int32_t count) { std::cout << rc << std::endl; ///< Clear screen and print gamepad state on each data update};Terminal Output
Section titled “Terminal Output”After running, the terminal displays gamepad state in a table format:

When a button is pressed, the corresponding item turns green showing pressed.
Skydroid Gamepad Example
Section titled “Skydroid Gamepad Example”example/example_skydroid.cpp usage is similar to Retroid:
SkydroidGamepad rc(12121);InitialSkydroidKeys(rc);rc.StartDataThread();
rc.updateCallback_ = [&](int32_t count) { std::cout << rc << std::endl;};Terminal output shows Skydroid buttons, toggle switches, and joystick data:

Android Method
Section titled “Android Method”Get gamepad data via ControllerSDK:
controller.addJoystickListener { data -> val leftX = data.leftX val leftY = data.leftY val rightX = data.rightX val rightY = data.rightY
Log.d("Controller", "Left joystick: ($leftX, $leftY)") Log.d("Controller", "Right joystick: ($rightX, $rightY)")}Onboard Method
Section titled “Onboard Method”Get keyboard/gamepad input via SDK:
UserCommand cmd;if (getUserInput(&cmd)) { printf("vx: %.2f, vy: %.2f, vyaw: %.2f\n", cmd.vx, cmd.vy, cmd.vyaw);}