Skip to content

Commit 961f0b7

Browse files
authored
Reallocate SAFE_RANGE (#19909)
1 parent ea77246 commit 961f0b7

File tree

50 files changed

+31
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+31
-132
lines changed

docs/configurator_default_keymaps.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
153153
154154
```c
155155
enum keyboard_keycodes {
156-
CUSTOM_1 = SAFE_RANGE,
156+
CUSTOM_1 = QK_KB_0,
157157
CUSTOM_2,
158158
CUSTOM_3,
159-
NEW_SAFE_RANGE // Important!
160159
};
161160
```
162161

@@ -185,8 +184,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
185184
};
186185
```
187186
188-
Note the call to `process_record_user()` at the end. Additionally, users of the keyboard will need to use `NEW_SAFE_RANGE` instead of `SAFE_RANGE` if they wish to add their own custom keycodes at keymap level, beyond what is provided by the keyboard.
189-
187+
Note the call to `process_record_user()` at the end.
190188
191189
## Additional Reading :id=additional-reading
192190

keyboards/annepro2/annepro2.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern ble_capslock_t ble_capslock;
5959
// clang-format on
6060

6161
enum AP2KeyCodes {
62-
KC_AP2_BT1 = SAFE_RANGE,
62+
KC_AP2_BT1 = QK_KB_0,
6363
KC_AP2_BT2,
6464
KC_AP2_BT3,
6565
KC_AP2_BT4,
@@ -76,9 +76,4 @@ enum AP2KeyCodes {
7676
KC_AP_RGB_VAD,
7777
KC_AP_RGB_TOG,
7878
KC_AP_RGB_MOD,
79-
AP2_SAFE_RANGE,
8079
};
81-
82-
#undef SAFE_RANGE
83-
#define SAFE_RANGE AP2_SAFE_RANGE
84-

keyboards/bajjak/bajjak.h

-10
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ inline void bajjak_led_all_set(uint8_t n) {
117117
bajjak_right_led_3_set(n);
118118
}
119119

120-
enum BAJJAK_ez_keycodes {
121-
LED_LEVEL = SAFE_RANGE,
122-
TOGGLE_LAYER_COLOR,
123-
EZ_SAFE_RANGE,
124-
};
125-
126-
#ifndef WEBUSB_ENABLE
127-
# define WEBUSB_PAIR KC_NO
128-
#endif
129-
130120
typedef union {
131121
uint32_t raw;
132122
struct {

keyboards/bastardkb/charybdis/charybdis.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
304304
}
305305
# endif // !NO_CHARYBDIS_KEYCODES
306306
# endif // POINTING_DEVICE_ENABLE
307-
if ((keycode >= POINTER_DEFAULT_DPI_FORWARD && keycode < CHARYBDIS_SAFE_RANGE) || IS_MOUSEKEY(keycode)) {
307+
if (IS_QK_KB(keycode) || IS_MOUSEKEY(keycode)) {
308308
debug_charybdis_config_to_console(&g_charybdis_config);
309309
}
310310
return true;

keyboards/bastardkb/charybdis/charybdis.h

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ enum charybdis_keycodes {
4343
SNIPING_MODE_TOGGLE,
4444
DRAGSCROLL_MODE,
4545
DRAGSCROLL_MODE_TOGGLE,
46-
CHARYBDIS_SAFE_RANGE,
4746
};
4847

4948
# define DPI_MOD POINTER_DEFAULT_DPI_FORWARD

keyboards/bastardkb/charybdis/readme.md

+1-16
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,14 @@ The Charybdis firmware defines a number of keycodes to leverage its features, na
121121
```
122122
#ifndef NO_CHARYBDIS_KEYCODES
123123
enum charybdis_keycodes {
124-
POINTER_DEFAULT_DPI_FORWARD = SAFE_RANGE,
124+
POINTER_DEFAULT_DPI_FORWARD = QK_KB_0,
125125
POINTER_DEFAULT_DPI_REVERSE,
126126
POINTER_SNIPING_DPI_FORWARD,
127127
POINTER_SNIPING_DPI_REVERSE,
128128
SNIPING_MODE,
129129
SNIPING_MODE_TOGGLE,
130130
DRAGSCROLL_MODE,
131131
DRAGSCROLL_MODE_TOGGLE,
132-
CHARYBDIS_SAFE_RANGE,
133132
};
134133

135134
#define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
@@ -143,20 +142,6 @@ enum charybdis_keycodes {
143142
#endif // !NO_CHARYBDIS_KEYCODES
144143
```
145144

146-
Users extending the keycode set themselves (either in their keymap, or in their userspace) must start at `CHARYBDIS_SAFE_RANGE` to avoid conflicts, _eg._:
147-
148-
```c
149-
enum userspace_keycodes {
150-
#ifndef NO_CHARYBDIS_KEYCODES
151-
MY_FIRST_KEYCODE = CHARYBDIS_SAFE_RANGE,
152-
#else
153-
MY_FIRST_KEYCODE = SAFE_RANGE,
154-
#endif // !NO_CHARYBDIS_KEYCODES
155-
MY_SECOND_KEYCODE,
156-
157-
};
158-
```
159-
160145
To disable the custom keycodes, and reduce binary size, simply add a definition in `config.h`:
161146

162147
```c

keyboards/bastardkb/dilemma/dilemma.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
308308
# endif // !NO_DILEMMA_KEYCODES
309309
# endif // POINTING_DEVICE_ENABLE
310310
debug_dilemma_config_to_console(&g_dilemma_config);
311-
if ((keycode >= POINTER_DEFAULT_DPI_FORWARD && keycode < DILEMMA_SAFE_RANGE) || IS_MOUSEKEY(keycode)) {
311+
if (IS_QK_KB(keycode) || IS_MOUSEKEY(keycode)) {
312312
debug_dilemma_config_to_console(&g_dilemma_config);
313313
}
314314
return true;

keyboards/bastardkb/dilemma/dilemma.h

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ enum dilemma_keycodes {
4040
SNIPING_MODE_TOGGLE,
4141
DRAGSCROLL_MODE,
4242
DRAGSCROLL_MODE_TOGGLE,
43-
DILEMMA_SAFE_RANGE,
4443
};
4544

4645
# define DPI_MOD POINTER_DEFAULT_DPI_FORWARD

keyboards/clueboard/2x1800/2019/2019.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@
1818
#include "quantum.h"
1919

2020
enum TWOx1800_keycodes {
21-
ENC_BTN1 = SAFE_RANGE,
21+
ENC_BTN1 = QK_KB_0,
2222
ENC_BTN2,
2323
ENC_BTN3,
2424
ENC_BTN4,
25-
NEW_SAFE_RANGE
2625
};
2726

28-
#undef SAFE_RANGE
29-
#define SAFE_RANGE NEW_SAFE_RANGE
30-
3127
// Encoder update function that returns true/false
3228
bool encoder_update_keymap(uint8_t index, bool clockwise);
3329

keyboards/ergodox_ez/ergodox_ez.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ inline void ergodox_led_all_set(uint8_t n) {
127127
}
128128

129129
enum ergodox_ez_keycodes {
130-
LED_LEVEL = SAFE_RANGE,
130+
LED_LEVEL = QK_KB_0,
131131
TOGGLE_LAYER_COLOR,
132-
EZ_SAFE_RANGE,
133132
};
134133

135134
#ifndef WEBUSB_ENABLE

keyboards/ergodox_ez/keymaps/default/keymap.c

-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ enum layers {
88
};
99

1010
enum custom_keycodes {
11-
#ifdef ORYX_CONFIGURATOR
12-
VRSN = EZ_SAFE_RANGE,
13-
#else
1411
VRSN = SAFE_RANGE,
15-
#endif
1612
};
1713

1814
// clang-format off

keyboards/ergodox_ez/keymaps/nathanvercaemert/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define NO_BSLS_ALT KC_EQUAL
2828

2929
enum custom_keycodes {
30-
RGB_SLD = EZ_SAFE_RANGE,
30+
RGB_SLD = SAFE_RANGE,
3131
MS_WH_UP,
3232
MS_WH_DOWN,
3333
MS_WH_RIGHT,

keyboards/ergodox_ez/keymaps/stamm/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#define ARROWS MO(_3_ARROW)
3838

3939
enum custom_keycodes {
40-
RGB_SLD = EZ_SAFE_RANGE,
40+
RGB_SLD = SAFE_RANGE,
4141
ALT_TAB,
4242
};
4343

keyboards/ffkeebs/puca/puca.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818

1919
#include "quantum.h"
2020

21-
/* Keycodes defined here can be used by any keymap. If you wish to
22-
* define additional keycodes for your personal keymap only, assign
23-
* your first custom keycode to `= NEW_SAFE_RANGE`.
21+
/* Keycodes defined here can be used by any keymap.
2422
*
2523
* See `process_record_kb()` in `puca.c`.
2624
*/
2725
enum keyboard_keycodes {
28-
MC_00 = SAFE_RANGE,
29-
NEW_SAFE_RANGE,
26+
MC_00 = QK_KB_0,
3027
};
3128

3229
#define XXX KC_NO

keyboards/handwired/tractyl_manuform/tractyl_manuform.h

-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ enum charybdis_keycodes {
3333
SNIPING_MODE_TOGGLE,
3434
DRAGSCROLL_MODE,
3535
DRAGSCROLL_MODE_TOGGLE,
36-
KEYMAP_SAFE_RANGE,
3736
};
38-
# define CHARYBDIS_SAFE_RANGE KEYMAP_SAFE_RANGE
3937
# define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
4038
# define DPI_RMOD POINTER_DEFAULT_DPI_REVERSE
4139
# define S_D_MOD POINTER_SNIPING_DPI_FORWARD

keyboards/mechwild/puckbuddy/puckbuddy.h

-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ enum keyboard_keycodes {
4848
TAP_ON,
4949
TAP_OFF,
5050
TAP_TOG,
51-
NEW_SAFE_RANGE
5251
};

keyboards/moonlander/keymaps/default/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum layers {
2828
};
2929

3030
enum custom_keycodes {
31-
VRSN = ML_SAFE_RANGE,
31+
VRSN = SAFE_RANGE,
3232
};
3333

3434
// clang-format off

keyboards/moonlander/keymaps/shahn-neo/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum layers {
2424
};
2525

2626
enum custom_keycodes {
27-
a_umlaut = ML_SAFE_RANGE,
27+
a_umlaut = SAFE_RANGE,
2828
o_umlaut,
2929
u_umlaut,
3030
eszett,

keyboards/moonlander/moonlander.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ extern bool mcp23018_leds[];
9090
// clang-format on
9191

9292
enum planck_ez_keycodes {
93-
TOGGLE_LAYER_COLOR = SAFE_RANGE,
93+
TOGGLE_LAYER_COLOR = QK_KB_0,
9494
LED_LEVEL,
95-
ML_SAFE_RANGE,
9695
};
9796

9897
#ifndef WEBUSB_ENABLE

keyboards/mxss/keymaps/default/keymap.c

-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ hs_set layer_colors[4] = {
2929
};
3030
size_t lc_size = ARRAY_SIZE(layer_colors);
3131

32-
// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
33-
enum custom_keycodes {
34-
MY_KEYCODE = NEW_SAFE_RANGE,
35-
};
36-
3732
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
3833
LAYOUT( /* Base */
3934
QK_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,

keyboards/mxss/mxss_frontled.h

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ enum fled_keycodes {
6767
FLED_MOD = QK_KB_0, // QK_KB_0 = VIA custom keycode start
6868
FLED_VAI,
6969
FLED_VAD,
70-
NEW_SAFE_RANGE // define a new safe range
7170
};
7271

7372
void fled_init(void); // Run init functions for front LEDs

keyboards/mxss/readme.md

-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,3 @@ Colors for FLED_INDI mode are hardcoded as hue/saturation values, the caps lock
5353
- FLED_MOD - Cycle between the 3 modes (FLED_OFF -> FLED_RGB -> FLED_INDI)
5454
- FLED_VAI - Increase front LED brightness
5555
- FLED_VAD - Decrease front LED brightness
56-
57-
# Further Notes
58-
59-
As SAFE_RANGE is used for defining the custom keycodes seen above, please use NEW_SAFE_RANGE as the starting value for any custom keycodes in keymap.c, as per the example.

keyboards/mxss/templates/keymap.c

-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ hs_set layer_colors[4] = {
2929
};
3030
size_t lc_size = ARRAY_SIZE(layer_colors);
3131

32-
// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
33-
enum custom_keycodes {
34-
MY_KEYCODE = NEW_SAFE_RANGE,
35-
};
36-
37-
3832
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
3933
__KEYMAP_GOES_HERE__
4034
};

keyboards/oddball/oddball.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737

3838
enum custom_keycodes {
39-
KC_SCROLL = SAFE_RANGE,
39+
KC_SCROLL = QK_KB_0,
4040
KC_CPI_1,
4141
KC_CPI_2,
4242
KC_CPI_3

keyboards/omnikeyish/omnikeyish.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#include "quantum.h"
44

55
enum keycodes {
6-
QWERTY = SAFE_RANGE,
7-
DYNAMIC_MACRO_RANGE
6+
DYNAMIC_MACRO_RANGE = QK_KB_0
87
};
98

109
#include "dynamic_macro.h"

keyboards/orthocode/orthocode.h

-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@
3838

3939
enum custom_keycodes {
4040
SHIFTSPACE = QK_KB_0,
41-
QWERTY
4241
};

keyboards/planck/ez/ez.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ void planck_ez_left_led_off(void);
6868
void planck_ez_left_led_level(uint8_t level);
6969

7070
enum planck_ez_keycodes {
71-
LED_LEVEL = SAFE_RANGE,
71+
LED_LEVEL = QK_KB_0,
7272
TOGGLE_LAYER_COLOR,
73-
EZ_SAFE_RANGE,
7473
};
7574

7675
#ifndef WEBUSB_ENABLE

keyboards/planck/keymaps/charlesrocket/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc)
2121

2222
enum planck_keycodes {
23-
RGB_SLD = EZ_SAFE_RANGE,
23+
RGB_SLD = SAFE_RANGE,
2424
};
2525

2626
enum planck_layers {

keyboards/planck/keymaps/oryx/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include QMK_KEYBOARD_H
1919

2020
enum planck_keycodes {
21-
RGB_SLD = EZ_SAFE_RANGE,
21+
RGB_SLD = SAFE_RANGE,
2222
};
2323

2424
enum planck_layers {

keyboards/ploopyco/mouse/keymaps/default/keymap.c

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
#include QMK_KEYBOARD_H
1919

20-
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
21-
2220
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
2321
[0] = LAYOUT(/* Base */
2422
C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG)

keyboards/ploopyco/mouse/keymaps/drashna/keymap.c

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
#include QMK_KEYBOARD_H
1919

20-
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
21-
2220
// clang-format off
2321
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
2422
[0] = LAYOUT(

keyboards/ploopyco/mouse/mouse.h

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ extern uint16_t dpi_array[];
4343
enum ploopy_keycodes {
4444
DPI_CONFIG = QK_KB_0,
4545
DRAG_SCROLL,
46-
PLOOPY_SAFE_RANGE,
4746
};
4847

4948
bool encoder_update_user(uint8_t index, bool clockwise);

keyboards/ploopyco/trackball/keymaps/default/keymap.c

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
#include QMK_KEYBOARD_H
1919

20-
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
21-
2220
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
2321
[0] = LAYOUT( /* Base */
2422
KC_BTN1, KC_BTN3, KC_BTN2,

keyboards/ploopyco/trackball/trackball.h

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extern uint16_t dpi_array[];
4646
enum ploopy_keycodes {
4747
DPI_CONFIG = QK_KB_0,
4848
DRAG_SCROLL,
49-
PLOOPY_SAFE_RANGE,
5049
};
5150

5251
bool encoder_update_user(uint8_t index, bool clockwise);

keyboards/ploopyco/trackball_mini/keymaps/default/keymap.c

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
#include QMK_KEYBOARD_H
2020

21-
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
22-
2321
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
2422
[0] = LAYOUT( /* Base */
2523
KC_BTN1, KC_BTN3, KC_BTN2,

0 commit comments

Comments
 (0)