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:
parent
0f7ebe81cc
commit
19e55ee62d
78
layouts.h
78
layouts.h
@ -4,8 +4,9 @@
|
||||
// Modifier Mask
|
||||
#define MODIFIERS_KEYPAD 0
|
||||
#define MODIFIERS_KEYBOARD 4
|
||||
static uint8_t keypad_modifierMask[] = {};
|
||||
static uint8_t keyboard_modifierMask[] = { 1, 17, 33, 49 };
|
||||
static uint8_t keypad_modifierMask[] = {};
|
||||
static uint8_t keyboard_modifierMask[] = { 1, 17, 33, 49 };
|
||||
static uint8_t alternate_modifierMask[] = { 1, 17, 33, 49, 62 };
|
||||
|
||||
// Default 1-indexed key mappings
|
||||
static uint8_t keypadDefaultMap[] = { 0,
|
||||
@ -91,6 +92,71 @@ static uint8_t defaultMap[] = { 0,
|
||||
KEY_RIGHT,
|
||||
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,
|
||||
KEY_GUI,
|
||||
KEY_1,
|
||||
@ -123,7 +189,7 @@ static uint8_t colemakMap[] = { 0,
|
||||
KEY_LEFT_BRACE,
|
||||
KEY_RIGHT_BRACE,
|
||||
KEY_DELETE,
|
||||
KEY_UP,
|
||||
KEY_PAGE_UP,
|
||||
KEY_CTRL,
|
||||
KEY_CAPS_LLOCK,
|
||||
KEY_A,
|
||||
@ -138,7 +204,7 @@ static uint8_t colemakMap[] = { 0,
|
||||
KEY_O,
|
||||
KEY_QUOTE,
|
||||
KEY_ENTER,
|
||||
KEY_DOWN,
|
||||
KEY_PAGE_DOWN,
|
||||
KEY_ESC,
|
||||
KEY_LEFT_SHIFT,
|
||||
KEY_Z,
|
||||
@ -152,8 +218,8 @@ static uint8_t colemakMap[] = { 0,
|
||||
KEY_PERIOD,
|
||||
KEY_SLASH,
|
||||
KEY_RIGHT_SHIFT,
|
||||
KEY_LEFT,
|
||||
KEY_RIGHT,
|
||||
165,
|
||||
KEY_RIGHT_ALT,
|
||||
KEY_SPACE };
|
||||
|
||||
#endif
|
||||
|
39
main.c
39
main.c
@ -39,7 +39,7 @@
|
||||
|
||||
|
||||
// Debouncing Defines
|
||||
#define SAMPLE_THRESHOLD 100
|
||||
#define SAMPLE_THRESHOLD 110
|
||||
#define MAX_SAMPLES 127 // Max is 127, reaching 128 is very bad
|
||||
|
||||
|
||||
@ -288,7 +288,10 @@ void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys,
|
||||
// Too many keys
|
||||
if ( *validKeys == 6 )
|
||||
break;
|
||||
keyboard_keys[(*validKeys)++] = map[key];
|
||||
|
||||
// Allow ignoring keys with 0's
|
||||
if ( map[key] != 0 )
|
||||
keyboard_keys[(*validKeys)++] = map[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -374,19 +377,37 @@ int main( void )
|
||||
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
|
||||
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
|
||||
keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_modifierMask, MODIFIERS_KEYBOARD, colemakMap );
|
||||
keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_modifierMask, MODIFIERS_KEYPAD, keypadDefaultMap );
|
||||
}
|
||||
else {
|
||||
keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_modifierMask, MODIFIERS_KEYBOARD, defaultMap );
|
||||
keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_modifierMask, MODIFIERS_KEYPAD, keypadDefaultMap );
|
||||
keyboard_MAP = colemakMap;
|
||||
keyboard_MODMASK = alternate_modifierMask;
|
||||
keyboard_NUMMODS = 5;
|
||||
|
||||
// Function Key
|
||||
if ( keyDetectArray[61] & (1 << 7) ) {
|
||||
keyboard_MAP = navigationMap;
|
||||
}
|
||||
}
|
||||
|
||||
keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE, keyboard_MODMASK, keyboard_NUMMODS, keyboard_MAP );
|
||||
keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE, keypad_MODMASK, keypad_NUMMODS, keypad_MAP );
|
||||
print(":\n");
|
||||
|
||||
// TODO undo potentially old keys
|
||||
|
Reference in New Issue
Block a user