diff options
Diffstat (limited to 'common/action.c')
| -rw-r--r-- | common/action.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/common/action.c b/common/action.c index c22f681fb..59c6f252d 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -336,9 +336,10 @@ void register_code(uint8_t code) | |||
| 336 | if (code == KC_NO) { | 336 | if (code == KC_NO) { |
| 337 | return; | 337 | return; |
| 338 | } | 338 | } |
| 339 | #ifdef CAPSLOCK_LOCKING_ENABLE | 339 | |
| 340 | #ifdef LOCKING_SUPPORT_ENABLE | ||
| 340 | else if (KC_LOCKING_CAPS == code) { | 341 | else if (KC_LOCKING_CAPS == code) { |
| 341 | #ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE | 342 | #ifdef LOCKING_RESYNC_ENABLE |
| 342 | // Resync: ignore if caps lock already is on | 343 | // Resync: ignore if caps lock already is on |
| 343 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return; | 344 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return; |
| 344 | #endif | 345 | #endif |
| @@ -347,7 +348,28 @@ void register_code(uint8_t code) | |||
| 347 | host_del_key(KC_CAPSLOCK); | 348 | host_del_key(KC_CAPSLOCK); |
| 348 | host_send_keyboard_report(); | 349 | host_send_keyboard_report(); |
| 349 | } | 350 | } |
| 351 | |||
| 352 | else if (KC_LOCKING_NUM == code) { | ||
| 353 | #ifdef LOCKING_RESYNC_ENABLE | ||
| 354 | if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return; | ||
| 355 | #endif | ||
| 356 | host_add_key(KC_NUMLOCK); | ||
| 357 | host_send_keyboard_report(); | ||
| 358 | host_del_key(KC_NUMLOCK); | ||
| 359 | host_send_keyboard_report(); | ||
| 360 | } | ||
| 361 | |||
| 362 | else if (KC_LOCKING_SCROLL == code) { | ||
| 363 | #ifdef LOCKING_RESYNC_ENABLE | ||
| 364 | if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return; | ||
| 365 | #endif | ||
| 366 | host_add_key(KC_SCROLLLOCK); | ||
| 367 | host_send_keyboard_report(); | ||
| 368 | host_del_key(KC_SCROLLLOCK); | ||
| 369 | host_send_keyboard_report(); | ||
| 370 | } | ||
| 350 | #endif | 371 | #endif |
| 372 | |||
| 351 | else if IS_KEY(code) { | 373 | else if IS_KEY(code) { |
| 352 | // TODO: should push command_proc out of this block? | 374 | // TODO: should push command_proc out of this block? |
| 353 | if (command_proc(code)) return; | 375 | if (command_proc(code)) return; |
| @@ -386,9 +408,10 @@ void unregister_code(uint8_t code) | |||
| 386 | if (code == KC_NO) { | 408 | if (code == KC_NO) { |
| 387 | return; | 409 | return; |
| 388 | } | 410 | } |
| 389 | #ifdef CAPSLOCK_LOCKING_ENABLE | 411 | |
| 412 | #ifdef LOCKING_SUPPORT_ENABLE | ||
| 390 | else if (KC_LOCKING_CAPS == code) { | 413 | else if (KC_LOCKING_CAPS == code) { |
| 391 | #ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE | 414 | #ifdef LOCKING_RESYNC_ENABLE |
| 392 | // Resync: ignore if caps lock already is off | 415 | // Resync: ignore if caps lock already is off |
| 393 | if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return; | 416 | if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return; |
| 394 | #endif | 417 | #endif |
| @@ -397,7 +420,28 @@ void unregister_code(uint8_t code) | |||
| 397 | host_del_key(KC_CAPSLOCK); | 420 | host_del_key(KC_CAPSLOCK); |
| 398 | host_send_keyboard_report(); | 421 | host_send_keyboard_report(); |
| 399 | } | 422 | } |
| 423 | |||
| 424 | else if (KC_LOCKING_NUM == code) { | ||
| 425 | #ifdef LOCKING_RESYNC_ENABLE | ||
| 426 | if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return; | ||
| 427 | #endif | ||
| 428 | host_add_key(KC_NUMLOCK); | ||
| 429 | host_send_keyboard_report(); | ||
| 430 | host_del_key(KC_NUMLOCK); | ||
| 431 | host_send_keyboard_report(); | ||
| 432 | } | ||
| 433 | |||
| 434 | else if (KC_LOCKING_SCROLL == code) { | ||
| 435 | #ifdef LOCKING_RESYNC_ENABLE | ||
| 436 | if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return; | ||
| 437 | #endif | ||
| 438 | host_add_key(KC_SCROLLLOCK); | ||
| 439 | host_send_keyboard_report(); | ||
| 440 | host_del_key(KC_SCROLLLOCK); | ||
| 441 | host_send_keyboard_report(); | ||
| 442 | } | ||
| 400 | #endif | 443 | #endif |
| 444 | |||
| 401 | else if IS_KEY(code) { | 445 | else if IS_KEY(code) { |
| 402 | host_del_key(code); | 446 | host_del_key(code); |
| 403 | host_send_keyboard_report(); | 447 | host_send_keyboard_report(); |
