13cbedd43SMatthias Ringwald /* 23cbedd43SMatthias Ringwald * Copyright (C) 2021 BlueKitchen GmbH 33cbedd43SMatthias Ringwald * 43cbedd43SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 53cbedd43SMatthias Ringwald * modification, are permitted provided that the following conditions 63cbedd43SMatthias Ringwald * are met: 73cbedd43SMatthias Ringwald * 83cbedd43SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 93cbedd43SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 103cbedd43SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 113cbedd43SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 123cbedd43SMatthias Ringwald * documentation and/or other materials provided with the distribution. 133cbedd43SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 143cbedd43SMatthias Ringwald * contributors may be used to endorse or promote products derived 153cbedd43SMatthias Ringwald * from this software without specific prior written permission. 163cbedd43SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 173cbedd43SMatthias Ringwald * personal benefit and not for any commercial purpose or for 183cbedd43SMatthias Ringwald * monetary gain. 193cbedd43SMatthias Ringwald * 203cbedd43SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 213cbedd43SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 223cbedd43SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 253cbedd43SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 263cbedd43SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 273cbedd43SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 283cbedd43SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 293cbedd43SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 303cbedd43SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 313cbedd43SMatthias Ringwald * SUCH DAMAGE. 323cbedd43SMatthias Ringwald * 333cbedd43SMatthias Ringwald * Please inquire about commercial licensing options at 343cbedd43SMatthias Ringwald * [email protected] 353cbedd43SMatthias Ringwald * 363cbedd43SMatthias Ringwald */ 373cbedd43SMatthias Ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title Human Interface Device (HID) 40fe5a6c4eSMilanka Ringwald * 41fe5a6c4eSMilanka Ringwald */ 42fe5a6c4eSMilanka Ringwald 433cbedd43SMatthias Ringwald #ifndef HID_H 443cbedd43SMatthias Ringwald #define HID_H 453cbedd43SMatthias Ringwald 463cbedd43SMatthias Ringwald #if defined __cplusplus 473cbedd43SMatthias Ringwald extern "C" { 483cbedd43SMatthias Ringwald #endif 493cbedd43SMatthias Ringwald 503cbedd43SMatthias Ringwald 513cbedd43SMatthias Ringwald #include <stdint.h> 523cbedd43SMatthias Ringwald 533cbedd43SMatthias Ringwald #define HID_BOOT_MODE_KEYBOARD_ID 1 543cbedd43SMatthias Ringwald #define HID_BOOT_MODE_MOUSE_ID 2 553cbedd43SMatthias Ringwald 56*279225e6SMatthias Ringwald // used to indicate that no 8-bit Report ID has been set / is used 57*279225e6SMatthias Ringwald #define HID_REPORT_ID_UNDEFINED 0xffff 58*279225e6SMatthias Ringwald 593cbedd43SMatthias Ringwald typedef enum { 603cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_HANDSHAKE = 0, 613cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_HID_CONTROL, 623cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_RESERVED_2, 633cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_RESERVED_3, 643cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_GET_REPORT, 653cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_SET_REPORT, 663cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_GET_PROTOCOL, 673cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_SET_PROTOCOL, 683cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_GET_IDLE_DEPRECATED, 693cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_SET_IDLE_DEPRECATED, 703cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_DATA, 713cbedd43SMatthias Ringwald HID_MESSAGE_TYPE_DATC_DEPRECATED 723cbedd43SMatthias Ringwald } hid_message_type_t; 733cbedd43SMatthias Ringwald 743cbedd43SMatthias Ringwald typedef enum { 753cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_SUCCESSFUL = 0x00, // This code is used to acknowledge requests. A device that has correctly received SET_REPORT, SET_IDLE or SET_PROTOCOL payload transmits an acknowledgment to the host. 763cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_NOT_READY, // This code indicates that a device is too busy to accept data. The Bluetooth HID Host should retransmit the data the next time it communicates with the device. 773cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_ERR_INVALID_REPORT_ID, // Invalid report ID transmitted. 783cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_ERR_UNSUPPORTED_REQUEST, // The device does not support the request. This result code shall be used if the HIDP message type is unsupported. 793cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_ERR_INVALID_PARAMETER, // A parameter value is out of range or inappropriate for the request. 803cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_ERR_UNKNOWN = 0x0E, // Device could not identify the error condition. 813cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_ERR_FATAL = 0x0F, // Restart is essential to resume functionality 823cbedd43SMatthias Ringwald // BTstack custom error codes 833cbedd43SMatthias Ringwald HID_HANDSHAKE_PARAM_TYPE_ERR_DISCONNECT 843cbedd43SMatthias Ringwald } hid_handshake_param_type_t; 853cbedd43SMatthias Ringwald 863cbedd43SMatthias Ringwald typedef enum { 873cbedd43SMatthias Ringwald HID_CONTROL_PARAM_NOP_DEPRECATED = 0, // Deprecated: No Operation. 883cbedd43SMatthias Ringwald HID_CONTROL_PARAM_HARD_RESET_DEPRECATED, // Deprecated: Device performs Power On System Test (POST) then initializes all internal variables and initiates normal operations. 893cbedd43SMatthias Ringwald HID_CONTROL_PARAM_SOFT_RESET_DEPRECATED, // Deprecated: Device initializes all internal variables and initiates normal operations. 903cbedd43SMatthias Ringwald HID_CONTROL_PARAM_SUSPEND = 0x03, // Go to reduced power mode. 913cbedd43SMatthias Ringwald HID_CONTROL_PARAM_EXIT_SUSPEND, // Exit reduced power mode. 923cbedd43SMatthias Ringwald HID_CONTROL_PARAM_VIRTUAL_CABLE_UNPLUG 933cbedd43SMatthias Ringwald } hid_control_param_t; 943cbedd43SMatthias Ringwald 953cbedd43SMatthias Ringwald typedef enum { 963cbedd43SMatthias Ringwald HID_PROTOCOL_MODE_BOOT = 0, 973cbedd43SMatthias Ringwald HID_PROTOCOL_MODE_REPORT, 983cbedd43SMatthias Ringwald 993cbedd43SMatthias Ringwald // the following item is only used for API calls in hid_host.h: hid_host_connect, hid_host_accept_connection 1003cbedd43SMatthias Ringwald // in contrast to previous two enum items that will enforce given mode, this one enables fallback from report to boot mode 1013cbedd43SMatthias Ringwald HID_PROTOCOL_MODE_REPORT_WITH_FALLBACK_TO_BOOT 1023cbedd43SMatthias Ringwald } hid_protocol_mode_t; 1033cbedd43SMatthias Ringwald 1043cbedd43SMatthias Ringwald typedef enum { 1053cbedd43SMatthias Ringwald HID_REPORT_TYPE_RESERVED = 0, 1063cbedd43SMatthias Ringwald HID_REPORT_TYPE_INPUT, 1073cbedd43SMatthias Ringwald HID_REPORT_TYPE_OUTPUT, 1083cbedd43SMatthias Ringwald HID_REPORT_TYPE_FEATURE 1093cbedd43SMatthias Ringwald } hid_report_type_t; 1103cbedd43SMatthias Ringwald 1113cbedd43SMatthias Ringwald typedef enum { 1123cbedd43SMatthias Ringwald HID_REPORT_ID_UNDECLARED, 1133cbedd43SMatthias Ringwald HID_REPORT_ID_VALID, 1143cbedd43SMatthias Ringwald HID_REPORT_ID_INVALID 1153cbedd43SMatthias Ringwald } hid_report_id_status_t; 1163cbedd43SMatthias Ringwald 1173cbedd43SMatthias Ringwald /* API_START */ 1183cbedd43SMatthias Ringwald 1193cbedd43SMatthias Ringwald /* 1203cbedd43SMatthias Ringwald * @brief Get boot descriptor data 1213cbedd43SMatthias Ringwald * @result data 1223cbedd43SMatthias Ringwald */ 123e9933dfeSMatthias Ringwald const uint8_t * btstack_hid_get_boot_descriptor_data(void); 1243cbedd43SMatthias Ringwald 1253cbedd43SMatthias Ringwald /* 1263cbedd43SMatthias Ringwald * @brief Get boot descriptor length 1273cbedd43SMatthias Ringwald * @result length 1283cbedd43SMatthias Ringwald */ 129e9933dfeSMatthias Ringwald uint16_t btstack_hid_get_boot_descriptor_len(void); 1303cbedd43SMatthias Ringwald 1313cbedd43SMatthias Ringwald /* API_END */ 1323cbedd43SMatthias Ringwald 1333cbedd43SMatthias Ringwald #if defined __cplusplus 1343cbedd43SMatthias Ringwald } 1353cbedd43SMatthias Ringwald #endif 1363cbedd43SMatthias Ringwald 1373cbedd43SMatthias Ringwald #endif 138