Restore baseline key handling
This commit is contained in:
5
prj.conf
5
prj.conf
@@ -68,11 +68,6 @@ CONFIG_BT_DIS_PNP_PID=0x0001
|
|||||||
|
|
||||||
CONFIG_USB_DEVICE_STACK_NEXT=y
|
CONFIG_USB_DEVICE_STACK_NEXT=y
|
||||||
CONFIG_USBD_HID_SUPPORT=y
|
CONFIG_USBD_HID_SUPPORT=y
|
||||||
CONFIG_SERIAL=y
|
|
||||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
|
||||||
CONFIG_UART_LINE_CTRL=y
|
|
||||||
CONFIG_USBD_CDC_ACM_CLASS=y
|
|
||||||
CONFIG_CDC_ACM_SERIAL_INITIALIZE_AT_BOOT=n
|
|
||||||
CONFIG_UDC_BUF_POOL_SIZE=8192
|
CONFIG_UDC_BUF_POOL_SIZE=8192
|
||||||
CONFIG_UDC_BUF_COUNT=32
|
CONFIG_UDC_BUF_COUNT=32
|
||||||
CONFIG_USBD_MAX_UDC_MSG=20
|
CONFIG_USBD_MAX_UDC_MSG=20
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
#include "hid_protocol_event.h"
|
#include "hid_protocol_event.h"
|
||||||
#include "hid_report_event.h"
|
#include "hid_report_event.h"
|
||||||
#include "hid_vendor_mask_event.h"
|
#include "hid_vendor_mask_event.h"
|
||||||
#include "function_bitmap_event.h"
|
|
||||||
#include "function_key_event.h"
|
|
||||||
#include "qdec_step_event.h"
|
#include "qdec_step_event.h"
|
||||||
|
|
||||||
#include <zephyr/sys/util.h>
|
#include <zephyr/sys/util.h>
|
||||||
@@ -102,7 +100,6 @@ struct keyboard_state {
|
|||||||
uint8_t physical_usage_bm[KEYBOARD_BITMAP_SIZE];
|
uint8_t physical_usage_bm[KEYBOARD_BITMAP_SIZE];
|
||||||
uint8_t mask_modifier_bm;
|
uint8_t mask_modifier_bm;
|
||||||
uint8_t mask_bm[KEYBOARD_BITMAP_SIZE];
|
uint8_t mask_bm[KEYBOARD_BITMAP_SIZE];
|
||||||
uint8_t function_bm[KEYBOARD_BITMAP_SIZE];
|
|
||||||
enum hid_protocol_type current_protocol;
|
enum hid_protocol_type current_protocol;
|
||||||
uint16_t consumer_usage;
|
uint16_t consumer_usage;
|
||||||
};
|
};
|
||||||
@@ -127,16 +124,6 @@ static void keyboard_mask_init(void)
|
|||||||
{
|
{
|
||||||
ks.mask_modifier_bm = 0xFF;
|
ks.mask_modifier_bm = 0xFF;
|
||||||
memset(ks.mask_bm, 0xFF, sizeof(ks.mask_bm));
|
memset(ks.mask_bm, 0xFF, sizeof(ks.mask_bm));
|
||||||
memset(ks.function_bm, 0, sizeof(ks.function_bm));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool function_usage_active(uint16_t usage_id)
|
|
||||||
{
|
|
||||||
if (usage_id > KEYBOARD_USAGE_MAX) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ks.function_bm[usage_id / 8] & BIT(usage_id % 8)) != 0U;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 查询某 usage 位在当前键盘位图里是否处于按下状态。 */
|
/* 查询某 usage 位在当前键盘位图里是否处于按下状态。 */
|
||||||
@@ -311,11 +298,6 @@ static void submit_consumer_click_usage(uint16_t usage_id)
|
|||||||
*/
|
*/
|
||||||
static bool handle_keyboard_usage_event(const struct hid_keymap *map, bool pressed)
|
static bool handle_keyboard_usage_event(const struct hid_keymap *map, bool pressed)
|
||||||
{
|
{
|
||||||
if (function_usage_active(map->usage_id)) {
|
|
||||||
function_key_event_submit(map->usage_id, pressed);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!keyboard_usage_update(map->usage_id, pressed))
|
if (!keyboard_usage_update(map->usage_id, pressed))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -331,11 +313,6 @@ static bool handle_keyboard_usage_event(const struct hid_keymap *map, bool press
|
|||||||
*/
|
*/
|
||||||
static bool handle_consumer_usage_event(const struct hid_keymap *map, bool pressed)
|
static bool handle_consumer_usage_event(const struct hid_keymap *map, bool pressed)
|
||||||
{
|
{
|
||||||
if (function_usage_active(map->usage_id)) {
|
|
||||||
function_key_event_submit(map->usage_id, pressed);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active_protocol_get() == HID_PROTO_BOOT)
|
if (active_protocol_get() == HID_PROTO_BOOT)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -404,21 +381,6 @@ static bool handle_hid_vendor_mask_event(const struct hid_vendor_mask_event *eve
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_function_bitmap_event(const struct function_bitmap_event *event)
|
|
||||||
{
|
|
||||||
const uint8_t *data = function_bitmap_event_get_data(event);
|
|
||||||
size_t size = function_bitmap_event_get_size(event);
|
|
||||||
|
|
||||||
if (size != sizeof(ks.function_bm)) {
|
|
||||||
LOG_WRN("Ignore function bitmap len=%u expect=%u",
|
|
||||||
size, sizeof(ks.function_bm));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(ks.function_bm, data, sizeof(ks.function_bm));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool handle_qdec_step_event(const struct qdec_step_event *event)
|
static bool handle_qdec_step_event(const struct qdec_step_event *event)
|
||||||
{
|
{
|
||||||
int8_t step = qdec_step_event_get_step(event);
|
int8_t step = qdec_step_event_get_step(event);
|
||||||
@@ -453,10 +415,6 @@ static bool app_event_handler(const struct app_event_header *aeh)
|
|||||||
return handle_hid_vendor_mask_event(cast_hid_vendor_mask_event(aeh));
|
return handle_hid_vendor_mask_event(cast_hid_vendor_mask_event(aeh));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_function_bitmap_event(aeh)) {
|
|
||||||
return handle_function_bitmap_event(cast_function_bitmap_event(aeh));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_module_state_event(aeh)) {
|
if (is_module_state_event(aeh)) {
|
||||||
const struct module_state_event *event = cast_module_state_event(aeh);
|
const struct module_state_event *event = cast_module_state_event(aeh);
|
||||||
|
|
||||||
@@ -478,6 +436,5 @@ APP_EVENT_LISTENER(MODULE, app_event_handler);
|
|||||||
APP_EVENT_SUBSCRIBE(MODULE, button_event);
|
APP_EVENT_SUBSCRIBE(MODULE, button_event);
|
||||||
APP_EVENT_SUBSCRIBE(MODULE, hid_protocol_event);
|
APP_EVENT_SUBSCRIBE(MODULE, hid_protocol_event);
|
||||||
APP_EVENT_SUBSCRIBE(MODULE, hid_vendor_mask_event);
|
APP_EVENT_SUBSCRIBE(MODULE, hid_vendor_mask_event);
|
||||||
APP_EVENT_SUBSCRIBE(MODULE, function_bitmap_event);
|
|
||||||
APP_EVENT_SUBSCRIBE(MODULE, qdec_step_event);
|
APP_EVENT_SUBSCRIBE(MODULE, qdec_step_event);
|
||||||
APP_EVENT_SUBSCRIBE(MODULE, module_state_event);
|
APP_EVENT_SUBSCRIBE(MODULE, module_state_event);
|
||||||
|
|||||||
Reference in New Issue
Block a user