Skip to content

Commit 182cc44

Browse files
authored
Revert 14083 && 14144 (qmk#14150)
* Revert "Short term bodge for firmware size bloat (qmk#14144)" This reverts commit 9076f8b. * Revert "Tidy up quantum.c now some of tmk_core has been merged (qmk#14083)" This reverts commit df83e9d.
1 parent 69b52f8 commit 182cc44

File tree

8 files changed

+104
-118
lines changed

8 files changed

+104
-118
lines changed

quantum/action.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -960,34 +960,6 @@ void unregister_weak_mods(uint8_t mods) {
960960
}
961961
}
962962

963-
static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
964-
965-
void register_code16(uint16_t code) {
966-
if (IS_MOD(code) || code == KC_NO) {
967-
do_code16(code, register_mods);
968-
} else {
969-
do_code16(code, register_weak_mods);
970-
}
971-
register_code(code);
972-
}
973-
974-
void unregister_code16(uint16_t code) {
975-
unregister_code(code);
976-
if (IS_MOD(code) || code == KC_NO) {
977-
do_code16(code, unregister_mods);
978-
} else {
979-
do_code16(code, unregister_weak_mods);
980-
}
981-
}
982-
983-
void tap_code16(uint16_t code) {
984-
register_code16(code);
985-
#if TAP_CODE_DELAY > 0
986-
wait_ms(TAP_CODE_DELAY);
987-
#endif
988-
unregister_code16(code);
989-
}
990-
991963
/** \brief Utilities for actions. (FIXME: Needs better description)
992964
*
993965
* FIXME: Needs documentation.

quantum/action.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ void register_mods(uint8_t mods);
109109
void unregister_mods(uint8_t mods);
110110
void register_weak_mods(uint8_t mods);
111111
void unregister_weak_mods(uint8_t mods);
112-
void register_code16(uint16_t code);
113-
void unregister_code16(uint16_t code);
114-
void tap_code16(uint16_t code);
115112
// void set_mods(uint8_t mods);
116113
void clear_keyboard(void);
117114
void clear_keyboard_but_mods(void);
@@ -121,8 +118,6 @@ bool is_tap_key(keypos_t key);
121118
bool is_tap_record(keyrecord_t *record);
122119
bool is_tap_action(action_t action);
123120

124-
uint8_t extract_mod_bits(uint16_t code);
125-
126121
#ifndef NO_ACTION_TAPPING
127122
void process_record_tap_hint(keyrecord_t *record);
128123
#endif

quantum/action_tapping.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "action_tapping.h"
66
#include "keycode.h"
77
#include "timer.h"
8-
#include "keymap_common.h"
98

109
#ifdef DEBUG_ACTION
1110
# include "debug.h"
@@ -59,40 +58,6 @@ static void waiting_buffer_scan_tap(void);
5958
static void debug_tapping_key(void);
6059
static void debug_waiting_buffer(void);
6160

62-
/* Convert record into usable keycode via the contained event. */
63-
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
64-
#ifdef COMBO_ENABLE
65-
if (record->keycode) { return record->keycode; }
66-
#endif
67-
return get_event_keycode(record->event, update_layer_cache);
68-
}
69-
70-
/* Convert event into usable keycode. Checks the layer cache to ensure that it
71-
* retains the correct keycode after a layer change, if the key is still pressed.
72-
* "update_layer_cache" is to ensure that it only updates the layer cache when
73-
* appropriate, otherwise, it will update it and cause layer tap (and other keys)
74-
* from triggering properly.
75-
*/
76-
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
77-
const keypos_t key = event.key;
78-
79-
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
80-
/* TODO: Use store_or_get_action() or a similar function. */
81-
if (!disable_action_cache) {
82-
uint8_t layer;
83-
84-
if (event.pressed && update_layer_cache) {
85-
layer = layer_switch_get_layer(key);
86-
update_source_layers_cache(key, layer);
87-
} else {
88-
layer = read_source_layers_cache(key);
89-
}
90-
return keymap_key_to_keycode(layer, key);
91-
}
92-
#endif
93-
return keymap_key_to_keycode(layer_switch_get_layer(key), key);
94-
}
95-
9661
/** \brief Action Tapping Process
9762
*
9863
* FIXME: Needs doc

quantum/keymap.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3333
// #include "print.h"
3434
#include "debug.h"
3535
#include "keycode_config.h"
36-
#include "keymap_common.h"
3736

3837
// ChibiOS uses RESET in its FlagStatus enumeration
3938
// 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/>.
4746

4847
#include "quantum_keycodes.h"
4948

49+
// translates key to keycode
50+
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
51+
5052
// translates function id to action
5153
uint16_t keymap_function_id_to_action(uint16_t function_id);
5254

quantum/keymap_common.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,6 @@ extern keymap_config_t keymap_config;
3636

3737
#include <inttypes.h>
3838

39-
uint8_t extract_mod_bits(uint16_t code) {
40-
switch (code) {
41-
case QK_MODS ... QK_MODS_MAX:
42-
break;
43-
default:
44-
return 0;
45-
}
46-
47-
uint8_t mods_to_send = 0;
48-
49-
if (code & QK_RMODS_MIN) { // Right mod flag is set
50-
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
51-
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
52-
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
53-
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
54-
} else {
55-
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
56-
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
57-
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
58-
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
59-
}
60-
61-
return mods_to_send;
62-
}
63-
6439
/* converts key to action */
6540
action_t action_for_key(uint8_t layer, keypos_t key) {
6641
// 16bit keycodes - important

quantum/keymap_common.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

quantum/quantum.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,63 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
5151
# endif
5252
#endif
5353

54+
#ifdef AUTO_SHIFT_ENABLE
55+
# include "process_auto_shift.h"
56+
#endif
57+
58+
uint8_t extract_mod_bits(uint16_t code) {
59+
switch (code) {
60+
case QK_MODS ... QK_MODS_MAX:
61+
break;
62+
default:
63+
return 0;
64+
}
65+
66+
uint8_t mods_to_send = 0;
67+
68+
if (code & QK_RMODS_MIN) { // Right mod flag is set
69+
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
70+
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
71+
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
72+
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
73+
} else {
74+
if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
75+
if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
76+
if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
77+
if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
78+
}
79+
80+
return mods_to_send;
81+
}
82+
83+
static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
84+
85+
void register_code16(uint16_t code) {
86+
if (IS_MOD(code) || code == KC_NO) {
87+
do_code16(code, register_mods);
88+
} else {
89+
do_code16(code, register_weak_mods);
90+
}
91+
register_code(code);
92+
}
93+
94+
void unregister_code16(uint16_t code) {
95+
unregister_code(code);
96+
if (IS_MOD(code) || code == KC_NO) {
97+
do_code16(code, unregister_mods);
98+
} else {
99+
do_code16(code, unregister_weak_mods);
100+
}
101+
}
102+
103+
void tap_code16(uint16_t code) {
104+
register_code16(code);
105+
#if TAP_CODE_DELAY > 0
106+
wait_ms(TAP_CODE_DELAY);
107+
#endif
108+
unregister_code16(code);
109+
}
110+
54111
__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; }
55112

56113
__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) {
85142
bootloader_jump();
86143
}
87144

145+
/* Convert record into usable keycode via the contained event. */
146+
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
147+
#ifdef COMBO_ENABLE
148+
if (record->keycode) { return record->keycode; }
149+
#endif
150+
return get_event_keycode(record->event, update_layer_cache);
151+
}
152+
153+
154+
/* Convert event into usable keycode. Checks the layer cache to ensure that it
155+
* retains the correct keycode after a layer change, if the key is still pressed.
156+
* "update_layer_cache" is to ensure that it only updates the layer cache when
157+
* appropriate, otherwise, it will update it and cause layer tap (and other keys)
158+
* from triggering properly.
159+
*/
160+
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
161+
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
162+
/* TODO: Use store_or_get_action() or a similar function. */
163+
if (!disable_action_cache) {
164+
uint8_t layer;
165+
166+
if (event.pressed && update_layer_cache) {
167+
layer = layer_switch_get_layer(event.key);
168+
update_source_layers_cache(event.key, layer);
169+
} else {
170+
layer = read_source_layers_cache(event.key);
171+
}
172+
return keymap_key_to_keycode(layer, event.key);
173+
} else
174+
#endif
175+
return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
176+
}
177+
88178
/* Get keycode, and then process pre tapping functionality */
89179
bool pre_process_record_quantum(keyrecord_t *record) {
90180
if (!(

quantum/quantum.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,23 @@ void set_single_persistent_default_layer(uint8_t default_layer);
212212
#define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
213213
#define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
214214

215-
bool process_action_kb(keyrecord_t *record);
216-
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
217-
bool process_record_user(uint16_t keycode, keyrecord_t *record);
218-
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
219-
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
215+
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
216+
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
217+
bool process_action_kb(keyrecord_t *record);
218+
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
219+
bool process_record_user(uint16_t keycode, keyrecord_t *record);
220+
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
221+
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
220222

221223
void reset_keyboard(void);
222224

223225
void startup_user(void);
224226
void shutdown_user(void);
225227

228+
void register_code16(uint16_t code);
229+
void unregister_code16(uint16_t code);
230+
void tap_code16(uint16_t code);
231+
226232
void led_set_user(uint8_t usb_led);
227233
void led_set_kb(uint8_t usb_led);
228234
bool led_update_user(led_t led_state);

0 commit comments

Comments
 (0)