ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Committer:
cho45
Date:
Sat Aug 27 08:43:53 2016 +0000
Revision:
42:2c3be8694896
Parent:
40:364deaa190fe
Child:
47:5bf2ae8cc710
?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cho45 42:2c3be8694896 1 #include "config.h"
cho45 5:65d4e94735b6 2 #include "keyboard.h"
cho45 5:65d4e94735b6 3 #include "keyboard--short-names.h"
cho45 5:65d4e94735b6 4
cho45 5:65d4e94735b6 5 static const uint8_t ROWS = 8;
cho45 5:65d4e94735b6 6 static const uint8_t COLS = 16;
cho45 5:65d4e94735b6 7
cho45 5:65d4e94735b6 8 // unimplemented in hardware is __
cho45 5:65d4e94735b6 9 #define __________ 0
cho45 5:65d4e94735b6 10 // unimplemented in firmware is _undef
cho45 5:65d4e94735b6 11 #define _undef 0
cho45 5:65d4e94735b6 12
cho45 5:65d4e94735b6 13 static const uint8_t KEYMAP_DEFINITION[ROWS][COLS] = {
cho45 13:b0ffdf2012b9 14 /*0*/{ _esc , _F1 , _F2 , _F3 , _F4 , _F5 , _F6 , __________ , __________ , _F7 , _F8 , _F9 , _F10 , _F11 , _F12 , _undef } ,
cho45 5:65d4e94735b6 15 /*1*/{ _esc , _1 , _2 , _3 , _4 , _5 , _6 , _7 , _6 , _7 , _8 , _9 , _0 , _dash , _equal , _backslash } ,
cho45 14:3a8c126b7834 16 /*2*/{ _tab , _Q , _W , _E , _R , _T , _Y , __________ , _T , _Y , _U , _I , _O , _P , _bracketL , _grave } ,
cho45 14:3a8c126b7834 17 /*3*/{ _ctrlL , _A , _S , _D , _F , _G , _H , __________ , _G , _H , _J , _K , _L , _semicolon , _quote , _bracketR } ,
cho45 14:3a8c126b7834 18 /*4*/{ _shiftL , _Z , _X , _C , _V , _B , _N , __________ , _B , _N , _M , _comma , _period , _slash , _shiftR , _bs } ,
cho45 14:3a8c126b7834 19 /*5*/{ _altL , _guiL , _space , __________ , __________ , _undef , __________ , __________ , __________ , _arrowU , _space , __________ , _guiR , _altR , _undef , _enter } ,
cho45 14:3a8c126b7834 20 /*6*/{ __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , _arrowL , _arrowD , _arrowR , __________ , __________ , __________ , __________ , __________ } ,
cho45 5:65d4e94735b6 21 /*7*/{ __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ } ,
cho45 5:65d4e94735b6 22 };
cho45 5:65d4e94735b6 23
cho45 5:65d4e94735b6 24 #undef __________
cho45 5:65d4e94735b6 25 #undef _undef
cho45 5:65d4e94735b6 26
cho45 5:65d4e94735b6 27 class Keymap {
cho45 5:65d4e94735b6 28 public:
cho45 6:f1c3ea8bc850 29 Keymap() {
cho45 5:65d4e94735b6 30 }
cho45 5:65d4e94735b6 31
cho45 5:65d4e94735b6 32 uint8_t mappingFor(int col, int row) const {
cho45 5:65d4e94735b6 33 return KEYMAP_DEFINITION[row][col];
cho45 5:65d4e94735b6 34 }
cho45 5:65d4e94735b6 35
cho45 5:65d4e94735b6 36 void execute(int col, int row, bool pressed) {
cho45 5:65d4e94735b6 37 uint8_t key = KEYMAP_DEFINITION[row][col];
cho45 5:65d4e94735b6 38 if (key) {
cho45 5:65d4e94735b6 39 if (pressed) {
cho45 42:2c3be8694896 40 DEBUG_PRINTF_KEYEVENT("D %x\r\n", key);
cho45 6:f1c3ea8bc850 41 HIDController::appendReportData(key);
cho45 5:65d4e94735b6 42 } else {
cho45 42:2c3be8694896 43 DEBUG_PRINTF_KEYEVENT("U %x\r\n", key);
cho45 6:f1c3ea8bc850 44 HIDController::deleteReportData(key);
cho45 5:65d4e94735b6 45 }
cho45 5:65d4e94735b6 46 }
cho45 5:65d4e94735b6 47 }
cho45 5:65d4e94735b6 48 };
cho45 5:65d4e94735b6 49