48using namespace gamepad::input;
53const std::string kBluetoothDeviceAddress =
"16:00:00:00:03:27";
58 printf(
"Start to connect %s\n", kBluetoothDeviceAddress.c_str());
61 while (!g_codex_pad.
Connect(kBluetoothDeviceAddress, 5000)) {
62 printf(
"Retry to connect %s\n", kBluetoothDeviceAddress.c_str());
70 if (
const auto ble_client = g_codex_pad.
ble_client(); ble_client !=
nullptr) {
71 printf(
"Remote Bluetooth Device Address: %s\n", ble_client->getPeerAddress().toString().c_str());
73 printf(
"Remote Bluetooth Device Address: unknown\n");
84 printf(
"Set remote tx power to 0 dBm successfully\n");
87 printf(
"Connected\n");
122 const gamepad::input::Tracker& it = g_codex_pad.
Update();
142 printf(
"Disconnected, start to reconnect\n");
147 static uint32_t s_print_time = 0;
148 if (s_print_time != 0 && s_print_time + 30 > millis()) {
152 s_print_time = millis();
155 "Up:%u, Down:%u, Left:%u, Right:%u, Square(X):%u, Triangle(Y):%u, Cross(A):%u, Circle(B):%u, L1:%u, L2:%u, L3:%u, R1:%u, "
156 "R2:%u, R3:%u, Select:%u, Start:%u, Home:%u, L(X:%3u, Y:%3u), R(X:%3u, Y:%3u)\n",
168 it[Button::kUp], it[Button::kDown], it[Button::kLeft], it[Button::kRight], it[Button::kSquareX], it[Button::kTriangleY],
169 it[Button::kCrossA], it[Button::kCircleB], it[Button::kL1], it[Button::kL2], it[Button::kL3], it[Button::kR1],
170 it[Button::kR2], it[Button::kR3], it[Button::kSelect], it[Button::kStart], it[Button::kHome],
182 it[Axis::kLeftStickX], it[Axis::kLeftStickY], it[Axis::kRightStickX], it[Axis::kRightStickY]);
bool Connect(const std::string &bluetooth_device_address, uint32_t timeout_ms=5000) noexcept
Connect.
bool is_connected() const noexcept
Is connected.
const std::array< uint8_t, 3 > & remote_firmware_version() const noexcept
Get firmware version of the CodexPad.
const gamepad::input::Tracker & Update() noexcept
Update, need to be called in Loop.
const std::string & remote_model_number() const noexcept
Get model number of the CodexPad.
void Init() noexcept
Initialize.
NimBLEClient * ble_client() const noexcept
Get the BLE client object.
const std::string & remote_device_name() const noexcept
Get model number of the CodexPad.
bool set_remote_tx_power(TxPower power) noexcept
Set transmission power, only effective when connected, immediately effective for current connection,...