}
#ifdef LOCKING_SUPPORT_ENABLE
- else if (KC_LOCKING_CAPS == code) {
-#ifdef LOCKING_RESYNC_ENABLE
- // Resync: ignore if caps lock already is on
- if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
-#endif
- add_key(KC_CAPSLOCK);
- send_keyboard_report();
- wait_ms(100);
- del_key(KC_CAPSLOCK);
- send_keyboard_report();
- }
-
- else if (KC_LOCKING_NUM == code) {
-#ifdef LOCKING_RESYNC_ENABLE
- if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return;
-#endif
- add_key(KC_NUMLOCK);
- send_keyboard_report();
- wait_ms(100);
- del_key(KC_NUMLOCK);
- send_keyboard_report();
- }
-
- else if (KC_LOCKING_SCROLL == code) {
+ else if (code == KC_LOCKING_CAPS ||
+ code == KC_LOCKING_NUM ||
+ code == KC_LOCKING_SCROLL) {
+ uint8_t c, l;
+ if (code == KC_LOCKING_CAPS) {
+ c = KC_CAPSLOCK;
+ l = 1<<USB_LED_CAPS_LOCK;
+ } else if (code == KC_LOCKING_NUM) {
+ c = KC_NUMLOCK;
+ l = 1<<USB_LED_NUM_LOCK;
+ } else if (code == KC_LOCKING_SCROLL) {
+ c = KC_SCROLLLOCK;
+ l = 1<<USB_LED_SCROLL_LOCK;
+ }
#ifdef LOCKING_RESYNC_ENABLE
- if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return;
+ // Resync: ignore if lock indicator is already on
+ if (host_keyboard_leds() & l) return;
#endif
- add_key(KC_SCROLLLOCK);
+ add_key(c);
send_keyboard_report();
- wait_ms(100);
- del_key(KC_SCROLLLOCK);
+ wait_ms(100); // Delay for MacOS #390
+ del_key(c);
send_keyboard_report();
}
#endif
}
#ifdef LOCKING_SUPPORT_ENABLE
- else if (KC_LOCKING_CAPS == code) {
-#ifdef LOCKING_RESYNC_ENABLE
- // Resync: ignore if caps lock already is off
- if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return;
-#endif
- add_key(KC_CAPSLOCK);
- send_keyboard_report();
- wait_ms(100);
- del_key(KC_CAPSLOCK);
- send_keyboard_report();
- }
-
- else if (KC_LOCKING_NUM == code) {
-#ifdef LOCKING_RESYNC_ENABLE
- if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return;
-#endif
- add_key(KC_NUMLOCK);
- send_keyboard_report();
- wait_ms(100);
- del_key(KC_NUMLOCK);
- send_keyboard_report();
- }
-
- else if (KC_LOCKING_SCROLL == code) {
+ else if (code == KC_LOCKING_CAPS ||
+ code == KC_LOCKING_NUM ||
+ code == KC_LOCKING_SCROLL) {
+ uint8_t c, l;
+ if (code == KC_LOCKING_CAPS) {
+ c = KC_CAPSLOCK;
+ l = 1<<USB_LED_CAPS_LOCK;
+ } else if (code == KC_LOCKING_NUM) {
+ c = KC_NUMLOCK;
+ l = 1<<USB_LED_NUM_LOCK;
+ } else if (code == KC_LOCKING_SCROLL) {
+ c = KC_SCROLLLOCK;
+ l = 1<<USB_LED_SCROLL_LOCK;
+ }
#ifdef LOCKING_RESYNC_ENABLE
- if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return;
+ // Resync: ignore if lock indicator is already off
+ if (!(host_keyboard_leds() & l)) return;
#endif
- add_key(KC_SCROLLLOCK);
+ add_key(c);
send_keyboard_report();
- wait_ms(100);
- del_key(KC_SCROLLLOCK);
+ wait_ms(100); // Delay for MacOS #390
+ del_key(c);
send_keyboard_report();
}
#endif