Big keycode cleanup (#230)
* clean up quantum.c (#7485) * idea * progress * more stuff * wip * wip * last couple of keycodes you can move safely * Update quantum/quantum.c Co-Authored-By: fauxpark <fauxpark@gmail.com> * Put back RGB_MODE_BREATHE * Compile out some keycode processing when features are disabled (#7506) * Add shift-to-invert to remaining directional RGB_* keycode pairs (#7484) * Add shift-to-invert to remaining directional RGB_* keycode pairs RGB_MODE_FORWARD / RGB_MODE_REVERSE invert their functions when shift is held. This change adds the same capabilities to the remaining directional RGB_* keycode pairs. This improves consistency and provides full RGB control in a keymap containing only one keycode from each pair. * remove redundant variable * fix typo * Fix more typos Flyspell is on now I swear! * Relocate magic keycode processing (#7512) * Move magic keycode processing to own file * Save some bytes * Update comments * Update define to one thats not already used... * Fix audio * Fix breathing toggle when rgb is disabled (#7550) * Ifdef MAGIC_EE_HANDS until #178 drops revert this commit once it does * Add short aliases for Magic keycodes (#7541) * Add short alias for `MAGIC_TOGGLE_NKRO` * Add aliases for the other Bootmagic keycodes * Replace long form in default keymaps * Fix FORCE_NKRO handling (#7601) * Add until #173 drops * Relocate RGB keycode processing (#7508) * Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled Co-authored-by: Yan-Fa Li <yanfali@gmail.com> Co-authored-by: Joel Challis <git@zvecr.com> Co-authored-by: Manna Harbour <51143715+manna-harbour@users.noreply.github.com> Co-authored-by: fauxpark <fauxpark@gmail.com> Co-authored-by: Florian Didron <fdidron@users.noreply.github.com>
This commit is contained in:
committed by
Florian Didron
parent
1a62f5c142
commit
493c675778
@@ -109,6 +109,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
|
|||||||
SRC += $(QUANTUM_DIR)/rgblight.c
|
SRC += $(QUANTUM_DIR)/rgblight.c
|
||||||
CIE1931_CURVE = yes
|
CIE1931_CURVE = yes
|
||||||
LED_BREATHING_TABLE = yes
|
LED_BREATHING_TABLE = yes
|
||||||
|
RGB_KEYCODES_ENABLE = yes
|
||||||
ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
|
ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
|
||||||
OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
|
OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
|
||||||
else
|
else
|
||||||
@@ -147,6 +148,7 @@ endif
|
|||||||
SRC += $(QUANTUM_DIR)/rgb_matrix.c
|
SRC += $(QUANTUM_DIR)/rgb_matrix.c
|
||||||
SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
|
SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
|
||||||
CIE1931_CURVE = yes
|
CIE1931_CURVE = yes
|
||||||
|
RGB_KEYCODES_ENABLE = yes
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
||||||
@@ -187,6 +189,10 @@ ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
|
|||||||
OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
|
OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
|
||||||
|
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
|
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
|
||||||
OPT_DEFS += -DTAP_DANCE_ENABLE
|
OPT_DEFS += -DTAP_DANCE_ENABLE
|
||||||
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
|
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
|
||||||
@@ -411,6 +417,12 @@ ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
|
|||||||
OPT_DEFS += -DSPACE_CADET_ENABLE
|
OPT_DEFS += -DSPACE_CADET_ENABLE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
MAGIC_ENABLE ?= yes
|
||||||
|
ifeq ($(strip $(MAGIC_ENABLE)), yes)
|
||||||
|
SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
|
||||||
|
OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
|
ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
|
||||||
SRC += $(QUANTUM_DIR)/dip_switch.c
|
SRC += $(QUANTUM_DIR)/dip_switch.c
|
||||||
OPT_DEFS += -DDIP_SWITCH_ENABLE
|
OPT_DEFS += -DDIP_SWITCH_ENABLE
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
|
|||||||
uint8_t action_layer, when, mod;
|
uint8_t action_layer, when, mod;
|
||||||
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case KC_FN0 ... KC_FN31:
|
|
||||||
action.code = keymap_function_id_to_action(FN_INDEX(keycode));
|
|
||||||
break;
|
|
||||||
case KC_A ... KC_EXSEL:
|
case KC_A ... KC_EXSEL:
|
||||||
case KC_LCTRL ... KC_RGUI:
|
case KC_LCTRL ... KC_RGUI:
|
||||||
action.code = ACTION_KEY(keycode);
|
action.code = ACTION_KEY(keycode);
|
||||||
@@ -65,9 +62,11 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
|
|||||||
case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN:
|
case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN:
|
||||||
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
|
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
|
||||||
break;
|
break;
|
||||||
|
#ifdef MOUSEKEY_ENABLE
|
||||||
case KC_MS_UP ... KC_MS_ACCEL2:
|
case KC_MS_UP ... KC_MS_ACCEL2:
|
||||||
action.code = ACTION_MOUSEKEY(keycode);
|
action.code = ACTION_MOUSEKEY(keycode);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case KC_TRNS:
|
case KC_TRNS:
|
||||||
action.code = ACTION_TRANSPARENT;
|
action.code = ACTION_TRANSPARENT;
|
||||||
break;
|
break;
|
||||||
@@ -76,17 +75,24 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
|
|||||||
// Split it up
|
// Split it up
|
||||||
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
|
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
|
||||||
break;
|
break;
|
||||||
|
#ifndef NO_ACTION_FUNCTION
|
||||||
|
case KC_FN0 ... KC_FN31:
|
||||||
|
action.code = keymap_function_id_to_action(FN_INDEX(keycode));
|
||||||
|
break;
|
||||||
case QK_FUNCTION ... QK_FUNCTION_MAX:;
|
case QK_FUNCTION ... QK_FUNCTION_MAX:;
|
||||||
// Is a shortcut for function action_layer, pull last 12bits
|
// Is a shortcut for function action_layer, pull last 12bits
|
||||||
// This means we have 4,096 FN macros at our disposal
|
// This means we have 4,096 FN macros at our disposal
|
||||||
action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
|
action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifndef NO_ACTION_MACRO
|
||||||
case QK_MACRO ... QK_MACRO_MAX:
|
case QK_MACRO ... QK_MACRO_MAX:
|
||||||
if (keycode & 0x800) // tap macros have upper bit set
|
if (keycode & 0x800) // tap macros have upper bit set
|
||||||
action.code = ACTION_MACRO_TAP(keycode & 0xFF);
|
action.code = ACTION_MACRO_TAP(keycode & 0xFF);
|
||||||
else
|
else
|
||||||
action.code = ACTION_MACRO(keycode & 0xFF);
|
action.code = ACTION_MACRO(keycode & 0xFF);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
|
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
|
||||||
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
|
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
|
||||||
break;
|
break;
|
||||||
|
|||||||
179
quantum/process_keycode/process_magic.c
Normal file
179
quantum/process_keycode/process_magic.c
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
/* Copyright 2019 Jack Humbert
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "process_magic.h"
|
||||||
|
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
# ifndef AG_NORM_SONG
|
||||||
|
# define AG_NORM_SONG SONG(AG_NORM_SOUND)
|
||||||
|
# endif
|
||||||
|
# ifndef AG_SWAP_SONG
|
||||||
|
# define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
|
||||||
|
# endif
|
||||||
|
# ifndef CG_NORM_SONG
|
||||||
|
# define CG_NORM_SONG SONG(AG_NORM_SOUND)
|
||||||
|
# endif
|
||||||
|
# ifndef CG_SWAP_SONG
|
||||||
|
# define CG_SWAP_SONG SONG(AG_SWAP_SOUND)
|
||||||
|
# endif
|
||||||
|
float ag_norm_song[][2] = AG_NORM_SONG;
|
||||||
|
float ag_swap_song[][2] = AG_SWAP_SONG;
|
||||||
|
float cg_norm_song[][2] = CG_NORM_SONG;
|
||||||
|
float cg_swap_song[][2] = CG_SWAP_SONG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MAGIC actions (BOOTMAGIC without the boot)
|
||||||
|
*/
|
||||||
|
bool process_magic(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
// skip anything that isn't a keyup
|
||||||
|
if (record->event.pressed) {
|
||||||
|
switch (keycode) {
|
||||||
|
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
|
||||||
|
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_TOGGLE_CTL_GUI:
|
||||||
|
/* keymap config */
|
||||||
|
keymap_config.raw = eeconfig_read_keymap();
|
||||||
|
switch (keycode) {
|
||||||
|
case MAGIC_SWAP_CONTROL_CAPSLOCK:
|
||||||
|
keymap_config.swap_control_capslock = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_CAPSLOCK_TO_CONTROL:
|
||||||
|
keymap_config.capslock_to_control = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_LALT_LGUI:
|
||||||
|
keymap_config.swap_lalt_lgui = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_RALT_RGUI:
|
||||||
|
keymap_config.swap_ralt_rgui = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_LCTL_LGUI:
|
||||||
|
keymap_config.swap_lctl_lgui = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_RCTL_RGUI:
|
||||||
|
keymap_config.swap_rctl_rgui = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_NO_GUI:
|
||||||
|
keymap_config.no_gui = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_GRAVE_ESC:
|
||||||
|
keymap_config.swap_grave_esc = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_BACKSLASH_BACKSPACE:
|
||||||
|
keymap_config.swap_backslash_backspace = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_HOST_NKRO:
|
||||||
|
clear_keyboard(); // clear first buffer to prevent stuck keys
|
||||||
|
keymap_config.nkro = true;
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_ALT_GUI:
|
||||||
|
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true;
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
PLAY_SONG(ag_swap_song);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case MAGIC_SWAP_CTL_GUI:
|
||||||
|
keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true;
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
PLAY_SONG(cg_swap_song);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
|
||||||
|
keymap_config.swap_control_capslock = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNCAPSLOCK_TO_CONTROL:
|
||||||
|
keymap_config.capslock_to_control = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_LALT_LGUI:
|
||||||
|
keymap_config.swap_lalt_lgui = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_RALT_RGUI:
|
||||||
|
keymap_config.swap_ralt_rgui = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_LCTL_LGUI:
|
||||||
|
keymap_config.swap_lctl_lgui = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_RCTL_RGUI:
|
||||||
|
keymap_config.swap_rctl_rgui = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNNO_GUI:
|
||||||
|
keymap_config.no_gui = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_GRAVE_ESC:
|
||||||
|
keymap_config.swap_grave_esc = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
|
||||||
|
keymap_config.swap_backslash_backspace = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNHOST_NKRO:
|
||||||
|
clear_keyboard(); // clear first buffer to prevent stuck keys
|
||||||
|
keymap_config.nkro = false;
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_ALT_GUI:
|
||||||
|
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false;
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
PLAY_SONG(ag_norm_song);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case MAGIC_UNSWAP_CTL_GUI:
|
||||||
|
keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false;
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
PLAY_SONG(cg_norm_song);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case MAGIC_TOGGLE_ALT_GUI:
|
||||||
|
keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui;
|
||||||
|
keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui;
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
if (keymap_config.swap_ralt_rgui) {
|
||||||
|
PLAY_SONG(ag_swap_song);
|
||||||
|
} else {
|
||||||
|
PLAY_SONG(ag_norm_song);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case MAGIC_TOGGLE_CTL_GUI:
|
||||||
|
keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui;
|
||||||
|
keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui;
|
||||||
|
#ifdef AUDIO_ENABLE
|
||||||
|
if (keymap_config.swap_rctl_rgui) {
|
||||||
|
PLAY_SONG(cg_swap_song);
|
||||||
|
} else {
|
||||||
|
PLAY_SONG(cg_norm_song);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case MAGIC_TOGGLE_NKRO:
|
||||||
|
clear_keyboard(); // clear first buffer to prevent stuck keys
|
||||||
|
keymap_config.nkro = !keymap_config.nkro;
|
||||||
|
break;
|
||||||
|
#if 0
|
||||||
|
case MAGIC_EE_HANDS_LEFT:
|
||||||
|
eeconfig_update_handedness(true);
|
||||||
|
break;
|
||||||
|
case MAGIC_EE_HANDS_RIGHT:
|
||||||
|
eeconfig_update_handedness(false);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
eeconfig_update_keymap(keymap_config.raw);
|
||||||
|
clear_keyboard(); // clear to prevent stuck keys
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not a magic keycode so continue processing
|
||||||
|
return true;
|
||||||
|
}
|
||||||
20
quantum/process_keycode/process_magic.h
Normal file
20
quantum/process_keycode/process_magic.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/* Copyright 2019
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
|
bool process_magic(uint16_t keycode, keyrecord_t *record);
|
||||||
141
quantum/process_keycode/process_rgb.c
Normal file
141
quantum/process_keycode/process_rgb.c
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/* Copyright 2019
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "process_rgb.h"
|
||||||
|
#include "rgb.h"
|
||||||
|
|
||||||
|
typedef void (*rgb_func_pointer)(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for inc/dec rgb keycode
|
||||||
|
*
|
||||||
|
* noinline to optimise for firmware size not speed (not in hot path)
|
||||||
|
*/
|
||||||
|
static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) {
|
||||||
|
if (is_shifted) {
|
||||||
|
dec_func();
|
||||||
|
} else {
|
||||||
|
inc_func();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for animation mode
|
||||||
|
* - if not in animation family -> jump to that animation
|
||||||
|
* - otherwise -> wrap round animation speed
|
||||||
|
*
|
||||||
|
* noinline to optimise for firmware size not speed (not in hot path)
|
||||||
|
*/
|
||||||
|
static void __attribute__((noinline,unused)) handleKeycodeRGBMode(const uint8_t start, const uint8_t end) {
|
||||||
|
if ((start <= rgblight_get_mode()) && (rgblight_get_mode() < end)) {
|
||||||
|
rgblight_step();
|
||||||
|
} else {
|
||||||
|
rgblight_mode(start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle keycodes for both rgblight and rgbmatrix
|
||||||
|
*/
|
||||||
|
bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
|
||||||
|
#ifndef SPLIT_KEYBOARD
|
||||||
|
if (record->event.pressed) {
|
||||||
|
#else
|
||||||
|
// Split keyboards need to trigger on key-up for edge-case issue
|
||||||
|
if (!record->event.pressed) {
|
||||||
|
#endif
|
||||||
|
uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
|
||||||
|
switch (keycode) {
|
||||||
|
case RGB_TOG:
|
||||||
|
rgblight_toggle();
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_FORWARD:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_step, rgblight_step_reverse);
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_REVERSE:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_step_reverse, rgblight_step);
|
||||||
|
return false;
|
||||||
|
case RGB_HUI:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_increase_hue, rgblight_decrease_hue);
|
||||||
|
return false;
|
||||||
|
case RGB_HUD:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_decrease_hue, rgblight_increase_hue);
|
||||||
|
return false;
|
||||||
|
case RGB_SAI:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_increase_sat, rgblight_decrease_sat);
|
||||||
|
return false;
|
||||||
|
case RGB_SAD:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_decrease_sat, rgblight_increase_sat);
|
||||||
|
return false;
|
||||||
|
case RGB_VAI:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_increase_val, rgblight_decrease_val);
|
||||||
|
return false;
|
||||||
|
case RGB_VAD:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_decrease_val, rgblight_increase_val);
|
||||||
|
return false;
|
||||||
|
case RGB_SPI:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_increase_speed, rgblight_decrease_speed);
|
||||||
|
return false;
|
||||||
|
case RGB_SPD:
|
||||||
|
handleKeycodeRGB(shifted, rgblight_decrease_speed, rgblight_increase_speed);
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_PLAIN:
|
||||||
|
rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_BREATHE:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_BREATHING
|
||||||
|
handleKeycodeRGBMode(RGBLIGHT_MODE_BREATHING, RGBLIGHT_MODE_BREATHING_end);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_RAINBOW:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
|
||||||
|
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_SWIRL:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
|
||||||
|
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_SNAKE:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_SNAKE
|
||||||
|
handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_KNIGHT:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_KNIGHT
|
||||||
|
handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_XMAS:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
|
||||||
|
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_GRADIENT:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
|
||||||
|
handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
case RGB_MODE_RGBTEST:
|
||||||
|
#ifdef RGBLIGHT_EFFECT_RGB_TEST
|
||||||
|
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
20
quantum/process_keycode/process_rgb.h
Normal file
20
quantum/process_keycode/process_rgb.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/* Copyright 2019
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
|
bool process_rgb(const uint16_t keycode, const keyrecord_t *record);
|
||||||
@@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
|
|
||||||
# include "rgb.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_LUFA
|
#ifdef PROTOCOL_LUFA
|
||||||
# include "outputselect.h"
|
# include "outputselect.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -61,23 +57,7 @@ extern backlight_config_t backlight_config;
|
|||||||
# ifndef GOODBYE_SONG
|
# ifndef GOODBYE_SONG
|
||||||
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
|
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
|
||||||
# endif
|
# endif
|
||||||
# ifndef AG_NORM_SONG
|
|
||||||
# define AG_NORM_SONG SONG(AG_NORM_SOUND)
|
|
||||||
# endif
|
|
||||||
# ifndef AG_SWAP_SONG
|
|
||||||
# define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
|
|
||||||
# endif
|
|
||||||
# ifndef CG_NORM_SONG
|
|
||||||
# define CG_NORM_SONG SONG(AG_NORM_SOUND)
|
|
||||||
# endif
|
|
||||||
# ifndef CG_SWAP_SONG
|
|
||||||
# define CG_SWAP_SONG SONG(AG_SWAP_SOUND)
|
|
||||||
# endif
|
|
||||||
float goodbye_song[][2] = GOODBYE_SONG;
|
float goodbye_song[][2] = GOODBYE_SONG;
|
||||||
float ag_norm_song[][2] = AG_NORM_SONG;
|
|
||||||
float ag_swap_song[][2] = AG_SWAP_SONG;
|
|
||||||
float cg_norm_song[][2] = CG_NORM_SONG;
|
|
||||||
float cg_swap_song[][2] = CG_SWAP_SONG;
|
|
||||||
# ifdef DEFAULT_LAYER_SONGS
|
# ifdef DEFAULT_LAYER_SONGS
|
||||||
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
|
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
|
||||||
# endif
|
# endif
|
||||||
@@ -168,11 +148,6 @@ void reset_keyboard(void) {
|
|||||||
bootloader_jump();
|
bootloader_jump();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
|
|
||||||
* Used to ensure that the correct keycode is released if the key is released.
|
|
||||||
*/
|
|
||||||
static bool grave_esc_was_shifted = false;
|
|
||||||
|
|
||||||
/* Convert record into usable keycode via the contained event. */
|
/* Convert record into usable keycode via the contained event. */
|
||||||
uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
|
uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
|
||||||
|
|
||||||
@@ -275,403 +250,83 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef SPACE_CADET_ENABLE
|
#ifdef SPACE_CADET_ENABLE
|
||||||
process_space_cadet(keycode, record) &&
|
process_space_cadet(keycode, record) &&
|
||||||
|
#endif
|
||||||
|
#ifdef MAGIC_KEYCODE_ENABLE
|
||||||
|
process_magic(keycode, record) &&
|
||||||
|
#endif
|
||||||
|
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
|
||||||
|
process_rgb(keycode, record) &&
|
||||||
#endif
|
#endif
|
||||||
true)) {
|
true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift / paren setup
|
if (record->event.pressed) {
|
||||||
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case RESET:
|
case RESET:
|
||||||
if (record->event.pressed) {
|
|
||||||
reset_keyboard();
|
reset_keyboard();
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
#ifndef NO_DEBUG
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
if (record->event.pressed) {
|
|
||||||
debug_enable ^= 1;
|
debug_enable ^= 1;
|
||||||
if (debug_enable) {
|
if (debug_enable) {
|
||||||
print("DEBUG: enabled.\n");
|
print("DEBUG: enabled.\n");
|
||||||
} else {
|
} else {
|
||||||
print("DEBUG: disabled.\n");
|
print("DEBUG: disabled.\n");
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
return false;
|
return false;
|
||||||
case EEPROM_RESET:
|
case EEPROM_RESET:
|
||||||
if (record->event.pressed) {
|
|
||||||
eeconfig_init();
|
eeconfig_init();
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
#ifdef FAUXCLICKY_ENABLE
|
#ifdef FAUXCLICKY_ENABLE
|
||||||
case FC_TOG:
|
case FC_TOG:
|
||||||
if (record->event.pressed) {
|
|
||||||
FAUXCLICKY_TOGGLE;
|
FAUXCLICKY_TOGGLE;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case FC_ON:
|
case FC_ON:
|
||||||
if (record->event.pressed) {
|
|
||||||
FAUXCLICKY_ON;
|
FAUXCLICKY_ON;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case FC_OFF:
|
case FC_OFF:
|
||||||
if (record->event.pressed) {
|
|
||||||
FAUXCLICKY_OFF;
|
FAUXCLICKY_OFF;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
|
|
||||||
case RGB_TOG:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_toggle();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_FORWARD:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
|
|
||||||
if (shifted) {
|
|
||||||
rgblight_step_reverse();
|
|
||||||
} else {
|
|
||||||
rgblight_step();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_REVERSE:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
|
|
||||||
if (shifted) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_step_reverse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_HUI:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_increase_hue();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_HUD:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_decrease_hue();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_SAI:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_increase_sat();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_SAD:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_decrease_sat();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_VAI:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_increase_val();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_VAD:
|
|
||||||
// Split keyboards need to trigger on key-up for edge-case issue
|
|
||||||
# ifndef SPLIT_KEYBOARD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
# else
|
|
||||||
if (!record->event.pressed) {
|
|
||||||
# endif
|
|
||||||
rgblight_decrease_val();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_SPI:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
rgblight_increase_speed();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_SPD:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
rgblight_decrease_speed();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_PLAIN:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_BREATHE:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_BREATHING
|
|
||||||
if (record->event.pressed) {
|
|
||||||
if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_BREATHING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_RAINBOW:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
|
|
||||||
if (record->event.pressed) {
|
|
||||||
if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_SWIRL:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
|
|
||||||
if (record->event.pressed) {
|
|
||||||
if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_SNAKE:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_SNAKE
|
|
||||||
if (record->event.pressed) {
|
|
||||||
if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_SNAKE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_KNIGHT:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_KNIGHT
|
|
||||||
if (record->event.pressed) {
|
|
||||||
if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_KNIGHT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_XMAS:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_CHRISTMAS
|
|
||||||
if (record->event.pressed) {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_GRADIENT:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
|
|
||||||
if (record->event.pressed) {
|
|
||||||
if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) {
|
|
||||||
rgblight_step();
|
|
||||||
} else {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
case RGB_MODE_RGBTEST:
|
|
||||||
# ifdef RGBLIGHT_EFFECT_RGB_TEST
|
|
||||||
if (record->event.pressed) {
|
|
||||||
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return false;
|
|
||||||
#endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
|
|
||||||
#ifdef VELOCIKEY_ENABLE
|
#ifdef VELOCIKEY_ENABLE
|
||||||
case VLK_TOG:
|
case VLK_TOG:
|
||||||
if (record->event.pressed) {
|
|
||||||
velocikey_toggle();
|
velocikey_toggle();
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef PROTOCOL_LUFA
|
#ifdef BLUETOOTH_ENABLE
|
||||||
case OUT_AUTO:
|
case OUT_AUTO:
|
||||||
if (record->event.pressed) {
|
|
||||||
set_output(OUTPUT_AUTO);
|
set_output(OUTPUT_AUTO);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case OUT_USB:
|
case OUT_USB:
|
||||||
if (record->event.pressed) {
|
|
||||||
set_output(OUTPUT_USB);
|
set_output(OUTPUT_USB);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
# ifdef BLUETOOTH_ENABLE
|
|
||||||
case OUT_BT:
|
case OUT_BT:
|
||||||
if (record->event.pressed) {
|
|
||||||
set_output(OUTPUT_BLUETOOTH);
|
set_output(OUTPUT_BLUETOOTH);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING)
|
||||||
|
case BL_BRTG:
|
||||||
|
backlight_toggle_breathing();
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
#ifdef WEBUSB_ENABLE
|
||||||
|
case WEBUSB_PAIR:
|
||||||
|
webusb_state.pairing = true;
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
|
|
||||||
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
// MAGIC actions (BOOTMAGIC without the boot)
|
|
||||||
if (!eeconfig_is_enabled()) {
|
|
||||||
eeconfig_init();
|
|
||||||
}
|
}
|
||||||
/* keymap config */
|
}
|
||||||
keymap_config.raw = eeconfig_read_keymap();
|
|
||||||
|
// keycodes that depend on both pressed and non-pressed state
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case MAGIC_SWAP_CONTROL_CAPSLOCK:
|
|
||||||
keymap_config.swap_control_capslock = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_CAPSLOCK_TO_CONTROL:
|
|
||||||
keymap_config.capslock_to_control = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_LALT_LGUI:
|
|
||||||
keymap_config.swap_lalt_lgui = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_RALT_RGUI:
|
|
||||||
keymap_config.swap_ralt_rgui = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_LCTL_LGUI:
|
|
||||||
keymap_config.swap_lctl_lgui = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_RCTL_RGUI:
|
|
||||||
keymap_config.swap_rctl_rgui = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_NO_GUI:
|
|
||||||
keymap_config.no_gui = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_GRAVE_ESC:
|
|
||||||
keymap_config.swap_grave_esc = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_BACKSLASH_BACKSPACE:
|
|
||||||
keymap_config.swap_backslash_backspace = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_HOST_NKRO:
|
|
||||||
clear_keyboard(); // clear first buffer to prevent stuck keys
|
|
||||||
keymap_config.nkro = true;
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_ALT_GUI:
|
|
||||||
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true;
|
|
||||||
#ifdef AUDIO_ENABLE
|
|
||||||
PLAY_SONG(ag_swap_song);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case MAGIC_SWAP_CTL_GUI:
|
|
||||||
keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true;
|
|
||||||
#ifdef AUDIO_ENABLE
|
|
||||||
PLAY_SONG(cg_swap_song);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
|
|
||||||
keymap_config.swap_control_capslock = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNCAPSLOCK_TO_CONTROL:
|
|
||||||
keymap_config.capslock_to_control = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_LALT_LGUI:
|
|
||||||
keymap_config.swap_lalt_lgui = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_RALT_RGUI:
|
|
||||||
keymap_config.swap_ralt_rgui = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_LCTL_LGUI:
|
|
||||||
keymap_config.swap_lctl_lgui = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_RCTL_RGUI:
|
|
||||||
keymap_config.swap_rctl_rgui = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNNO_GUI:
|
|
||||||
keymap_config.no_gui = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_GRAVE_ESC:
|
|
||||||
keymap_config.swap_grave_esc = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
|
|
||||||
keymap_config.swap_backslash_backspace = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNHOST_NKRO:
|
|
||||||
clear_keyboard(); // clear first buffer to prevent stuck keys
|
|
||||||
keymap_config.nkro = false;
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_ALT_GUI:
|
|
||||||
keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false;
|
|
||||||
#ifdef AUDIO_ENABLE
|
|
||||||
PLAY_SONG(ag_norm_song);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case MAGIC_UNSWAP_CTL_GUI:
|
|
||||||
keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false;
|
|
||||||
#ifdef AUDIO_ENABLE
|
|
||||||
PLAY_SONG(cg_norm_song);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case MAGIC_TOGGLE_ALT_GUI:
|
|
||||||
keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui;
|
|
||||||
keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui;
|
|
||||||
#ifdef AUDIO_ENABLE
|
|
||||||
if (keymap_config.swap_ralt_rgui) {
|
|
||||||
PLAY_SONG(ag_swap_song);
|
|
||||||
} else {
|
|
||||||
PLAY_SONG(ag_norm_song);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case MAGIC_TOGGLE_CTL_GUI:
|
|
||||||
keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui;
|
|
||||||
keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui;
|
|
||||||
#ifdef AUDIO_ENABLE
|
|
||||||
if (keymap_config.swap_rctl_rgui) {
|
|
||||||
PLAY_SONG(cg_swap_song);
|
|
||||||
} else {
|
|
||||||
PLAY_SONG(cg_norm_song);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case MAGIC_TOGGLE_NKRO:
|
|
||||||
clear_keyboard(); // clear first buffer to prevent stuck keys
|
|
||||||
keymap_config.nkro = !keymap_config.nkro;
|
|
||||||
break;
|
|
||||||
case MAGIC_EE_HANDS_LEFT:
|
|
||||||
eeconfig_update_handedness(true);
|
|
||||||
break;
|
|
||||||
case MAGIC_EE_HANDS_RIGHT:
|
|
||||||
eeconfig_update_handedness(false);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
eeconfig_update_keymap(keymap_config.raw);
|
|
||||||
clear_keyboard(); // clear to prevent stuck keys
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GRAVE_ESC: {
|
case GRAVE_ESC: {
|
||||||
|
/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
|
||||||
|
* Used to ensure that the correct keycode is released if the key is released.
|
||||||
|
*/
|
||||||
|
static bool grave_esc_was_shifted = false;
|
||||||
|
|
||||||
uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)));
|
uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)));
|
||||||
|
|
||||||
#ifdef GRAVE_ESC_ALT_OVERRIDE
|
#ifdef GRAVE_ESC_ALT_OVERRIDE
|
||||||
@@ -714,22 +369,6 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING)
|
|
||||||
case BL_BRTG: {
|
|
||||||
if (record->event.pressed) {
|
|
||||||
backlight_toggle_breathing();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef WEBUSB_ENABLE
|
|
||||||
case WEBUSB_PAIR:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
webusb_state.pairing = true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_action_kb(record);
|
return process_action_kb(record);
|
||||||
|
|||||||
@@ -133,6 +133,14 @@ extern layer_state_t layer_state;
|
|||||||
# include "process_space_cadet.h"
|
# include "process_space_cadet.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAGIC_KEYCODE_ENABLE
|
||||||
|
# include "process_magic.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
|
||||||
|
# include "process_rgb.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HD44780_ENABLE
|
#ifdef HD44780_ENABLE
|
||||||
# include "hd44780.h"
|
# include "hd44780.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -657,13 +657,42 @@ enum quantum_keycodes {
|
|||||||
// L-ayer, T-ap - 256 keycode max, 16 layer max
|
// L-ayer, T-ap - 256 keycode max, 16 layer max
|
||||||
#define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF))
|
#define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF))
|
||||||
|
|
||||||
|
#define CL_SWAP MAGIC_SWAP_CONTROL_CAPSLOCK
|
||||||
|
#define CL_NORM MAGIC_UNSWAP_CONTROL_CAPSLOCK
|
||||||
|
#define CL_CTRL MAGIC_CAPSLOCK_TO_CONTROL
|
||||||
|
#define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL
|
||||||
|
|
||||||
|
#define LCG_SWP MAGIC_SWAP_LCTL_LGUI
|
||||||
|
#define LCG_NRM MAGIC_UNSWAP_LCTL_LGUI
|
||||||
|
#define RCG_SWP MAGIC_SWAP_RCTL_RGUI
|
||||||
|
#define RCG_NRM MAGIC_UNSWAP_RCTL_RGUI
|
||||||
|
#define CG_SWAP MAGIC_SWAP_CTL_GUI
|
||||||
|
#define CG_NORM MAGIC_UNSWAP_CTL_GUI
|
||||||
|
#define CG_TOGG MAGIC_TOGGLE_CTL_GUI
|
||||||
|
|
||||||
|
#define LAG_SWP MAGIC_SWAP_LALT_LGUI
|
||||||
|
#define LAG_NRM MAGIC_UNSWAP_LALT_LGUI
|
||||||
|
#define RAG_SWP MAGIC_SWAP_RALT_RGUI
|
||||||
|
#define RAG_NRM MAGIC_UNSWAP_RALT_RGUI
|
||||||
#define AG_SWAP MAGIC_SWAP_ALT_GUI
|
#define AG_SWAP MAGIC_SWAP_ALT_GUI
|
||||||
#define AG_NORM MAGIC_UNSWAP_ALT_GUI
|
#define AG_NORM MAGIC_UNSWAP_ALT_GUI
|
||||||
#define AG_TOGG MAGIC_TOGGLE_ALT_GUI
|
#define AG_TOGG MAGIC_TOGGLE_ALT_GUI
|
||||||
|
|
||||||
#define CG_SWAP MAGIC_SWAP_CTL_GUI
|
#define GUI_OFF MAGIC_NO_GUI
|
||||||
#define CG_NORM MAGIC_UNSWAP_CTL_GUI
|
#define GUI_ON MAGIC_UNNO_GUI
|
||||||
#define CG_TOGG MAGIC_TOGGLE_CTL_GUI
|
|
||||||
|
#define GE_SWAP MAGIC_SWAP_GRAVE_ESC
|
||||||
|
#define GE_NORM MAGIC_UNSWAP_GRAVE_ESC
|
||||||
|
|
||||||
|
#define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE
|
||||||
|
#define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE
|
||||||
|
|
||||||
|
#define NK_ON MAGIC_HOST_NKRO
|
||||||
|
#define NK_OFF MAGIC_UNHOST_NKRO
|
||||||
|
#define NK_TOGG MAGIC_TOGGLE_NKRO
|
||||||
|
|
||||||
|
#define EH_LEFT MAGIC_EE_HANDS_LEFT
|
||||||
|
#define EH_RGHT MAGIC_EE_HANDS_RIGHT
|
||||||
|
|
||||||
// GOTO layer - 16 layers max
|
// GOTO layer - 16 layers max
|
||||||
// when:
|
// when:
|
||||||
|
|||||||
@@ -128,26 +128,26 @@ void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
|
|||||||
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
|
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
|
||||||
|
|
||||||
#ifndef RGBLIGHT_ENABLE
|
#ifndef RGBLIGHT_ENABLE
|
||||||
# define rgblight_toggle() rgb_matrix_toggle()
|
# define rgblight_toggle rgb_matrix_toggle
|
||||||
# define rgblight_enable() rgb_matrix_enable()
|
# define rgblight_enable rgb_matrix_enable
|
||||||
# define rgblight_enable_noeeprom() rgb_matrix_enable_noeeprom()
|
# define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom
|
||||||
# define rgblight_disable() rgb_matrix_disable()
|
# define rgblight_disable rgb_matrix_disable
|
||||||
# define rgblight_disable_noeeprom() rgb_matrix_disable_noeeprom()
|
# define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom
|
||||||
# define rgblight_step() rgb_matrix_step()
|
# define rgblight_step rgb_matrix_step
|
||||||
# define rgblight_sethsv(hue, sat, val) rgb_matrix_sethsv(hue, sat, val)
|
# define rgblight_sethsv rgb_matrix_sethsv
|
||||||
# define rgblight_sethsv_noeeprom(hue, sat, val) rgb_matrix_sethsv_noeeprom(hue, sat, val)
|
# define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom
|
||||||
# define rgblight_step_reverse() rgb_matrix_step_reverse()
|
# define rgblight_step_reverse rgb_matrix_step_reverse
|
||||||
# define rgblight_increase_hue() rgb_matrix_increase_hue()
|
# define rgblight_increase_hue rgb_matrix_increase_hue
|
||||||
# define rgblight_decrease_hue() rgb_matrix_decrease_hue()
|
# define rgblight_decrease_hue rgb_matrix_decrease_hue
|
||||||
# define rgblight_increase_sat() rgb_matrix_increase_sat()
|
# define rgblight_increase_sat rgb_matrix_increase_sat
|
||||||
# define rgblight_decrease_sat() rgb_matrix_decrease_sat()
|
# define rgblight_decrease_sat rgb_matrix_decrease_sat
|
||||||
# define rgblight_increase_val() rgb_matrix_increase_val()
|
# define rgblight_increase_val rgb_matrix_increase_val
|
||||||
# define rgblight_decrease_val() rgb_matrix_decrease_val()
|
# define rgblight_decrease_val rgb_matrix_decrease_val
|
||||||
# define rgblight_increase_speed() rgb_matrix_increase_speed()
|
# define rgblight_increase_speed rgb_matrix_increase_speed
|
||||||
# define rgblight_decrease_speed() rgb_matrix_decrease_speed()
|
# define rgblight_decrease_speed rgb_matrix_decrease_speed
|
||||||
# define rgblight_mode(mode) rgb_matrix_mode(mode)
|
# define rgblight_mode rgb_matrix_mode
|
||||||
# define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode)
|
# define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom
|
||||||
# define rgblight_get_mode() rgb_matrix_get_mode()
|
# define rgblight_get_mode rgb_matrix_get_mode
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ void keyboard_init(void) {
|
|||||||
#endif
|
#endif
|
||||||
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
|
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
|
||||||
keymap_config.nkro = 1;
|
keymap_config.nkro = 1;
|
||||||
|
eeconfig_update_keymap(keymap_config.raw);
|
||||||
#endif
|
#endif
|
||||||
keyboard_post_init_kb(); /* Always keep this last */
|
keyboard_post_init_kb(); /* Always keep this last */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user