ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Committer:
cho45
Date:
Thu Jul 21 00:38:09 2016 +0900
Revision:
5:65d4e94735b6
Child:
6:f1c3ea8bc850
keyboard controller

Who changed what in which revision?

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