diff --git a/main/adb.c b/main/adb.c index 463fff9..2f0ac1c 100644 --- a/main/adb.c +++ b/main/adb.c @@ -31,9 +31,6 @@ #include "esp_system.h" #include "esp_spi_flash.h" #include "driver/rmt.h" -#include "driver/periph_ctrl.h" -#include "soc/periph_defs.h" -#include "soc/rmt_reg.h" #include "adb.h" #include "led.h" @@ -49,7 +46,6 @@ extern TaskHandle_t t_click, t_qx, t_qy; /* static defines */ static void adb_handle_button(bool action); -static void adb_rmt_reset(void); static bool adb_rx_isone(rmt_item32_t cell); static bool adb_rx_isstop(rmt_item32_t cell); static bool adb_rx_iszero(rmt_item32_t cell); diff --git a/main/blue.c b/main/blue.c index 50feaba..17b4f95 100644 --- a/main/blue.c +++ b/main/blue.c @@ -30,6 +30,7 @@ #include "blue.h" #include "gpio.h" #include "led.h" +#include "m4848.h" /* debug tag */ static const char *TAG = "blue"; diff --git a/main/m4848.h b/main/m4848.h new file mode 100644 index 0000000..4136c6e --- /dev/null +++ b/main/m4848.h @@ -0,0 +1,83 @@ +/* + * m4848.h + * quack + * + * Created by Michel DEPEIGE on 18/05/2021. + * Copyright (c) 2021 Michel DEPEIGE. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING); if not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + */ + +#ifndef M4848_H +#define M4848_H + +/* + * This is dumped from an Apple USB "Hockey Puck" Mouse + * + * We will use this HID Report Descriptor as it's the closer to an ADB Mouse + */ + +const unsigned char m4848_HIDDD[] = { + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x02, // Usage (Mouse) + 0xA1, 0x01, // Collection (Application) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (0x01) + 0x29, 0x01, // Usage Maximum (0x01) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x95, 0x01, // Report Count (1) + 0x75, 0x01, // Report Size (1) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x95, 0x01, // Report Count (1) + 0x75, 0x07, // Report Size (7) + 0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x01, // Usage (Pointer) + 0xA1, 0x00, // Collection (Physical) + 0x09, 0x30, // Usage (X) + 0x09, 0x31, // Usage (Y) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x75, 0x08, // Report Size (8) + 0x95, 0x02, // Report Count (2) + 0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) + 0xC0, // End Collection + 0xC0, // End Collection + + // 50 bytes +}; + +static esp_hid_raw_report_map_t m4848_report_maps[] = { + { + .data = m4848_HIDDD, + .len = sizeof(m4848_HIDDD) + } +}; + +static esp_hid_device_config_t m4848_config = { + .vendor_id = 0x05ac, // Apple, Inc. + .product_id = 0x0301, // USB Mouse [Mitsumi, M4848] + .version = 0x0104, + .device_name = "Quack Mouse Adapter", + .manufacturer_name = "68kmla", + .serial_number = "0", + .report_maps = m4848_report_maps, + .report_maps_len = 1 +}; + +#endif diff --git a/sdkconfig b/sdkconfig index f4c8d6d..bd4b679 100644 --- a/sdkconfig +++ b/sdkconfig @@ -123,8 +123,8 @@ CONFIG_PARTITION_TABLE_MD5=y # # Compiler options # -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set +CONFIG_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_COMPILER_OPTIMIZATION_PERF is not set # CONFIG_COMPILER_OPTIMIZATION_NONE is not set CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y @@ -137,7 +137,7 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y # CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set # CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set CONFIG_COMPILER_STACK_CHECK=y -# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +CONFIG_COMPILER_WARN_WRITE_STRINGS=y # CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set # end of Compiler options @@ -804,7 +804,6 @@ CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 # CONFIG_FREERTOS_USE_TRACE_FACILITY is not set # CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set -CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set CONFIG_FREERTOS_DEBUG_OCDAWARE=y @@ -1291,8 +1290,8 @@ CONFIG_MONITOR_BAUD_115200B=y # CONFIG_MONITOR_BAUD_OTHER is not set CONFIG_MONITOR_BAUD_OTHER_VAL=115200 CONFIG_MONITOR_BAUD=115200 -CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y -# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set +CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y # CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set # CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set @@ -1302,7 +1301,7 @@ CONFIG_STACK_CHECK_NORM=y # CONFIG_STACK_CHECK_STRONG is not set # CONFIG_STACK_CHECK_ALL is not set CONFIG_STACK_CHECK=y -# CONFIG_WARN_WRITE_STRINGS is not set +CONFIG_WARN_WRITE_STRINGS=y # CONFIG_DISABLE_GCC8_WARNINGS is not set # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y