10#include "NimBLEDevice.h"
11#include "gamepad_input_tracker.h"
194 void Init() noexcept;
214 bool Connect(const std::
string& bluetooth_device_address, uint32_t timeout_ms = 5000) noexcept;
287 const gamepad::input::Tracker&
Update() noexcept;
368 const gamepad::input::Tracker&
input_tracker() const noexcept {
return input_tracker_; }
383 NimBLEClient*
ble_client() const noexcept {
return ble_client_; }
386 static constexpr size_t kInputsQueueMax = 10;
388 bool Connect(
const NimBLEAddress& address,
bool async_connect,
const uint32_t timeout_ms);
389 void OnNotify(
const NimBLERemoteCharacteristic* remote_characteristic,
const uint8_t* data,
const size_t length,
390 const bool is_notify);
393 mutable std::mutex mutex_;
394 NimBLEClient* ble_client_ =
nullptr;
395 std::string remote_device_name_;
396 std::string remote_model_number_;
397 std::array<uint8_t, 3> remote_firmware_version_ = {0, 0, 0};
398 std::queue<gamepad::input::State> inputs_queue_;
399 gamepad::input::Tracker input_tracker_;
CodexPad() noexcept
Constructor.
bool Connect(const std::string &bluetooth_device_address, uint32_t timeout_ms=5000) noexcept
Connect.
bool is_connected() const noexcept
Is connected.
const gamepad::input::Tracker & input_tracker() const noexcept
Get the input tracker object.
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.
void Disconnect() noexcept
Disconnect.
bool set_remote_tx_power(TxPower power) noexcept
Set transmission power, only effective when connected, immediately effective for current connection,...
bool ScanAndConnect(gamepad::input::Button buttons) noexcept
Scans for nearby CodexPad devices and automatically connects to a device whose button state matches t...