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 233cbedd43SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 243cbedd43SMatthias Ringwald * RINGWALD 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 383cbedd43SMatthias Ringwald #include "btstack_hid.h" 393cbedd43SMatthias Ringwald 403cbedd43SMatthias Ringwald 413cbedd43SMatthias Ringwald // from USB HID Specification 1.1, Appendix B.1 42*e9933dfeSMatthias Ringwald const uint8_t btstack_hid_descriptor_boot_mode[] = { 433cbedd43SMatthias Ringwald // Keyboard 443cbedd43SMatthias Ringwald 453cbedd43SMatthias Ringwald 0x05, 0x01, // Usage Page (Generic Desktop) 463cbedd43SMatthias Ringwald 0x09, 0x06, // Usage (Keyboard) 473cbedd43SMatthias Ringwald 0xa1, 0x01, // Collection (Application) 483cbedd43SMatthias Ringwald 493cbedd43SMatthias Ringwald 0x85, 0x01, // Report ID 1 503cbedd43SMatthias Ringwald 513cbedd43SMatthias Ringwald // Modifier byte 523cbedd43SMatthias Ringwald 533cbedd43SMatthias Ringwald 0x75, 0x01, // Report Size (1) 543cbedd43SMatthias Ringwald 0x95, 0x08, // Report Count (8) 553cbedd43SMatthias Ringwald 0x05, 0x07, // Usage Page (Key codes) 563cbedd43SMatthias Ringwald 0x19, 0xe0, // Usage Minimum (Keyboard LeftControl) 573cbedd43SMatthias Ringwald 0x29, 0xe7, // Usage Maxium (Keyboard Right GUI) 583cbedd43SMatthias Ringwald 0x15, 0x00, // Logical Minimum (0) 593cbedd43SMatthias Ringwald 0x25, 0x01, // Logical Maximum (1) 603cbedd43SMatthias Ringwald 0x81, 0x02, // Input (Data, Variable, Absolute) 613cbedd43SMatthias Ringwald 623cbedd43SMatthias Ringwald // Reserved byte 633cbedd43SMatthias Ringwald 643cbedd43SMatthias Ringwald 0x75, 0x01, // Report Size (1) 653cbedd43SMatthias Ringwald 0x95, 0x08, // Report Count (8) 663cbedd43SMatthias Ringwald 0x81, 0x03, // Input (Constant, Variable, Absolute) 673cbedd43SMatthias Ringwald 683cbedd43SMatthias Ringwald // LED report + padding 693cbedd43SMatthias Ringwald 703cbedd43SMatthias Ringwald 0x95, 0x05, // Report Count (5) 713cbedd43SMatthias Ringwald 0x75, 0x01, // Report Size (1) 723cbedd43SMatthias Ringwald 0x05, 0x08, // Usage Page (LEDs) 733cbedd43SMatthias Ringwald 0x19, 0x01, // Usage Minimum (Num Lock) 743cbedd43SMatthias Ringwald 0x29, 0x05, // Usage Maxium (Kana) 753cbedd43SMatthias Ringwald 0x91, 0x02, // Output (Data, Variable, Absolute) 763cbedd43SMatthias Ringwald 773cbedd43SMatthias Ringwald 0x95, 0x01, // Report Count (1) 783cbedd43SMatthias Ringwald 0x75, 0x03, // Report Size (3) 793cbedd43SMatthias Ringwald 0x91, 0x03, // Output (Constant, Variable, Absolute) 803cbedd43SMatthias Ringwald 813cbedd43SMatthias Ringwald // Keycodes 823cbedd43SMatthias Ringwald 833cbedd43SMatthias Ringwald 0x95, 0x06, // Report Count (6) 843cbedd43SMatthias Ringwald 0x75, 0x08, // Report Size (8) 853cbedd43SMatthias Ringwald 0x15, 0x00, // Logical Minimum (0) 863cbedd43SMatthias Ringwald 0x25, 0xff, // Logical Maximum (1) 873cbedd43SMatthias Ringwald 0x05, 0x07, // Usage Page (Key codes) 883cbedd43SMatthias Ringwald 0x19, 0x00, // Usage Minimum (Reserved (no event indicated)) 893cbedd43SMatthias Ringwald 0x29, 0xff, // Usage Maxium (Reserved) 903cbedd43SMatthias Ringwald 0x81, 0x00, // Input (Data, Array) 913cbedd43SMatthias Ringwald 923cbedd43SMatthias Ringwald 0xc0, // End collection 933cbedd43SMatthias Ringwald 943cbedd43SMatthias Ringwald // Mouse 953cbedd43SMatthias Ringwald 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 963cbedd43SMatthias Ringwald 0x09, 0x02, // USAGE (Mouse) 973cbedd43SMatthias Ringwald 0xa1, 0x01, // COLLECTION (Application) 983cbedd43SMatthias Ringwald 993cbedd43SMatthias Ringwald 0x85, 0x01, // Report ID 1 1003cbedd43SMatthias Ringwald 1013cbedd43SMatthias Ringwald 0x09, 0x01, // USAGE (Pointer) 1023cbedd43SMatthias Ringwald 1033cbedd43SMatthias Ringwald 0xa1, 0x00, // COLLECTION (Physical) 1043cbedd43SMatthias Ringwald 1053cbedd43SMatthias Ringwald #if 1 1063cbedd43SMatthias Ringwald 0x05, 0x09, // USAGE_PAGE (Button) 1073cbedd43SMatthias Ringwald 0x19, 0x01, // USAGE_MINIMUM (Button 1) 1083cbedd43SMatthias Ringwald 0x29, 0x03, // USAGE_MAXIMUM (Button 3) 1093cbedd43SMatthias Ringwald 0x15, 0x00, // LOGICAL_MINIMUM (0) 1103cbedd43SMatthias Ringwald 0x25, 0x01, // LOGICAL_MAXIMUM (1) 1113cbedd43SMatthias Ringwald 0x95, 0x03, // REPORT_COUNT (3) 1123cbedd43SMatthias Ringwald 0x75, 0x01, // REPORT_SIZE (1) 1133cbedd43SMatthias Ringwald 0x81, 0x02, // INPUT (Data,Var,Abs) 1143cbedd43SMatthias Ringwald 0x95, 0x01, // REPORT_COUNT (1) 1153cbedd43SMatthias Ringwald 0x75, 0x05, // REPORT_SIZE (5) 1163cbedd43SMatthias Ringwald 0x81, 0x03, // INPUT (Cnst,Var,Abs) 1173cbedd43SMatthias Ringwald #endif 1183cbedd43SMatthias Ringwald 1193cbedd43SMatthias Ringwald #if 1 1203cbedd43SMatthias Ringwald 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 1213cbedd43SMatthias Ringwald 0x09, 0x30, // USAGE (X) 1223cbedd43SMatthias Ringwald 0x09, 0x31, // USAGE (Y) 1233cbedd43SMatthias Ringwald 0x15, 0x81, // LOGICAL_MINIMUM (-127) 1243cbedd43SMatthias Ringwald 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 1253cbedd43SMatthias Ringwald 0x75, 0x08, // REPORT_SIZE (8) 1263cbedd43SMatthias Ringwald 0x95, 0x02, // REPORT_COUNT (2) 1273cbedd43SMatthias Ringwald 0x81, 0x06, // INPUT (Data,Var,Rel) 1283cbedd43SMatthias Ringwald #endif 1293cbedd43SMatthias Ringwald 1303cbedd43SMatthias Ringwald 0xc0, // END_COLLECTION 1313cbedd43SMatthias Ringwald 0xc0 // END_COLLECTION 1323cbedd43SMatthias Ringwald }; 1333cbedd43SMatthias Ringwald 134*e9933dfeSMatthias Ringwald const uint8_t * btstack_hid_get_boot_descriptor_data(void){ 135*e9933dfeSMatthias Ringwald return &btstack_hid_descriptor_boot_mode[0]; 1363cbedd43SMatthias Ringwald } 1373cbedd43SMatthias Ringwald 138*e9933dfeSMatthias Ringwald uint16_t btstack_hid_get_boot_descriptor_len(void){ 139*e9933dfeSMatthias Ringwald return sizeof(btstack_hid_descriptor_boot_mode); 1403cbedd43SMatthias Ringwald } 1413cbedd43SMatthias Ringwald 142