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

Make default layer size 16-bit #15286

Merged
merged 13 commits into from
Jun 18, 2022
7 changes: 3 additions & 4 deletions docs/zh-cn/custom_quantum_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void suspend_wakeup_init_user(void) {

```c
layer_state_t layer_state_set_user(layer_state_t state) {
switch (biton32(state)) {
switch (get_highest_layer(state)) {
case _RAISE:
rgblight_setrgb (0x00, 0x00, 0xFF);
break;
Expand All @@ -267,7 +267,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {

### `layer_state_set_*` 函数文档

* 键盘/各子版本:`uint32_t layer_state_set_kb(uint32_t state)`
* 键盘/各子版本:`layer_state_t layer_state_set_kb(layer_state_t state)`
* 布局: `layer_state_t layer_state_set_user(layer_state_t state)`


Expand Down Expand Up @@ -325,7 +325,7 @@ void keyboard_post_init_user(void) {

```c
layer_state_t layer_state_set_user(layer_state_t state) {
switch (biton32(state)) {
switch (get_highest_layer(state)) {
case _RAISE:
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_magenta(); rgblight_mode_noeeprom(1); }
break;
Expand Down Expand Up @@ -474,4 +474,3 @@ cancel_deferred_exec(my_token);
```c
#define MAX_DEFERRED_EXECUTORS 16
```

Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void matrix_scan_user(void) {
}
}
layer_state_t layer_state_set_user(layer_state_t state) {
switch (biton32(state)) {
switch (get_highest_layer(state)) {
case _TAPLAND:
rgblight_setrgb(0, 16, 0); //green
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void matrix_scan_user(void) {
#ifdef RGBLIGHT_ENABLE

static uint8_t old_layer = 255;
uint8_t new_layer = biton32(layer_state);
uint8_t new_layer = get_highest_layer(layer_state);

// Color of the Icons.
if (old_layer != new_layer) {
Expand Down
4 changes: 2 additions & 2 deletions keyboards/40percentclub/half_n_half/keymaps/Boy_314/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ void tap_dance_choose_layer_reset (qk_tap_dance_state_t *state, void *user_data)
layer_off(_RAISE);
break;
case 3:
if (biton32(default_layer_state) == _DVORAK) {
if (get_highest_layer(default_layer_state) == _DVORAK) {
set_single_persistent_default_layer(_QWERTY);
}
else if (biton32(default_layer_state) == _QWERTY) {
else if (get_highest_layer(default_layer_state) == _QWERTY) {
set_single_persistent_default_layer(_DVORAK);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion keyboards/bandominedoni/keymaps/led/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void keyboard_post_init_user(void) {
#ifdef RGB_MATRIX_ENABLE
void rgb_matrix_indicators_user(void) {
if (rgb_matrix_is_enabled()) { // turn the lights on when it is enabled.
uint8_t layer = biton32(layer_state);
uint8_t layer = get_highest_layer(layer_state);
switch (layer) {
case _CLOSE:
// rgb_matrix_set_color(pgm_read_byte(&convert_led_location2number[11]), RGB_RED); // RGB_TOG <- too heavy.
Expand Down
2 changes: 1 addition & 1 deletion keyboards/bandominedoni/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void keyboard_post_init_user(void) {
#ifdef RGB_MATRIX_ENABLE
void rgb_matrix_indicators_user(void) {
if (rgb_matrix_is_enabled()) { // turn the lights on when it is enabled.
uint8_t layer = biton32(layer_state);
uint8_t layer = get_highest_layer(layer_state);
switch (layer) {
case _CLOSE:
// rgb_matrix_set_color(pgm_read_byte(&convert_led_location2number[11]), RGB_RED); // RGB_TOG <- too heavy.
Expand Down
4 changes: 2 additions & 2 deletions keyboards/biacco42/ergo42/keymaps/hdbx/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};

// RGB Underglow使用時のレイヤー毎のカラー切り替え
uint32_t layer_state_set_keymap (uint32_t state) {
layer_state_t layer_state_set_keymap (layer_state_t state) {
return state;
}

Expand All @@ -148,7 +148,7 @@ void matrix_init_user(void) {
layer_state_t layer_state_set_user(layer_state_t state) {
state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
#ifdef RGBLIGHT_ENABLE
switch (biton32(state)) {
switch (get_highest_layer(state)) {
case _RAISE:
rgblight_setrgb_chartreuse(); // RAISE:シャルトリューズ
break;
Expand Down
4 changes: 2 additions & 2 deletions keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

void matrix_scan_user(void) {
uint8_t layer;
layer = biton32(layer_state);
layer = get_highest_layer(layer_state);

if (current_layer_global != layer) {
current_layer_global = layer;
Expand Down Expand Up @@ -132,7 +132,7 @@ void tap_helper(keyrecord_t *record, uint16_t orig_mod, uint16_t macro_mod, uint

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t layer;
layer = biton32(layer_state);
layer = get_highest_layer(layer_state);
if (layer == PROG2) {
if (keycode >= KC_A && keycode <= KC_EXSEL && \
!( // do not send LSFT + these keycodes, they are needed for emulating the US layout
Expand Down
2 changes: 1 addition & 1 deletion keyboards/bpiphany/pegasushoof/keymaps/blowrak/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

void matrix_scan_user(void)
{
uint8_t layer = biton32(layer_state);
uint8_t layer = get_highest_layer(layer_state);
switch (layer) {
case KM_BLOWRAK:
ph_caps_led_on();
Expand Down
73 changes: 37 additions & 36 deletions keyboards/cannonkeys/ortho75/ortho75.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,48 @@

uint8_t layer = 0;

uint32_t layer_state_set_kb(uint32_t state) {
state = layer_state_set_user(state);
layer = biton32(state);
return state;
layer_state_t layer_state_set_kb(layer_state_t state) {
state = layer_state_set_user(state);
layer = get_highest_layer(state);
return state;
}

bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false;
uint16_t mapped_code = 0;
if (index == 0) {
if (clockwise) {
switch(layer){
case 0:
default:
mapped_code = KC_VOLU;
break;
case 1:
mapped_code = KC_MEDIA_NEXT_TRACK;
break;
case 2:
mapped_code = KC_PGDN;
break;
uint16_t mapped_code = 0;
if (index == 0) {
if (clockwise) {
switch (layer) {
case 0:
default:
mapped_code = KC_VOLU;
break;
case 1:
mapped_code = KC_MEDIA_NEXT_TRACK;
break;
case 2:
mapped_code = KC_PGDN;
break;
}
} else {
switch (layer) {
case 0:
default:
mapped_code = KC_VOLD;
break;
case 1:
mapped_code = KC_MEDIA_PREV_TRACK;
break;
case 2:
mapped_code = KC_PGUP;
break;
}
}
} else {
switch(layer){
case 0:
default:
mapped_code = KC_VOLD;
break;
case 1:
mapped_code = KC_MEDIA_PREV_TRACK;
break;
case 2:
mapped_code = KC_PGUP;
break;
uint16_t held_keycode_timer = timer_read();
register_code(mapped_code);
while (timer_elapsed(held_keycode_timer) < MEDIA_KEY_DELAY) { /* no-op */
}
unregister_code(mapped_code);
}
uint16_t held_keycode_timer = timer_read();
register_code(mapped_code);
while (timer_elapsed(held_keycode_timer) < MEDIA_KEY_DELAY){ /* no-op */ }
unregister_code(mapped_code);
}
return true;
return true;
}
2 changes: 1 addition & 1 deletion keyboards/cannonkeys/satisfaction75/satisfaction75.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void read_host_led_state(void) {

layer_state_t layer_state_set_kb(layer_state_t state) {
state = layer_state_set_user(state);
layer = biton32(state);
layer = get_highest_layer(state);
oled_request_wakeup();
return state;
}
Expand Down
4 changes: 2 additions & 2 deletions keyboards/ckeys/washington/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};

bool encoder_update_user(uint8_t index, bool clockwise) {
switch (biton32(layer_state)) {
switch (get_highest_layer(layer_state)) {
case _BASE:
if (clockwise) {
tap_code(KC_VOLU);
Expand All @@ -62,7 +62,7 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
bool oled_task_user(void) {
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);
switch (biton32(layer_state)) {
switch (get_highest_layer(layer_state)) {
case _BASE:
oled_write_P(PSTR("Default\n"), false);
break;
Expand Down
2 changes: 1 addition & 1 deletion keyboards/clueboard/66/keymaps/magicmonty/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void matrix_scan_user(void) {

if (!rgblight_config.enable || rgblight_config.mode != 1) { return; }

uint32_t layer = layer_state;
layer_state_t layer = layer_state;
uint8_t val = rgblight_config.val;

if (layer & (1<<_FL)) {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/crkbd/keymaps/dsanchezseco/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {

const char *read_logo(void);
bool oled_task_user(void){
switch (biton32(layer_state)){
switch (get_highest_layer(layer_state)){
case _DVORAK:
oled_write_ln_P(PSTR("DVRK"), false);
break;
Expand Down
4 changes: 2 additions & 2 deletions keyboards/crkbd/keymaps/edvorakjp/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// clang-format on

#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
uint32_t layer_state_set_keymap(uint32_t state) {
layer_state_t layer_state_set_keymap(layer_state_t state) {
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
switch (biton32(state)) {
switch (get_highest_layer(state)) {
case L_EDVORAKJP_LOWER:
rgblight_sethsv_noeeprom_red();
break;
Expand Down
2 changes: 1 addition & 1 deletion keyboards/crkbd/keymaps/edvorakjp/oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void render_layer_state(void) {
char layer_name[17];
oled_write_P(PSTR("Layer: "), false);

switch (biton32(layer_state)) {
switch (get_highest_layer(layer_state)) {
case L_EDVORAKJP_BASE:
oled_write_ln_P(PSTR("Default"), false);
break;
Expand Down
2 changes: 1 addition & 1 deletion keyboards/crkbd/keymaps/jarred/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const char *read_keylogs(void);
char matrix_line_str[24];

const char *read_layer_state(void) {
uint8_t layer = biton32(layer_state);
uint8_t layer = get_highest_layer(layer_state);

strcpy(matrix_line_str, "Layer: ");

Expand Down
4 changes: 2 additions & 2 deletions keyboards/dichotomy/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ report_mouse_t currentReport = {};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
//uint8_t layer;
//layer = biton32(layer_state); // get the current layer //Or don't, I didn't use it.
//layer = get_highest_layer(layer_state); // get the current layer //Or don't, I didn't use it.
bool returnVal = true; //this is to determine if more key processing is needed.

//custom layer handling for tri_layer,
Expand Down Expand Up @@ -437,7 +437,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
};

void matrix_scan_user(void) {
//uint8_t layer = biton32(layer_state);
//uint8_t layer = get_highest_layer(layer_state);
for (uint8_t i = 0; i<LONGPRESS_COUNT; i++){
if ((timer_elapsed(special_timers[i]) >= CUSTOM_LONGPRESS) && (!special_key_states[i]) && special_key_pressed[i]){
switch (i + SAFE_RANGE){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_laye

// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
uint8_t layer = biton32(layer_state);
uint8_t layer = get_highest_layer(layer_state);

switch (layer) {
case _LOWER:
Expand Down
28 changes: 14 additions & 14 deletions keyboards/dz60/keymaps/iso_split-spacebar/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// thanks to atlacat, hailbreno, itsaferbie and weeheavy...

// and special thanks to AGausmann and drashna for the layer-activated RGB underglow
// https://www.reddit.com/r/olkb/comments/6t1vdu/update_layeractivated_rgb_underglow/
// https://www.reddit.com/r/olkb/comments/6t1vdu/update_layeractivated_rgb_underglow/
// https://github.com/AGausmann/qmk_firmware/blob/agausmann-v3.x/keyboards/nyquist/keymaps/agausmann/keymap.c

#include QMK_KEYBOARD_H

/*
/*
* Each layer gets a name for readability.
* The underscores don't mean anything - you can
* have a layer called STUFF or any other name.
Expand All @@ -23,8 +23,8 @@
#define NL 2 // Numpad Layer
#define RL 3 // RGB Layer

/*
* Let's give an easier name to the RGB modes
/*
* Let's give an easier name to the RGB modes
* and assign the ones we want to the different layer
* these will then be used by the function below
*
Expand All @@ -49,10 +49,10 @@
//
#define RGB_RL_MODE rgblight_mode_noeeprom(22) //rgb mode for RL layer
#define RGB_RL_LIGHT rgblight_sethsv_noeeprom_red() //rgb light for RL layer


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

/* Keymap BL: Base Layer (Default Layer)
*
* ,-----------------------------------------------------------.
Expand Down Expand Up @@ -140,7 +140,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, RGB_STA, RGB_BRE, RGB_RAI, RGB_SWI, _______, _______, RGB_SNA, RGB_KNI, RGB_GRA, RGB_XMS, _______, _______, _______,
_______, BL_DEC, BL_TOGG, BL_INC, BL_STEP, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, MO(FL), _______, _______, _______, TO(BL), _______),


};

Expand Down Expand Up @@ -175,25 +175,25 @@ void matrix_scan_user(void) {
#ifdef RGBLIGHT_ENABLE

static uint8_t old_layer = 1;
uint8_t new_layer = biton32(layer_state);
uint8_t new_layer = get_highest_layer(layer_state);

if (old_layer != new_layer) {
switch (new_layer) {
case BL:
RGB_BL_MODE;
RGB_BL_LIGHT;
RGB_BL_LIGHT;
break;
case FL:
RGB_FL_MODE;
RGB_FL_LIGHT;
RGB_FL_LIGHT;
break;
case NL:
RGB_NL_MODE;
RGB_NL_LIGHT;
RGB_NL_MODE;
RGB_NL_LIGHT;
break;
case RL:
RGB_RL_MODE;
RGB_RL_LIGHT;
RGB_RL_MODE;
RGB_RL_LIGHT;
break;
}

Expand Down
Loading