Rip out old macro and action_function system (#16025)

* Rip out old macro and action_function system

* Update quantum/action_util.c

Co-authored-by: Joel Challis <git@zvecr.com>
master
Ryan 2022-01-25 08:22:20 +11:00 committed by GitHub
parent 3340ca46e8
commit 1d11ae3087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 8 additions and 538 deletions

View File

@ -20,7 +20,6 @@ QUANTUM_SRC += \
$(QUANTUM_DIR)/led.c \
$(QUANTUM_DIR)/action.c \
$(QUANTUM_DIR)/action_layer.c \
$(QUANTUM_DIR)/action_macro.c \
$(QUANTUM_DIR)/action_tapping.c \
$(QUANTUM_DIR)/action_util.c \
$(QUANTUM_DIR)/eeconfig.c \

View File

@ -129,10 +129,6 @@
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
/* disable these deprecated features by default */
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
/* Bootmagic Lite key configuration */
//#define BOOTMAGIC_LITE_ROW 0
//#define BOOTMAGIC_LITE_COLUMN 0

View File

@ -119,10 +119,6 @@
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
/* disable these deprecated features by default */
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
/* Bootmagic Lite key configuration */
//#define BOOTMAGIC_LITE_ROW 0
//#define BOOTMAGIC_LITE_COLUMN 0

View File

@ -124,10 +124,6 @@ If you define these options you will disable the associated feature, which can s
* disable tap dance and other tapping features
* `#define NO_ACTION_ONESHOT`
* disable one-shot modifiers
* `#define NO_ACTION_MACRO`
* disable old-style macro handling using `MACRO()`, `action_get_macro()` _(deprecated)_
* `#define NO_ACTION_FUNCTION`
* disable old-style function handling using `fn_actions`, `action_function()` _(deprecated)_
## Features That Can Be Enabled
@ -383,7 +379,6 @@ This is a [make](https://www.gnu.org/software/make/manual/make.html) file that i
* A list of [layouts](feature_layouts.md) this keyboard supports.
* `LTO_ENABLE`
* Enables Link Time Optimization (LTO) when compiling the keyboard. This makes the process take longer, but it can significantly reduce the compiled size (and since the firmware is small, the added time is not noticeable).
However, this will automatically disable the legacy TMK Macros and Functions features, as these break when LTO is enabled. It does this by automatically defining `NO_ACTION_MACRO` and `NO_ACTION_FUNCTION`. (Note: This does not affect QMK [Macros](feature_macros.md) and [Layers](feature_layers.md).)
## AVR MCU Options
* `MCU = atmega32u4`

View File

@ -191,9 +191,6 @@ With the entry of `#define NO_HAPTIC_MOD` in config.h, the following keys will n
* `TT()` layer tap toggle keys, when held to activate a layer. However when tapped `TAPPING_TOGGLE` times to permanently toggle the layer, on the last tap haptic feedback is still triggered.
* `MT()` mod tap keys, when held to keep a usual modifier key pressed. However when tapped, and the key is quickly released, and sends a keycode, haptic feedback is still triggered. See also [Mod-Tap](mod_tap.md).
### NO_HAPTIC_FN
With the entry of `#define NO_HAPTIC_FN` in config.h, deprecated `fn_actions` type function keys will not trigger a feedback.
### NO_HAPTIC_ALPHA
With the entry of `#define NO_HAPTIC_ALPHA` in config.h, none of the alpha keys (A ... Z) will trigger a feedback.

View File

@ -136,7 +136,7 @@ After this you'll find a list of LAYOUT() macros. A LAYOUT() is simply a list of
`keymaps[][MATRIX_ROWS][MATRIX_COLS]` in QMK holds the 16 bit action code (sometimes referred as the quantum keycode) in it. For the keycode representing typical keys, its high byte is 0 and its low byte is the USB HID usage ID for keyboard.
> TMK from which QMK was forked uses `const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS]` instead and holds the 8 bit keycode. Some keycode values are reserved to induce execution of certain action codes via the `fn_actions[]` array.
> TMK from which QMK was forked uses `const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS]` instead and holds the 8 bit keycode.
#### Base Layer

View File

@ -20,8 +20,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET,
KC_BSLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, KC_VOLU, KC_UP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
M(1), KC_LEFT, KC_DOWN, KC_RGHT, KC_PAUS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, KC_VOLD, M(0), KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PAUS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, KC_VOLD, _______, KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
),

View File

@ -11,7 +11,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[1] = LAYOUT_ortho(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC, KC_RBRC, KC_MINS, KC_EQL, KC_BSLS, KC_DEL,
KC_TRNS, KC_TRNS, KC_TRNS, M(1), M(1), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY),
[2] = LAYOUT_ortho(

View File

@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "led.h"
#include "action_layer.h"
#include "action_tapping.h"
#include "action_macro.h"
#include "action_util.h"
#include "action.h"
#include "wait.h"
@ -634,12 +633,7 @@ void process_action(keyrecord_t *record, action_t action) {
break;
# endif
#endif
/* Extentions */
#ifndef NO_ACTION_MACRO
case ACT_MACRO:
action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
break;
#endif
#ifdef SWAP_HANDS_ENABLE
case ACT_SWAP_HANDS:
switch (action.swap.code) {
@ -712,11 +706,6 @@ void process_action(keyrecord_t *record, action_t action) {
}
# endif
}
#endif
#ifndef NO_ACTION_FUNCTION
case ACT_FUNCTION:
action_function(record, action.func.id, action.func.opt);
break;
#endif
default:
break;
@ -1041,7 +1030,6 @@ void clear_keyboard_but_mods_and_keys() {
host_consumer_send(0);
#endif
clear_weak_mods();
clear_macro_mods();
send_keyboard_report();
#ifdef MOUSEKEY_ENABLE
mousekey_clear();
@ -1104,12 +1092,6 @@ bool is_tap_action(action_t action) {
return true;
}
return false;
case ACT_MACRO:
case ACT_FUNCTION:
if (action.func.opt & FUNC_TAP) {
return true;
}
return false;
}
return false;
}
@ -1166,12 +1148,6 @@ void debug_action(action_t action) {
case ACT_LAYER_TAP_EXT:
dprint("ACT_LAYER_TAP_EXT");
break;
case ACT_MACRO:
dprint("ACT_MACRO");
break;
case ACT_FUNCTION:
dprint("ACT_FUNCTION");
break;
case ACT_SWAP_HANDS:
dprint("ACT_SWAP_HANDS");
break;

View File

@ -22,22 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keyboard.h"
#include "keycode.h"
#include "action_code.h"
#include "action_macro.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Disable macro and function features when LTO is enabled, since they break */
#ifdef LTO_ENABLE
# ifndef NO_ACTION_MACRO
# define NO_ACTION_MACRO
# endif
# ifndef NO_ACTION_FUNCTION
# define NO_ACTION_FUNCTION
# endif
#endif
#ifndef TAP_CODE_DELAY
# define TAP_CODE_DELAY 0
#endif
@ -72,12 +61,6 @@ void action_exec(keyevent_t event);
action_t action_for_key(uint8_t layer, keypos_t key);
action_t action_for_keycode(uint16_t keycode);
/* macro */
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
/* user defined special function */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
/* keyboard-specific key event (pre)processing */
bool process_record_quantum(keyrecord_t *record);

View File

@ -79,19 +79,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* 101E|LLLL|1111 0100 One Shot Layer (0xF4) [TAP]
* 101E|LLLL|1111 xxxx Reserved (0xF5-FF)
* ELLLL: layer 0-31(E: extra bit for layer 16-31)
*
* Extensions(11xx)
* ----------------
* ACT_MACRO(1100):
* 1100|opt | id(8) Macro play?
* 1100|1111| id(8) Macro record?
*
* 1101|xxxx xxxx xxxx (reserved)
* 1110|xxxx xxxx xxxx (reserved)
*
* ACT_FUNCTION(1111):
* 1111| address(12) Function?
* 1111|opt | id(8) Function?
*/
enum action_kind_id {
/* Key Actions */
@ -111,9 +98,6 @@ enum action_kind_id {
ACT_LAYER_MODS = 0b1001,
ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */
ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */
/* Extensions */
ACT_MACRO = 0b1100,
ACT_FUNCTION = 0b1111
};
/** \brief Action Code Struct
@ -164,11 +148,6 @@ typedef union {
uint8_t page : 2;
uint8_t kind : 4;
} usage;
struct action_function {
uint8_t id : 8;
uint8_t opt : 4;
uint8_t kind : 4;
} func;
struct action_swap {
uint8_t code : 8;
uint8_t opt : 4;
@ -275,17 +254,6 @@ enum layer_param_tap_op {
#define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0)
#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0)
/* 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))
/* Function */
enum function_opts {
FUNC_TAP = 0x8, /* indciates function is tappable */
};
#define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id))
#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP << 8 | (id))
#define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt) << 8 | (id))
/* OneHand Support */
enum swap_hands_param_tap_op {
OP_SH_TOGGLE = 0xF0,

View File

@ -1,93 +0,0 @@
/*
Copyright 2013 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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "action.h"
#include "action_util.h"
#include "action_macro.h"
#include "wait.h"
#ifdef DEBUG_ACTION
# include "debug.h"
#else
# include "nodebug.h"
#endif
#ifndef NO_ACTION_MACRO
# define MACRO_READ() (macro = MACRO_GET(macro_p++))
/** \brief Action Macro Play
*
* FIXME: Needs doc
*/
void action_macro_play(const macro_t *macro_p) {
macro_t macro = END;
uint8_t interval = 0;
if (!macro_p) return;
while (true) {
switch (MACRO_READ()) {
case KEY_DOWN:
MACRO_READ();
dprintf("KEY_DOWN(%02X)\n", macro);
if (IS_MOD(macro)) {
add_macro_mods(MOD_BIT(macro));
send_keyboard_report();
} else {
register_code(macro);
}
break;
case KEY_UP:
MACRO_READ();
dprintf("KEY_UP(%02X)\n", macro);
if (IS_MOD(macro)) {
del_macro_mods(MOD_BIT(macro));
send_keyboard_report();
} else {
unregister_code(macro);
}
break;
case WAIT:
MACRO_READ();
dprintf("WAIT(%u)\n", macro);
{
uint8_t ms = macro;
while (ms--) wait_ms(1);
}
break;
case INTERVAL:
interval = MACRO_READ();
dprintf("INTERVAL(%u)\n", interval);
break;
case 0x04 ... 0x73:
dprintf("DOWN(%02X)\n", macro);
register_code(macro);
break;
case 0x84 ... 0xF3:
dprintf("UP(%02X)\n", macro);
unregister_code(macro & 0x7F);
break;
case END:
default:
return;
}
// interval
{
uint8_t ms = interval;
while (ms--) wait_ms(1);
}
}
}
#endif

View File

@ -1,123 +0,0 @@
/*
Copyright 2013 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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include "progmem.h"
typedef uint8_t macro_t;
#define MACRO_NONE (macro_t *)0
#define MACRO(...) \
({ \
static const macro_t __m[] PROGMEM = {__VA_ARGS__}; \
&__m[0]; \
})
#define MACRO_GET(p) pgm_read_byte(p)
// Sends press when the macro key is pressed, release when release, or tap_macro when the key has been tapped
#define MACRO_TAP_HOLD(record, press, release, tap_macro) (((record)->event.pressed) ? (((record)->tap.count <= 0 || (record)->tap.interrupted) ? (press) : MACRO_NONE) : (((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (tap_macro) : (release)))
// Holds down the modifier mod when the macro key is held, or sends macro instead when tapped
#define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro)
// Holds down the modifier mod when the macro key is held, or pressed a shifted key when tapped (eg: shift+3 for #)
#define MACRO_TAP_SHFT_KEY_HOLD_MOD(record, key, mod) MACRO_TAP_HOLD_MOD(record, (MACRO(I(10), D(LSFT), T(key), U(LSFT), END)), mod)
// Momentary switch layer when held, sends macro if tapped
#define MACRO_TAP_HOLD_LAYER(record, macro, layer) \
(((record)->event.pressed) ? (((record)->tap.count <= 0 || (record)->tap.interrupted) ? ({ \
layer_on((layer)); \
MACRO_NONE; \
}) \
: MACRO_NONE) \
: (((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : ({ \
layer_off((layer)); \
MACRO_NONE; \
})))
// Momentary switch layer when held, presses a shifted key when tapped (eg: shift+3 for #)
#define MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, key, layer) MACRO_TAP_HOLD_LAYER(record, MACRO(I(10), D(LSFT), T(key), U(LSFT), END), layer)
#ifndef NO_ACTION_MACRO
void action_macro_play(const macro_t *macro_p);
#else
# define action_macro_play(macro)
#endif
/* Macro commands
* code(0x04-73) // key down(1byte)
* code(0x04-73) | 0x80 // key up(1byte)
* { KEY_DOWN, code(0x04-0xff) } // key down(2bytes)
* { KEY_UP, code(0x04-0xff) } // key up(2bytes)
* WAIT // wait milli-seconds
* INTERVAL // set interval between macro commands
* END // stop macro execution
*
* Ideas(Not implemented):
* modifiers
* system usage
* consumer usage
* unicode usage
* function call
* conditionals
* loop
*/
enum macro_command_id {
/* 0x00 - 0x03 */
END = 0x00,
KEY_DOWN,
KEY_UP,
/* 0x04 - 0x73 (reserved for keycode down) */
/* 0x74 - 0x83 */
WAIT = 0x74,
INTERVAL,
/* 0x84 - 0xf3 (reserved for keycode up) */
/* 0xf4 - 0xff */
};
/* TODO: keycode:0x04-0x73 can be handled by 1byte command else 2bytes are needed
* if keycode between 0x04 and 0x73
* keycode / (keycode|0x80)
* else
* {KEY_DOWN, keycode} / {KEY_UP, keycode}
*/
#define DOWN(key) KEY_DOWN, (key)
#define UP(key) KEY_UP, (key)
#define TYPE(key) DOWN(key), UP(key)
#define WAIT(ms) WAIT, (ms)
#define INTERVAL(ms) INTERVAL, (ms)
/* key down */
#define D(key) DOWN(KC_##key)
/* key up */
#define U(key) UP(KC_##key)
/* key type */
#define T(key) TYPE(KC_##key)
/* wait */
#define W(ms) WAIT(ms)
/* interval */
#define I(ms) INTERVAL(ms)
/* for backward comaptibility */
#define MD(key) DOWN(KC_##key)
#define MU(key) UP(KC_##key)

View File

@ -27,7 +27,6 @@ extern keymap_config_t keymap_config;
static uint8_t real_mods = 0;
static uint8_t weak_mods = 0;
static uint8_t macro_mods = 0;
#ifdef KEY_OVERRIDE_ENABLE
static uint8_t weak_override_mods = 0;
static uint8_t suppressed_mods = 0;
@ -224,7 +223,6 @@ bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; }
void send_keyboard_report(void) {
keyboard_report->mods = real_mods;
keyboard_report->mods |= weak_mods;
keyboard_report->mods |= macro_mods;
#ifndef NO_ACTION_ONESHOT
if (oneshot_mods) {
@ -325,33 +323,6 @@ void set_suppressed_override_mods(uint8_t mods) { suppressed_mods = mods; }
void clear_suppressed_override_mods(void) { suppressed_mods = 0; }
#endif
/* macro modifier */
/** \brief get macro mods
*
* FIXME: needs doc
*/
uint8_t get_macro_mods(void) { return macro_mods; }
/** \brief add macro mods
*
* FIXME: needs doc
*/
void add_macro_mods(uint8_t mods) { macro_mods |= mods; }
/** \brief del macro mods
*
* FIXME: needs doc
*/
void del_macro_mods(uint8_t mods) { macro_mods &= ~mods; }
/** \brief set macro mods
*
* FIXME: needs doc
*/
void set_macro_mods(uint8_t mods) { macro_mods = mods; }
/** \brief clear macro mods
*
* FIXME: needs doc
*/
void clear_macro_mods(void) { macro_mods = 0; }
#ifndef NO_ACTION_ONESHOT
/** \brief get oneshot mods
*

View File

@ -49,13 +49,6 @@ void del_weak_mods(uint8_t mods);
void set_weak_mods(uint8_t mods);
void clear_weak_mods(void);
/* macro modifier */
uint8_t get_macro_mods(void);
void add_macro_mods(uint8_t mods);
void del_macro_mods(uint8_t mods);
void set_macro_mods(uint8_t mods);
void clear_macro_mods(void);
/* oneshot modifier */
uint8_t get_oneshot_mods(void);
void add_oneshot_mods(uint8_t mods);

View File

@ -35,8 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE)
#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_BRID)
#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN8)
@ -62,11 +60,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
#define FN_BIT(code) (1 << FN_INDEX(code))
#define FN_INDEX(code) ((code)-KC_FN0)
#define FN_MIN KC_FN0
#define FN_MAX KC_FN31
// clang-format off
/*
@ -509,41 +502,7 @@ enum internal_special_keycodes {
KC_MEDIA_FAST_FORWARD,
KC_MEDIA_REWIND,
KC_BRIGHTNESS_UP,
KC_BRIGHTNESS_DOWN,
/* Fn keys */
KC_FN0 = 0xC0,
KC_FN1,
KC_FN2,
KC_FN3,
KC_FN4,
KC_FN5,
KC_FN6,
KC_FN7,
KC_FN8,
KC_FN9,
KC_FN10,
KC_FN11,
KC_FN12,
KC_FN13,
KC_FN14,
KC_FN15,
KC_FN16, // 0xD0
KC_FN17,
KC_FN18,
KC_FN19,
KC_FN20,
KC_FN21,
KC_FN22,
KC_FN23,
KC_FN24,
KC_FN25,
KC_FN26,
KC_FN27,
KC_FN28,
KC_FN29,
KC_FN30,
KC_FN31
KC_BRIGHTNESS_DOWN
};
enum mouse_keys {

View File

@ -27,7 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include <ch.h>
#endif
#include "keycode.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
// #include "print.h"
@ -49,8 +48,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// translates key to keycode
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
// translates function id to action
uint16_t keymap_function_id_to_action(uint16_t function_id);
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];

View File

@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keycode.h"
#include "action_layer.h"
#include "action.h"
#include "action_macro.h"
#include "debug.h"
#include "quantum.h"
@ -80,24 +79,6 @@ action_t action_for_keycode(uint16_t keycode) {
// Split it up
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
break;
#ifndef NO_ACTION_FUNCTION
case KC_FN0 ... KC_FN31:
action.code = keymap_function_id_to_action(FN_INDEX(keycode));
break;
case QK_FUNCTION ... QK_FUNCTION_MAX:;
// Is a shortcut for function action_layer, pull last 12bits
// This means we have 4,096 FN macros at our disposal
action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
break;
#endif
#ifndef NO_ACTION_MACRO
case QK_MACRO ... QK_MACRO_MAX:
if (keycode & 0x800) // tap macros have upper bit set
action.code = ACTION_MACRO_TAP(keycode & 0xFF);
else
action.code = ACTION_MACRO(keycode & 0xFF);
break;
#endif
#ifndef NO_ACTION_LAYER
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
@ -165,30 +146,8 @@ action_t action_for_keycode(uint16_t keycode) {
return action;
}
__attribute__((weak)) const uint16_t PROGMEM fn_actions[] = {
};
/* Macro */
__attribute__((weak)) const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; }
/* Function */
__attribute__((weak)) void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {}
// translates key to keycode
__attribute__((weak)) uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
// Read entire word (16bits)
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
}
// translates function id to action
__attribute__((weak)) uint16_t keymap_function_id_to_action(uint16_t function_id) {
// The compiler sees the empty (weak) fn_actions and generates a warning
// This function should not be called in that case, so the warning is too strict
// If this function is called however, the keymap should have overridden fn_actions, and then the compile
// is comparing against the wrong array
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
return pgm_read_word(&fn_actions[function_id]);
#pragma GCC diagnostic pop
}

View File

@ -35,9 +35,6 @@ __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t
case QK_MOMENTARY ... QK_MOMENTARY_MAX:
case QK_LAYER_MOD ... QK_LAYER_MOD_MAX:
#endif
#ifdef NO_HAPTIC_FN
case KC_FN0 ... KC_FN31:
#endif
#ifdef NO_HAPTIC_ALPHA
case KC_A ... KC_Z:
#endif

View File

@ -37,10 +37,6 @@ enum quantum_keycodes {
QK_RALT = 0x1400,
QK_RGUI = 0x1800,
QK_MODS_MAX = 0x1FFF,
QK_FUNCTION = 0x2000,
QK_FUNCTION_MAX = 0x2FFF,
QK_MACRO = 0x3000,
QK_MACRO_MAX = 0x3FFF,
QK_LAYER_TAP = 0x4000,
QK_LAYER_TAP_MAX = 0x4FFF,
QK_TO = 0x5000,
@ -710,12 +706,6 @@ enum quantum_keycodes {
#define A(kc) LALT(kc)
#define G(kc) LGUI(kc)
// Deprecated - do not use
#define F(kc) (QK_FUNCTION | (kc))
#define M(kc) (QK_MACRO | (kc))
#define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc))
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
#define QK_GESC QK_GRAVE_ESCAPE
#define QK_BOOT QK_BOOTLOADER

View File

@ -1,88 +0,0 @@
/* Copyright 2017 Fred Sundvik
*
* 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
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "test_common.hpp"
#include "time.h"
using testing::InSequence;
using testing::InvokeWithoutArgs;
class Macro : public TestFixture {};
#define AT_TIME(t) WillOnce(InvokeWithoutArgs([current_time]() { EXPECT_EQ(timer_elapsed32(current_time), t); }))
extern "C" const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
if (record->event.pressed) {
switch (id) {
case 0:
return MACRO(D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), T(SPACE), W(100), D(LSFT), T(W), U(LSFT), I(10), T(O), T(R), T(L), T(D), D(LSFT), T(1), U(LSFT), END);
}
}
return MACRO_NONE;
};
TEST_F(Macro, PlayASimpleMacro) {
TestDriver driver;
InSequence s;
auto key_macro = KeymapKey(0, 8, 0, M(0));
set_keymap({key_macro});
key_macro.press();
uint32_t current_time = timer_read32();
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_H))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_E))).AT_TIME(0);
// The macro system could actually skip these empty keyboard reports
// it should be enough to just send a report with the next key down
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_O))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_SPACE))).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(0);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(100);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_W))).AT_TIME(100);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(100);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(100);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_O)))
// BUG: The timer should not really have advanced 10 ms here
// See issue #1477
.AT_TIME(110);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()))
// BUG: The timer should not advance on both keydown and key-up
// See issue #1477
.AT_TIME(120);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_R))).AT_TIME(130);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(140);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_L))).AT_TIME(150);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(160);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_D))).AT_TIME(170);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(180);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(190);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_1))).AT_TIME(200);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(210);
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(220);
run_one_scan_loop();
key_macro.release();
}