ble nano hid over gatt
Dependencies: BLE_API mbed-dev nRF51822
keymap.h@6:f1c3ea8bc850, 2016-07-21 (annotated)
- Committer:
- cho45
- Date:
- Thu Jul 21 01:25:31 2016 +0900
- Revision:
- 6:f1c3ea8bc850
- Parent:
- 5:65d4e94735b6
- Child:
- 13:b0ffdf2012b9
act as keyboard
Who changed what in which revision?
User | Revision | Line number | New 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 | public: |
cho45 |
6:f1c3ea8bc850 | 28 | Keymap() { |
cho45 |
5:65d4e94735b6 | 29 | } |
cho45 |
5:65d4e94735b6 | 30 | |
cho45 |
5:65d4e94735b6 | 31 | uint8_t mappingFor(int col, int row) const { |
cho45 |
5:65d4e94735b6 | 32 | return KEYMAP_DEFINITION[row][col]; |
cho45 |
5:65d4e94735b6 | 33 | } |
cho45 |
5:65d4e94735b6 | 34 | |
cho45 |
5:65d4e94735b6 | 35 | void execute(int col, int row, bool pressed) { |
cho45 |
5:65d4e94735b6 | 36 | uint8_t key = KEYMAP_DEFINITION[row][col]; |
cho45 |
5:65d4e94735b6 | 37 | if (key) { |
cho45 |
5:65d4e94735b6 | 38 | if (pressed) { |
cho45 |
6:f1c3ea8bc850 | 39 | printf("appendReportData %x\r\n", key); |
cho45 |
6:f1c3ea8bc850 | 40 | HIDController::appendReportData(key); |
cho45 |
5:65d4e94735b6 | 41 | } else { |
cho45 |
6:f1c3ea8bc850 | 42 | printf("deleteReportData %x\r\n", key); |
cho45 |
6:f1c3ea8bc850 | 43 | HIDController::deleteReportData(key); |
cho45 |
5:65d4e94735b6 | 44 | } |
cho45 |
5:65d4e94735b6 | 45 | } |
cho45 |
5:65d4e94735b6 | 46 | } |
cho45 |
5:65d4e94735b6 | 47 | }; |
cho45 |
5:65d4e94735b6 | 48 |