Skip to content

Commit 517aa71

Browse files
committed
1 parent f8dd485 commit 517aa71

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

BleKeyboard.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ void BleKeyboard::releaseAll(void)
470470
sendReport(&_keyReport);
471471
}
472472

473+
bool BleKeyboard::getLedStatus(uint8_t led)
474+
{
475+
return ((_keyboardLedsStatus & led)!=0);
476+
}
477+
473478
size_t BleKeyboard::write(uint8_t c)
474479
{
475480
uint8_t p = press(c); // Keydown
@@ -531,6 +536,7 @@ void BleKeyboard::onDisconnect(BLEServer* pServer) {
531536
void BleKeyboard::onWrite(BLECharacteristic* me) {
532537
uint8_t* value = (uint8_t*)(me->getValue().c_str());
533538
(void)value;
539+
_keyboardLedsStatus = *value;
534540
ESP_LOGI(LOG_TAG, "special keys: %d", *value);
535541
}
536542

BleKeyboard.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ const uint8_t KEY_NUM_PLUS = 0xDF;
100100
const uint8_t KEY_NUM_ENTER = 0xE0;
101101
const uint8_t KEY_NUM_PERIOD = 0xEB;
102102

103+
const uint8_t LED_CAPS_LOCK = 0x02;
104+
const uint8_t LED_NUM_LOCK = 0x01;
105+
const uint8_t LED_SCROLL_LOCK = 0x04;
106+
103107
typedef uint8_t MediaKeyReport[2];
104108

105109
const MediaKeyReport KEY_MEDIA_NEXT_TRACK = {1, 0};
@@ -140,6 +144,7 @@ class BleKeyboard : public Print, public BLEServerCallbacks, public BLECharacter
140144
MediaKeyReport _mediaKeyReport;
141145
std::string deviceName;
142146
std::string deviceManufacturer;
147+
uint8_t _keyboardLedsStatus;
143148
uint8_t batteryLevel;
144149
bool connected = false;
145150
uint32_t _delay_ms = 7;
@@ -163,6 +168,7 @@ class BleKeyboard : public Print, public BLEServerCallbacks, public BLECharacter
163168
size_t write(const MediaKeyReport c);
164169
size_t write(const uint8_t *buffer, size_t size);
165170
void releaseAll(void);
171+
bool getLedStatus(uint8_t led);
166172
bool isConnected(void);
167173
void setBatteryLevel(uint8_t level);
168174
void setName(std::string deviceName);

0 commit comments

Comments
 (0)