#ifndef HID_KEYBOARD_H #define HID_KEYBOARD_H #include #include #include #include #include "hid_descriptor.h" #include "hid_keyboard_callbacks.h" #include "utils.h" /* UUID for services, characteristics and descriptors */ #define HID_SERVICE_UUID 0x1812 #define HID_REPORT_REFERENCE_UUID 0x2908 #define HID_DESCR_EXTERNAL_REPORT_REFERENCE 0x2907 #define HID_BOOT_KEYBOARD_INPUT_REPORT_UUID 0x2A22 #define HID_BOOT_KEYBOARD_OUTPUT_REPORT_UUID 0x2A32 #define HID_INFORMATION_UUID 0x2A4A #define HID_REPORT_MAP_UUID 0x2A4B #define HID_CONTROL_POINT_UUID 0x2A4C #define HID_REPORT_UUID 0x2A4D #define HID_PROTOCOL_MODE_UUID 0x2A4E #define HID_BOOT_PROTOCOL 0x00 #define HID_REPORT_PROTOCOL 0x01 /* handles index for characteristics */ #define PROTOCOL_MODE_HANDLE_INDEX 0 #define REPORT_MAP_HANDLE_INDEX 1 #define REPORT_HANDLE_INDEX 2 #define BOOT_KEYBOARD_INPUT_HANDLE_INDEX 3 #define BOOT_KEYBOARD_OUTPUT_REPORT 4 #define HID_INFORMATION_HANDLE_INDEX 5 #define HID_CONTROL_POINT_HANDLE_INDEX 6 #define HANDLE_INDEX_LENGTH 7 #define REPORT_DESCRIPTOR_INPUT 0x01 #define REPORT_DESCRIPTOR_OUTPUT 0x02 #define REPORT_DESCRIPTOR_FEATURE 0x03 int init_keyboard_service(void); void keyboard_subscribe_event(struct ble_gap_event *event, void *arg); void set_connection_handle(uint16_t connection_handle); void send_key(TimerHandle_t ev); typedef struct s_boot_input_report { uint8_t modifiers_keycode_mask; uint8_t reserved_byte; uint8_t key_list[6]; } t_boot_input_report; typedef struct s_boot_output_report { uint8_t num_lock : 1; uint8_t caps_lock : 1; uint8_t scroll_lock : 1; uint8_t compose : 1; uint8_t kana : 1; uint8_t constant : 3; } t_boot_output_report; typedef struct s_input_report { uint8_t modifiers_keycode_mask; uint8_t reserved_byte; uint8_t key_list[6]; } t_input_report; typedef struct s_report_descriptor { uint8_t id; uint8_t type; } t_report_descriptor; typedef struct s_hid_info { uint16_t bcdHID; uint8_t bCountryCode; uint8_t flags; } t_hid_info; typedef struct s_keyboard { t_boot_input_report boot_input_report; t_boot_output_report boot_output_report; uint8_t *report_map; t_report_descriptor report_descriptor; t_input_report input_report; t_hid_info hid_info; uint8_t *control_point; } t_keyboard; extern t_keyboard keyboard; #endif