diff options
Diffstat (limited to 'common')
| -rw-r--r--[-rwxr-xr-x] | common/keyboard.c | 29 | ||||
| -rw-r--r--[-rwxr-xr-x] | common/keyboard.h | 0 |
2 files changed, 22 insertions, 7 deletions
diff --git a/common/keyboard.c b/common/keyboard.c index 9f0c27670..b7063a264 100755..100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -163,7 +163,7 @@ static void unregister_code(uint8_t code) | |||
| 163 | * Event/State|IDLE DELAYING[f] WAITING[f,k] PRESSING | 163 | * Event/State|IDLE DELAYING[f] WAITING[f,k] PRESSING |
| 164 | * -----------+------------------------------------------------------------------ | 164 | * -----------+------------------------------------------------------------------ |
| 165 | * Fn Down |IDLE(L+) WAITING(Sk) WAITING(Sk) - | 165 | * Fn Down |IDLE(L+) WAITING(Sk) WAITING(Sk) - |
| 166 | * Up |IDLE(L-) IDLE(L-) IDLE(L-) IDLE(L-) | 166 | * Up |IDLE(L-) IDLE(L-) IDLE(L-) IDLE(L-) |
| 167 | * Fnk Down |DELAYING(Sf) WAITING(Sk) WAINTING(Sk) PRESSING(Rf) | 167 | * Fnk Down |DELAYING(Sf) WAITING(Sk) WAINTING(Sk) PRESSING(Rf) |
| 168 | * Up |IDLE(L-) IDLE(Rf,Uf) IDLE(Rf,Ps,Uf)*3 PRESSING(Uf) | 168 | * Up |IDLE(L-) IDLE(Rf,Uf) IDLE(Rf,Ps,Uf)*3 PRESSING(Uf) |
| 169 | * Key Down |PRESSING(Rk) WAITING(Sk) WAITING(Sk) PRESSING(Rk) | 169 | * Key Down |PRESSING(Rk) WAITING(Sk) WAITING(Sk) PRESSING(Rk) |
| @@ -208,7 +208,6 @@ static void unregister_code(uint8_t code) | |||
| 208 | 208 | ||
| 209 | static inline void process_key(keyevent_t event) | 209 | static inline void process_key(keyevent_t event) |
| 210 | { | 210 | { |
| 211 | |||
| 212 | /* TODO: ring buffer | 211 | /* TODO: ring buffer |
| 213 | static keyrecord_t waiting_keys[5]; | 212 | static keyrecord_t waiting_keys[5]; |
| 214 | static uint8_t waiting_keys_head = 0; | 213 | static uint8_t waiting_keys_head = 0; |
| @@ -220,12 +219,12 @@ static inline void process_key(keyevent_t event) | |||
| 220 | 219 | ||
| 221 | uint8_t tmp_mods; | 220 | uint8_t tmp_mods; |
| 222 | 221 | ||
| 223 | //debug("kbdstate: "); debug_hex(kbdstate); | ||
| 224 | debug("state: "); print_P(state_str(kbdstate)); | 222 | debug("state: "); print_P(state_str(kbdstate)); |
| 225 | debug(" kind: "); debug_hex(kind); | 223 | debug(" kind: "); debug_hex(kind); |
| 226 | debug(" code: "); debug_hex(code); | 224 | debug(" code: "); debug_hex(code); |
| 227 | if (event.pressed) { debug("d"); } else { debug("u"); } | 225 | if (event.pressed) { debug("d"); } else { debug("u"); } |
| 228 | debug("\n"); | 226 | debug("\n"); |
| 227 | |||
| 229 | switch (kbdstate) { | 228 | switch (kbdstate) { |
| 230 | case IDLE: | 229 | case IDLE: |
| 231 | switch (kind) { | 230 | switch (kind) { |
| @@ -236,9 +235,20 @@ static inline void process_key(keyevent_t event) | |||
| 236 | layer_switch_off(code); | 235 | layer_switch_off(code); |
| 237 | break; | 236 | break; |
| 238 | case FNK_DOWN: | 237 | case FNK_DOWN: |
| 239 | // store event | 238 | // repeat Fn alt key when press Fn key down, up then down again quickly |
| 240 | delayed_fn = (keyrecord_t) { .event = event, .code = code, .mods = keyboard_report->mods, .time = timer_read() }; | 239 | if (KEYEQ(delayed_fn.event.key, event.key) && |
| 241 | NEXT(DELAYING); | 240 | timer_elapsed(delayed_fn.time) < LAYER_DELAY) { |
| 241 | register_code(keymap_fn_keycode(FN_INDEX(code))); | ||
| 242 | NEXT(PRESSING); | ||
| 243 | } else { | ||
| 244 | delayed_fn = (keyrecord_t) { | ||
| 245 | .event = event, | ||
| 246 | .code = code, | ||
| 247 | .mods = keyboard_report->mods, | ||
| 248 | .time = timer_read() | ||
| 249 | }; | ||
| 250 | NEXT(DELAYING); | ||
| 251 | } | ||
| 242 | break; | 252 | break; |
| 243 | case FNK_UP: | 253 | case FNK_UP: |
| 244 | layer_switch_off(code); | 254 | layer_switch_off(code); |
| @@ -298,7 +308,12 @@ static inline void process_key(keyevent_t event) | |||
| 298 | case FNK_DOWN: | 308 | case FNK_DOWN: |
| 299 | case KEY_DOWN: | 309 | case KEY_DOWN: |
| 300 | case MOUSEKEY_DOWN: | 310 | case MOUSEKEY_DOWN: |
| 301 | waiting_key = (keyrecord_t) { .event = event, .code = code, .mods = keyboard_report->mods, .time = timer_read() }; | 311 | waiting_key = (keyrecord_t) { |
| 312 | .event = event, | ||
| 313 | .code = code, | ||
| 314 | .mods = keyboard_report->mods, | ||
| 315 | .time = timer_read() | ||
| 316 | }; | ||
| 302 | NEXT(WAITING); | 317 | NEXT(WAITING); |
| 303 | break; | 318 | break; |
| 304 | case MOD_DOWN: | 319 | case MOD_DOWN: |
diff --git a/common/keyboard.h b/common/keyboard.h index 2353805e1..2353805e1 100755..100644 --- a/common/keyboard.h +++ b/common/keyboard.h | |||
