From b8e913c8db73ebf890e4604ee41991a34354a600 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 18 Aug 2021 00:18:58 +0100 Subject: Migrate platform independent code from tmk_core -> quantum (#13673) * Migrate action|keyboard|keycode|eeconfig from tmk_core -> quantum --- quantum/action.h | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 quantum/action.h (limited to 'quantum/action.h') diff --git a/quantum/action.h b/quantum/action.h new file mode 100644 index 0000000000..3d357b33b8 --- /dev/null +++ b/quantum/action.h @@ -0,0 +1,132 @@ +/* +Copyright 2012,2013 Jun Wako + +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 . +*/ + +#pragma once + +#include +#include +#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 + +/* tapping count and state */ +typedef struct { + bool interrupted : 1; + bool reserved2 : 1; + bool reserved1 : 1; + bool reserved0 : 1; + uint8_t count : 4; +} tap_t; + +/* Key event container for recording */ +typedef struct { + keyevent_t event; +#ifndef NO_ACTION_TAPPING + tap_t tap; +#endif +#ifdef COMBO_ENABLE + uint16_t keycode; +#endif +} keyrecord_t; + +/* Execute action per keyevent */ +void action_exec(keyevent_t event); + +/* action for key */ +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); + +/* Utilities for actions. */ +#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) +extern bool disable_action_cache; +#endif + +/* Code for handling one-handed key modifiers. */ +#ifdef SWAP_HANDS_ENABLE +extern bool swap_hands; +extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; +# if (MATRIX_COLS <= 8) +typedef uint8_t swap_state_row_t; +# elif (MATRIX_COLS <= 16) +typedef uint16_t swap_state_row_t; +# elif (MATRIX_COLS <= 32) +typedef uint32_t swap_state_row_t; +# else +# error "MATRIX_COLS: invalid value" +# endif + +void process_hand_swap(keyevent_t *record); +#endif + +void process_record_nocache(keyrecord_t *record); +void process_record(keyrecord_t *record); +void process_record_handler(keyrecord_t *record); +void post_process_record_quantum(keyrecord_t *record); +void process_action(keyrecord_t *record, action_t action); +void register_code(uint8_t code); +void unregister_code(uint8_t code); +void tap_code(uint8_t code); +void tap_code_delay(uint8_t code, uint16_t delay); +void register_mods(uint8_t mods); +void unregister_mods(uint8_t mods); +void register_weak_mods(uint8_t mods); +void unregister_weak_mods(uint8_t mods); +// void set_mods(uint8_t mods); +void clear_keyboard(void); +void clear_keyboard_but_mods(void); +void clear_keyboard_but_mods_and_keys(void); +void layer_switch(uint8_t new_layer); +bool is_tap_key(keypos_t key); +bool is_tap_record(keyrecord_t *record); +bool is_tap_action(action_t action); + +#ifndef NO_ACTION_TAPPING +void process_record_tap_hint(keyrecord_t *record); +#endif + +/* debug */ +void debug_event(keyevent_t event); +void debug_record(keyrecord_t record); +void debug_action(action_t action); + +#ifdef __cplusplus +} +#endif -- cgit v1.2.3 From c4dbf4bf0118dd785802861beb247433b5b7411d Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 24 Aug 2021 14:28:37 +0100 Subject: Tidy up quantum.c now some of tmk_core has been merged (#14083) --- quantum/action.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'quantum/action.h') diff --git a/quantum/action.h b/quantum/action.h index 3d357b33b8..4382c7ba4a 100644 --- a/quantum/action.h +++ b/quantum/action.h @@ -109,6 +109,9 @@ void register_mods(uint8_t mods); void unregister_mods(uint8_t mods); void register_weak_mods(uint8_t mods); void unregister_weak_mods(uint8_t mods); +void register_code16(uint16_t code); +void unregister_code16(uint16_t code); +void tap_code16(uint16_t code); // void set_mods(uint8_t mods); void clear_keyboard(void); void clear_keyboard_but_mods(void); @@ -118,6 +121,8 @@ bool is_tap_key(keypos_t key); bool is_tap_record(keyrecord_t *record); bool is_tap_action(action_t action); +uint8_t extract_mod_bits(uint16_t code); + #ifndef NO_ACTION_TAPPING void process_record_tap_hint(keyrecord_t *record); #endif -- cgit v1.2.3 From a84de5e22be25e2059dfee732f5cca3ec0953a35 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 25 Aug 2021 01:16:59 +0100 Subject: Revert 14083 && 14144 (#14150) * Revert "Short term bodge for firmware size bloat (#14144)" This reverts commit a8d65473461c337fb1e168d907bfb8c3ac8fdbd0. * Revert "Tidy up quantum.c now some of tmk_core has been merged (#14083)" This reverts commit c4dbf4bf0118dd785802861beb247433b5b7411d. --- quantum/action.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'quantum/action.h') diff --git a/quantum/action.h b/quantum/action.h index 4382c7ba4a..3d357b33b8 100644 --- a/quantum/action.h +++ b/quantum/action.h @@ -109,9 +109,6 @@ void register_mods(uint8_t mods); void unregister_mods(uint8_t mods); void register_weak_mods(uint8_t mods); void unregister_weak_mods(uint8_t mods); -void register_code16(uint16_t code); -void unregister_code16(uint16_t code); -void tap_code16(uint16_t code); // void set_mods(uint8_t mods); void clear_keyboard(void); void clear_keyboard_but_mods(void); @@ -121,8 +118,6 @@ bool is_tap_key(keypos_t key); bool is_tap_record(keyrecord_t *record); bool is_tap_action(action_t action); -uint8_t extract_mod_bits(uint16_t code); - #ifndef NO_ACTION_TAPPING void process_record_tap_hint(keyrecord_t *record); #endif -- cgit v1.2.3