/*
-Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+Copyright 2012,2013,2020 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "action.h"
#include "hook.h"
#include "wait.h"
+#include "bootloader.h"
#ifdef DEBUG_ACTION
#include "debug.h"
} else {
dprint("MODS_TAP: Tap: register_code\n");
register_code(action.key.code);
+
+ // Delay for MacOS #659
+ if (action.key.code == KC_CAPSLOCK ||
+ action.key.code == KC_NUMLOCK ||
+ action.key.code == KC_SCROLLLOCK) {
+ wait_ms(100);
+ }
}
} else {
dprint("MODS_TAP: No tap: add_mods\n");
if (tap_count > 0) {
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
register_code(action.layer_tap.code);
+
+ // Delay for MacOS #659
+ if (action.layer_tap.code == KC_CAPSLOCK ||
+ action.layer_tap.code == KC_NUMLOCK ||
+ action.layer_tap.code == KC_SCROLLLOCK) {
+ wait_ms(100);
+ }
} else {
dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
layer_on(action.layer_tap.val);
break;
#endif
case ACT_COMMAND:
+ switch (action.command.id) {
+ case COMMAND_BOOTLOADER:
+ if (event.pressed) {
+ clear_keyboard();
+ wait_ms(50);
+ bootloader_jump();
+ }
+ break;
+ }
break;
#ifndef NO_ACTION_FUNCTION
case ACT_FUNCTION:
}
#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
switch (action.key.code) {
case MODS_ONESHOT:
case MODS_TAP_TOGGLE:
- case KC_A ... KC_EXSEL: // tap key
- case KC_LCTRL ... KC_RGUI: // tap key
+ default: // tap key
return true;
}
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
+ case OP_ON_OFF:
+ case OP_OFF_ON:
+ case OP_SET_CLEAR:
case 0xc0 ... 0xdf: // with modifiers
return false;
- case KC_A ... KC_EXSEL: // tap key
- case KC_LCTRL ... KC_RGUI: // tap key
case OP_TAP_TOGGLE:
+ default: // tap key
return true;
}
return false;