forked from kofal.net/zmk
Move Zephyr app into subdirectory.
This commit is contained in:
142
app/include/dt-bindings/zmk/keys.h
Normal file
142
app/include/dt-bindings/zmk/keys.h
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define KC_A 0x04
|
||||
#define KC_B 0x05
|
||||
#define KC_C 0x06
|
||||
#define KC_D 0x07
|
||||
#define KC_E 0x08
|
||||
#define KC_F 0x09
|
||||
#define KC_G 0x0A
|
||||
#define KC_H 0x0B
|
||||
#define KC_I 0x0C
|
||||
#define KC_J 0x0D
|
||||
#define KC_K 0x0E
|
||||
#define KC_L 0x0F
|
||||
#define KC_M 0x10
|
||||
#define KC_N 0x11
|
||||
#define KC_O 0x12
|
||||
#define KC_P 0x13
|
||||
#define KC_Q 0x14
|
||||
#define KC_R 0x15
|
||||
#define KC_S 0x16
|
||||
#define KC_T 0x17
|
||||
#define KC_U 0x18
|
||||
#define KC_V 0x19
|
||||
#define KC_W 0x1A
|
||||
#define KC_X 0x1B
|
||||
#define KC_Y 0x1C
|
||||
#define KC_Z 0x1D
|
||||
#define KC_1 0x1E
|
||||
#define KC_2 0x1F
|
||||
#define KC_3 0x20
|
||||
#define KC_4 0x21
|
||||
#define KC_5 0x22
|
||||
#define KC_6 0x23
|
||||
#define KC_7 0x24
|
||||
#define KC_8 0x25
|
||||
#define KC_9 0x26
|
||||
#define KC_0 0x27
|
||||
#define KC_RET 0x28
|
||||
#define KC_ESC 0x29
|
||||
#define KC_DEL 0x2A
|
||||
#define KC_BKSP KC_DEL
|
||||
#define KC_TAB 0x2B
|
||||
#define KC_SPC 0x2C
|
||||
#define KC_MIN 0x2D
|
||||
#define KC_EQL 0x2E
|
||||
#define KC_LBKT 0x2F
|
||||
#define KC_RBKT 0x30
|
||||
#define KC_FSLH 0x31
|
||||
|
||||
#define KC_SCLN 0x33
|
||||
#define KC_QUOT 0x34
|
||||
#define KC_GRAV 0x35
|
||||
#define KC_CMMA 0x36
|
||||
#define KC_DOT 0x37
|
||||
#define KC_BSLH 0x38
|
||||
#define KC_CLCK 0x39
|
||||
#define KC_F1 0x3A
|
||||
#define KC_F2 0x3B
|
||||
|
||||
#define KC_RARW 0x4F
|
||||
#define KC_LARW 0x50
|
||||
#define KC_DARW 0x51
|
||||
#define KC_UARW 0x52
|
||||
|
||||
#define KC_KDIV 0x54
|
||||
#define KC_KMLT 0x55
|
||||
#define KC_KMIN 0x56
|
||||
#define KC_KPLS 0x57
|
||||
|
||||
#define KC_APP 0x65
|
||||
|
||||
#define KC_CURU 0xB4
|
||||
|
||||
#define KC_LPRN 0xB6
|
||||
#define KC_RPRN 0xB7
|
||||
#define KC_LCUR 0xB8
|
||||
#define KC_RCUR 0xB9
|
||||
|
||||
#define KC_CRRT 0xC3
|
||||
#define KC_PRCT 0xC4
|
||||
#define KC_LABT 0xC5
|
||||
#define KC_RABT 0xC6
|
||||
#define KC_AMPS 0xC7
|
||||
#define KC_PIPE 0xC9
|
||||
#define KC_COLN 0xCB
|
||||
#define KC_HASH 0xCC
|
||||
#define KC_KSPC 0xCD
|
||||
#define KC_ATSN 0xCE
|
||||
#define KC_BANG 0xCF
|
||||
|
||||
#define KC_LCTL 0xE0
|
||||
#define KC_LSFT 0xE1
|
||||
#define KC_LALT 0xE2
|
||||
#define KC_LGUI 0xE3
|
||||
#define KC_RCTL 0xE4
|
||||
#define KC_RSFT 0xE5
|
||||
#define KC_RALT 0xE6
|
||||
#define KC_RGUI 0xE7
|
||||
|
||||
#define KC_VOLU 0x80
|
||||
#define KC_VOLD 0x81
|
||||
|
||||
/* The following are select consumer page usages */
|
||||
|
||||
#define KC_MNXT 0x100
|
||||
#define KC_MPRV 0x101
|
||||
#define KC_MSTP 0x102
|
||||
#define KC_MJCT 0x103
|
||||
#define KC_MPLY 0x104
|
||||
#define KC_MMUT 0x105
|
||||
#define KC_MVLU 0x106
|
||||
#define KC_MVLD 0x107
|
||||
|
||||
#define ZC_TRNS (0xFFFF)
|
||||
#define ZC_NO (0xFFFF - 1)
|
||||
|
||||
#define ZC_CSTM(n) (0xFFF + n)
|
||||
|
||||
#define MOD_LCTL (1 << 0x00)
|
||||
#define MOD_LSFT (1 << 0x01)
|
||||
#define MOD_LALT (1 << 0x02)
|
||||
#define MOD_LGUI (1 << 0x03)
|
||||
#define MOD_RCTL (1 << 0x04)
|
||||
#define MOD_RSFT (1 << 0x05)
|
||||
#define MOD_RALT (1 << 0x06)
|
||||
#define MOD_RGUI (1 << 0x07)
|
||||
|
||||
#define ZK_ACTION(k) (k >> 24)
|
||||
#define _ACTION(a) (a << 24)
|
||||
#define _ACTION_MODS(m) (m << 16)
|
||||
#define ZK_KEY(a) (a & 0xFFFF)
|
||||
#define ZK_MODS(a) ((a >> 16) & 0xFF)
|
||||
|
||||
#define ZK_IS_CONSUMER(k) (ZK_KEY(k) >= 0x100)
|
||||
|
||||
#define ZMK_ACTION_KEY 0x01
|
||||
#define ZMK_ACTION_MOD_TAP 0x01
|
||||
#define ZMK_ACTION_ONE_SHOT 0x02
|
||||
|
||||
#define MT(mods, kc) (_ACTION(ZMK_ACTION_MOD_TAP) + _ACTION_MODS(mods) + kc)
|
||||
7
app/include/zmk/ble.h
Normal file
7
app/include/zmk/ble.h
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zmk/keys.h>
|
||||
|
||||
int zmk_ble_init();
|
||||
bool zmk_ble_handle_key_user(struct zmk_key_event *key_event);
|
||||
8
app/include/zmk/endpoints.h
Normal file
8
app/include/zmk/endpoints.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <zmk/keys.h>
|
||||
#include <zmk/hid.h>
|
||||
|
||||
int zmk_endpoints_init();
|
||||
int zmk_endpoints_send_report(enum zmk_hid_report_changes changes);
|
||||
int zmk_endpoints_send_key_event(struct zmk_key_event key_event);
|
||||
8
app/include/zmk/handlers.h
Normal file
8
app/include/zmk/handlers.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
#include <zmk/keymap.h>
|
||||
#include <zmk/keys.h>
|
||||
|
||||
void zmk_handle_key(struct zmk_key_event key_event);
|
||||
194
app/include/zmk/hid.h
Normal file
194
app/include/zmk/hid.h
Normal file
@@ -0,0 +1,194 @@
|
||||
#pragma once
|
||||
|
||||
#include <usb/usb_device.h>
|
||||
#include <usb/class/usb_hid.h>
|
||||
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
#include <zmk/keys.h>
|
||||
|
||||
#define COLLECTION_REPORT 0x03
|
||||
|
||||
#define ZMK_HID_MAX_KEYCODE KC_APP
|
||||
|
||||
static const u8_t zmk_hid_report_desc[] = {
|
||||
/* USAGE_PAGE (Generic Desktop) */
|
||||
HID_GI_USAGE_PAGE,
|
||||
USAGE_GEN_DESKTOP,
|
||||
/* USAGE (Keyboard) */
|
||||
HID_LI_USAGE,
|
||||
USAGE_GEN_DESKTOP_KEYBOARD,
|
||||
/* COLLECTION (Application) */
|
||||
HID_MI_COLLECTION,
|
||||
COLLECTION_APPLICATION,
|
||||
/* REPORT ID (1) */
|
||||
HID_GI_REPORT_ID,
|
||||
0x01,
|
||||
/* USAGE_PAGE (Keypad) */
|
||||
HID_GI_USAGE_PAGE,
|
||||
USAGE_GEN_DESKTOP_KEYPAD,
|
||||
/* USAGE_MINIMUM (Keyboard LeftControl) */
|
||||
HID_LI_USAGE_MIN(1),
|
||||
0xE0,
|
||||
/* USAGE_MAXIMUM (Keyboard Right GUI) */
|
||||
HID_LI_USAGE_MAX(1),
|
||||
0xE7,
|
||||
/* LOGICAL_MINIMUM (0) */
|
||||
HID_GI_LOGICAL_MIN(1),
|
||||
0x00,
|
||||
/* LOGICAL_MAXIMUM (1) */
|
||||
HID_GI_LOGICAL_MAX(1),
|
||||
0x01,
|
||||
|
||||
/* REPORT_SIZE (1) */
|
||||
HID_GI_REPORT_SIZE,
|
||||
0x01,
|
||||
/* REPORT_COUNT (8) */
|
||||
HID_GI_REPORT_COUNT,
|
||||
0x08,
|
||||
/* INPUT (Data,Var,Abs) */
|
||||
HID_MI_INPUT,
|
||||
0x02,
|
||||
|
||||
/* USAGE_PAGE (Keypad) */
|
||||
HID_GI_USAGE_PAGE,
|
||||
USAGE_GEN_DESKTOP_KEYPAD,
|
||||
/* LOGICAL_MINIMUM (0) */
|
||||
HID_GI_LOGICAL_MIN(1),
|
||||
0x00,
|
||||
/* LOGICAL_MAXIMUM (1) */
|
||||
HID_GI_LOGICAL_MAX(1),
|
||||
0x01,
|
||||
/* USAGE_MINIMUM (Reserved) */
|
||||
HID_LI_USAGE_MIN(1),
|
||||
0x00,
|
||||
/* USAGE_MAXIMUM (Keyboard Application) */
|
||||
HID_LI_USAGE_MAX(1),
|
||||
ZMK_HID_MAX_KEYCODE,
|
||||
/* REPORT_SIZE (8) */
|
||||
HID_GI_REPORT_SIZE,
|
||||
0x01,
|
||||
/* REPORT_COUNT (6) */
|
||||
HID_GI_REPORT_COUNT,
|
||||
ZMK_HID_MAX_KEYCODE + 1,
|
||||
/* INPUT (Data,Ary,Abs) */
|
||||
HID_MI_INPUT,
|
||||
0x02,
|
||||
/* USAGE_PAGE (Keypad) */
|
||||
HID_GI_USAGE_PAGE,
|
||||
USAGE_GEN_DESKTOP_KEYPAD,
|
||||
/* REPORT_SIZE (8) */
|
||||
HID_GI_REPORT_SIZE,
|
||||
0x02,
|
||||
/* REPORT_COUNT (6) */
|
||||
HID_GI_REPORT_COUNT,
|
||||
0x01,
|
||||
/* INPUT (Cnst,Var,Abs) */
|
||||
HID_MI_INPUT,
|
||||
0x03,
|
||||
/* END_COLLECTION */
|
||||
HID_MI_COLLECTION_END,
|
||||
/* USAGE_PAGE (Consumer) */
|
||||
HID_GI_USAGE_PAGE,
|
||||
0x0C,
|
||||
/* USAGE (Consumer Control) */
|
||||
HID_LI_USAGE,
|
||||
0x01,
|
||||
/* Consumer Page */
|
||||
HID_MI_COLLECTION,
|
||||
COLLECTION_APPLICATION,
|
||||
/* REPORT ID (1) */
|
||||
HID_GI_REPORT_ID,
|
||||
0x02,
|
||||
/* USAGE_PAGE (Consumer) */
|
||||
HID_GI_USAGE_PAGE,
|
||||
0x0C,
|
||||
/* LOGICAL_MINIMUM (0) */
|
||||
HID_GI_LOGICAL_MIN(1),
|
||||
0x00,
|
||||
/* LOGICAL_MAXIMUM (1) */
|
||||
HID_GI_LOGICAL_MAX(1),
|
||||
0x01,
|
||||
/* USAGE (Scan Next Track) */
|
||||
HID_LI_USAGE,
|
||||
0xB5,
|
||||
/* USAGE (Scan Previous Track) */
|
||||
HID_LI_USAGE,
|
||||
0xB6,
|
||||
/* USAGE (Stop) */
|
||||
HID_LI_USAGE,
|
||||
0xB7,
|
||||
/* USAGE (Eject) */
|
||||
HID_LI_USAGE,
|
||||
0xB8,
|
||||
/* USAGE (Media Play/Pause) */
|
||||
HID_LI_USAGE,
|
||||
0xCD,
|
||||
/* USAGE (Mute) */
|
||||
HID_LI_USAGE,
|
||||
0xE2,
|
||||
/* USAGE (Volume Increment) */
|
||||
HID_LI_USAGE,
|
||||
0xE9,
|
||||
/* USAGE (Volume Decrement) */
|
||||
HID_LI_USAGE,
|
||||
0xEA,
|
||||
/* INPUT (Data,Ary,Abs) */
|
||||
/* REPORT_SIZE (1) */
|
||||
HID_GI_REPORT_SIZE,
|
||||
0x01,
|
||||
/* REPORT_COUNT (8) */
|
||||
HID_GI_REPORT_COUNT,
|
||||
0x08,
|
||||
HID_MI_INPUT,
|
||||
0x02,
|
||||
/* END COLLECTION */
|
||||
HID_MI_COLLECTION_END,
|
||||
};
|
||||
|
||||
// struct zmk_hid_boot_report
|
||||
// {
|
||||
// u8_t modifiers;
|
||||
// u8_t _unused;
|
||||
// u8_t keys[6];
|
||||
// } __packed;
|
||||
|
||||
struct zmk_hid_keypad_report_body
|
||||
{
|
||||
zmk_mod_flags modifiers;
|
||||
u8_t keys[13];
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_keypad_report
|
||||
{
|
||||
u8_t report_id;
|
||||
struct zmk_hid_keypad_report_body body;
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_consumer_report_body
|
||||
{
|
||||
u8_t keys;
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_consumer_report
|
||||
{
|
||||
u8_t report_id;
|
||||
struct zmk_hid_consumer_report_body body;
|
||||
} __packed;
|
||||
|
||||
enum zmk_hid_report_changes
|
||||
{
|
||||
None = 0x00,
|
||||
Keypad = (0x01 << 0x00),
|
||||
Consumer = (0x01 << 0x01)
|
||||
};
|
||||
|
||||
int zmk_hid_register_mod(zmk_mod modifier);
|
||||
int zmk_hid_unregister_mod(zmk_mod modifier);
|
||||
int zmk_hid_register_mods(zmk_mod_flags modifiers);
|
||||
int zmk_hid_unregister_mods(zmk_mod_flags modifiers);
|
||||
enum zmk_hid_report_changes zmk_hid_press_key(zmk_key key);
|
||||
enum zmk_hid_report_changes zmk_hid_release_key(zmk_key key);
|
||||
|
||||
struct zmk_hid_keypad_report *zmk_hid_get_keypad_report();
|
||||
struct zmk_hid_consumer_report *zmk_hid_get_consumer_report();
|
||||
10
app/include/zmk/hog.h
Normal file
10
app/include/zmk/hog.h
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zmk/keys.h>
|
||||
#include <zmk/hid.h>
|
||||
|
||||
int zmk_hog_init();
|
||||
|
||||
int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *body);
|
||||
int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *body);
|
||||
28
app/include/zmk/keymap.h
Normal file
28
app/include/zmk/keymap.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <devicetree.h>
|
||||
#include <usb/usb_device.h>
|
||||
#include <usb/class/usb_hid.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
#include <zmk/matrix.h>
|
||||
#include <zmk/keys.h>
|
||||
|
||||
#define ZMK_KEYMAP_NODE DT_CHOSEN(zmk_keymap)
|
||||
#define ZMK_KEYMAP_LAYERS_LEN DT_PROP_LEN(ZMK_KEYMAP_NODE, layers)
|
||||
|
||||
/* TODO: Need to actually be able to get a NODELABEL from a node id
|
||||
#define _ZMK_KEYMAP_GENERATE_LAYER_CONST(node_id) \
|
||||
DT_NODELABEL_FOR_NODE(node_id)_layer,
|
||||
|
||||
enum zmk_keymap_layer
|
||||
{
|
||||
DT_FOREACH_CHILD(DT_INST(0, zmk_layers), _ZMK_KEYMAP_GENERATE_LAYER_CONST)
|
||||
};
|
||||
*/
|
||||
|
||||
bool zmk_keymap_layer_activate(u8_t layer);
|
||||
bool zmk_keymap_layer_deactivate(u8_t layer);
|
||||
|
||||
zmk_key
|
||||
zmk_keymap_keycode_from_position(u32_t row, u32_t column);
|
||||
17
app/include/zmk/keys.h
Normal file
17
app/include/zmk/keys.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
typedef u32_t zmk_key;
|
||||
typedef u8_t zmk_action;
|
||||
typedef u8_t zmk_mod;
|
||||
typedef u8_t zmk_mod_flags;
|
||||
|
||||
struct zmk_key_event
|
||||
{
|
||||
u32_t column;
|
||||
u32_t row;
|
||||
zmk_key key;
|
||||
bool pressed;
|
||||
};
|
||||
8
app/include/zmk/kscan-mock.h
Normal file
8
app/include/zmk/kscan-mock.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0)
|
||||
#define ZMK_MOCK_PRESS(row, col, msec) (row + (col << 8) + (msec << 16) + (0x01 << 31))
|
||||
#define ZMK_MOCK_RELEASE(row, col, msec) (row + (col << 8) + (msec << 16))
|
||||
#define ZMK_MOCK_ROW(v) (v & 0xFF)
|
||||
#define ZMK_MOCK_COL(v) ((v >> 8) & 0xFF)
|
||||
#define ZMK_MOCK_MSEC(v) ((v & ~(0x01 << 31)) >> 16)
|
||||
3
app/include/zmk/kscan.h
Normal file
3
app/include/zmk/kscan.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
int zmk_kscan_init(char *name);
|
||||
12
app/include/zmk/matrix.h
Normal file
12
app/include/zmk/matrix.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan)
|
||||
|
||||
#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,row_gpios)
|
||||
#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,row_gpios)
|
||||
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios)
|
||||
#else
|
||||
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID,rows)
|
||||
#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID,columns)
|
||||
#endif
|
||||
|
||||
14
app/include/zmk/usb_hid.h
Normal file
14
app/include/zmk/usb_hid.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ZMK_USB_HID
|
||||
#define ZMK_USB_HID
|
||||
|
||||
#include <usb/usb_device.h>
|
||||
#include <usb/class/usb_hid.h>
|
||||
|
||||
#include <zmk/keys.h>
|
||||
#include <zmk/hid.h>
|
||||
|
||||
int zmk_usb_hid_init();
|
||||
|
||||
int zmk_usb_hid_send_report(u8_t *report, size_t len);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user