From 0f84c8d79875b9440eda0d1a1f408a16e85ecb54 Mon Sep 17 00:00:00 2001 From: Lunzima Date: Wed, 25 Sep 2024 16:35:09 +0800 Subject: [PATCH] canokey-nrf52: enable dumb dongle support for nRF52 targets --- CMakeLists.txt | 2 ++ src/device.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index be94e31..eada943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,8 @@ add_definitions(-DMBR_PRESENT) add_definitions(-DCFG_BOARD=${CANOKEY_BOARD}) add_definitions(-DCFG_TUSB_MCU=OPT_MCU_NRF5X) add_definitions(-DMBEDTLS_CONFIG_FILE="${BASE_DIR}/config/mbedtls_config.h") +# simulate touching for dumb dongles with no hardware buttons +# add_definitions(-DDUMB_DONGLE) # nrf5 sdk configs add_definitions(-DCUSTOM_BOARD_INC=board_selection) diff --git a/src/device.c b/src/device.c index fe48603..28d49e6 100644 --- a/src/device.c +++ b/src/device.c @@ -40,6 +40,14 @@ inline static bool btn_down() { return bsp_board_button_state_get(BSP_BOARD_BUTTON_0); } +/* Only works when DUMB_DONGLE macro is enabled. */ +int testmode_emulate_user_presence(void) { + if (!device_is_blinking()) return 0; // user only touches while blinking + + set_touch_result(TOUCH_SHORT); + return 0; +} + static void (*tim_callback)(void); // every 10ms