ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

keymap.h

Committer:
cho45
Date:
2016-07-21
Revision:
6:f1c3ea8bc850
Parent:
5:65d4e94735b6
Child:
13:b0ffdf2012b9

File content as of revision 6:f1c3ea8bc850:

#include "keyboard.h"
#include "keyboard--short-names.h"

static const uint8_t ROWS = 8;
static const uint8_t COLS = 16;

// unimplemented in hardware is __
#define __________ 0
// unimplemented in firmware is _undef
#define _undef 0

static const uint8_t KEYMAP_DEFINITION[ROWS][COLS] = {
	/*0*/{ _undef     , _F1        , _F2        , _F3        , _F4        , _F5        , _F6        , __________ , __________ , _F7        , _F8        , _F9        , _F10       , _F11       , _F12       , _undef }     , 
	/*1*/{ _esc       , _1         , _2         , _3         , _4         , _5         , _6         , _7         , _6         , _7         , _8         , _9         , _0         , _dash      , _equal     , _backslash } , 
	/*2*/{ _tab       , _Q         , _W         , _E         , _R         , _T         , _Y         , _T         , __________ , _Y         , _U         , _I         , _O         , _P         , _bracketL  , _grave }     , 
	/*3*/{ _ctrlL     , _A         , _S         , _D         , _F         , _G         , _H         , _G         , __________ , _H         , _J         , _K         , _L         , _semicolon , _quote     , _bracketR }  , 
	/*4*/{ _shiftL    , _Z         , _X         , _C         , _V         , _B         , _N         , _B         , __________ , _N         , _M         , _comma     , _period    , _slash     , _shiftR    , _bs }       , 
	/*5*/{ _altL      , _guiL      , _space     , __________ , __________ , _undef     , __________ , __________ , __________ , __________ , _arrowU    , _space     , _guiR      , _altR      , _undef     , _return }    , 
	/*6*/{ __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , _arrowL    , _arrowD    , _arrowR    , __________ , __________ , __________ , __________ } , 
	/*7*/{ __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ , __________ } , 
};

#undef __________
#undef _undef

class Keymap {
public:
	Keymap() {
	}

	uint8_t mappingFor(int col, int row) const {
		return KEYMAP_DEFINITION[row][col];
	}

	void execute(int col, int row, bool pressed) {
		uint8_t key = KEYMAP_DEFINITION[row][col];
		if (key) {
			if (pressed) {
				printf("appendReportData %x\r\n", key);
				HIDController::appendReportData(key);
			} else {
				printf("deleteReportData %x\r\n", key);
				HIDController::deleteReportData(key);
			}
		}
	}
};