minor cleanup, order of execution changes for oot.py ; boot now honors settings.toml and will auto-disable any dangerous features (usb disk / usb serial / usb cdc) and enable use w/ a pc bios

This commit is contained in:
KemoNine 2023-04-19 09:31:55 -04:00
parent bba59ca7ab
commit c35962e50a

10
boot.py
View file

@ -11,7 +11,6 @@ import usb_cdc
import usb_hid import usb_hid
from kmk.quickpin.pro_micro.kb2040 import pinout as pins from kmk.quickpin.pro_micro.kb2040 import pinout as pins
from kb import KMKKeyboard
from usb_hid import Device from usb_hid import Device
# Print env vars if debugging enabled # Print env vars if debugging enabled
@ -28,14 +27,12 @@ if os.getenv('ARDUX_KMK_DEBUGGING'):
else: else:
print('debugging disabled') print('debugging disabled')
# Enable use w/ BIOS
usb_hid.enable((Device.KEYBOARD, Device.MOUSE), boot_device=1)
# If this key is held during boot, don't run the code which hides the storage and disables serial # If this key is held during boot, don't run the code which hides the storage and disables serial
# bottom row, index finger key / bottom row pinky key # bottom row, index finger key / bottom row pinky key
key_1 = digitalio.DigitalInOut(pins[12]) key_1 = digitalio.DigitalInOut(pins[12])
key_2 = digitalio.DigitalInOut(pins[15]) key_2 = digitalio.DigitalInOut(pins[15])
# Configure gpio for boot
key_1.switch_to_input(pull=digitalio.Pull.UP) key_1.switch_to_input(pull=digitalio.Pull.UP)
key_2.switch_to_input(pull=digitalio.Pull.UP) key_2.switch_to_input(pull=digitalio.Pull.UP)
@ -43,6 +40,7 @@ key_2.switch_to_input(pull=digitalio.Pull.UP)
key_1_val = not (key_1.value) key_1_val = not (key_1.value)
key_2_val = not (key_2.value) key_2_val = not (key_2.value)
# Check for key hold and disable any dangerous features
if not (key_1_val or key_2_val) and not os.getenv('ARDUX_KMK_DEBUGGING'): if not (key_1_val or key_2_val) and not os.getenv('ARDUX_KMK_DEBUGGING'):
if not os.getenv('ARDUX_KMK_USB_DISK_ALWAYS'): if not os.getenv('ARDUX_KMK_USB_DISK_ALWAYS'):
storage.disable_usb_drive() storage.disable_usb_drive()
@ -52,4 +50,8 @@ if not (key_1_val or key_2_val) and not os.getenv('ARDUX_KMK_DEBUGGING'):
key_1.deinit() key_1.deinit()
key_2.deinit() key_2.deinit()
# Enable use w/ BIOS
usb_hid.enable(boot_device=1)
print('END boot.py') print('END boot.py')