Add repeating of Fn key with alt keycode.

master
tmk 2012-10-07 12:25:18 +09:00
parent c845fd078c
commit e9af482690
2 changed files with 22 additions and 7 deletions

25
common/keyboard.c 100755 → 100644
View File

@ -208,7 +208,6 @@ static void unregister_code(uint8_t code)
static inline void process_key(keyevent_t event) static inline void process_key(keyevent_t event)
{ {
/* TODO: ring buffer /* TODO: ring buffer
static keyrecord_t waiting_keys[5]; static keyrecord_t waiting_keys[5];
static uint8_t waiting_keys_head = 0; static uint8_t waiting_keys_head = 0;
@ -220,12 +219,12 @@ static inline void process_key(keyevent_t event)
uint8_t tmp_mods; uint8_t tmp_mods;
//debug("kbdstate: "); debug_hex(kbdstate);
debug("state: "); print_P(state_str(kbdstate)); debug("state: "); print_P(state_str(kbdstate));
debug(" kind: "); debug_hex(kind); debug(" kind: "); debug_hex(kind);
debug(" code: "); debug_hex(code); debug(" code: "); debug_hex(code);
if (event.pressed) { debug("d"); } else { debug("u"); } if (event.pressed) { debug("d"); } else { debug("u"); }
debug("\n"); debug("\n");
switch (kbdstate) { switch (kbdstate) {
case IDLE: case IDLE:
switch (kind) { switch (kind) {
@ -236,9 +235,20 @@ static inline void process_key(keyevent_t event)
layer_switch_off(code); layer_switch_off(code);
break; break;
case FNK_DOWN: case FNK_DOWN:
// store event // repeat Fn alt key when press Fn key down, up then down again quickly
delayed_fn = (keyrecord_t) { .event = event, .code = code, .mods = keyboard_report->mods, .time = timer_read() }; if (KEYEQ(delayed_fn.event.key, event.key) &&
timer_elapsed(delayed_fn.time) < LAYER_DELAY) {
register_code(keymap_fn_keycode(FN_INDEX(code)));
NEXT(PRESSING);
} else {
delayed_fn = (keyrecord_t) {
.event = event,
.code = code,
.mods = keyboard_report->mods,
.time = timer_read()
};
NEXT(DELAYING); NEXT(DELAYING);
}
break; break;
case FNK_UP: case FNK_UP:
layer_switch_off(code); layer_switch_off(code);
@ -298,7 +308,12 @@ static inline void process_key(keyevent_t event)
case FNK_DOWN: case FNK_DOWN:
case KEY_DOWN: case KEY_DOWN:
case MOUSEKEY_DOWN: case MOUSEKEY_DOWN:
waiting_key = (keyrecord_t) { .event = event, .code = code, .mods = keyboard_report->mods, .time = timer_read() }; waiting_key = (keyrecord_t) {
.event = event,
.code = code,
.mods = keyboard_report->mods,
.time = timer_read()
};
NEXT(WAITING); NEXT(WAITING);
break; break;
case MOD_DOWN: case MOD_DOWN:

0
common/keyboard.h 100755 → 100644
View File