diff options
author | tmk <nobody@nowhere> | 2013-07-23 10:56:03 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-07-23 10:56:03 +0900 |
commit | 2721022078c30dd00c1063e4a2f8199b2b53e0d5 (patch) | |
tree | 421f2d6bdaad59fb338b1dbaffe38b5468aa66bb /common | |
parent | 5b425731c5b662d107ba0f970a7ae7c7fe97d01b (diff) |
Add mechanical locking switch support for NumLock and ScrollLock
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 c22f681fba..59c6f252dc 100644 --- a/common/action.c +++ b/common/action.c @@ -336,9 +336,10 @@ void register_code(uint8_t code) if (code == KC_NO) { return; } -#ifdef CAPSLOCK_LOCKING_ENABLE + +#ifdef LOCKING_SUPPORT_ENABLE else if (KC_LOCKING_CAPS == code) { -#ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE +#ifdef LOCKING_RESYNC_ENABLE // Resync: ignore if caps lock already is on if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return; #endif @@ -347,7 +348,28 @@ void register_code(uint8_t code) host_del_key(KC_CAPSLOCK); host_send_keyboard_report(); } + + else if (KC_LOCKING_NUM == code) { +#ifdef LOCKING_RESYNC_ENABLE + if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return; +#endif + host_add_key(KC_NUMLOCK); + host_send_keyboard_report(); + host_del_key(KC_NUMLOCK); + host_send_keyboard_report(); + } + + else if (KC_LOCKING_SCROLL == code) { +#ifdef LOCKING_RESYNC_ENABLE + if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return; +#endif + host_add_key(KC_SCROLLLOCK); + host_send_keyboard_report(); + host_del_key(KC_SCROLLLOCK); + host_send_keyboard_report(); + } #endif + else if IS_KEY(code) { // TODO: should push command_proc out of this block? if (command_proc(code)) return; @@ -386,9 +408,10 @@ void unregister_code(uint8_t code) if (code == KC_NO) { return; } -#ifdef CAPSLOCK_LOCKING_ENABLE + +#ifdef LOCKING_SUPPORT_ENABLE else if (KC_LOCKING_CAPS == code) { -#ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE +#ifdef LOCKING_RESYNC_ENABLE // Resync: ignore if caps lock already is off if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return; #endif @@ -397,7 +420,28 @@ void unregister_code(uint8_t code) host_del_key(KC_CAPSLOCK); host_send_keyboard_report(); } + + else if (KC_LOCKING_NUM == code) { +#ifdef LOCKING_RESYNC_ENABLE + if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return; +#endif + host_add_key(KC_NUMLOCK); + host_send_keyboard_report(); + host_del_key(KC_NUMLOCK); + host_send_keyboard_report(); + } + + else if (KC_LOCKING_SCROLL == code) { +#ifdef LOCKING_RESYNC_ENABLE + if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return; +#endif + host_add_key(KC_SCROLLLOCK); + host_send_keyboard_report(); + host_del_key(KC_SCROLLLOCK); + host_send_keyboard_report(); + } #endif + else if IS_KEY(code) { host_del_key(code); host_send_keyboard_report(); diff --git a/common/keycode.h b/common/keycode.h index 77d5b79baf..08c3cbf42b 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/>. #define KC_DEL KC_DELETE #define KC_INS KC_INSERT #define KC_CAPS KC_CAPSLOCK +#define KC_CLCK KC_CAPSLOCK #define KC_RGHT KC_RIGHT #define KC_PGDN KC_PGDOWN #define KC_PSCR KC_PSCREEN -#define KC_SLCK KC_SCKLOCK +#define KC_SLCK KC_SCROLLLOCK #define KC_PAUS KC_PAUSE #define KC_BRK KC_PAUSE #define KC_NLCK KC_NUMLOCK @@ -82,6 +83,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define KC_NUHS KC_NONUS_HASH #define KC_NUBS KC_NONUS_BSLASH #define KC_LCAP KC_LOCKING_CAPS +#define KC_LNUM KC_LOCKING_NUM +#define KC_LSCR KC_LOCKING_SCROLL #define KC_ERAS KC_ALT_ERASE, #define KC_CLR KC_CLEAR /* Japanese specific */ @@ -230,7 +233,7 @@ enum hid_keyboard_keypad_usage { KC_F11, KC_F12, KC_PSCREEN, - KC_SCKLOCK, + KC_SCROLLLOCK, KC_PAUSE, KC_INSERT, KC_HOME, |