Skip to content

Commit be0d639

Browse files
zvecrdrashna
authored andcommitted
Strip out features to allow minimum firmware sizes (qmk#8645)
1 parent 3a69126 commit be0d639

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

quantum/keymap_common.c

+14
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,23 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
5151
action_t action = {};
5252
uint8_t action_layer, when, mod;
5353

54+
(void)action_layer;
55+
(void)when;
56+
(void)mod;
57+
5458
switch (keycode) {
5559
case KC_A ... KC_EXSEL:
5660
case KC_LCTRL ... KC_RGUI:
5761
action.code = ACTION_KEY(keycode);
5862
break;
63+
#ifdef EXTRAKEY_ENABLE
5964
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
6065
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
6166
break;
6267
case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN:
6368
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
6469
break;
70+
#endif
6571
#ifdef MOUSEKEY_ENABLE
6672
case KC_MS_UP ... KC_MS_ACCEL2:
6773
action.code = ACTION_MOUSEKEY(keycode);
@@ -93,6 +99,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
9399
action.code = ACTION_MACRO(keycode & 0xFF);
94100
break;
95101
#endif
102+
#ifndef NO_ACTION_LAYER
96103
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
97104
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
98105
break;
@@ -117,6 +124,8 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
117124
action_layer = keycode & 0xFF;
118125
action.code = ACTION_LAYER_TOGGLE(action_layer);
119126
break;
127+
#endif
128+
#ifndef NO_ACTION_ONESHOT
120129
case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX:;
121130
// OSL(action_layer) - One-shot action_layer
122131
action_layer = keycode & 0xFF;
@@ -127,6 +136,8 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
127136
mod = mod_config(keycode & 0xFF);
128137
action.code = ACTION_MODS_ONESHOT(mod);
129138
break;
139+
#endif
140+
#ifndef NO_ACTION_LAYER
130141
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
131142
action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF);
132143
break;
@@ -135,10 +146,13 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
135146
action_layer = (keycode >> 4) & 0xF;
136147
action.code = ACTION_LAYER_MODS(action_layer, mod);
137148
break;
149+
#endif
150+
#ifndef NO_ACTION_TAPPING
138151
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
139152
mod = mod_config((keycode >> 0x8) & 0x1F);
140153
action.code = ACTION_MODS_TAP_KEY(mod, keycode & 0xFF);
141154
break;
155+
#endif
142156
#ifdef SWAP_HANDS_ENABLE
143157
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
144158
action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff);

quantum/quantum.c

+2
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ bool process_record_quantum(keyrecord_t *record) {
284284

285285
if (record->event.pressed) {
286286
switch (keycode) {
287+
#ifndef NO_RESET
287288
case RESET:
288289
reset_keyboard();
289290
return false;
291+
#endif
290292
#ifndef NO_DEBUG
291293
case DEBUG:
292294
debug_enable ^= 1;

tmk_core/common/action.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,12 @@ void register_code(uint8_t code) {
775775
add_mods(MOD_BIT(code));
776776
send_keyboard_report();
777777
}
778+
#ifdef EXTRAKEY_ENABLE
778779
else if
779780
IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); }
780781
else if
781782
IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); }
782-
783+
#endif
783784
#ifdef MOUSEKEY_ENABLE
784785
else if
785786
IS_MOUSEKEY(code) {

tmk_core/common/action_layer.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ void layer_xor(layer_state_t state);
8282

8383
# define layer_debug()
8484
# define layer_clear()
85-
# define layer_move(layer)
86-
# define layer_on(layer)
87-
# define layer_off(layer)
88-
# define layer_invert(layer)
89-
# define layer_or(state)
90-
# define layer_and(state)
91-
# define layer_xor(state)
85+
# define layer_move(layer) (void)layer
86+
# define layer_on(layer) (void)layer
87+
# define layer_off(layer) (void)layer
88+
# define layer_invert(layer) (void)layer
89+
# define layer_or(state) (void)state
90+
# define layer_and(state) (void)state
91+
# define layer_xor(state) (void)state
9292
#endif
9393

9494
layer_state_t layer_state_set_user(layer_state_t state);

tmk_core/common/util.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#include "util.h"
1919

2020
// bit population - return number of on-bit
21-
uint8_t bitpop(uint8_t bits) {
21+
__attribute__((noinline)) uint8_t bitpop(uint8_t bits) {
2222
uint8_t c;
2323
for (c = 0; bits; c++) bits &= bits - 1;
2424
return c;
@@ -42,7 +42,7 @@ uint8_t bitpop32(uint32_t bits) {
4242

4343
// most significant on-bit - return highest location of on-bit
4444
// NOTE: return 0 when bit0 is on or all bits are off
45-
uint8_t biton(uint8_t bits) {
45+
__attribute__((noinline)) uint8_t biton(uint8_t bits) {
4646
uint8_t n = 0;
4747
if (bits >> 4) {
4848
bits >>= 4;
@@ -105,7 +105,7 @@ uint8_t biton32(uint32_t bits) {
105105
return n;
106106
}
107107

108-
uint8_t bitrev(uint8_t bits) {
108+
__attribute__((noinline)) uint8_t bitrev(uint8_t bits) {
109109
bits = (bits & 0x0f) << 4 | (bits & 0xf0) >> 4;
110110
bits = (bits & 0b00110011) << 2 | (bits & 0b11001100) >> 2;
111111
bits = (bits & 0b01010101) << 1 | (bits & 0b10101010) >> 1;

tmk_core/protocol/vusb/vusb.c

+2
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ typedef struct {
159159
} __attribute__((packed)) vusb_mouse_report_t;
160160

161161
static void send_mouse(report_mouse_t *report) {
162+
#if defined(MOUSE_ENABLE)
162163
vusb_mouse_report_t r = {.report_id = REPORT_ID_MOUSE, .report = *report};
163164
if (usbInterruptIsReady3()) {
164165
usbSetInterrupt3((void *)&r, sizeof(vusb_mouse_report_t));
165166
}
167+
#endif
166168
}
167169

168170
#ifdef EXTRAKEY_ENABLE

0 commit comments

Comments
 (0)