AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
nrf52840/src/ble_keyboard_adapter.cpp
Go to the documentation of this file.
1#include "ble_keyboard_adapter.h"
2
4{
5 Bluefruit.begin();
6 Bluefruit.setTxPower(4);
7 Bluefruit.setName("Strix-Pedal");
8
9 hid.begin();
10
11 // Start BLE advertising
12 Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
13 Bluefruit.Advertising.addTxPower();
14 Bluefruit.Advertising.addAppearance(BLE_APPEARANCE_HID_KEYBOARD);
15 Bluefruit.Advertising.addService(hid);
16 Bluefruit.ScanResponse.addName();
17 Bluefruit.Advertising.restartOnDisconnect(true);
18 Bluefruit.Advertising.setInterval(32, 244);
19 Bluefruit.Advertising.setFastTimeout(30);
20 Bluefruit.Advertising.start(0);
21}
22
23bool BleKeyboardAdapter::isConnected() { return Bluefruit.connected(); }
24
25void BleKeyboardAdapter::write(uint8_t key)
26{
27 hid.keyPress(key);
28 hid.keyRelease();
29}
30
32{
33 // MediaKeyReport is a 2-byte array; map byte[0] to Adafruit consumer key
34 hid.consumerKeyPress(key[0]);
35 hid.consumerKeyRelease();
36}
37
38void BleKeyboardAdapter::print(const char* text) { hid.keySequence(text); }
39
Adapter that implements IBleKeyboard interface using BleKeyboard.
void print(const char *text) override
Sends a text string.
void begin() override
Initializes the BLE keyboard.
void write(uint8_t key) override
Sends a single key press.
bool isConnected() override
Checks if BLE keyboard is connected.
uint8_t[2] MediaKeyReport
Type alias for media key reports.
BleKeyboardAdapter * createBleKeyboardAdapter()
Creates the platform-specific BleKeyboardAdapter instance.