Browse Source

refactor(hid): Mod defines in dedicated header.

xmkb
Pete Johanson 4 years ago
parent
commit
32e7159373
  1. 23
      app/include/dt-bindings/zmk/keys.h
  2. 28
      app/include/dt-bindings/zmk/modifiers.h
  3. 2
      app/include/zmk/events/keycode-state-changed.h
  4. 2
      app/include/zmk/handlers.h
  5. 2
      app/src/hid.c
  6. 1
      app/src/usb.c

23
app/include/dt-bindings/zmk/keys.h

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
*/
#pragma once
#include <dt-bindings/zmk/modifiers.h>
#define USAGE_KEYPAD 0x07
#define USAGE_CONSUMER 0x0C
@ -143,24 +145,3 @@ @@ -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

@ -0,0 +1,28 @@ @@ -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)

2
app/include/zmk/events/keycode-state-changed.h

@ -7,7 +7,7 @@ @@ -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 {

2
app/include/zmk/handlers.h

@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
#pragma once
#include <dt-bindings/zmk/keys.h>
#include <zmk/keymap.h>
#include <zmk/keys.h>

2
app/src/hid.c

@ -8,7 +8,7 @@ @@ -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}}};

1
app/src/usb.c

@ -9,7 +9,6 @@ @@ -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…
Cancel
Save