adafruit / Adafruit_CircuitPython_HID

USB Human Interface Device drivers.
MIT License
373 stars 105 forks source link

Pass in devices #43

Closed tannewt closed 4 years ago

tannewt commented 4 years ago

This will be a new major version because the constructor signature changes.

hid_simpletest.py and hid_keyboard_shortcuts.py tested and work.

tannewt commented 4 years ago

I'd rather not have the USB be auto-magic. It's more readable to have it passed in. (Taking a USB example and porting to BLE would be much clearer for example.) Furthermore, it removes a dependency on usb_hid.

dhalbert commented 4 years ago

The issue I see is that there are many existing examples including in Learn Guides (I counted at least 17 Learn Guides, and there may be more), and we'll break a lot of existing code if the bundles start including an incompatible library. We'd also probably want to update the frozen lib again on 4.x.

Suppose we made it upward compatible for 5.0, and then gradually changed the examples and cut over for 6.0 (like we are doing for stop for I2C)?

tannewt commented 4 years ago

I'd rather figure out how to update everything as needed than stretch out the update over a period of time where more examples may be created. It's important for us to have the flexibility to update our APIs over time.

I can prep a PR for updating these examples:

 /V/G/Adafruit_Learning_System_Guides   master 
 ag -Ql "from adafruit_hid" .                                                             Thu Dec 19 16:08:22 2019
Introducing_Gemma_M0/Gemma_HIDkeyboard.py
Foul_Fowl/main.py
Make_It_Log/time-light-temp.py
GemmaM0_Radio_Tuning_Knob/main.py
Arcade_Button_Control_Box/Arcade_Button_Control_Box.py
Make_It_A-Mouse/cpx-mouse-buttons.py
Make_It_A-Mouse/mouse-cursor.py
Launch_Deck_Trellis_M4/launch_deck_trellis_m4.py
Make_It_A_Keyboard/keyboard-multimedia.py
Make_It_A_Keyboard/keycodes.py
Make_It_A_Keyboard/strings.py
Minecraft_Gesture_Controller/main.py
Introducing_CircuitPlaygroundExpress/CircuitPlaygroundExpress_HIDKeyboard.py
GemmaM0_Password_Vault/main.py
CPX_GBoard/touch_hid.py
CPX_GBoard/arcade_hid.py
CPX_GBoard/universal.py
Giant_Mechanical_Keyboard/code.py
CircuitPython_Essentials/CircuitPython_HID_Mouse.py
CircuitPython_Essentials/CircuitPython_HID_Keyboard.py
Rotary_Encoder/rotary_encoder_volume.py
Crank_USB_HID/code.py
Adafruit_pIRKey/NEC_keyboard_example.py
Adafruit_pIRKey/raw_code_keyboard/main.py
dhalbert commented 4 years ago

I'll approve, but won't merge, so we can merge a corresponding Learn Guides PR immediately after the bundle is published

tannewt commented 4 years ago

Merging now. Will follow up with Learn code updates and updating frozen in CP master.