refactor(hid): Replace deprecated HID usage page references

Deprecate `USAGE_KEYPAD` and replace with `HID_USAGE_KEY`.

Deprecate `USAGE_CONSUMER` and replace with `HID_USAGE_CONSUMER`.

Closes #217.
This commit is contained in:
innovaker 2020-11-03 16:54:16 +00:00 committed by Pete Johanson
parent 3c0a0ff308
commit e925319e4c
7 changed files with 24 additions and 19 deletions

View file

@ -1,18 +1,19 @@
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/hid_usage_pages.h>
/ {
behaviors {
kp: behavior_key_press {
compatible = "zmk,behavior-key-press";
label = "KEY_PRESS";
usage_page = <USAGE_KEYPAD>;
usage_page = <HID_USAGE_KEY>;
#binding-cells = <1>;
};
cp: behavior_consumer_press {
compatible = "zmk,behavior-key-press";
label = "CONSUMER_PRESS";
usage_page = <USAGE_CONSUMER>;
usage_page = <HID_USAGE_CONSUMER>;
#binding-cells = <1>;
};
};

View file

@ -1,18 +1,19 @@
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/hid_usage_pages.h>
/ {
behaviors {
inc_dec_kp: behavior_sensor_rotate_key_press {
compatible = "zmk,behavior-sensor-rotate-key-press";
label = "ENC_KEY_PRESS";
usage_page = <USAGE_KEYPAD>;
usage_page = <HID_USAGE_KEY>;
#sensor-binding-cells = <2>;
};
inc_dec_cp: behavior_sensor_rotate_consumer_press {
compatible = "zmk,behavior-sensor-rotate-key-press";
label = "ENC_CONSUMER_PRESS";
usage_page = <USAGE_CONSUMER>;
usage_page = <HID_USAGE_CONSUMER>;
#sensor-binding-cells = <2>;
};
};

View file

@ -10,6 +10,10 @@
#pragma once
/* WARNING: DEPRECATED from dt-bindings/zmk/keys.h */
#define USAGE_KEYPAD (0x07) // WARNING: DEPRECATED (DO NOT USE)
#define USAGE_CONSUMER (0x0C) // WARNING: DEPRECATED (DO NOT USE)
#define HID_USAGE_GD (0x01) // Generic Desktop
#define HID_USAGE_SIM (0x02) // Simulation Controls
#define HID_USAGE_VR (0x03) // VR Controls

View file

@ -6,10 +6,6 @@
#pragma once
#include <dt-bindings/zmk/modifiers.h>
#define USAGE_KEYPAD 0x07
#define USAGE_CONSUMER 0x0C
#define A 0x04
#define B 0x05
#define C 0x06

View file

@ -9,6 +9,7 @@
#include <device.h>
#include <drivers/behavior.h>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/hid_usage_pages.h>
#include <logging/log.h>
#include <zmk/behavior.h>
#include <zmk/matrix.h>
@ -428,7 +429,7 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) {
}
static inline bool only_mods(struct keycode_state_changed *ev) {
return ev->usage_page == USAGE_KEYPAD && ev->keycode >= LCTL && ev->keycode <= RGUI;
return ev->usage_page == HID_USAGE_KEY && ev->keycode >= LCTL && ev->keycode <= RGUI;
}
static int keycode_state_changed_listener(const struct zmk_event_header *eh) {

View file

@ -10,6 +10,7 @@
#include <zmk/ble.h>
#include <zmk/endpoints.h>
#include <zmk/hid.h>
#include <dt-bindings/zmk/hid_usage_pages.h>
#include <zmk/usb.h>
#include <zmk/hog.h>
#include <zmk/event-manager.h>
@ -116,9 +117,9 @@ int zmk_endpoints_send_report(u8_t usage_page) {
LOG_DBG("usage page 0x%02X", usage_page);
switch (usage_page) {
case USAGE_KEYPAD:
case HID_USAGE_KEY:
return send_keypad_report();
case USAGE_CONSUMER:
case HID_USAGE_CONSUMER:
return send_consumer_report();
default:
LOG_ERR("Unsupported usage page %d", usage_page);
@ -209,8 +210,8 @@ static void disconnect_current_endpoint() {
zmk_hid_keypad_clear();
zmk_hid_consumer_clear();
zmk_endpoints_send_report(USAGE_KEYPAD);
zmk_endpoints_send_report(USAGE_CONSUMER);
zmk_endpoints_send_report(HID_USAGE_KEY);
zmk_endpoints_send_report(HID_USAGE_CONSUMER);
}
static void update_current_endpoint() {

View file

@ -13,6 +13,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/events/keycode-state-changed.h>
#include <zmk/events/modifiers-state-changed.h>
#include <zmk/hid.h>
#include <dt-bindings/zmk/hid_usage_pages.h>
#include <zmk/endpoints.h>
static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode,
@ -21,14 +22,14 @@ static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode,
LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode,
implicit_modifiers);
switch (usage_page) {
case USAGE_KEYPAD:
case HID_USAGE_KEY:
err = zmk_hid_keypad_press(keycode);
if (err) {
LOG_ERR("Unable to press keycode");
return err;
}
break;
case USAGE_CONSUMER:
case HID_USAGE_CONSUMER:
err = zmk_hid_consumer_press(keycode);
if (err) {
LOG_ERR("Unable to press keycode");
@ -46,14 +47,14 @@ static int hid_listener_keycode_released(u8_t usage_page, u32_t keycode,
LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode,
implicit_modifiers);
switch (usage_page) {
case USAGE_KEYPAD:
case HID_USAGE_KEY:
err = zmk_hid_keypad_release(keycode);
if (err) {
LOG_ERR("Unable to release keycode");
return err;
}
break;
case USAGE_CONSUMER:
case HID_USAGE_CONSUMER:
err = zmk_hid_consumer_release(keycode);
if (err) {
LOG_ERR("Unable to release keycode");