refactor(hid): Mod defines in dedicated header.
This commit is contained in:
parent
55b5936d00
commit
32e7159373
6 changed files with 32 additions and 26 deletions
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <dt-bindings/zmk/modifiers.h>
|
||||
|
||||
#define USAGE_KEYPAD 0x07
|
||||
#define USAGE_CONSUMER 0x0C
|
||||
|
||||
|
@ -143,24 +145,3 @@
|
|||
#define M_VOLU 0xE9
|
||||
#define M_VOLD 0xEA
|
||||
|
||||
#define MOD_LCTL 0x01
|
||||
#define MOD_LSFT 0x02
|
||||
#define MOD_LALT 0x04
|
||||
#define MOD_LGUI 0x08
|
||||
#define MOD_RCTL 0x10
|
||||
#define MOD_RSFT 0x20
|
||||
#define MOD_RALT 0x40
|
||||
#define MOD_RGUI 0x80
|
||||
|
||||
#define SELECT_MODS(keycode) (keycode >> 24)
|
||||
#define STRIP_MODS(keycode) (keycode & ~(0xFF << 24))
|
||||
#define APPLY_MODS(mods, keycode) (mods << 24 | keycode)
|
||||
|
||||
#define LC(keycode) APPLY_MODS(MOD_LCTL, keycode)
|
||||
#define LS(keycode) APPLY_MODS(MOD_LSFT, keycode)
|
||||
#define LA(keycode) APPLY_MODS(MOD_LALT, keycode)
|
||||
#define LG(keycode) APPLY_MODS(MOD_LGUI, keycode)
|
||||
#define RC(keycode) APPLY_MODS(MOD_RCTL, keycode)
|
||||
#define RS(keycode) APPLY_MODS(MOD_RSFT, keycode)
|
||||
#define RA(keycode) APPLY_MODS(MOD_RALT, keycode)
|
||||
#define RG(keycode) APPLY_MODS(MOD_RGUI, keycode)
|
||||
|
|
28
app/include/dt-bindings/zmk/modifiers.h
Normal file
28
app/include/dt-bindings/zmk/modifiers.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define MOD_LCTL 0x01
|
||||
#define MOD_LSFT 0x02
|
||||
#define MOD_LALT 0x04
|
||||
#define MOD_LGUI 0x08
|
||||
#define MOD_RCTL 0x10
|
||||
#define MOD_RSFT 0x20
|
||||
#define MOD_RALT 0x40
|
||||
#define MOD_RGUI 0x80
|
||||
|
||||
#define SELECT_MODS(keycode) (keycode >> 24)
|
||||
#define STRIP_MODS(keycode) (keycode & ~(0xFF << 24))
|
||||
#define APPLY_MODS(mods, keycode) (mods << 24 | keycode)
|
||||
|
||||
#define LC(keycode) APPLY_MODS(MOD_LCTL, keycode)
|
||||
#define LS(keycode) APPLY_MODS(MOD_LSFT, keycode)
|
||||
#define LA(keycode) APPLY_MODS(MOD_LALT, keycode)
|
||||
#define LG(keycode) APPLY_MODS(MOD_LGUI, keycode)
|
||||
#define RC(keycode) APPLY_MODS(MOD_RCTL, keycode)
|
||||
#define RS(keycode) APPLY_MODS(MOD_RSFT, keycode)
|
||||
#define RA(keycode) APPLY_MODS(MOD_RALT, keycode)
|
||||
#define RG(keycode) APPLY_MODS(MOD_RGUI, keycode)
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
#include <dt-bindings/zmk/modifiers.h>
|
||||
#include <zmk/event-manager.h>
|
||||
|
||||
struct keycode_state_changed {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
#include <zmk/keymap.h>
|
||||
#include <zmk/keys.h>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
#include <zmk/hid.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
#include <dt-bindings/zmk/modifiers.h>
|
||||
|
||||
static struct zmk_hid_keypad_report kp_report = {
|
||||
.report_id = 1, .body = {.modifiers = 0, ._reserved = 0, .keys = {0}}};
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <usb/usb_device.h>
|
||||
#include <usb/class/usb_hid.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
#include <zmk/hid.h>
|
||||
#include <zmk/keymap.h>
|
||||
|
|
Loading…
Reference in a new issue