Revert 14083 && 14144 (#14150)
* Revert "Short term bodge for firmware size bloat (#14144)" This reverts commita8d6547346
. * Revert "Tidy up quantum.c now some of tmk_core has been merged (#14083)" This reverts commitc4dbf4bf01
.
This commit is contained in:
parent
3855713ca0
commit
a84de5e22b
8 changed files with 104 additions and 118 deletions
|
@ -960,34 +960,6 @@ void unregister_weak_mods(uint8_t mods) {
|
|||
}
|
||||
}
|
||||
|
||||
static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
|
||||
|
||||
void register_code16(uint16_t code) {
|
||||
if (IS_MOD(code) || code == KC_NO) {
|
||||
do_code16(code, register_mods);
|
||||
} else {
|
||||
do_code16(code, register_weak_mods);
|
||||
}
|
||||
register_code(code);
|
||||
}
|
||||
|
||||
void unregister_code16(uint16_t code) {
|
||||
unregister_code(code);
|
||||
if (IS_MOD(code) || code == KC_NO) {
|
||||
do_code16(code, unregister_mods);
|
||||
} else {
|
||||
do_code16(code, unregister_weak_mods);
|
||||
}
|
||||
}
|
||||
|
||||
void tap_code16(uint16_t code) {
|
||||
register_code16(code);
|
||||
#if TAP_CODE_DELAY > 0
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
#endif
|
||||
unregister_code16(code);
|
||||
}
|
||||
|
||||
/** \brief Utilities for actions. (FIXME: Needs better description)
|
||||
*
|
||||
* FIXME: Needs documentation.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "action_tapping.h"
|
||||
#include "keycode.h"
|
||||
#include "timer.h"
|
||||
#include "keymap_common.h"
|
||||
|
||||
#ifdef DEBUG_ACTION
|
||||
# include "debug.h"
|
||||
|
@ -59,40 +58,6 @@ static void waiting_buffer_scan_tap(void);
|
|||
static void debug_tapping_key(void);
|
||||
static void debug_waiting_buffer(void);
|
||||
|
||||
/* Convert record into usable keycode via the contained event. */
|
||||
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
|
||||
#ifdef COMBO_ENABLE
|
||||
if (record->keycode) { return record->keycode; }
|
||||
#endif
|
||||
return get_event_keycode(record->event, update_layer_cache);
|
||||
}
|
||||
|
||||
/* Convert event into usable keycode. Checks the layer cache to ensure that it
|
||||
* retains the correct keycode after a layer change, if the key is still pressed.
|
||||
* "update_layer_cache" is to ensure that it only updates the layer cache when
|
||||
* appropriate, otherwise, it will update it and cause layer tap (and other keys)
|
||||
* from triggering properly.
|
||||
*/
|
||||
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
|
||||
const keypos_t key = event.key;
|
||||
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
/* TODO: Use store_or_get_action() or a similar function. */
|
||||
if (!disable_action_cache) {
|
||||
uint8_t layer;
|
||||
|
||||
if (event.pressed && update_layer_cache) {
|
||||
layer = layer_switch_get_layer(key);
|
||||
update_source_layers_cache(key, layer);
|
||||
} else {
|
||||
layer = read_source_layers_cache(key);
|
||||
}
|
||||
return keymap_key_to_keycode(layer, key);
|
||||
}
|
||||
#endif
|
||||
return keymap_key_to_keycode(layer_switch_get_layer(key), key);
|
||||
}
|
||||
|
||||
/** \brief Action Tapping Process
|
||||
*
|
||||
* FIXME: Needs doc
|
||||
|
|
|
@ -33,7 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// #include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keycode_config.h"
|
||||
#include "keymap_common.h"
|
||||
|
||||
// ChibiOS uses RESET in its FlagStatus enumeration
|
||||
// Therefore define it as QK_RESET here, to avoid name collision
|
||||
|
@ -47,6 +46,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "quantum_keycodes.h"
|
||||
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -36,31 +36,6 @@ extern keymap_config_t keymap_config;
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
uint8_t extract_mod_bits(uint16_t code) {
|
||||
switch (code) {
|
||||
case QK_MODS ... QK_MODS_MAX:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t mods_to_send = 0;
|
||||
|
||||
if (code & QK_RMODS_MIN) { // Right mod flag is set
|
||||
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
|
||||
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
|
||||
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
|
||||
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
|
||||
} else {
|
||||
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
|
||||
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
|
||||
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
|
||||
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
|
||||
}
|
||||
|
||||
return mods_to_send;
|
||||
}
|
||||
|
||||
/* converts key to action */
|
||||
action_t action_for_key(uint8_t layer, keypos_t key) {
|
||||
// 16bit keycodes - important
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright 2021 QMK
|
||||
*
|
||||
* 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 3 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
|
||||
|
||||
// translates key to keycode
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
|
|
@ -51,6 +51,63 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef AUTO_SHIFT_ENABLE
|
||||
# include "process_auto_shift.h"
|
||||
#endif
|
||||
|
||||
uint8_t extract_mod_bits(uint16_t code) {
|
||||
switch (code) {
|
||||
case QK_MODS ... QK_MODS_MAX:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t mods_to_send = 0;
|
||||
|
||||
if (code & QK_RMODS_MIN) { // Right mod flag is set
|
||||
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
|
||||
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
|
||||
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
|
||||
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
|
||||
} else {
|
||||
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
|
||||
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
|
||||
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
|
||||
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
|
||||
}
|
||||
|
||||
return mods_to_send;
|
||||
}
|
||||
|
||||
static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
|
||||
|
||||
void register_code16(uint16_t code) {
|
||||
if (IS_MOD(code) || code == KC_NO) {
|
||||
do_code16(code, register_mods);
|
||||
} else {
|
||||
do_code16(code, register_weak_mods);
|
||||
}
|
||||
register_code(code);
|
||||
}
|
||||
|
||||
void unregister_code16(uint16_t code) {
|
||||
unregister_code(code);
|
||||
if (IS_MOD(code) || code == KC_NO) {
|
||||
do_code16(code, unregister_mods);
|
||||
} else {
|
||||
do_code16(code, unregister_weak_mods);
|
||||
}
|
||||
}
|
||||
|
||||
void tap_code16(uint16_t code) {
|
||||
register_code16(code);
|
||||
#if TAP_CODE_DELAY > 0
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
#endif
|
||||
unregister_code16(code);
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; }
|
||||
|
||||
__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); }
|
||||
|
@ -85,6 +142,39 @@ void reset_keyboard(void) {
|
|||
bootloader_jump();
|
||||
}
|
||||
|
||||
/* Convert record into usable keycode via the contained event. */
|
||||
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
|
||||
#ifdef COMBO_ENABLE
|
||||
if (record->keycode) { return record->keycode; }
|
||||
#endif
|
||||
return get_event_keycode(record->event, update_layer_cache);
|
||||
}
|
||||
|
||||
|
||||
/* Convert event into usable keycode. Checks the layer cache to ensure that it
|
||||
* retains the correct keycode after a layer change, if the key is still pressed.
|
||||
* "update_layer_cache" is to ensure that it only updates the layer cache when
|
||||
* appropriate, otherwise, it will update it and cause layer tap (and other keys)
|
||||
* from triggering properly.
|
||||
*/
|
||||
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
/* TODO: Use store_or_get_action() or a similar function. */
|
||||
if (!disable_action_cache) {
|
||||
uint8_t layer;
|
||||
|
||||
if (event.pressed && update_layer_cache) {
|
||||
layer = layer_switch_get_layer(event.key);
|
||||
update_source_layers_cache(event.key, layer);
|
||||
} else {
|
||||
layer = read_source_layers_cache(event.key);
|
||||
}
|
||||
return keymap_key_to_keycode(layer, event.key);
|
||||
} else
|
||||
#endif
|
||||
return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
|
||||
}
|
||||
|
||||
/* Get keycode, and then process pre tapping functionality */
|
||||
bool pre_process_record_quantum(keyrecord_t *record) {
|
||||
if (!(
|
||||
|
|
|
@ -212,17 +212,23 @@ void set_single_persistent_default_layer(uint8_t default_layer);
|
|||
#define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
|
||||
#define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
|
||||
|
||||
bool process_action_kb(keyrecord_t *record);
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
|
||||
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
|
||||
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
|
||||
bool process_action_kb(keyrecord_t *record);
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
|
||||
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
void reset_keyboard(void);
|
||||
|
||||
void startup_user(void);
|
||||
void shutdown_user(void);
|
||||
|
||||
void register_code16(uint16_t code);
|
||||
void unregister_code16(uint16_t code);
|
||||
void tap_code16(uint16_t code);
|
||||
|
||||
void led_set_user(uint8_t usb_led);
|
||||
void led_set_kb(uint8_t usb_led);
|
||||
bool led_update_user(led_t led_state);
|
||||
|
|
Loading…
Reference in a new issue