diff options
author | Joel Challis <git@zvecr.com> | 2023-03-11 02:27:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 18:27:29 -0800 |
commit | a974c51d25411f171ee9271eae50af461640330d (patch) | |
tree | e41dcbfb59739c0935d6df4215e750af36ff3ecc /quantum | |
parent | 46bbb81dd2aeee48ed571e78d8315bf94cc3cce8 (diff) |
Relocate various modifier defines (#18638)
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/action_code.h | 24 | ||||
-rw-r--r-- | quantum/action_util.h | 1 | ||||
-rw-r--r-- | quantum/keycode.h | 20 | ||||
-rw-r--r-- | quantum/modifiers.h | 54 |
4 files changed, 59 insertions, 40 deletions
diff --git a/quantum/action_code.h b/quantum/action_code.h index 58d929016d..d9a575b518 100644 --- a/quantum/action_code.h +++ b/quantum/action_code.h @@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once +#include "modifiers.h" + /** \brief Action codes * * 16bit code: action_kind(4bit) + action_parameter(12bit) @@ -160,28 +162,6 @@ typedef union { #define ACTION_TRANSPARENT 1 #define ACTION(kind, param) ((kind) << 12 | (param)) -/** \brief Key Actions - * - * Mod bits: 43210 - * bit 0 ||||+- Control - * bit 1 |||+-- Shift - * bit 2 ||+--- Alt - * bit 3 |+---- Gui - * bit 4 +----- LR flag(Left:0, Right:1) - */ -enum mods_bit { - MOD_LCTL = 0x01, - MOD_LSFT = 0x02, - MOD_LALT = 0x04, - MOD_LGUI = 0x08, - MOD_RCTL = 0x11, - MOD_RSFT = 0x12, - MOD_RALT = 0x14, - MOD_RGUI = 0x18, -}; -#define MOD_HYPR (MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI) -#define MOD_MEH (MOD_LCTL | MOD_LSFT | MOD_LALT) - enum mods_codes { MODS_ONESHOT = 0x00, MODS_TAP_TOGGLE = 0x01, diff --git a/quantum/action_util.h b/quantum/action_util.h index 6f1f09c4bd..0ecf15ae4b 100644 --- a/quantum/action_util.h +++ b/quantum/action_util.h @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdint.h> #include "report.h" +#include "modifiers.h" #ifdef __cplusplus extern "C" { diff --git a/quantum/keycode.h b/quantum/keycode.h index 701c078ad0..df1452d296 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h @@ -34,26 +34,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT) #define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2) -#define MOD_BIT(code) (1 << MOD_INDEX(code)) -#define MOD_INDEX(code) ((code)&0x07) - -#define MOD_MASK_CTRL (MOD_BIT(KC_LEFT_CTRL) | MOD_BIT(KC_RIGHT_CTRL)) -#define MOD_MASK_SHIFT (MOD_BIT(KC_LEFT_SHIFT) | MOD_BIT(KC_RIGHT_SHIFT)) -#define MOD_MASK_ALT (MOD_BIT(KC_LEFT_ALT) | MOD_BIT(KC_RIGHT_ALT)) -#define MOD_MASK_GUI (MOD_BIT(KC_LEFT_GUI) | MOD_BIT(KC_RIGHT_GUI)) -#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT) -#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT) -#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI) -#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT) -#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI) -#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI) -#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT) -#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI) -#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI) -#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) -#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_BIT(code) (1 << ((code)&0x07)) // clang-format off // TODO: dd keycodes #include "keycodes.h" +#include "modifiers.h" diff --git a/quantum/modifiers.h b/quantum/modifiers.h new file mode 100644 index 0000000000..45bcd6508d --- /dev/null +++ b/quantum/modifiers.h @@ -0,0 +1,54 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +/** \brief 5-bit packed modifiers + * + * Mod bits: 43210 + * bit 0 ||||+- Control + * bit 1 |||+-- Shift + * bit 2 ||+--- Alt + * bit 3 |+---- Gui + * bit 4 +----- LR flag(Left:0, Right:1) + */ +enum mods_5bit { + MOD_LCTL = 0x01, + MOD_LSFT = 0x02, + MOD_LALT = 0x04, + MOD_LGUI = 0x08, + MOD_RCTL = 0x11, + MOD_RSFT = 0x12, + MOD_RALT = 0x14, + MOD_RGUI = 0x18, +}; +#define MOD_HYPR (MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI) +#define MOD_MEH (MOD_LCTL | MOD_LSFT | MOD_LALT) + +/** \brief 8-bit packed modifiers + */ +enum mods_8bit { + MOD_BIT_LCTRL = 0b00000001, + MOD_BIT_LSHIFT = 0b00000010, + MOD_BIT_LALT = 0b00000100, + MOD_BIT_LGUI = 0b00001000, + MOD_BIT_RCTRL = 0b00010000, + MOD_BIT_RSHIFT = 0b00100000, + MOD_BIT_RALT = 0b01000000, + MOD_BIT_RGUI = 0b10000000, +}; +#define MOD_MASK_CTRL (MOD_BIT_LCTRL | MOD_BIT_RCTRL) +#define MOD_MASK_SHIFT (MOD_BIT_LSHIFT | MOD_BIT_RSHIFT) +#define MOD_MASK_ALT (MOD_BIT_LALT | MOD_BIT_RALT) +#define MOD_MASK_GUI (MOD_BIT_LGUI | MOD_BIT_RGUI) +#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT) +#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT) +#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI) +#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT) +#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI) +#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT) +#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI) +#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) |