Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reallocate SAFE_RANGE #19909

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/configurator_default_keymaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {

```c
enum keyboard_keycodes {
CUSTOM_1 = SAFE_RANGE,
CUSTOM_1 = QK_KB_0,
CUSTOM_2,
CUSTOM_3,
NEW_SAFE_RANGE // Important!
};
```

Expand Down Expand Up @@ -185,8 +184,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
};
```

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.

Note the call to `process_record_user()` at the end.

## Additional Reading :id=additional-reading

Expand Down
7 changes: 1 addition & 6 deletions keyboards/annepro2/annepro2.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern ble_capslock_t ble_capslock;
// clang-format on

enum AP2KeyCodes {
KC_AP2_BT1 = SAFE_RANGE,
KC_AP2_BT1 = QK_KB_0,
KC_AP2_BT2,
KC_AP2_BT3,
KC_AP2_BT4,
Expand All @@ -76,9 +76,4 @@ enum AP2KeyCodes {
KC_AP_RGB_VAD,
KC_AP_RGB_TOG,
KC_AP_RGB_MOD,
AP2_SAFE_RANGE,
};

#undef SAFE_RANGE
#define SAFE_RANGE AP2_SAFE_RANGE

10 changes: 0 additions & 10 deletions keyboards/bajjak/bajjak.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ inline void bajjak_led_all_set(uint8_t n) {
bajjak_right_led_3_set(n);
}

enum BAJJAK_ez_keycodes {
LED_LEVEL = SAFE_RANGE,
TOGGLE_LAYER_COLOR,
EZ_SAFE_RANGE,
};

#ifndef WEBUSB_ENABLE
# define WEBUSB_PAIR KC_NO
#endif

typedef union {
uint32_t raw;
struct {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/bastardkb/charybdis/charybdis.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
}
# endif // !NO_CHARYBDIS_KEYCODES
# endif // POINTING_DEVICE_ENABLE
if ((keycode >= POINTER_DEFAULT_DPI_FORWARD && keycode < CHARYBDIS_SAFE_RANGE) || IS_MOUSEKEY(keycode)) {
if (IS_QK_KB(keycode) || IS_MOUSEKEY(keycode)) {
debug_charybdis_config_to_console(&g_charybdis_config);
}
return true;
Expand Down
1 change: 0 additions & 1 deletion keyboards/bastardkb/charybdis/charybdis.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ enum charybdis_keycodes {
SNIPING_MODE_TOGGLE,
DRAGSCROLL_MODE,
DRAGSCROLL_MODE_TOGGLE,
CHARYBDIS_SAFE_RANGE,
};

# define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
Expand Down
17 changes: 1 addition & 16 deletions keyboards/bastardkb/charybdis/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ The Charybdis firmware defines a number of keycodes to leverage its features, na
```
#ifndef NO_CHARYBDIS_KEYCODES
enum charybdis_keycodes {
POINTER_DEFAULT_DPI_FORWARD = SAFE_RANGE,
POINTER_DEFAULT_DPI_FORWARD = QK_KB_0,
POINTER_DEFAULT_DPI_REVERSE,
POINTER_SNIPING_DPI_FORWARD,
POINTER_SNIPING_DPI_REVERSE,
SNIPING_MODE,
SNIPING_MODE_TOGGLE,
DRAGSCROLL_MODE,
DRAGSCROLL_MODE_TOGGLE,
CHARYBDIS_SAFE_RANGE,
};

#define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
Expand All @@ -143,20 +142,6 @@ enum charybdis_keycodes {
#endif // !NO_CHARYBDIS_KEYCODES
```

Users extending the keycode set themselves (either in their keymap, or in their userspace) must start at `CHARYBDIS_SAFE_RANGE` to avoid conflicts, _eg._:

```c
enum userspace_keycodes {
#ifndef NO_CHARYBDIS_KEYCODES
MY_FIRST_KEYCODE = CHARYBDIS_SAFE_RANGE,
#else
MY_FIRST_KEYCODE = SAFE_RANGE,
#endif // !NO_CHARYBDIS_KEYCODES
MY_SECOND_KEYCODE,
};
```

To disable the custom keycodes, and reduce binary size, simply add a definition in `config.h`:

```c
Expand Down
2 changes: 1 addition & 1 deletion keyboards/bastardkb/dilemma/dilemma.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
# endif // !NO_DILEMMA_KEYCODES
# endif // POINTING_DEVICE_ENABLE
debug_dilemma_config_to_console(&g_dilemma_config);
if ((keycode >= POINTER_DEFAULT_DPI_FORWARD && keycode < DILEMMA_SAFE_RANGE) || IS_MOUSEKEY(keycode)) {
if (IS_QK_KB(keycode) || IS_MOUSEKEY(keycode)) {
debug_dilemma_config_to_console(&g_dilemma_config);
}
return true;
Expand Down
1 change: 0 additions & 1 deletion keyboards/bastardkb/dilemma/dilemma.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ enum dilemma_keycodes {
SNIPING_MODE_TOGGLE,
DRAGSCROLL_MODE,
DRAGSCROLL_MODE_TOGGLE,
DILEMMA_SAFE_RANGE,
};

# define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
Expand Down
6 changes: 1 addition & 5 deletions keyboards/clueboard/2x1800/2019/2019.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@
#include "quantum.h"

enum TWOx1800_keycodes {
ENC_BTN1 = SAFE_RANGE,
ENC_BTN1 = QK_KB_0,
ENC_BTN2,
ENC_BTN3,
ENC_BTN4,
NEW_SAFE_RANGE
};

#undef SAFE_RANGE
#define SAFE_RANGE NEW_SAFE_RANGE

// Encoder update function that returns true/false
bool encoder_update_keymap(uint8_t index, bool clockwise);

Expand Down
3 changes: 1 addition & 2 deletions keyboards/ergodox_ez/ergodox_ez.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ inline void ergodox_led_all_set(uint8_t n) {
}

enum ergodox_ez_keycodes {
LED_LEVEL = SAFE_RANGE,
LED_LEVEL = QK_KB_0,
TOGGLE_LAYER_COLOR,
EZ_SAFE_RANGE,
};

#ifndef WEBUSB_ENABLE
Expand Down
4 changes: 0 additions & 4 deletions keyboards/ergodox_ez/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ enum layers {
};

enum custom_keycodes {
#ifdef ORYX_CONFIGURATOR
VRSN = EZ_SAFE_RANGE,
#else
VRSN = SAFE_RANGE,
#endif
};

// clang-format off
Expand Down
2 changes: 1 addition & 1 deletion keyboards/ergodox_ez/keymaps/nathanvercaemert/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define NO_BSLS_ALT KC_EQUAL

enum custom_keycodes {
RGB_SLD = EZ_SAFE_RANGE,
RGB_SLD = SAFE_RANGE,
MS_WH_UP,
MS_WH_DOWN,
MS_WH_RIGHT,
Expand Down
2 changes: 1 addition & 1 deletion keyboards/ergodox_ez/keymaps/stamm/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define ARROWS MO(_3_ARROW)

enum custom_keycodes {
RGB_SLD = EZ_SAFE_RANGE,
RGB_SLD = SAFE_RANGE,
ALT_TAB,
};

Expand Down
7 changes: 2 additions & 5 deletions keyboards/ffkeebs/puca/puca.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@

#include "quantum.h"

/* Keycodes defined here can be used by any keymap. If you wish to
* define additional keycodes for your personal keymap only, assign
* your first custom keycode to `= NEW_SAFE_RANGE`.
/* Keycodes defined here can be used by any keymap.
*
* See `process_record_kb()` in `puca.c`.
*/
enum keyboard_keycodes {
MC_00 = SAFE_RANGE,
NEW_SAFE_RANGE,
MC_00 = QK_KB_0,
};

#define XXX KC_NO
Expand Down
2 changes: 0 additions & 2 deletions keyboards/handwired/tractyl_manuform/tractyl_manuform.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ enum charybdis_keycodes {
SNIPING_MODE_TOGGLE,
DRAGSCROLL_MODE,
DRAGSCROLL_MODE_TOGGLE,
KEYMAP_SAFE_RANGE,
};
# define CHARYBDIS_SAFE_RANGE KEYMAP_SAFE_RANGE
# define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
# define DPI_RMOD POINTER_DEFAULT_DPI_REVERSE
# define S_D_MOD POINTER_SNIPING_DPI_FORWARD
Expand Down
1 change: 0 additions & 1 deletion keyboards/mechwild/puckbuddy/puckbuddy.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ enum keyboard_keycodes {
TAP_ON,
TAP_OFF,
TAP_TOG,
NEW_SAFE_RANGE
};
2 changes: 1 addition & 1 deletion keyboards/moonlander/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum layers {
};

enum custom_keycodes {
VRSN = ML_SAFE_RANGE,
VRSN = SAFE_RANGE,
};

// clang-format off
Expand Down
2 changes: 1 addition & 1 deletion keyboards/moonlander/keymaps/shahn-neo/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum layers {
};

enum custom_keycodes {
a_umlaut = ML_SAFE_RANGE,
a_umlaut = SAFE_RANGE,
o_umlaut,
u_umlaut,
eszett,
Expand Down
3 changes: 1 addition & 2 deletions keyboards/moonlander/moonlander.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ extern bool mcp23018_leds[];
// clang-format on

enum planck_ez_keycodes {
TOGGLE_LAYER_COLOR = SAFE_RANGE,
TOGGLE_LAYER_COLOR = QK_KB_0,
LED_LEVEL,
ML_SAFE_RANGE,
};

#ifndef WEBUSB_ENABLE
Expand Down
5 changes: 0 additions & 5 deletions keyboards/mxss/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ hs_set layer_colors[4] = {
};
size_t lc_size = ARRAY_SIZE(layer_colors);

// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
enum custom_keycodes {
MY_KEYCODE = NEW_SAFE_RANGE,
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT( /* Base */
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,
Expand Down
1 change: 0 additions & 1 deletion keyboards/mxss/mxss_frontled.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ enum fled_keycodes {
FLED_MOD = QK_KB_0, // QK_KB_0 = VIA custom keycode start
FLED_VAI,
FLED_VAD,
NEW_SAFE_RANGE // define a new safe range
};

void fled_init(void); // Run init functions for front LEDs
Expand Down
4 changes: 0 additions & 4 deletions keyboards/mxss/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ Colors for FLED_INDI mode are hardcoded as hue/saturation values, the caps lock
- FLED_MOD - Cycle between the 3 modes (FLED_OFF -> FLED_RGB -> FLED_INDI)
- FLED_VAI - Increase front LED brightness
- FLED_VAD - Decrease front LED brightness

# Further Notes

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.
6 changes: 0 additions & 6 deletions keyboards/mxss/templates/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ hs_set layer_colors[4] = {
};
size_t lc_size = ARRAY_SIZE(layer_colors);

// Use NEW_SAFE_RANGE to define new custom keycodes in order to not overwrite the ones used for front LED control
enum custom_keycodes {
MY_KEYCODE = NEW_SAFE_RANGE,
};


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
__KEYMAP_GOES_HERE__
};
2 changes: 1 addition & 1 deletion keyboards/oddball/oddball.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

enum custom_keycodes {
KC_SCROLL = SAFE_RANGE,
KC_SCROLL = QK_KB_0,
KC_CPI_1,
KC_CPI_2,
KC_CPI_3
Expand Down
3 changes: 1 addition & 2 deletions keyboards/omnikeyish/omnikeyish.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include "quantum.h"

enum keycodes {
QWERTY = SAFE_RANGE,
DYNAMIC_MACRO_RANGE
DYNAMIC_MACRO_RANGE = QK_KB_0
};

#include "dynamic_macro.h"
Expand Down
1 change: 0 additions & 1 deletion keyboards/orthocode/orthocode.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@

enum custom_keycodes {
SHIFTSPACE = QK_KB_0,
QWERTY
};
3 changes: 1 addition & 2 deletions keyboards/planck/ez/ez.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ void planck_ez_left_led_off(void);
void planck_ez_left_led_level(uint8_t level);

enum planck_ez_keycodes {
LED_LEVEL = SAFE_RANGE,
LED_LEVEL = QK_KB_0,
TOGGLE_LAYER_COLOR,
EZ_SAFE_RANGE,
};

#ifndef WEBUSB_ENABLE
Expand Down
2 changes: 1 addition & 1 deletion keyboards/planck/keymaps/charlesrocket/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc)

enum planck_keycodes {
RGB_SLD = EZ_SAFE_RANGE,
RGB_SLD = SAFE_RANGE,
};

enum planck_layers {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/planck/keymaps/oryx/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include QMK_KEYBOARD_H

enum planck_keycodes {
RGB_SLD = EZ_SAFE_RANGE,
RGB_SLD = SAFE_RANGE,
};

enum planck_layers {
Expand Down
2 changes: 0 additions & 2 deletions keyboards/ploopyco/mouse/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
#include QMK_KEYBOARD_H

// safe range starts at `PLOOPY_SAFE_RANGE` instead.

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(/* Base */
C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG)
Expand Down
2 changes: 0 additions & 2 deletions keyboards/ploopyco/mouse/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
#include QMK_KEYBOARD_H

// safe range starts at `PLOOPY_SAFE_RANGE` instead.

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
Expand Down
1 change: 0 additions & 1 deletion keyboards/ploopyco/mouse/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ extern uint16_t dpi_array[];
enum ploopy_keycodes {
DPI_CONFIG = QK_KB_0,
DRAG_SCROLL,
PLOOPY_SAFE_RANGE,
};

bool encoder_update_user(uint8_t index, bool clockwise);
Expand Down
2 changes: 0 additions & 2 deletions keyboards/ploopyco/trackball/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
#include QMK_KEYBOARD_H

// safe range starts at `PLOOPY_SAFE_RANGE` instead.

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT( /* Base */
KC_BTN1, KC_BTN3, KC_BTN2,
Expand Down
1 change: 0 additions & 1 deletion keyboards/ploopyco/trackball/trackball.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ extern uint16_t dpi_array[];
enum ploopy_keycodes {
DPI_CONFIG = QK_KB_0,
DRAG_SCROLL,
PLOOPY_SAFE_RANGE,
};

bool encoder_update_user(uint8_t index, bool clockwise);
Expand Down
2 changes: 0 additions & 2 deletions keyboards/ploopyco/trackball_mini/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
#include QMK_KEYBOARD_H

// safe range starts at `PLOOPY_SAFE_RANGE` instead.

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT( /* Base */
KC_BTN1, KC_BTN3, KC_BTN2,
Expand Down
Loading