Skip to content
Snippets Groups Projects
Commit 2fc5fc16 authored by schneider's avatar schneider
Browse files

change(hid): Use consumer control instead of remote

parent 82dd18a3
No related branches found
No related tags found
No related merge requests found
......@@ -235,7 +235,7 @@ static const attsCccSet_t bleCccSet[BLE_NUM_CCC_IDX] =
{ESS_PRES_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* BLE_ESS_PRES_CCC_IDX */
{HID_MOUSE_BOOT_IN_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* HIDAPP_MBI_CCC_HDL */
{HID_KEYBOARD_BOOT_IN_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* HIDAPP_KBI_CCC_HDL */
{HID_INPUT_REPORT_1_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* HIDAPP_IN_REMOTE_CCC_HDL */
{HID_INPUT_REPORT_1_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* HIDAPP_IN_CONSUMER_CCC_HDL */
{HID_INPUT_REPORT_2_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* HIDAPP_IN_KEYBOARD_CCC_HDL */
{HID_INPUT_REPORT_3_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* HIDAPP_IN_MOUSE_CCC_HDL */
};
......
......@@ -9,7 +9,7 @@ enum
BLE_ESS_PRES_CCC_IDX, /*! Environmental sensing service, pressure characteristic */
HIDAPP_MBI_CCC_HDL, /*! HID Boot Mouse Input characteristic */
HIDAPP_KBI_CCC_HDL, /*! HID Boot Keyboard Input characteristic */
HIDAPP_IN_REMOTE_CCC_HDL, /*! HID Input Report characteristic for remote inputs */
HIDAPP_IN_CONSUMER_CCC_HDL, /*! HID Input Report characteristic for consumer control inputs */
HIDAPP_IN_KEYBOARD_CCC_HDL, /*! HID Input Report characteristic for keyboard inputs */
HIDAPP_IN_MOUSE_CCC_HDL, /*! HID Input Report characteristic for mouse inputs */
BLE_NUM_CCC_IDX
......
......@@ -21,36 +21,18 @@
/* clang-format off */
const uint8_t hidReportMap[] =
{
0x05, 0x0c, /* Usage Page (Consumer Devices) */
0x05, 0x0C, /* Usage Page (Consumer) */
0x09, 0x01, /* Usage (Consumer Control) */
0xa1, 0x01, /* Collection (Application) */
0x85, HIDAPP_REMOTE_REPORT_ID, /* report ID (HIDAPP_REMOTE_REPORT_ID) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x01, /* Logical Maximum (1) */
0x09, 0xe9, /* Usage (Volume Up) */
0x09, 0xea, /* Usage (Volume Down) */
0x75, 0x01, /* Report Size (1) */
0x95, 0x02, /* Report Count (2) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0x09, 0xe2, /* Usage (Mute) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0x09, 0xb0, /* Usage (Play) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0x09, 0xb1, /* Usage (Pause) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0x09, 0xb7, /* Usage (Stop) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0x09, 0xb5, /* Usage (Next) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0x09, 0xb6, /* Usage (Previous) */
0xA1, 0x01, /* Collection (Application) */
0x85, HIDAPP_CONSUMER_REPORT_ID,/* Report ID (HIDAPP_CONSUMER_REPORT_ID) */
0x75, 0x10, /* Report Size (16) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0xc0, /* End Collection */
0x15, 0x01, /* Logical Minimum (1) */
0x26, 0x8C, 0x02, /* Logical Maximum (652) */
0x19, 0x01, /* Usage Minimum (Consumer Control) */
0x2A, 0x8C, 0x02, /* Usage Maximum (AC Send) */
0x81, 0x00, /* Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) */
0xC0, /* End Collection */
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x06, /* Usage (Keyboard) */
0xA1, 0x01, /* Collection (Application) */
......@@ -121,7 +103,7 @@ const uint16_t hidReportMapLen = sizeof(hidReportMap);
static const hidReportIdMap_t hidAppReportIdSet[] =
{
/* type ID handle */
{HID_REPORT_TYPE_INPUT, HIDAPP_REMOTE_REPORT_ID, HID_INPUT_REPORT_1_HDL}, /* Remote Input Report */
{HID_REPORT_TYPE_INPUT, HIDAPP_CONSUMER_REPORT_ID, HID_INPUT_REPORT_1_HDL}, /* Consumer Control Input Report */
{HID_REPORT_TYPE_INPUT, HIDAPP_KEYBOARD_REPORT_ID, HID_INPUT_REPORT_2_HDL}, /* Keyboard Input Report */
{HID_REPORT_TYPE_OUTPUT, HIDAPP_KEYBOARD_REPORT_ID, HID_OUTPUT_REPORT_HDL}, /* Keyboard Output Report */
{HID_REPORT_TYPE_FEATURE, HIDAPP_KEYBOARD_REPORT_ID, HID_FEATURE_REPORT_HDL}, /* Keyboard Feature Report */
......@@ -156,16 +138,16 @@ static void hidAppReportInit(void)
{
uint8_t iKeyboardBuffer[HIDAPP_KEYBOARD_INPUT_REPORT_LEN];
uint8_t iMouseBuffer[HIDAPP_MOUSE_INPUT_REPORT_LEN];
uint8_t iRemoteBuffer[HIDAPP_REMOTE_INPUT_REPORT_LEN];
uint8_t iConsumerBuffer[HIDAPP_CONSUMER_INPUT_REPORT_LEN];
uint8_t oBuffer[HIDAPP_OUTPUT_REPORT_LEN];
uint8_t fBuffer[HIDAPP_FEATURE_REPORT_LEN];
/* Remote Input report */
memset(iRemoteBuffer, 0, HIDAPP_REMOTE_INPUT_REPORT_LEN);
/* Consumer Control Input report */
memset(iConsumerBuffer, 0, HIDAPP_CONSUMER_INPUT_REPORT_LEN);
AttsSetAttr(
HID_INPUT_REPORT_1_HDL,
HIDAPP_REMOTE_INPUT_REPORT_LEN,
iRemoteBuffer
HIDAPP_CONSUMER_INPUT_REPORT_LEN,
iConsumerBuffer
);
/* Keyboard Input report */
......
......@@ -3,12 +3,12 @@
/* The input report fits in one byte */
#define HIDAPP_KEYBOARD_INPUT_REPORT_LEN 8
#define HIDAPP_MOUSE_INPUT_REPORT_LEN 3
#define HIDAPP_REMOTE_INPUT_REPORT_LEN 1
#define HIDAPP_CONSUMER_INPUT_REPORT_LEN 2
#define HIDAPP_OUTPUT_REPORT_LEN 1
#define HIDAPP_FEATURE_REPORT_LEN 1
/* HID Report IDs */
#define HIDAPP_REMOTE_REPORT_ID 1
#define HIDAPP_CONSUMER_REPORT_ID 1
#define HIDAPP_KEYBOARD_REPORT_ID 2
#define HIDAPP_MOUSE_REPORT_ID 3
......@@ -90,8 +90,8 @@ static bool hid_dequeue_data(dmConnId_t connId)
cccHandle = HIDAPP_IN_KEYBOARD_CCC_HDL;
} else if (report.reportId == HIDAPP_MOUSE_REPORT_ID) {
cccHandle = HIDAPP_IN_MOUSE_CCC_HDL;
} else if (report.reportId == HIDAPP_REMOTE_REPORT_ID) {
cccHandle = HIDAPP_IN_REMOTE_CCC_HDL;
} else if (report.reportId == HIDAPP_CONSUMER_REPORT_ID) {
cccHandle = HIDAPP_IN_CONSUMER_CCC_HDL;
} else {
break;
};
......
......@@ -3,9 +3,9 @@ import buttons
import color
import display
BUTTON_VOLUME_UP = 1
BUTTON_VOLUME_DOWN = 2
BUTTON_PLAY = 8
VOLUME_UP = 0xE9
VOLUME_DOWN = 0xEA
PLAY_PAUSE = 0xCD
disp = display.open()
disp.clear()
......@@ -23,11 +23,11 @@ while True:
print(b_new)
b_old = b_new
if b_new == buttons.TOP_RIGHT:
hid.set_button(BUTTON_VOLUME_UP)
hid.set_button(0)
hid.set_control(VOLUME_UP)
hid.set_control(0)
elif b_new == buttons.BOTTOM_RIGHT:
hid.set_button(BUTTON_VOLUME_DOWN)
hid.set_button(0)
hid.set_control(VOLUME_DOWN)
hid.set_control(0)
elif b_new == buttons.BOTTOM_LEFT:
hid.set_button(BUTTON_PLAY)
hid.set_button(0)
hid.set_control(PLAY_PAUSE)
hid.set_control(0)
......@@ -4,18 +4,18 @@
#include "py/obj.h"
#include "py/runtime.h"
static mp_obj_t mp_hid_set_button(mp_obj_t button_id)
static mp_obj_t mp_hid_set_control(mp_obj_t control_code)
{
int id = mp_obj_get_int(button_id);
uint8_t data[] = { id };
int code = mp_obj_get_int(control_code);
uint8_t data[] = { code, code >> 8 };
int ret = epic_hid_send_report(1, data, sizeof(data));
return mp_obj_new_int(ret);
}
static MP_DEFINE_CONST_FUN_OBJ_1(hid_set_button_obj, mp_hid_set_button);
static MP_DEFINE_CONST_FUN_OBJ_1(hid_set_control_obj, mp_hid_set_control);
static const mp_rom_map_elem_t hid_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hid) },
{ MP_ROM_QSTR(MP_QSTR_set_button), MP_ROM_PTR(&hid_set_button_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_control), MP_ROM_PTR(&hid_set_control_obj) },
};
static MP_DEFINE_CONST_DICT(hid_module_globals, hid_module_globals_table);
......
......@@ -212,7 +212,7 @@ Q(EVENT_PAIRING_COMPLETE)
Q(EVENT_PAIRING_FAILED)
Q(EVENT_SCAN_REPORT)
Q(hid)
Q(set_button)
Q(set_control)
/* SpO2 */
Q(spo2_algo)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment