|
| 1 | +/* |
| 2 | + * m5769.h |
| 3 | + * quack |
| 4 | + * |
| 5 | + * Created by Michel DEPEIGE on 29/06/2025. |
| 6 | + * Copyright (c) 2021 Michel DEPEIGE. |
| 7 | + * |
| 8 | + * This program is free software; you can redistribute it and/or modify |
| 9 | + * it under the terms of the Apache License, Version 2.0 (the "License"); |
| 10 | + * You may obtain a copy of the License at: |
| 11 | + * |
| 12 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | + * |
| 14 | + * Unless required by applicable law or agreed to in writing, software |
| 15 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | + * See the License for the specific language governing permissions and |
| 18 | + * limitations under the License. |
| 19 | + * |
| 20 | + */ |
| 21 | + |
| 22 | +#ifndef M5769_H |
| 23 | +#define M5769_H |
| 24 | + |
| 25 | +/* |
| 26 | + * Dunno what this is for... The ESP-IDF stack freeze without it. |
| 27 | + * See similar issue at: https://www.esp32.com/viewtopic.php?t=22661&p=81652 |
| 28 | + */ |
| 29 | + |
| 30 | +const unsigned char m5769_APIRM[] = { |
| 31 | + 0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00) |
| 32 | + 0x0A, 0x00, 0x01, // Usage (0x0100) |
| 33 | + 0xA1, 0x01, // Collection (Application) |
| 34 | + 0x85, 0x01, // Report ID (1) |
| 35 | + 0x15, 0x00, // Logical Minimum (0) |
| 36 | + 0x26, 0xFF, 0x00, // Logical Maximum (255) |
| 37 | + 0x75, 0x08, // Report Size (8) |
| 38 | + 0x95, 0x08, // Report Count (8) |
| 39 | + 0x09, 0x01, // Usage (0x01) |
| 40 | + 0x82, 0x02, 0x01, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Buffered Bytes) |
| 41 | + 0x95, 0x08, // Report Count (8) |
| 42 | + 0x09, 0x02, // Usage (0x02) |
| 43 | + 0xB2, 0x02, 0x01, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile,Buffered Bytes) |
| 44 | + 0x95, 0x08, // Report Count (8) |
| 45 | + 0x09, 0x03, // Usage (0x03) |
| 46 | + 0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) |
| 47 | + 0xC0, // End Collection |
| 48 | + |
| 49 | + // 38 bytes |
| 50 | +}; |
| 51 | + |
| 52 | +/* |
| 53 | + * This is dumped from an Apple USB "Pro White" Mouse |
| 54 | + * https://en.wikipedia.org/wiki/Apple_pointing_devices |
| 55 | + * Not used yet, might be used as backup in the future |
| 56 | + * For now it's just documentation. This one is built by Logitech |
| 57 | + */ |
| 58 | + |
| 59 | +const unsigned char m5769_HIDDD[] = { |
| 60 | + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) |
| 61 | + 0x09, 0x02, // Usage (Mouse) |
| 62 | + 0xA1, 0x01, // Collection (Application) |
| 63 | + 0x09, 0x01, // Usage (Pointer) |
| 64 | + 0xA1, 0x00, // Collection (Physical) |
| 65 | + 0x05, 0x09, // Usage Page (Button) |
| 66 | + 0x19, 0x01, // Usage Minimum (0x01) |
| 67 | + 0x29, 0x01, // Usage Maximum (0x01) |
| 68 | + 0x15, 0x00, // Logical Minimum (0) |
| 69 | + 0x25, 0x01, // Logical Maximum (1) |
| 70 | + 0x75, 0x01, // Report Size (1) |
| 71 | + 0x95, 0x01, // Report Count (1) |
| 72 | + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) |
| 73 | + 0x75, 0x07, // Report Size (7) |
| 74 | + 0x95, 0x01, // Report Count (1) |
| 75 | + 0x81, 0x01, // Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) |
| 76 | + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) |
| 77 | + 0x09, 0x30, // Usage (X) |
| 78 | + 0x09, 0x31, // Usage (Y) |
| 79 | + 0x15, 0x81, // Logical Minimum (-127) |
| 80 | + 0x25, 0x7F, // Logical Maximum (127) |
| 81 | + 0x75, 0x08, // Report Size (8) |
| 82 | + 0x95, 0x02, // Report Count (2) |
| 83 | + 0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) |
| 84 | + 0xC0, // End Collection |
| 85 | + 0xC0, // End Collection |
| 86 | + |
| 87 | + // 50 bytes |
| 88 | +}; |
| 89 | + |
| 90 | +static esp_hid_raw_report_map_t m5769_report_maps[] = { |
| 91 | + { |
| 92 | + .data = m5769_APIRM, |
| 93 | + .len = sizeof(m5769_APIRM) |
| 94 | + }, |
| 95 | + { |
| 96 | + .data = m5769_HIDDD, |
| 97 | + .len = sizeof(m5769_HIDDD) |
| 98 | + } |
| 99 | +}; |
| 100 | + |
| 101 | +static esp_hid_device_config_t m5769_config = { |
| 102 | + .vendor_id = 0x05ac, // Apple, Inc. |
| 103 | + .product_id = 0x0307, // USB Mouse |
| 104 | + .version = 0x0304, |
| 105 | + .device_name = "Quack ADB Mouse", |
| 106 | + .manufacturer_name = "68kmla", |
| 107 | + .serial_number = "0", |
| 108 | + .report_maps = m5769_report_maps, |
| 109 | + .report_maps_len = 2 |
| 110 | +}; |
| 111 | + |
| 112 | +/* precalculed table for 0-64 values to 0-127 with a slight acceleration of x^1.2 */ |
| 113 | +const unsigned char m5769_accel[] = { |
| 114 | + 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, |
| 115 | + 0x0C, 0x0D, 0x0F, 0x11, 0x13, 0x15, 0x17, 0x19, |
| 116 | + 0x1B, 0x1D, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2B, |
| 117 | + 0x2D, 0x2F, 0x31, 0x34, 0x36, 0x38, 0x3B, 0x3D, |
| 118 | + 0x3F, 0x42, 0x44, 0x47, 0x49, 0x4C, 0x4E, 0x51, |
| 119 | + 0x53, 0x56, 0x58, 0x5B, 0x5D, 0x60, 0x62, 0x65, |
| 120 | + 0x68, 0x6A, 0x6D, 0x6F, 0x72, 0x75, 0x77, 0x7A, |
| 121 | + 0x7D, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F |
| 122 | +}; |
| 123 | + |
| 124 | +#endif |
0 commit comments