From: tmk Date: Tue, 17 Sep 2019 11:55:35 +0000 (+0900) Subject: core: Add AC_BTLD to actionmap and unimap X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=83b90f4b6fe6744cababc153e3fee5ed42ee4322;p=max%2Ftmk_keyboard.git core: Add AC_BTLD to actionmap and unimap Now that it can jump to bootloader with AC_BTLD --- diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index c256892c..5a6f3df3 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -28,6 +28,7 @@ along with this program. If not, see . #include "action.h" #include "hook.h" #include "wait.h" +#include "bootloader.h" #ifdef DEBUG_ACTION #include "debug.h" @@ -341,6 +342,15 @@ void process_action(keyrecord_t *record) 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: diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 1eb69104..77c7c342 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h @@ -48,7 +48,7 @@ along with this program. If not, see . * 0100|10| usage(10) (reserved) * 0100|11| usage(10) (reserved) * - * ACT_MOUSEKEY(0110): TODO: Not needed? + * ACT_MOUSEKEY(0101): TODO: Not needed? * 0101|xxxx| keycode Mouse key * * 011x|xxxx xxxx xxxx (reseved) @@ -290,6 +290,12 @@ enum layer_pram_tap_op { /* * Extensions */ +/* Macro */ +#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) +#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) +#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) + +/* Backlight */ enum backlight_opt { BACKLIGHT_INCREASE = 0, BACKLIGHT_DECREASE = 1, @@ -297,18 +303,18 @@ enum backlight_opt { BACKLIGHT_STEP = 3, BACKLIGHT_LEVEL = 4, }; -/* Macro */ -#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) -#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) -#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) -/* Backlight */ #define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8) #define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) #define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) #define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) #define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level) + /* Command */ -#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) +enum command_ids { + COMMAND_BOOTLOADER, // jump to bootloader +}; +#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (id)) + /* Function */ enum function_opts { FUNC_TAP = 0x8, /* indciates function is tappable */ diff --git a/tmk_core/common/actionmap.h b/tmk_core/common/actionmap.h index 2ebfb0d0..a96c84b3 100644 --- a/tmk_core/common/actionmap.h +++ b/tmk_core/common/actionmap.h @@ -283,43 +283,7 @@ along with this program. If not, see . #define AC_WWW_STOP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) #define AC_WWW_REFRESH ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) #define AC_WWW_FAVORITES ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) -/* Jump to bootloader */ -#define AC_BOOTLOADER ACTION_KEY(KC_BOOTLOADER) -/* Fn key */ -/* -#define AC_FN0 ACTION_KEY(KC_FN0) -#define AC_FN1 ACTION_KEY(KC_FN1) -#define AC_FN2 ACTION_KEY(KC_FN2) -#define AC_FN3 ACTION_KEY(KC_FN3) -#define AC_FN4 ACTION_KEY(KC_FN4) -#define AC_FN5 ACTION_KEY(KC_FN5) -#define AC_FN6 ACTION_KEY(KC_FN6) -#define AC_FN7 ACTION_KEY(KC_FN7) -#define AC_FN8 ACTION_KEY(KC_FN8) -#define AC_FN9 ACTION_KEY(KC_FN9) -#define AC_FN10 ACTION_KEY(KC_FN10) -#define AC_FN11 ACTION_KEY(KC_FN11) -#define AC_FN12 ACTION_KEY(KC_FN12) -#define AC_FN13 ACTION_KEY(KC_FN13) -#define AC_FN14 ACTION_KEY(KC_FN14) -#define AC_FN15 ACTION_KEY(KC_FN15) -#define AC_FN16 ACTION_KEY(KC_FN16) -#define AC_FN17 ACTION_KEY(KC_FN17) -#define AC_FN18 ACTION_KEY(KC_FN18) -#define AC_FN19 ACTION_KEY(KC_FN19) -#define AC_FN20 ACTION_KEY(KC_FN20) -#define AC_FN21 ACTION_KEY(KC_FN21) -#define AC_FN22 ACTION_KEY(KC_FN22) -#define AC_FN23 ACTION_KEY(KC_FN23) -#define AC_FN24 ACTION_KEY(KC_FN24) -#define AC_FN25 ACTION_KEY(KC_FN25) -#define AC_FN26 ACTION_KEY(KC_FN26) -#define AC_FN27 ACTION_KEY(KC_FN27) -#define AC_FN28 ACTION_KEY(KC_FN28) -#define AC_FN29 ACTION_KEY(KC_FN29) -#define AC_FN30 ACTION_KEY(KC_FN30) -#define AC_FN31 ACTION_KEY(KC_FN31) -*/ + /* Mousekey */ #define AC_MS_UP ACTION_MOUSEKEY(KC_MS_UP) #define AC_MS_DOWN ACTION_MOUSEKEY(KC_MS_DOWN) @@ -338,6 +302,10 @@ along with this program. If not, see . #define AC_MS_ACCEL1 ACTION_MOUSEKEY(KC_MS_ACCEL1) #define AC_MS_ACCEL2 ACTION_MOUSEKEY(KC_MS_ACCEL2) +/* Command */ +#define AC_BOOTLOADER ACTION_COMMAND(COMMAND_BOOTLOADER, 0) + + /* * Short names */ @@ -447,9 +415,10 @@ along with this program. If not, see . #define AC_WSTP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) #define AC_WREF ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) #define AC_WFAV ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) -/* Jump to bootloader */ -#define AC_BTLD ACTION_KEY(KC_BOOTLOADER) /* Transparent */ #define AC_TRNS ACTION_KEY(KC_TRANSPARENT) +/* Command */ +#define AC_BTLD AC_BOOTLOADER + #endif diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 01c6e642..80ad388e 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -155,9 +155,7 @@ static action_t keycode_to_action(uint8_t keycode) return (action_t)ACTION_TRANSPARENT; break; case KC_BOOTLOADER: - clear_keyboard(); - wait_ms(50); - bootloader_jump(); // not return + return (action_t)ACTION_COMMAND(COMMAND_BOOTLOADER, 0); break; default: return (action_t)ACTION_NO;