forked from forks/qmk_firmware
Relocate various modifier defines (#18638)
This commit is contained in:
parent
46bbb81dd2
commit
a974c51d25
|
@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "modifiers.h"
|
||||||
|
|
||||||
/** \brief Action codes
|
/** \brief Action codes
|
||||||
*
|
*
|
||||||
* 16bit code: action_kind(4bit) + action_parameter(12bit)
|
* 16bit code: action_kind(4bit) + action_parameter(12bit)
|
||||||
|
@ -160,28 +162,6 @@ typedef union {
|
||||||
#define ACTION_TRANSPARENT 1
|
#define ACTION_TRANSPARENT 1
|
||||||
#define ACTION(kind, param) ((kind) << 12 | (param))
|
#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 {
|
enum mods_codes {
|
||||||
MODS_ONESHOT = 0x00,
|
MODS_ONESHOT = 0x00,
|
||||||
MODS_TAP_TOGGLE = 0x01,
|
MODS_TAP_TOGGLE = 0x01,
|
||||||
|
|
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
#include "modifiers.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -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_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 IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
|
||||||
|
|
||||||
#define MOD_BIT(code) (1 << MOD_INDEX(code))
|
#define MOD_BIT(code) (1 << ((code)&0x07))
|
||||||
#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)
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
// TODO: dd keycodes
|
// TODO: dd keycodes
|
||||||
#include "keycodes.h"
|
#include "keycodes.h"
|
||||||
|
#include "modifiers.h"
|
||||||
|
|
54
quantum/modifiers.h
Normal file
54
quantum/modifiers.h
Normal file
|
@ -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)
|
Loading…
Reference in a new issue