From 83f7782223032a0ba654f9ea2526fcd81dc0b2b4 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 24 Jan 2017 00:53:33 +0700 Subject: [PATCH] rename BLEHid to BLEHidGeneric safer new with malloc --- cores/nRF5/rtos.h | 12 +- .../examples/hid_keyboard/hid_keyboard.ino | 2 +- libraries/Bluefruit52Lib/src/bluefruit.h | 4 +- .../Bluefruit52Lib/src/services/BLEHid.cpp | 292 ++++------ .../Bluefruit52Lib/src/services/BLEHid.h | 543 ------------------ 5 files changed, 116 insertions(+), 737 deletions(-) delete mode 100644 libraries/Bluefruit52Lib/src/services/BLEHid.h diff --git a/cores/nRF5/rtos.h b/cores/nRF5/rtos.h index dbdfec34..50601073 100644 --- a/cores/nRF5/rtos.h +++ b/cores/nRF5/rtos.h @@ -55,8 +55,16 @@ #define rtos_malloc(_size) ({ cprintf("[malloc] %s:%d : %d bytes\r\n", __PRETTY_FUNCTION__, __LINE__, _size); pvPortMalloc(_size); }) #define rtos_free(ptr) ({ cprintf("[free] %s:%d\r\n" ,__PRETTY_FUNCTION__, __LINE__/*malloc_usable_size(ptr)*/); vPortFree(ptr); }) #else -#define rtos_malloc(_size) pvPortMalloc(_size) -#define rtos_free(ptr) vPortFree(ptr) + +static inline void* rtos_malloc(size_t _size) +{ + return (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) ? malloc(_size) : pvPortMalloc(_size); +} + +static inline void rtos_free( void *pv ) +{ + return (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) ? free(pv) : vPortFree(pv); +} #endif #endif /* RTOS_H_ */ diff --git a/libraries/Bluefruit52Lib/examples/hid_keyboard/hid_keyboard.ino b/libraries/Bluefruit52Lib/examples/hid_keyboard/hid_keyboard.ino index 861cde25..1598ea16 100644 --- a/libraries/Bluefruit52Lib/examples/hid_keyboard/hid_keyboard.ino +++ b/libraries/Bluefruit52Lib/examples/hid_keyboard/hid_keyboard.ino @@ -15,7 +15,7 @@ BLEDis bledis; BLEUart bleuart; -BLEHid blehid; +BLEHidAdafruit blehid; bool hasKeyPressed = false; diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index f4b9fe5a..255d0389 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -47,7 +47,9 @@ #include "services/BLEUart.h" #include "services/BLEBas.h" #include "services/BLEBeacon.h" -#include "services/BLEHid.h" +#include "services/BLEHidGeneric.h" +#include "services/BLEHidAdafruit.h" + #define BLE_MAX_CHARS 50 diff --git a/libraries/Bluefruit52Lib/src/services/BLEHid.cpp b/libraries/Bluefruit52Lib/src/services/BLEHid.cpp index c50323e1..50af5844 100644 --- a/libraries/Bluefruit52Lib/src/services/BLEHid.cpp +++ b/libraries/Bluefruit52Lib/src/services/BLEHid.cpp @@ -1,6 +1,6 @@ /**************************************************************************/ /*! - @file BLEHid.cpp + @file BLEHidGeneric.cpp @author hathach @section LICENSE @@ -36,6 +36,12 @@ #include "bluefruit.h" +enum { + REPORT_TYPE_INPUT = 1, + REPORT_TYPE_OUTPUT, + REPORT_TYPE_FEATURE +}; + enum { REPORT_INDEX_KEYBOARD =0, @@ -46,7 +52,7 @@ enum enum { - REPORT_ID_KEYBOARD = 1, + REPORT_ID_KEYBOARD = 0, REPORT_ID_CONSUMER_CONTROL, REPORT_ID_MOUSE, REPORT_ID_GAMEPAD @@ -188,224 +194,130 @@ const hid_ascii_to_keycode_entry_t HID_ASCII_TO_KEYCODE[128] = }; -uint8_t const hid_report_descriptor[] = + + +BLEHidGeneric::BLEHidGeneric(uint8_t num_input, uint8_t num_output, uint8_t num_feature) + : BLEService(UUID16_SVC_HUMAN_INTERFACE_DEVICE), _chr_control(UUID16_CHR_HID_CONTROL_POINT) { - //------------- Keyboard Report -------------// - HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), - HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ), - HID_COLLECTION ( HID_COLLECTION_APPLICATION ), - HID_REPORT_ID ( REPORT_ID_KEYBOARD ), - HID_USAGE_PAGE( HID_USAGE_PAGE_KEYBOARD ), - // 8 bits Modifier Keys (Shfit, Control, Alt) - HID_USAGE_MIN ( 224 ), - HID_USAGE_MAX ( 231 ), - HID_LOGICAL_MIN ( 0 ), - HID_LOGICAL_MAX ( 1 ), + _boot_keyboard = _boot_mouse = false; + _report_map = NULL; + _report_map_len = 0; - HID_REPORT_COUNT ( 8 ), - HID_REPORT_SIZE ( 1 ), - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), + _input_len = _output_len = _feature_len = NULL; - // 8 bit reserved - HID_REPORT_COUNT ( 1 ), - HID_REPORT_SIZE ( 8 ), - HID_INPUT ( HID_CONSTANT ), + _num_input = num_input; + _num_output = num_output; + _num_feature = num_feature; - // LED Indicator Kana | Compose | Scroll Lock | CapsLock | NumLock - HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ), - /* 5-bit Led report */ - HID_USAGE_MIN ( 1 ), - HID_USAGE_MAX ( 5 ), - HID_REPORT_COUNT ( 5 ), - HID_REPORT_SIZE ( 1 ), - HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), - /* led padding */ - HID_REPORT_COUNT ( 1 ), - HID_REPORT_SIZE ( 3 ), - HID_OUTPUT ( HID_CONSTANT ), + // HID Information + // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.hid_information.xml + // bcd 1.1, country = 0, flag = normal connect + _hid_info[0] = 0x01; + _hid_info[1] = 0x01; + _hid_info[2] = 0x00; + _hid_info[3] = bit(1); - // 6-byte Keycodes - HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD), - HID_USAGE_MIN ( 0 ), - HID_USAGE_MAX ( 101 ), - HID_LOGICAL_MIN ( 0 ), - HID_LOGICAL_MAX ( 101 ), + _chr_inputs = _chr_outputs = _chr_features = NULL; + _chr_boot_keyboard = _chr_boot_mouse = NULL; - HID_REPORT_COUNT ( 6 ), - HID_REPORT_SIZE ( 8 ), - HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), - HID_COLLECTION_END, - -#if 0 - //------------- Consumer Control Report -------------// - HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ), - HID_USAGE ( HID_USAGE_CONSUMER_CONTROL ), - HID_COLLECTION ( HID_COLLECTION_APPLICATION ), - HID_REPORT_ID( REPORT_ID_CONSUMER_CONTROL ), - HID_LOGICAL_MIN ( 0x00 ), - HID_LOGICAL_MAX_N( 0x03FF, 2 ), - HID_USAGE_MIN ( 0x00 ), - HID_USAGE_MAX_N ( 0x03FF, 2 ), - HID_REPORT_COUNT ( 1 ), - HID_REPORT_SIZE ( 16 ), - HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), - HID_COLLECTION_END, - - //------------- Mouse Report: buttons + dx + dy + scroll + pan -------------// - HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), - HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ), - HID_COLLECTION ( HID_COLLECTION_APPLICATION ), - HID_REPORT_ID( REPORT_ID_MOUSE ), - HID_USAGE (HID_USAGE_DESKTOP_POINTER ), - HID_COLLECTION ( HID_COLLECTION_PHYSICAL ), - HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ), - HID_USAGE_MIN ( 1 ), - HID_USAGE_MAX ( 5 ), - HID_LOGICAL_MIN ( 0 ), - HID_LOGICAL_MAX ( 1 ), - - HID_REPORT_COUNT ( 5 ), /* Forward, Backward, Middle, Right, Left */ - HID_REPORT_SIZE ( 1 ), - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), - - HID_REPORT_COUNT ( 1 ), - HID_REPORT_SIZE ( 3 ), - HID_INPUT ( HID_CONSTANT ), /* 5 bit padding followed 3 bit buttons */ - - HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), - HID_USAGE ( HID_USAGE_DESKTOP_X ), - HID_USAGE ( HID_USAGE_DESKTOP_Y ), - HID_LOGICAL_MIN ( 0x81 ), /* -127 */ - HID_LOGICAL_MAX ( 0x7f ), /* 127 */ - - HID_REPORT_COUNT ( 2 ), /* X, Y position */ - HID_REPORT_SIZE ( 8 ), - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */ - - HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ), /* mouse scroll */ - HID_LOGICAL_MIN ( 0x81 ), /* -127 */ - HID_LOGICAL_MAX ( 0x7f ), /* 127 */ - HID_REPORT_COUNT( 1 ), - HID_REPORT_SIZE ( 8 ), /* 8-bit value */ - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */ - - HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ), - HID_USAGE_N ( HID_USAGE_CONSUMER_AC_PAN, 2 ), /* Horizontal wheel scroll */ - HID_LOGICAL_MIN ( 0x81 ), /* -127 */ - HID_LOGICAL_MAX ( 0x7f ), /* 127 */ - HID_REPORT_COUNT( 1 ), - HID_REPORT_SIZE ( 8 ), /* 8-bit value */ - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */ - HID_COLLECTION_END, - HID_COLLECTION_END, - - //------------- Gamepad Report -------------// - /* Byte 0: 4 pad | 2 Y-axis | 2 X-axis - * Byte 1: Button7-Button0 - */ - HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), - HID_USAGE ( HID_USAGE_DESKTOP_GAMEPAD ), - HID_COLLECTION ( HID_COLLECTION_APPLICATION ), - HID_REPORT_ID ( REPORT_ID_GAMEPAD ), - HID_USAGE (HID_USAGE_DESKTOP_POINTER ), - HID_COLLECTION ( HID_COLLECTION_PHYSICAL ), - // X,Y joystick - HID_USAGE ( HID_USAGE_DESKTOP_X ), - HID_USAGE ( HID_USAGE_DESKTOP_Y ), - HID_LOGICAL_MIN ( 0xFF ), /* -1 */ - HID_LOGICAL_MAX ( 0x01 ), /* 1 */ - HID_REPORT_COUNT( 2 ), /* X, Y position */ - HID_REPORT_SIZE ( 2 ), /* 2-bit value */ - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* input values */ - HID_COLLECTION_END, - - /* X,Y padding */ - HID_REPORT_COUNT ( 4 ), - HID_REPORT_SIZE ( 1 ), - HID_INPUT ( HID_CONSTANT | HID_VARIABLE | HID_ABSOLUTE), - - // Buttons - HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ), - HID_USAGE_MIN ( 1 ), - HID_USAGE_MAX ( 8 ), - HID_LOGICAL_MIN ( 0 ), - HID_LOGICAL_MAX ( 1 ), - HID_REPORT_COUNT ( 8 ), - HID_REPORT_SIZE ( 1 ), - HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE), - HID_COLLECTION_END -#endif -}; - -BLEHid::BLEHid(void) - : BLEService(UUID16_SVC_HUMAN_INTERFACE_DEVICE), - _chr_protocol(UUID16_CHR_PROTOCOL_MODE), _chr_input(), - _chr_control(UUID16_CHR_HID_CONTROL_POINT) -{ - _keyboard_en = true; - _mouse_en = false; - - _pchr_boot_keyboard = NULL; + if ( _num_input ) _chr_inputs = new BLECharacteristic[num_input]; + if ( _num_output ) _chr_outputs = new BLECharacteristic[num_output]; + if ( _num_feature ) _chr_features = new BLECharacteristic[num_feature]; } -err_t BLEHid::start(void) +void BLEHidGeneric::setBootProtocol(bool bootKeyboard, bool bootMouse) { + _boot_keyboard = bootKeyboard; + _boot_mouse = bootMouse; +} + +void BLEHidGeneric::setHidInfo(uint16_t bcd, uint8_t country, uint8_t flags) +{ + memcpy(_hid_info, &bcd, 2); + _hid_info[2] = country; + _hid_info[3] = flags; +} + +void BLEHidGeneric::setReportMap(const uint8_t* report_map, size_t len) +{ + _report_map = report_map; + _report_map_len = len; +} + +void BLEHidGeneric::setReportLen(uint16_t input_len[], uint16_t output_len[], uint16_t feature_len[]) +{ + _input_len = input_len; + _output_len = output_len; + _feature_len = feature_len; +} + +err_t BLEHidGeneric::start(void) +{ + VERIFY ( (_report_map != NULL) && _report_map_len, NRF_ERROR_INVALID_PARAM); + VERIFY_STATUS( this->addToGatt() ); // Protocol Mode - if ( _keyboard_en || _mouse_en ) + if ( _boot_keyboard || _boot_mouse ) { - _chr_protocol.setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE_WO_RESP); - _chr_protocol.setFixedLen(1); - VERIFY_STATUS( _chr_protocol.start() ); - _chr_protocol.write( (uint8_t) 1); + _chr_protocol = new BLECharacteristic(UUID16_CHR_PROTOCOL_MODE); + VERIFY(_chr_protocol, NRF_ERROR_NO_MEM); + + _chr_protocol->setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE_WO_RESP); + _chr_protocol->setFixedLen(1); + VERIFY_STATUS( _chr_protocol->start() ); + _chr_protocol->write( (uint8_t) 1); } // Input reports + for(uint8_t i=0; i<_num_input; i++) { - _chr_input.setUuid(UUID16_CHR_REPORT); - _chr_input.setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY); - _chr_input.setFixedLen(sizeof(hid_keyboard_report_t)); - _chr_input.setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); - _chr_input.setReportRefDescriptor(0x01, 0x01); - VERIFY_STATUS( _chr_input.start() ); + _chr_inputs[i].setUuid(UUID16_CHR_REPORT); + _chr_inputs[i].setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY); + _chr_inputs[i].setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); + _chr_inputs[i].setReportRefDescriptor(i, REPORT_TYPE_INPUT); + + // Input report len is configured, else variable len up to 255 + if ( _input_len ) _chr_inputs[i].setFixedLen( _input_len[i] ); + + VERIFY_STATUS( _chr_inputs[i].start() ); } // Report Map (HID Report Descriptor) BLECharacteristic report_map(UUID16_CHR_REPORT_MAP); report_map.setProperties(CHR_PROPS_READ); report_map.setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); - report_map.setFixedLen(sizeof(hid_report_descriptor)); + report_map.setFixedLen(_report_map_len); VERIFY_STATUS( report_map.start() ); - report_map.write(hid_report_descriptor, sizeof(hid_report_descriptor)); + report_map.write(_report_map, _report_map_len); // Boot Keyboard Input Report - if ( _keyboard_en ) + if ( _boot_keyboard ) { - _pchr_boot_keyboard = new BLECharacteristic(UUID16_CHR_BOOT_KEYBOARD_INPUT_REPORT); - _pchr_boot_keyboard->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY); - _pchr_boot_keyboard->setFixedLen(sizeof(hid_keyboard_report_t)); - _pchr_boot_keyboard->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); - VERIFY_STATUS(_pchr_boot_keyboard->start()); + _chr_boot_keyboard = new BLECharacteristic(UUID16_CHR_BOOT_KEYBOARD_INPUT_REPORT); + _chr_boot_keyboard->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY); + _chr_boot_keyboard->setFixedLen(sizeof(hid_keyboard_report_t)); + _chr_boot_keyboard->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); + VERIFY_STATUS(_chr_boot_keyboard->start()); } // Boot Mouse Input Report - if ( _mouse_en ) + if ( _boot_mouse ) { - + _chr_boot_mouse = new BLECharacteristic(UUID16_CHR_BOOT_MOUSE_INPUT_REPORT); + _chr_boot_mouse->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY); + _chr_boot_mouse->setFixedLen(sizeof(hid_mouse_report_t)); + _chr_boot_mouse->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); + VERIFY_STATUS(_chr_boot_mouse->start()); } - // HID Information - // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.hid_information.xml - // bcd 1.1, country = 0, flag = normal connect - uint8_t hid_info_data[] = { 0x01, 0x01, 0x00, bit(1) }; - + // HID Info BLECharacteristic hid_info(UUID16_CHR_HID_INFORMATION); hid_info.setProperties(CHR_PROPS_READ); hid_info.setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS); - hid_info.setFixedLen(sizeof(hid_info_data)); + hid_info.setFixedLen(sizeof(_hid_info)); VERIFY_STATUS( hid_info.start() ); - hid_info.write(hid_info_data, sizeof(hid_info_data)); + hid_info.write(_hid_info, sizeof(_hid_info)); // HID Control Point _chr_control.setProperties(CHR_PROPS_WRITE_WO_RESP); @@ -417,12 +329,12 @@ err_t BLEHid::start(void) return ERROR_NONE; } -err_t BLEHid::sendReport(uint8_t id, void const* data, int len) +err_t BLEHidGeneric::sendReport(uint8_t id, void const* data, int len) { - return _chr_input.notify( (uint8_t const*) data, len); + return _chr_inputs[id].notify( (uint8_t const*) data, len); } -err_t BLEHid::keyboardReport(uint8_t modifier, uint8_t keycode[6]) +err_t BLEHidGeneric::keyboardReport(uint8_t modifier, uint8_t keycode[6]) { hid_keyboard_report_t report = { @@ -433,12 +345,12 @@ err_t BLEHid::keyboardReport(uint8_t modifier, uint8_t keycode[6]) return keyboardReport(&report); } -err_t BLEHid::keyboardReport(hid_keyboard_report_t* report) +err_t BLEHidGeneric::keyboardReport(hid_keyboard_report_t* report) { return sendReport( REPORT_ID_KEYBOARD, report, sizeof(hid_keyboard_report_t)); } -err_t BLEHid::keyPress(char ch) +err_t BLEHidGeneric::keyPress(char ch) { hid_keyboard_report_t report; varclr(&report); @@ -449,7 +361,7 @@ err_t BLEHid::keyPress(char ch) return keyboardReport(&report); } -err_t BLEHid::keyRelease(void) +err_t BLEHidGeneric::keyRelease(void) { hid_keyboard_report_t report; varclr(&report); @@ -457,7 +369,7 @@ err_t BLEHid::keyRelease(void) return keyboardReport(&report); } -err_t BLEHid::keySequence(const char* str, int ms) +err_t BLEHidGeneric::keySequence(const char* str, int ms) { // Send each key in sequence char ch; diff --git a/libraries/Bluefruit52Lib/src/services/BLEHid.h b/libraries/Bluefruit52Lib/src/services/BLEHid.h deleted file mode 100644 index dac27a10..00000000 --- a/libraries/Bluefruit52Lib/src/services/BLEHid.h +++ /dev/null @@ -1,543 +0,0 @@ -/**************************************************************************/ -/*! - @file BLEHid.h - @author hathach - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2017, Adafruit Industries (adafruit.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/**************************************************************************/ -#ifndef BLEHID_H_ -#define BLEHID_H_ - -#include "bluefruit_common.h" -#include "utility/adafruit_fifo.h" - -#include "BLECharacteristic.h" -#include "BLEService.h" - -/// Standard HID Boot Protocol Mouse Report. -typedef ATTR_PACKED_STRUCT(struct) -{ - uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */ - int8_t x; /**< Current delta x movement of the mouse. */ - int8_t y; /**< Current delta y movement on the mouse. */ - int8_t wheel; /**< Current delta vertical wheel movement on the mouse. */ - int8_t pan; /**< Current delta horizontal wheel movement on the mouse. */ -} hid_mouse_report_t; - -/// Standard HID Boot Protocol Keyboard Report. -typedef ATTR_PACKED_STRUCT(struct) -{ - uint8_t modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of HID_KEYBOARD_MODIFER_* masks). */ - uint8_t reserved; /**< Reserved for OEM use, always set to 0. */ - uint8_t keycode[6]; /**< Key codes of the currently pressed keys. */ -} hid_keyboard_report_t; - -/// Gamepad report -typedef ATTR_PACKED_STRUCT(struct) -{ - ATTR_PACKED_STRUCT(struct){ - uint8_t x : 2; - uint8_t y : 2; - uint8_t : 4; - }; - - uint8_t buttons; -}hid_gamepad_report_t; - - -class BLEHid : public BLEService -{ - protected: - BLECharacteristic _chr_protocol; - BLECharacteristic _chr_input; - BLECharacteristic _chr_control; - - BLECharacteristic* _pchr_boot_keyboard; - - bool _keyboard_en; - bool _mouse_en; - - public: - BLEHid(void); - virtual err_t start(void); - - err_t sendReport(uint8_t id, void const* data, int len); - - // Keyboard - err_t keyboardReport(uint8_t modifier, uint8_t keycode[6]); - err_t keyboardReport(hid_keyboard_report_t* report); - err_t keyPress(char ch); - err_t keyRelease(void); - err_t keySequence(const char* str, int ms=5); -}; - -//--------------------------------------------------------------------+ -// MOUSE -//--------------------------------------------------------------------+ - -/// Standard Mouse Buttons Bitmap -typedef enum { - MOUSE_BUTTON_LEFT = bit(0), ///< Left button - MOUSE_BUTTON_RIGHT = bit(1), ///< Right button - MOUSE_BUTTON_MIDDLE = bit(2), ///< Middle button, - MOUSE_BUTTON_BACKWARD = bit(3), ///< Backward button, - MOUSE_BUTTON_FORWARD = bit(4), ///< Forward button, - - MOUSE_BUTTON_UNCHANGED = 0xff, ///< Not specified by HID but useful for holding mouse buttons -}hid_mouse_button_bm_t; - -//--------------------------------------------------------------------+ -// Keyboard -//--------------------------------------------------------------------+ -/// HID Consumer Control Report -typedef ATTR_PACKED_STRUCT(struct) -{ - uint16_t usage_value; ///< Usage value of the pressed control -} hid_consumer_control_report_t; - -///// Keyboard modifier codes bitmap -typedef enum { - KEYBOARD_MODIFIER_LEFTCTRL = bit(0), ///< Left Control - KEYBOARD_MODIFIER_LEFTSHIFT = bit(1), ///< Left Shift - KEYBOARD_MODIFIER_LEFTALT = bit(2), ///< Left Alt - KEYBOARD_MODIFIER_LEFTGUI = bit(3), ///< Left Window - KEYBOARD_MODIFIER_RIGHTCTRL = bit(4), ///< Right Control - KEYBOARD_MODIFIER_RIGHTSHIFT = bit(5), ///< Right Shift - KEYBOARD_MODIFIER_RIGHTALT = bit(6), ///< Right Alt - KEYBOARD_MODIFIER_RIGHTGUI = bit(7) ///< Right Window -}hid_keyboard_modifier_bm_t; - -typedef enum { - KEYBOARD_LED_NUMLOCK = bit(0), ///< Num Lock LED - KEYBOARD_LED_CAPSLOCK = bit(1), ///< Caps Lock LED - KEYBOARD_LED_SCROLLLOCK = bit(2), ///< Scroll Lock LED - KEYBOARD_LED_COMPOSE = bit(3), ///< Composition Mode - KEYBOARD_LED_KANA = bit(4) ///< Kana mode -}hid_keyboard_led_bm_t; - -//--------------------------------------------------------------------+ -// HID KEYCODE -//--------------------------------------------------------------------+ -#define HID_KEY_NONE 0x00 -#define HID_KEY_A 0x04 -#define HID_KEY_B 0x05 -#define HID_KEY_C 0x06 -#define HID_KEY_D 0x07 -#define HID_KEY_E 0x08 -#define HID_KEY_F 0x09 -#define HID_KEY_G 0x0A -#define HID_KEY_H 0x0B -#define HID_KEY_I 0x0C -#define HID_KEY_J 0x0D -#define HID_KEY_K 0x0E -#define HID_KEY_L 0x0F -#define HID_KEY_M 0x10 -#define HID_KEY_N 0x11 -#define HID_KEY_O 0x12 -#define HID_KEY_P 0x13 -#define HID_KEY_Q 0x14 -#define HID_KEY_R 0x15 -#define HID_KEY_S 0x16 -#define HID_KEY_T 0x17 -#define HID_KEY_U 0x18 -#define HID_KEY_V 0x19 -#define HID_KEY_W 0x1A -#define HID_KEY_X 0x1B -#define HID_KEY_Y 0x1C -#define HID_KEY_Z 0x1D -#define HID_KEY_1 0x1E -#define HID_KEY_2 0x1F -#define HID_KEY_3 0x20 -#define HID_KEY_4 0x21 -#define HID_KEY_5 0x22 -#define HID_KEY_6 0x23 -#define HID_KEY_7 0x24 -#define HID_KEY_8 0x25 -#define HID_KEY_9 0x26 -#define HID_KEY_0 0x27 -#define HID_KEY_RETURN 0x28 -#define HID_KEY_ESCAPE 0x29 -#define HID_KEY_BACKSPACE 0x2A -#define HID_KEY_TAB 0x2B -#define HID_KEY_SPACE 0x2C -#define HID_KEY_MINUS 0x2D -#define HID_KEY_EQUAL 0x2E -#define HID_KEY_BRACKET_LEFT 0x2F -#define HID_KEY_BRACKET_RIGHT 0x30 -#define HID_KEY_BACKSLASH 0x31 -#define HID_KEY_EUROPE_1 0x32 -#define HID_KEY_SEMICOLON 0x33 -#define HID_KEY_APOSTROPHE 0x34 -#define HID_KEY_GRAVE 0x35 -#define HID_KEY_COMMA 0x36 -#define HID_KEY_PERIOD 0x37 -#define HID_KEY_SLASH 0x38 -#define HID_KEY_CAPS_LOCK 0x39 -#define HID_KEY_F1 0x3A -#define HID_KEY_F2 0x3B -#define HID_KEY_F3 0x3C -#define HID_KEY_F4 0x3D -#define HID_KEY_F5 0x3E -#define HID_KEY_F6 0x3F -#define HID_KEY_F7 0x40 -#define HID_KEY_F8 0x41 -#define HID_KEY_F9 0x42 -#define HID_KEY_F10 0x43 -#define HID_KEY_F11 0x44 -#define HID_KEY_F12 0x45 -#define HID_KEY_PRINT_SCREEN 0x46 -#define HID_KEY_SCROLL_LOCK 0x47 -#define HID_KEY_PAUSE 0x48 -#define HID_KEY_INSERT 0x49 -#define HID_KEY_HOME 0x4A -#define HID_KEY_PAGE_UP 0x4B -#define HID_KEY_DELETE 0x4C -#define HID_KEY_END 0x4D -#define HID_KEY_PAGE_DOWN 0x4E -#define HID_KEY_ARROW_RIGHT 0x4F -#define HID_KEY_ARROW_LEFT 0x50 -#define HID_KEY_ARROW_DOWN 0x51 -#define HID_KEY_ARROW_UP 0x52 -#define HID_KEY_NUM_LOCK 0x53 -#define HID_KEY_KEYPAD_DIVIDE 0x54 -#define HID_KEY_KEYPAD_MULTIPLY 0x55 -#define HID_KEY_KEYPAD_SUBTRACT 0x56 -#define HID_KEY_KEYPAD_ADD 0x57 -#define HID_KEY_KEYPAD_ENTER 0x58 -#define HID_KEY_KEYPAD_1 0x59 -#define HID_KEY_KEYPAD_2 0x5A -#define HID_KEY_KEYPAD_3 0x5B -#define HID_KEY_KEYPAD_4 0x5C -#define HID_KEY_KEYPAD_5 0x5D -#define HID_KEY_KEYPAD_6 0x5E -#define HID_KEY_KEYPAD_7 0x5F -#define HID_KEY_KEYPAD_8 0x60 -#define HID_KEY_KEYPAD_9 0x61 -#define HID_KEY_KEYPAD_0 0x62 -#define HID_KEY_KEYPAD_DECIMAL 0x63 -#define HID_KEY_EUROPE_2 0x64 -#define HID_KEY_APPLICATION 0x65 -#define HID_KEY_POWER 0x66 -#define HID_KEY_KEYPAD_EQUAL 0x67 -#define HID_KEY_F13 0x68 -#define HID_KEY_F14 0x69 -#define HID_KEY_F15 0x6A -#define HID_KEY_CONTROL_LEFT 0xE0 -#define HID_KEY_SHIFT_LEFT 0xE1 -#define HID_KEY_ALT_LEFT 0xE2 -#define HID_KEY_GUI_LEFT 0xE3 -#define HID_KEY_CONTROL_RIGHT 0xE4 -#define HID_KEY_SHIFT_RIGHT 0xE5 -#define HID_KEY_ALT_RIGHT 0xE6 -#define HID_KEY_GUI_RIGHT 0xE7 - -typedef struct{ - uint8_t shift; - uint8_t keycode; -}hid_ascii_to_keycode_entry_t; -extern const hid_ascii_to_keycode_entry_t HID_ASCII_TO_KEYCODE[128]; - -//--------------------------------------------------------------------+ -// REPORT DESCRIPTOR -//--------------------------------------------------------------------+ -//------------- ITEM & TAG -------------// -#define HID_REPORT_DATA_0(data) -#define HID_REPORT_DATA_1(data) , (data) -#define HID_REPORT_DATA_2(data) , U16_TO_U8S_LE(data) -#define HID_REPORT_DATA_3(data) , U32_TO_U8S_LE(data) - -#define HID_REPORT_ITEM(data, tag, type, size) \ - (((tag) << 4) | ((type) << 2) | (size)) HID_REPORT_DATA_##size(data) - -#define RI_TYPE_MAIN 0 -#define RI_TYPE_GLOBAL 1 -#define RI_TYPE_LOCAL 2 - -//------------- MAIN ITEMS 6.2.2.4 -------------// -#define HID_INPUT(x) HID_REPORT_ITEM(x, 8, RI_TYPE_MAIN, 1) -#define HID_OUTPUT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_MAIN, 1) -#define HID_COLLECTION(x) HID_REPORT_ITEM(x, 10, RI_TYPE_MAIN, 1) -#define HID_FEATURE(x) HID_REPORT_ITEM(x, 11, RI_TYPE_MAIN, 1) -#define HID_COLLECTION_END HID_REPORT_ITEM(x, 12, RI_TYPE_MAIN, 0) - -//------------- INPUT, OUTPUT, FEATURE 6.2.2.5 -------------// -#define HID_DATA (0<<0) -#define HID_CONSTANT (1<<0) - -#define HID_ARRAY (0<<1) -#define HID_VARIABLE (1<<1) - -#define HID_ABSOLUTE (0<<2) -#define HID_RELATIVE (1<<2) - -#define HID_WRAP_NO (0<<3) -#define HID_WRAP (1<<3) - -#define HID_LINEAR (0<<4) -#define HID_NONLINEAR (1<<4) - -#define HID_PREFERRED_STATE (0<<5) -#define HID_PREFERRED_NO (1<<5) - -#define HID_NO_NULL_POSITION (0<<6) -#define HID_NULL_STATE (1<<6) - -#define HID_NON_VOLATILE (0<<7) -#define HID_VOLATILE (1<<7) - -#define HID_BITFIELD (0<<8) -#define HID_BUFFERED_BYTES (1<<8) - -//------------- COLLECTION ITEM 6.2.2.6 -------------// -enum { - HID_COLLECTION_PHYSICAL = 0, - HID_COLLECTION_APPLICATION, - HID_COLLECTION_LOGICAL, - HID_COLLECTION_REPORT, - HID_COLLECTION_NAMED_ARRAY, - HID_COLLECTION_USAGE_SWITCH, - HID_COLLECTION_USAGE_MODIFIER -}; - -//------------- GLOBAL ITEMS 6.2.2.7 -------------// -#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, 1) -#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, n) - -#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, 1) -#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, n) - -#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, 1) -#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, n) - -#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, 1) -#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, n) - -#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, 1) -#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, n) - -#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, 1) -#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, n) - -#define HID_UNIT(x) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, 1) -#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, n) - -#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, 1) -#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, n) - -#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, 1) -#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, n) - -#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, 1) -#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, n) - -#define HID_PUSH HID_REPORT_ITEM(x, 10, RI_TYPE_GLOBAL, 0) -#define HID_POP HID_REPORT_ITEM(x, 11, RI_TYPE_GLOBAL, 0) - -//------------- LOCAL ITEMS 6.2.2.8 -------------// -#define HID_USAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, 1) -#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, n) - -#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, 1) -#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, n) - -#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, 1) -#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, n) - -//--------------------------------------------------------------------+ -// Usage Table -//--------------------------------------------------------------------+ - -/// HID Usage Table - Table 1: Usage Page Summary -enum { - HID_USAGE_PAGE_DESKTOP = 0x01, - HID_USAGE_PAGE_SIMULATE = 0x02, - HID_USAGE_PAGE_VIRTUAL_REALITY = 0x03, - HID_USAGE_PAGE_SPORT = 0x04, - HID_USAGE_PAGE_GAME = 0x05, - HID_USAGE_PAGE_GENERIC_DEVICE = 0x06, - HID_USAGE_PAGE_KEYBOARD = 0x07, - HID_USAGE_PAGE_LED = 0x08, - HID_USAGE_PAGE_BUTTON = 0x09, - HID_USAGE_PAGE_ORDINAL = 0x0a, - HID_USAGE_PAGE_TELEPHONY = 0x0b, - HID_USAGE_PAGE_CONSUMER = 0x0c, - HID_USAGE_PAGE_DIGITIZER = 0x0d, - HID_USAGE_PAGE_PID = 0x0f, - HID_USAGE_PAGE_UNICODE = 0x10, - HID_USAGE_PAGE_ALPHA_DISPLAY = 0x14, - HID_USAGE_PAGE_MEDICAL = 0x40, - HID_USAGE_PAGE_MONITOR = 0x80, //0x80 - 0x83 - HID_USAGE_PAGE_POWER = 0x84, // 0x084 - 0x87 - HID_USAGE_PAGE_BARCODE_SCANNER = 0x8c, - HID_USAGE_PAGE_SCALE = 0x8d, - HID_USAGE_PAGE_MSR = 0x8e, - HID_USAGE_PAGE_CAMERA = 0x90, - HID_USAGE_PAGE_ARCADE = 0x91, - HID_USAGE_PAGE_VENDOR = 0xFFFF // 0xFF00 - 0xFFFF -}; - -/// HID Usage Table - Table 6: Generic Desktop Page -enum -{ - HID_USAGE_DESKTOP_POINTER = 0x01, - HID_USAGE_DESKTOP_MOUSE = 0x02, - HID_USAGE_DESKTOP_JOYSTICK = 0x04, - HID_USAGE_DESKTOP_GAMEPAD = 0x05, - HID_USAGE_DESKTOP_KEYBOARD = 0x06, - HID_USAGE_DESKTOP_KEYPAD = 0x07, - HID_USAGE_DESKTOP_MULTI_AXIS_CONTROLLER = 0x08, - HID_USAGE_DESKTOP_TABLET_PC_SYSTEM = 0x09, - HID_USAGE_DESKTOP_X = 0x30, - HID_USAGE_DESKTOP_Y = 0x31, - HID_USAGE_DESKTOP_Z = 0x32, - HID_USAGE_DESKTOP_RX = 0x33, - HID_USAGE_DESKTOP_RY = 0x34, - HID_USAGE_DESKTOP_RZ = 0x35, - HID_USAGE_DESKTOP_SLIDER = 0x36, - HID_USAGE_DESKTOP_DIAL = 0x37, - HID_USAGE_DESKTOP_WHEEL = 0x38, - HID_USAGE_DESKTOP_HAT_SWITCH = 0x39, - HID_USAGE_DESKTOP_COUNTED_BUFFER = 0x3a, - HID_USAGE_DESKTOP_BYTE_COUNT = 0x3b, - HID_USAGE_DESKTOP_MOTION_WAKEUP = 0x3c, - HID_USAGE_DESKTOP_START = 0x3d, - HID_USAGE_DESKTOP_SELECT = 0x3e, - HID_USAGE_DESKTOP_VX = 0x40, - HID_USAGE_DESKTOP_VY = 0x41, - HID_USAGE_DESKTOP_VZ = 0x42, - HID_USAGE_DESKTOP_VBRX = 0x43, - HID_USAGE_DESKTOP_VBRY = 0x44, - HID_USAGE_DESKTOP_VBRZ = 0x45, - HID_USAGE_DESKTOP_VNO = 0x46, - HID_USAGE_DESKTOP_FEATURE_NOTIFICATION = 0x47, - HID_USAGE_DESKTOP_RESOLUTION_MULTIPLIER = 0x48, - HID_USAGE_DESKTOP_SYSTEM_CONTROL = 0x80, - HID_USAGE_DESKTOP_SYSTEM_POWER_DOWN = 0x81, - HID_USAGE_DESKTOP_SYSTEM_SLEEP = 0x82, - HID_USAGE_DESKTOP_SYSTEM_WAKE_UP = 0x83, - HID_USAGE_DESKTOP_SYSTEM_CONTEXT_MENU = 0x84, - HID_USAGE_DESKTOP_SYSTEM_MAIN_MENU = 0x85, - HID_USAGE_DESKTOP_SYSTEM_APP_MENU = 0x86, - HID_USAGE_DESKTOP_SYSTEM_MENU_HELP = 0x87, - HID_USAGE_DESKTOP_SYSTEM_MENU_EXIT = 0x88, - HID_USAGE_DESKTOP_SYSTEM_MENU_SELECT = 0x89, - HID_USAGE_DESKTOP_SYSTEM_MENU_RIGHT = 0x8A, - HID_USAGE_DESKTOP_SYSTEM_MENU_LEFT = 0x8B, - HID_USAGE_DESKTOP_SYSTEM_MENU_UP = 0x8C, - HID_USAGE_DESKTOP_SYSTEM_MENU_DOWN = 0x8D, - HID_USAGE_DESKTOP_SYSTEM_COLD_RESTART = 0x8E, - HID_USAGE_DESKTOP_SYSTEM_WARM_RESTART = 0x8F, - HID_USAGE_DESKTOP_DPAD_UP = 0x90, - HID_USAGE_DESKTOP_DPAD_DOWN = 0x91, - HID_USAGE_DESKTOP_DPAD_RIGHT = 0x92, - HID_USAGE_DESKTOP_DPAD_LEFT = 0x93, - HID_USAGE_DESKTOP_SYSTEM_DOCK = 0xA0, - HID_USAGE_DESKTOP_SYSTEM_UNDOCK = 0xA1, - HID_USAGE_DESKTOP_SYSTEM_SETUP = 0xA2, - HID_USAGE_DESKTOP_SYSTEM_BREAK = 0xA3, - HID_USAGE_DESKTOP_SYSTEM_DEBUGGER_BREAK = 0xA4, - HID_USAGE_DESKTOP_APPLICATION_BREAK = 0xA5, - HID_USAGE_DESKTOP_APPLICATION_DEBUGGER_BREAK = 0xA6, - HID_USAGE_DESKTOP_SYSTEM_SPEAKER_MUTE = 0xA7, - HID_USAGE_DESKTOP_SYSTEM_HIBERNATE = 0xA8, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INVERT = 0xB0, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INTERNAL = 0xB1, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_EXTERNAL = 0xB2, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_BOTH = 0xB3, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_DUAL = 0xB4, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_SWAP_PRIMARY_SECONDARY = 0xB6, - HID_USAGE_DESKTOP_SYSTEM_DISPLAY_LCD_AUTOSCALE = 0xB7 -}; - -/// HID Usage Table: Consumer Page (0x0C) -/// Only contains controls that supported by Windows (whole list is too long) -enum -{ - // Generic Control - HID_USAGE_CONSUMER_CONTROL = 0x0001, - - // Power Control - HID_USAGE_CONSUMER_POWER = 0x0030, - HID_USAGE_CONSUMER_RESET = 0x0031, - HID_USAGE_CONSUMER_SLEEP = 0x0032, - - // Screen Brightness - HID_USAGE_CONSUMER_BRIGHTNESS_INCREMENT = 0x006F, - HID_USAGE_CONSUMER_BRIGHTNESS_DECREMENT = 0x0070, - - // These HID usages operate only on mobile systems (battery powered) and - // require Windows 8 (build 8302 or greater). - HID_USAGE_CONSUMER_WIRELESS_RADIO_CONTROLS = 0x000C, - HID_USAGE_CONSUMER_WIRELESS_RADIO_BUTTONS = 0x00C6, - HID_USAGE_CONSUMER_WIRELESS_RADIO_LED = 0x00C7, - HID_USAGE_CONSUMER_WIRELESS_RADIO_SLIDER_SWITCH = 0x00C8, - - // Media Control - HID_USAGE_CONSUMER_PLAY_PAUSE = 0x00CD, - HID_USAGE_CONSUMER_SCAN_NEXT = 0x00B5, - HID_USAGE_CONSUMER_SCAN_PREVIOUS = 0x00B6, - HID_USAGE_CONSUMER_STOP = 0x00B7, - HID_USAGE_CONSUMER_EJECT = 0x00B8, - - HID_USAGE_CONSUMER_VOLUME = 0x00E0, - HID_USAGE_CONSUMER_MUTE = 0x00E2, - HID_USAGE_CONSUMER_BASS = 0x00E3, - HID_USAGE_CONSUMER_TREBLE = 0x00E4, - HID_USAGE_CONSUMER_BASS_BOOST = 0x00E5, - HID_USAGE_CONSUMER_VOLUME_INCREMENT = 0x00E9, - HID_USAGE_CONSUMER_VOLUME_DECREMENT = 0x00EA, - HID_USAGE_CONSUMER_BASS_INCREMENT = 0x0152, - HID_USAGE_CONSUMER_BASS_DECREMENT = 0x0153, - HID_USAGE_CONSUMER_TREBLE_INCREMENT = 0x0154, - HID_USAGE_CONSUMER_TREBLE_DECREMENT = 0x0155, - - // Application Launcher - HID_USAGE_CONSUMER_AL_CONSUMER_CONTROL_CONFIGURATION = 0x0183, - HID_USAGE_CONSUMER_AL_EMAIL_READER = 0x018A, - HID_USAGE_CONSUMER_AL_CALCULATOR = 0x0192, - HID_USAGE_CONSUMER_AL_LOCAL_BROWSER = 0x0194, - - // Browser/Explorer Specific - HID_USAGE_CONSUMER_AC_SEARCH = 0x0221, - HID_USAGE_CONSUMER_AC_HOME = 0x0223, - HID_USAGE_CONSUMER_AC_BACK = 0x0224, - HID_USAGE_CONSUMER_AC_FORWARD = 0x0225, - HID_USAGE_CONSUMER_AC_STOP = 0x0226, - HID_USAGE_CONSUMER_AC_REFRESH = 0x0227, - HID_USAGE_CONSUMER_AC_BOOKMARKS = 0x022A, - - // Mouse Horizontal scroll - HID_USAGE_CONSUMER_AC_PAN = 0x0238, -}; - - -#endif /* BLEHID_H_ */