1
0
Fork 0

Add mechanical locking switch support for NumLock and ScrollLock

This commit is contained in:
tmk 2013-07-23 10:56:03 +09:00
parent 5b425731c5
commit 2721022078
7 changed files with 75 additions and 28 deletions

View file

@ -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();