KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.34k stars 462 forks source link

[BUG] Re-ordering the HID endpoint initialization and HID report type detection. #825

Closed ilukinov closed 1 year ago

ilukinov commented 1 year ago

Describe the bug When trying to use hid_type=HIDModes.BLE I'm getting an error:

  File "kmk/kmk_keyboard.py", line 472, in go
  File "kmk/kmk_keyboard.py", line 495, in _init
  File "kmk/kmk_keyboard.py", line 321, in _init_hid
  File "kmk/hid.py", line 308, in __init__
  File "kmk/hid.py", line 68, in __init__
  File "kmk/hid.py", line 358, in hid_send
AttributeError: 'BLEHID' object has no attribute 'ble'

Looks like we have to do the "custom HID" report tests after BLE is initialized. We may have to move the report initialization out of init and only do them after we're sure to have an endpoint to test against

To Reproduce

print("Starting")

import board

from kmk.hid import HIDModes
from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.scanners import DiodeOrientation

keyboard = KMKKeyboard()

keyboard.col_pins = (board.D6,)
keyboard.row_pins = (board.D0,)
keyboard.diode_orientation = DiodeOrientation.COL2ROW

keyboard.keymap = [
    [KC.A,]
]

if __name__ == '__main__':
    keyboard.go(hid_type=HIDModes.BLE)

Expected behavior Ble is working with 0 issues

Debug output If applicable, add debug output from the serial console to help explain your problem.

Additional context Error happening because of line 68 and line 100 in hid.py more context https://kmkfw.zulipchat.com/#narrow/stream/358347-general/topic/Xiao.20and.20BLE