Add BLE_DISCONNECT key

This commit is contained in:
xs5871 2023-02-14 20:35:00 +00:00 committed by xs5871
parent dc9b5f4512
commit 449aab7dcb
2 changed files with 11 additions and 0 deletions

View File

@ -127,3 +127,13 @@ def ble_refresh(key, keyboard, *args, **kwargs):
keyboard._hid_helper.stop_advertising() keyboard._hid_helper.stop_advertising()
keyboard._hid_helper.start_advertising() keyboard._hid_helper.start_advertising()
return keyboard 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

View File

@ -364,6 +364,7 @@ def maybe_make_unicode_key(candidate: str) -> Optional[Key]:
def maybe_make_firmware_key(candidate: str) -> Optional[Key]: def maybe_make_firmware_key(candidate: str) -> Optional[Key]:
keys = ( keys = (
((('BLE_REFRESH',), handlers.ble_refresh)), ((('BLE_REFRESH',), handlers.ble_refresh)),
((('BLE_DISCONNECT',), handlers.ble_disconnect)),
((('BOOTLOADER',), handlers.bootloader)), ((('BOOTLOADER',), handlers.bootloader)),
((('DEBUG', 'DBG'), handlers.debug_pressed)), ((('DEBUG', 'DBG'), handlers.debug_pressed)),
((('HID_SWITCH', 'HID'), handlers.hid_switch)), ((('HID_SWITCH', 'HID'), handlers.hid_switch)),