Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BleKeyboard.cpp #54

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions BleKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
static const char* LOG_TAG = "BLEDevice";
#endif


// Report IDs:
#define KEYBOARD_ID 0x01
#define MEDIA_KEYS_ID 0x02
Expand Down Expand Up @@ -53,10 +52,10 @@ static const uint8_t _hidReportDescriptor[] = {
REPORT_COUNT(1), 0x06, // REPORT_COUNT (6) ; 6 bytes (Keys)
REPORT_SIZE(1), 0x08, // REPORT_SIZE(8)
LOGICAL_MINIMUM(1), 0x00, // LOGICAL_MINIMUM(0)
LOGICAL_MAXIMUM(1), 0x65, // LOGICAL_MAXIMUM(0x65) ; 101 keys
LOGICAL_MAXIMUM(1), 0x73, // LOGICAL_MAXIMUM(0x73) ; 115 keys
USAGE_PAGE(1), 0x07, // USAGE_PAGE (Kbrd/Keypad)
USAGE_MINIMUM(1), 0x00, // USAGE_MINIMUM (0)
USAGE_MAXIMUM(1), 0x65, // USAGE_MAXIMUM (0x65)
USAGE_MAXIMUM(1), 0x73, // USAGE_MAXIMUM (0x73) ; 115 keys
HIDINPUT(1), 0x00, // INPUT (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
END_COLLECTION(0), // END_COLLECTION
// ------------------------------------------------- Media Keys
Expand Down Expand Up @@ -97,13 +96,16 @@ BleKeyboard::BleKeyboard(std::string deviceName, std::string deviceManufacturer,
this->connectionStatus = new BleConnectionStatus();
}

TaskHandle_t xHandle = NULL;

void BleKeyboard::begin(void)
{
xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, NULL);
xTaskCreate(this->taskServer, "server", 4096, (void *)this, 5, &xHandle);
}

void BleKeyboard::end(void)
{
vTaskDelete(xHandle);
}

bool BleKeyboard::isConnected(void) {
Expand Down
37 changes: 37 additions & 0 deletions BleKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "BLECharacteristic.h"
#include "Print.h"

#define BLE_KEYBOARD_VERSION "1.3"

const uint8_t KEY_LEFT_CTRL = 0x80;
const uint8_t KEY_LEFT_SHIFT = 0x81;
Expand All @@ -18,6 +19,41 @@ const uint8_t KEY_RIGHT_SHIFT = 0x85;
const uint8_t KEY_RIGHT_ALT = 0x86;
const uint8_t KEY_RIGHT_GUI = 0x87;

const uint8_t KEY_NUM_0 = 0xEA;
const uint8_t KEY_NUM_1 = 0xE1;
const uint8_t KEY_NUM_2 = 0xE2;
const uint8_t KEY_NUM_3 = 0xE3;
const uint8_t KEY_NUM_4 = 0xE4;
const uint8_t KEY_NUM_5 = 0xE5;
const uint8_t KEY_NUM_6 = 0xE6;
const uint8_t KEY_NUM_7 = 0xE7;
const uint8_t KEY_NUM_8 = 0xE8;
const uint8_t KEY_NUM_9 = 0xE9;
const uint8_t KEY_NUM_SLASH = 0xDC;
const uint8_t KEY_NUM_ASTERISK = 0xDD;
const uint8_t KEY_NUM_MINUS = 0xDE;
const uint8_t KEY_NUM_PLUS = 0xDF;
const uint8_t KEY_NUM_ENTER = 0xE0;
const uint8_t KEY_NUM_PERIOD = 0xEB;

// Old names, kept for backwards compatibility
const uint8_t NUM_0 = 0xEA;
const uint8_t NUM_1 = 0xE1;
const uint8_t NUM_2 = 0xE2;
const uint8_t NUM_3 = 0xE3;
const uint8_t NUM_4 = 0xE4;
const uint8_t NUM_5 = 0xE5;
const uint8_t NUM_6 = 0xE6;
const uint8_t NUM_7 = 0xE7;
const uint8_t NUM_8 = 0xE8;
const uint8_t NUM_9 = 0xE9;
const uint8_t NUM_SLASH = 0xDC;
const uint8_t NUM_ASTERIX = 0xDD;
const uint8_t NUM_MINUS = 0xDE;
const uint8_t NUM_PLUS = 0xDF;
const uint8_t NUM_ENTER = 0xE0;
const uint8_t NUM_PERIOD = 0xEB;

const uint8_t KEY_UP_ARROW = 0xDA;
const uint8_t KEY_DOWN_ARROW = 0xD9;
const uint8_t KEY_LEFT_ARROW = 0xD8;
Expand All @@ -27,6 +63,7 @@ const uint8_t KEY_TAB = 0xB3;
const uint8_t KEY_RETURN = 0xB0;
const uint8_t KEY_ESC = 0xB1;
const uint8_t KEY_INSERT = 0xD1;
const uint8_t KEY_PRTSC = 0xCE;
const uint8_t KEY_DELETE = 0xD4;
const uint8_t KEY_PAGE_UP = 0xD3;
const uint8_t KEY_PAGE_DOWN = 0xD6;
Expand Down