1
0
Fork 0
forked from forks/qmk_firmware

Reallocate SAFE_RANGE (#19909)

This commit is contained in:
Joel Challis 2023-02-22 22:49:07 +00:00 committed by GitHub
parent ea77246865
commit 961f0b7b2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 31 additions and 132 deletions

View file

@ -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!
};
```
@ -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

View file

@ -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,
@ -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

View file

@ -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 {

View file

@ -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;

View file

@ -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

View file

@ -121,7 +121,7 @@ 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,
@ -129,7 +129,6 @@ enum charybdis_keycodes {
SNIPING_MODE_TOGGLE,
DRAGSCROLL_MODE,
DRAGSCROLL_MODE_TOGGLE,
CHARYBDIS_SAFE_RANGE,
};
#define DPI_MOD POINTER_DEFAULT_DPI_FORWARD
@ -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

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -8,11 +8,7 @@ enum layers {
};
enum custom_keycodes {
#ifdef ORYX_CONFIGURATOR
VRSN = EZ_SAFE_RANGE,
#else
VRSN = SAFE_RANGE,
#endif
};
// clang-format off

View file

@ -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,

View file

@ -37,7 +37,7 @@
#define ARROWS MO(_3_ARROW)
enum custom_keycodes {
RGB_SLD = EZ_SAFE_RANGE,
RGB_SLD = SAFE_RANGE,
ALT_TAB,
};

View file

@ -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

View file

@ -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

View file

@ -48,5 +48,4 @@ enum keyboard_keycodes {
TAP_ON,
TAP_OFF,
TAP_TOG,
NEW_SAFE_RANGE
};

View file

@ -28,7 +28,7 @@ enum layers {
};
enum custom_keycodes {
VRSN = ML_SAFE_RANGE,
VRSN = SAFE_RANGE,
};
// clang-format off

View file

@ -24,7 +24,7 @@ enum layers {
};
enum custom_keycodes {
a_umlaut = ML_SAFE_RANGE,
a_umlaut = SAFE_RANGE,
o_umlaut,
u_umlaut,
eszett,

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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.

View file

@ -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__
};

View file

@ -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

View file

@ -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"

View file

@ -38,5 +38,4 @@
enum custom_keycodes {
SHIFTSPACE = QK_KB_0,
QWERTY
};

View file

@ -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

View file

@ -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 {

View file

@ -18,7 +18,7 @@
#include QMK_KEYBOARD_H
enum planck_keycodes {
RGB_SLD = EZ_SAFE_RANGE,
RGB_SLD = SAFE_RANGE,
};
enum planck_layers {

View file

@ -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)

View file

@ -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(

View file

@ -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);

View file

@ -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,

View file

@ -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);

View file

@ -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,

View file

@ -21,7 +21,7 @@
bool is_drag_scroll = false;
enum custom_keycodes {
DRAG_SCROLL = PLOOPY_SAFE_RANGE,
DRAG_SCROLL = SAFE_RANGE,
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {

View file

@ -43,7 +43,6 @@ extern keyboard_config_t keyboard_config;
enum ploopy_keycodes {
DPI_CONFIG = QK_KB_0,
DRAG_SCROLL,
PLOOPY_SAFE_RANGE,
};
bool encoder_update_user(uint8_t index, bool clockwise);

View file

@ -18,7 +18,5 @@
*/
#include QMK_KEYBOARD_H
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
// Dummy
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {{{ KC_NO }}};

View file

@ -23,7 +23,6 @@
#define DELTA_X_THRESHOLD 60
#define DELTA_Y_THRESHOLD 15
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
bool scroll_enabled = false;
bool lock_state = false;

View file

@ -31,8 +31,7 @@ typedef union {
extern keyboard_config_t keyboard_config;
enum ploopy_keycodes {
DPI_CONFIG = SAFE_RANGE,
PLOOPY_SAFE_RANGE,
DPI_CONFIG = QK_KB_0,
};
void cycle_dpi(void);

View file

@ -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_BTN4, KC_BTN1, KC_BTN3, KC_BTN2, KC_BTN5,

View file

@ -48,5 +48,4 @@ extern uint16_t dpi_array[];
enum ploopy_keycodes {
DPI_CONFIG = QK_KB_0,
DRAG_SCROLL,
PLOOPY_SAFE_RANGE,
};

View file

@ -15,11 +15,6 @@
*/
#include QMK_KEYBOARD_H
// enum custom_keycodes {
// FIRST = NEW_SAFE_RANGE,
// };
// Defines names for use in layer keycodes and the keymap
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Base */

View file

@ -20,11 +20,10 @@
#define CALC_DIGITS 12
enum rubi_keycodes {
ENC_PRESS = SAFE_RANGE,
ENC_PRESS = QK_KB_0,
CL_PLUS,
CL_STAR,
CL_TYPE,
NEW_SAFE_RANGE
CL_TYPE
};
enum oled_modes {

View file

@ -108,7 +108,7 @@ enum terrazzo_matrix_effects {
};
enum terrazzo_keycodes {
TZ_NXT = SAFE_RANGE,
TZ_NXT = QK_KB_0,
TZ_PRV,
TZ_OFF
};

View file

@ -25,7 +25,7 @@ void rgb_init(void);
void set_rgb_color(uint8_t pin, uint8_t value, uint8_t timer_value);
enum my_keycodes {
RGB_RI = SAFE_RANGE,
RGB_RI = QK_KB_0,
RGB_RD,
RGB_GI,
RGB_GD,

View file

@ -19,7 +19,7 @@
#include "quantum.h"
enum custom_keycodes {
TAP_00 = SAFE_RANGE
TAP_00 = QK_KB_0
};
enum layer_name {

View file

@ -34,7 +34,7 @@
#define QK_RALT 0x1400
#define QK_RGUI 0x1800
#define SAFE_RANGE QK_KB
#define SAFE_RANGE QK_USER
// clang-format on
// Generic decoding for the whole QK_MODS range

View file

@ -4,16 +4,8 @@
#pragma once
#include "drashna.h"
#if defined(KEYBOARD_handwired_tractyl_manuform) && defined(POINTING_DEVICE_ENABLE)
# define PLACEHOLDER_SAFE_RANGE KEYMAP_SAFE_RANGE
#elif defined(KEYBOARD_bastardkb_charybdis)
# define PLACEHOLDER_SAFE_RANGE CHARYBDIS_SAFE_RANGE
#else
# define PLACEHOLDER_SAFE_RANGE SAFE_RANGE
#endif
enum userspace_custom_keycodes {
VRSN = PLACEHOLDER_SAFE_RANGE, // Prints QMK Firmware and board info
VRSN = SAFE_RANGE, // Prints QMK Firmware and board info
KC_QWERTY, // Sets default layer to QWERTY
FIRST_DEFAULT_LAYER_KEYCODE = KC_QWERTY, // Sets default layer to QWERTY
KC_COLEMAK_DH, // Sets default layer to COLEMAK

View file

@ -82,9 +82,9 @@ bool is_mouse_record_user(uint16_t keycode, keyrecord_t* record) {
# if defined(KEYBOARD_ploopy)
case DPI_CONFIG:
# elif (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && !defined(NO_CHARYBDIS_KEYCODES)
case SAFE_RANGE ...(CHARYBDIS_SAFE_RANGE - 1):
case QK_KB ... QK_KB_MAX:
# elif (defined(KEYBOARD_bastardkb_dilemma) && !defined(NO_DILEMMA_KEYCODES))
case SAFE_RANGE ...(DILEMMA_SAFE_RANGE - 1):
case QK_KB ... QK_KB_MAX:
# endif
case KC_ACCEL:
return true;