diff options
| author | Joel Challis <git@zvecr.com> | 2024-11-23 10:09:34 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-23 10:09:34 +0000 |
| commit | 4a5bae51cd1f2cbca0ab8c8ae6e15262f8dc5a68 (patch) | |
| tree | 6dedf92beaa32ddd33476aec43c856f6a37901ed /quantum/process_keycode | |
| parent | 9e9b4acbde48acbe51fb9ff198be5dce49608ee9 (diff) | |
[Feature] Add keycode PDF(layer) to set the default layer in EEPROM (#24630)
* [Feature] Add keycode PDF(layer) to set the default layer in EEPROM (#21881)
* Apply suggestions from code review
Co-authored-by: Nick Brassel <nick@tzarc.org>
---------
Co-authored-by: Nebuleon <2391500+Nebuleon@users.noreply.github.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_autocorrect.c | 1 | ||||
| -rw-r--r-- | quantum/process_keycode/process_default_layer.c | 32 | ||||
| -rw-r--r-- | quantum/process_keycode/process_default_layer.h | 27 |
3 files changed, 60 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index edc47718f3..b7f9132acf 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c | |||
| @@ -98,6 +98,7 @@ bool process_autocorrect_default_handler(uint16_t *keycode, keyrecord_t *record, | |||
| 98 | case QK_TO ... QK_TO_MAX: | 98 | case QK_TO ... QK_TO_MAX: |
| 99 | case QK_MOMENTARY ... QK_MOMENTARY_MAX: | 99 | case QK_MOMENTARY ... QK_MOMENTARY_MAX: |
| 100 | case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: | 100 | case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: |
| 101 | case QK_PERSISTENT_DEF_LAYER ... QK_PERSISTENT_DEF_LAYER_MAX: | ||
| 101 | case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: | 102 | case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: |
| 102 | case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: | 103 | case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: |
| 103 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: | 104 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: |
diff --git a/quantum/process_keycode/process_default_layer.c b/quantum/process_keycode/process_default_layer.c new file mode 100644 index 0000000000..4bca30c410 --- /dev/null +++ b/quantum/process_keycode/process_default_layer.c | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* Copyright 2023 Nebuleon | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "process_default_layer.h" | ||
| 17 | #include "quantum.h" | ||
| 18 | #include "quantum_keycodes.h" | ||
| 19 | |||
| 20 | #if !defined(NO_ACTION_LAYER) | ||
| 21 | |||
| 22 | bool process_default_layer(uint16_t keycode, keyrecord_t *record) { | ||
| 23 | if (IS_QK_PERSISTENT_DEF_LAYER(keycode) && !record->event.pressed) { | ||
| 24 | uint8_t layer = QK_PERSISTENT_DEF_LAYER_GET_LAYER(keycode); | ||
| 25 | set_single_persistent_default_layer(layer); | ||
| 26 | return false; | ||
| 27 | } | ||
| 28 | |||
| 29 | return true; | ||
| 30 | } | ||
| 31 | |||
| 32 | #endif // !defined(NO_ACTION_LAYER) | ||
diff --git a/quantum/process_keycode/process_default_layer.h b/quantum/process_keycode/process_default_layer.h new file mode 100644 index 0000000000..246d995817 --- /dev/null +++ b/quantum/process_keycode/process_default_layer.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* Copyright 2023 Nebuleon | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include <stdint.h> | ||
| 20 | #include <stdbool.h> | ||
| 21 | #include "action.h" | ||
| 22 | |||
| 23 | #if !defined(NO_ACTION_LAYER) | ||
| 24 | |||
| 25 | bool process_default_layer(uint16_t keycode, keyrecord_t *record); | ||
| 26 | |||
| 27 | #endif // !defined(NO_ACTION_LAYER) | ||
