Archived
1
0

Adding the HHKB style navigation layer.

- Hack included for a minor debouncing/electrical problem (will fix later properly)
- Changed internal shift layers for nested switching.
This commit is contained in:
Jacob Alexander 2011-03-31 17:24:20 -07:00
parent 0f7ebe81cc
commit 19e55ee62d
2 changed files with 102 additions and 15 deletions

View File

@ -6,6 +6,7 @@
#define MODIFIERS_KEYBOARD 4 #define MODIFIERS_KEYBOARD 4
static uint8_t keypad_modifierMask[] = {}; static uint8_t keypad_modifierMask[] = {};
static uint8_t keyboard_modifierMask[] = { 1, 17, 33, 49 }; static uint8_t keyboard_modifierMask[] = { 1, 17, 33, 49 };
static uint8_t alternate_modifierMask[] = { 1, 17, 33, 49, 62 };
// Default 1-indexed key mappings // Default 1-indexed key mappings
static uint8_t keypadDefaultMap[] = { 0, static uint8_t keypadDefaultMap[] = { 0,
@ -91,6 +92,71 @@ static uint8_t defaultMap[] = { 0,
KEY_RIGHT, KEY_RIGHT,
KEY_SPACE }; KEY_SPACE };
static uint8_t navigationMap[] = { 0,
KEY_GUI,
KEY_F1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
KEY_F11,
KEY_F12,
KEY_INSERT,
KEY_DELETE,
KEY_BACKSPACE,
KEY_ALT,
KEY_CAPS_LOCK,
0,
0,
0,
0,
0,
0,
0,
KEY_SYSREQ_ATT,
KEY_SCROLL_LOCK,
KEY_PAUSE,
KEY_UP,
0,
0,
0,
KEY_CTRL,
KEY_CAPS_LLOCK,
0,
0,
0,
0,
0,
KEYPAD_ASTERIX,
KEYPAD_SLASH,
KEY_HOME,
KEY_PAGE_UP,
KEY_LEFT,
KEY_RIGHT,
KEY_ENTER,
0,
KEY_ESC,
KEY_LEFT_SHIFT,
0,
0,
0,
0,
0,
KEYPAD_PLUS,
KEYPAD_MINUS,
KEY_END,
KEY_PAGE_DOWN,
KEY_DOWN,
KEY_RIGHT_SHIFT,
165,
KEY_RIGHT_ALT,
KEY_SPACE };
static uint8_t colemakMap[] = { 0, static uint8_t colemakMap[] = { 0,
KEY_GUI, KEY_GUI,
KEY_1, KEY_1,
@ -123,7 +189,7 @@ static uint8_t colemakMap[] = { 0,
KEY_LEFT_BRACE, KEY_LEFT_BRACE,
KEY_RIGHT_BRACE, KEY_RIGHT_BRACE,
KEY_DELETE, KEY_DELETE,
KEY_UP, KEY_PAGE_UP,
KEY_CTRL, KEY_CTRL,
KEY_CAPS_LLOCK, KEY_CAPS_LLOCK,
KEY_A, KEY_A,
@ -138,7 +204,7 @@ static uint8_t colemakMap[] = { 0,
KEY_O, KEY_O,
KEY_QUOTE, KEY_QUOTE,
KEY_ENTER, KEY_ENTER,
KEY_DOWN, KEY_PAGE_DOWN,
KEY_ESC, KEY_ESC,
KEY_LEFT_SHIFT, KEY_LEFT_SHIFT,
KEY_Z, KEY_Z,
@ -152,8 +218,8 @@ static uint8_t colemakMap[] = { 0,
KEY_PERIOD, KEY_PERIOD,
KEY_SLASH, KEY_SLASH,
KEY_RIGHT_SHIFT, KEY_RIGHT_SHIFT,
KEY_LEFT, 165,
KEY_RIGHT, KEY_RIGHT_ALT,
KEY_SPACE }; KEY_SPACE };
#endif #endif

35
main.c
View File

@ -39,7 +39,7 @@
// Debouncing Defines // Debouncing Defines
#define SAMPLE_THRESHOLD 100 #define SAMPLE_THRESHOLD 110
#define MAX_SAMPLES 127 // Max is 127, reaching 128 is very bad #define MAX_SAMPLES 127 // Max is 127, reaching 128 is very bad
@ -288,6 +288,9 @@ void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys,
// Too many keys // Too many keys
if ( *validKeys == 6 ) if ( *validKeys == 6 )
break; break;
// Allow ignoring keys with 0's
if ( map[key] != 0 )
keyboard_keys[(*validKeys)++] = map[key]; keyboard_keys[(*validKeys)++] = map[key];
} }
} }
@ -374,19 +377,37 @@ int main( void )
continue; continue;
// XXX TODO HACK REMOVEME KILL_WITH_FIRE
// Too lazy to find (electrical?) issue, so I'm adding a software fix (case is impossible anyways without moar diodes)
if ( keyDetectArray[20] & (1 << 7) && keyDetectArray[21] & (1 << 7) && keyDetectArray[38] & (1 << 7) ) {
keyDetectArray[20] &= ~(1 << 7);
print("HACK!! - Fixme sometime");
}
// Detect Valid Keypresses - TODO // Detect Valid Keypresses - TODO
uint8_t validKeys = 0; uint8_t validKeys = 0;
// Map selection uint8_t *keyboard_MODMASK = keyboard_modifierMask;
uint8_t keyboard_NUMMODS = MODIFIERS_KEYBOARD;
uint8_t *keyboard_MAP = defaultMap;
uint8_t *keypad_MODMASK = keypad_modifierMask;
uint8_t keypad_NUMMODS = MODIFIERS_KEYPAD;
uint8_t *keypad_MAP = keypadDefaultMap;
// Map selection - CapsLock FN
if ( keyDetectArray[34] & (1 << 7) ) { // CapsLock FN Modifier if ( keyDetectArray[34] & (1 << 7) ) { // CapsLock FN Modifier
keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_modifierMask, MODIFIERS_KEYBOARD, colemakMap ); keyboard_MAP = colemakMap;
keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_modifierMask, MODIFIERS_KEYPAD, keypadDefaultMap ); keyboard_MODMASK = alternate_modifierMask;
keyboard_NUMMODS = 5;
// Function Key
if ( keyDetectArray[61] & (1 << 7) ) {
keyboard_MAP = navigationMap;
} }
else {
keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_modifierMask, MODIFIERS_KEYBOARD, defaultMap );
keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_modifierMask, MODIFIERS_KEYPAD, keypadDefaultMap );
} }
keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_MODMASK, keyboard_NUMMODS, keyboard_MAP );
keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_MODMASK, keypad_NUMMODS, keypad_MAP );
print(":\n"); print(":\n");
// TODO undo potentially old keys // TODO undo potentially old keys