diff options
| author | tmk <nobody@nowhere> | 2013-07-23 10:57:12 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-07-23 10:57:37 +0900 |
| commit | 7e5081b5a8f2c6e0c3c8d2dc73717c0b3597ef84 (patch) | |
| tree | 421f2d6bdaad59fb338b1dbaffe38b5468aa66bb /common | |
| parent | 5b425731c5b662d107ba0f970a7ae7c7fe97d01b (diff) | |
| parent | 2721022078c30dd00c1063e4a2f8199b2b53e0d5 (diff) | |
| download | qmk_firmware-7e5081b5a8f2c6e0c3c8d2dc73717c0b3597ef84.tar.gz qmk_firmware-7e5081b5a8f2c6e0c3c8d2dc73717c0b3597ef84.zip | |
Merge branch 'lockkey_fix'(Fix issue #46)
Diffstat (limited to 'common')
| -rw-r--r-- | common/action.c | 52 | ||||
| -rw-r--r-- | common/keycode.h | 7 |
2 files changed, 53 insertions, 6 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(); |
diff --git a/common/keycode.h b/common/keycode.h index 77d5b79ba..08c3cbf42 100644 --- a/common/keycode.h +++ b/common/keycode.h | |||
| @@ -60,10 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 60 | #define KC_DEL KC_DELETE | 60 | #define KC_DEL KC_DELETE |
| 61 | #define KC_INS KC_INSERT | 61 | #define KC_INS KC_INSERT |
| 62 | #define KC_CAPS KC_CAPSLOCK | 62 | #define KC_CAPS KC_CAPSLOCK |
| 63 | #define KC_CLCK KC_CAPSLOCK | ||
| 63 | #define KC_RGHT KC_RIGHT | 64 | #define KC_RGHT KC_RIGHT |
| 64 | #define KC_PGDN KC_PGDOWN | 65 | #define KC_PGDN KC_PGDOWN |
| 65 | #define KC_PSCR KC_PSCREEN | 66 | #define KC_PSCR KC_PSCREEN |
| 66 | #define KC_SLCK KC_SCKLOCK | 67 | #define KC_SLCK KC_SCROLLLOCK |
| 67 | #define KC_PAUS KC_PAUSE | 68 | #define KC_PAUS KC_PAUSE |
| 68 | #define KC_BRK KC_PAUSE | 69 | #define KC_BRK KC_PAUSE |
| 69 | #define KC_NLCK KC_NUMLOCK | 70 | #define KC_NLCK KC_NUMLOCK |
| @@ -82,6 +83,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 82 | #define KC_NUHS KC_NONUS_HASH | 83 | #define KC_NUHS KC_NONUS_HASH |
| 83 | #define KC_NUBS KC_NONUS_BSLASH | 84 | #define KC_NUBS KC_NONUS_BSLASH |
| 84 | #define KC_LCAP KC_LOCKING_CAPS | 85 | #define KC_LCAP KC_LOCKING_CAPS |
| 86 | #define KC_LNUM KC_LOCKING_NUM | ||
| 87 | #define KC_LSCR KC_LOCKING_SCROLL | ||
| 85 | #define KC_ERAS KC_ALT_ERASE, | 88 | #define KC_ERAS KC_ALT_ERASE, |
| 86 | #define KC_CLR KC_CLEAR | 89 | #define KC_CLR KC_CLEAR |
| 87 | /* Japanese specific */ | 90 | /* Japanese specific */ |
| @@ -230,7 +233,7 @@ enum hid_keyboard_keypad_usage { | |||
| 230 | KC_F11, | 233 | KC_F11, |
| 231 | KC_F12, | 234 | KC_F12, |
| 232 | KC_PSCREEN, | 235 | KC_PSCREEN, |
| 233 | KC_SCKLOCK, | 236 | KC_SCROLLLOCK, |
| 234 | KC_PAUSE, | 237 | KC_PAUSE, |
| 235 | KC_INSERT, | 238 | KC_INSERT, |
| 236 | KC_HOME, | 239 | KC_HOME, |
