summaryrefslogtreecommitdiff
path: root/app/include
diff options
context:
space:
mode:
Diffstat (limited to 'app/include')
-rw-r--r--app/include/drivers/behavior.h16
-rw-r--r--app/include/dt-bindings/zmk/keys.h19
-rw-r--r--app/include/zmk/endpoints.h3
-rw-r--r--app/include/zmk/events.h4
-rw-r--r--app/include/zmk/hid.h55
-rw-r--r--app/include/zmk/keymap.h4
6 files changed, 41 insertions, 60 deletions
diff --git a/app/include/drivers/behavior.h b/app/include/drivers/behavior.h
index b3c6ad2..cca9272 100644
--- a/app/include/drivers/behavior.h
+++ b/app/include/drivers/behavior.h
@@ -25,7 +25,7 @@ extern "C" {
typedef int (*behavior_position_callback_t)(struct device *dev, u32_t position);
typedef int (*behavior_keymap_binding_callback_t)(struct device *dev, u32_t position, u32_t param1, u32_t param2);
-typedef int (*behavior_keycode_callback_t)(struct device *dev, u32_t keycode);
+typedef int (*behavior_keycode_callback_t)(struct device *dev, u8_t usage_page, u32_t keycode);
typedef int (*behavior_modifiers_callback_t)(struct device *dev, zmk_mod_flags modifiers);
__subsystem struct behavior_driver_api {
@@ -135,14 +135,15 @@ static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u3
/**
* @brief Handle the keycode being pressed
* @param dev Pointer to the device structure for the driver instance.
+ * @param usage_page The usage page for the keycode.
* @param keycode The keycode that is being pressed.
*
* @retval 0 If successful.
* @retval Negative errno code if failure.
*/
-__syscall int behavior_keycode_pressed(struct device *dev, u32_t keycode);
+__syscall int behavior_keycode_pressed(struct device *dev, u8_t usage_page, u32_t keycode);
-static inline int z_impl_behavior_keycode_pressed(struct device *dev, u32_t keycode)
+static inline int z_impl_behavior_keycode_pressed(struct device *dev, u8_t usage_page, u32_t keycode)
{
const struct behavior_driver_api *api =
(const struct behavior_driver_api *)dev->driver_api;
@@ -151,21 +152,22 @@ static inline int z_impl_behavior_keycode_pressed(struct device *dev, u32_t keyc
return -ENOTSUP;
}
- return api->keycode_pressed(dev, keycode);
+ return api->keycode_pressed(dev, usage_page, keycode);
}
/**
* @brief Handle the keycode being released
* @param dev Pointer to the device structure for the driver instance.
+ * @param usage_page The usage page for the keycode.
* @param keycode The keycode that is being pressed.
*
* @retval 0 If successful.
* @retval Negative errno code if failure.
*/
-__syscall int behavior_keycode_released(struct device *dev, u32_t keycode);
+__syscall int behavior_keycode_released(struct device *dev, u8_t usage_page, u32_t keycode);
-static inline int z_impl_behavior_keycode_released(struct device *dev, u32_t keycode)
+static inline int z_impl_behavior_keycode_released(struct device *dev, u8_t usage_page, u32_t keycode)
{
const struct behavior_driver_api *api =
(const struct behavior_driver_api *)dev->driver_api;
@@ -174,7 +176,7 @@ static inline int z_impl_behavior_keycode_released(struct device *dev, u32_t key
return -ENOTSUP;
}
- return api->keycode_released(dev, keycode);
+ return api->keycode_released(dev, usage_page, keycode);
}
diff --git a/app/include/dt-bindings/zmk/keys.h b/app/include/dt-bindings/zmk/keys.h
index 476d110..c7003c6 100644
--- a/app/include/dt-bindings/zmk/keys.h
+++ b/app/include/dt-bindings/zmk/keys.h
@@ -1,6 +1,9 @@
#pragma once
+#define USAGE_KEYPAD 0x07
+#define USAGE_CONSUMER 0x0C
+
#define A 0x04
#define B 0x05
#define C 0x06
@@ -104,14 +107,14 @@
/* The following are select consumer page usages */
-#define MNXT 0x100
-#define MPRV 0x101
-#define MSTP 0x102
-#define MJCT 0x103
-#define MPLY 0x104
-#define MMUT 0x105
-#define MVLU 0x106
-#define MVLD 0x107
+#define M_NEXT 0xB5
+#define M_PREV 0xB6
+#define M_STOP 0xB7
+#define M_EJCT 0xB8
+#define M_PLAY 0xCD
+#define M_MUTE 0xE2
+#define M_VOLU 0xE9
+#define M_VOLD 0xEA
#define MOD_LCTL (1 << 0x00)
#define MOD_LSFT (1 << 0x01)
diff --git a/app/include/zmk/endpoints.h b/app/include/zmk/endpoints.h
index 255ca54..624bb4e 100644
--- a/app/include/zmk/endpoints.h
+++ b/app/include/zmk/endpoints.h
@@ -4,5 +4,4 @@
#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);
+int zmk_endpoints_send_report(u8_t usage_report);
diff --git a/app/include/zmk/events.h b/app/include/zmk/events.h
index 8d1ae6a..5be2beb 100644
--- a/app/include/zmk/events.h
+++ b/app/include/zmk/events.h
@@ -4,8 +4,8 @@
int zmk_events_position_pressed(u32_t position);
int zmk_events_position_released(u32_t position);
-int zmk_events_keycode_pressed(u32_t keycode);
-int zmk_events_keycode_released(u32_t keycode);
+int zmk_events_keycode_pressed(u8_t usage_page, u32_t keycode);
+int zmk_events_keycode_released(u8_t usage_page, u32_t keycode);
int zmk_events_modifiers_pressed(zmk_mod_flags modifiers);
int zmk_events_modifiers_released(zmk_mod_flags modifiers);
int zmk_events_consumer_key_pressed(u32_t usage);
diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h
index e14a51a..138606a 100644
--- a/app/include/zmk/hid.h
+++ b/app/include/zmk/hid.h
@@ -108,40 +108,21 @@ static const u8_t zmk_hid_report_desc[] = {
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,
+ 0xFF,
+ HID_LI_USAGE_MIN(1),
+ 0x00,
+ /* USAGE_MAXIMUM (Keyboard Application) */
+ HID_LI_USAGE_MAX(1),
+ 0xFF,
/* INPUT (Data,Ary,Abs) */
- /* REPORT_SIZE (1) */
+ /* REPORT_SIZE (8) */
HID_GI_REPORT_SIZE,
- 0x01,
+ 0x08,
/* REPORT_COUNT (8) */
HID_GI_REPORT_COUNT,
- 0x08,
+ 0x06,
HID_MI_INPUT,
- 0x02,
+ 0x00,
/* END COLLECTION */
HID_MI_COLLECTION_END,
};
@@ -167,7 +148,7 @@ struct zmk_hid_keypad_report
struct zmk_hid_consumer_report_body
{
- u8_t keys;
+ u8_t keys[6];
} __packed;
struct zmk_hid_consumer_report
@@ -176,19 +157,15 @@ struct zmk_hid_consumer_report
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);
+int zmk_hid_keypad_press(zmk_key key);
+int zmk_hid_keypad_release(zmk_key key);
+
+int zmk_hid_consumer_press(zmk_key key);
+int zmk_hid_consumer_release(zmk_key key);
struct zmk_hid_keypad_report *zmk_hid_get_keypad_report();
struct zmk_hid_consumer_report *zmk_hid_get_consumer_report();
diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h
index 38c1249..4a6bb37 100644
--- a/app/include/zmk/keymap.h
+++ b/app/include/zmk/keymap.h
@@ -1,6 +1,6 @@
#pragma once
-bool zmk_keymap_layer_activate(u8_t layer);
-bool zmk_keymap_layer_deactivate(u8_t layer);
+int zmk_keymap_layer_activate(u8_t layer);
+int zmk_keymap_layer_deactivate(u8_t layer);
int zmk_keymap_position_state_changed(u32_t position, bool pressed);