summaryrefslogtreecommitdiff
path: root/common/action.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-07-23 10:56:03 +0900
committertmk <nobody@nowhere>2013-07-23 10:56:03 +0900
commit2721022078c30dd00c1063e4a2f8199b2b53e0d5 (patch)
tree421f2d6bdaad59fb338b1dbaffe38b5468aa66bb /common/action.c
parent5b425731c5b662d107ba0f970a7ae7c7fe97d01b (diff)
Add mechanical locking switch support for NumLock and ScrollLock
Diffstat (limited to 'common/action.c')
-rw-r--r--common/action.c52
1 files changed, 48 insertions, 4 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();