From 449aab7dcbb536f57bbfd50c4d6e188e5c6687f4 Mon Sep 17 00:00:00 2001 From: xs5871 Date: Tue, 14 Feb 2023 20:35:00 +0000 Subject: [PATCH] Add BLE_DISCONNECT key --- kmk/handlers/stock.py | 10 ++++++++++ kmk/keys.py | 1 + 2 files changed, 11 insertions(+) diff --git a/kmk/handlers/stock.py b/kmk/handlers/stock.py index 124b48f..9345c8b 100644 --- a/kmk/handlers/stock.py +++ b/kmk/handlers/stock.py @@ -127,3 +127,13 @@ def ble_refresh(key, keyboard, *args, **kwargs): keyboard._hid_helper.stop_advertising() keyboard._hid_helper.start_advertising() return keyboard + + +def ble_disconnect(key, keyboard, *args, **kwargs): + from kmk.hid import HIDModes + + if keyboard.hid_type != HIDModes.BLE: + return keyboard + + keyboard._hid_helper.clear_bonds() + return keyboard diff --git a/kmk/keys.py b/kmk/keys.py index db81071..8cee305 100644 --- a/kmk/keys.py +++ b/kmk/keys.py @@ -364,6 +364,7 @@ def maybe_make_unicode_key(candidate: str) -> Optional[Key]: def maybe_make_firmware_key(candidate: str) -> Optional[Key]: keys = ( ((('BLE_REFRESH',), handlers.ble_refresh)), + ((('BLE_DISCONNECT',), handlers.ble_disconnect)), ((('BOOTLOADER',), handlers.bootloader)), ((('DEBUG', 'DBG'), handlers.debug_pressed)), ((('HID_SWITCH', 'HID'), handlers.hid_switch)),