#[adafruit/circuitpython] Pull request op...
1 messages · Page 1 of 1 (latest)
@kindred temple ping, in case you'd prefer to move the chat from Github comments over here.
This is similar to what you are thinking about but for usb host keyboards: https://docs.circuitpython.org/en/latest/shared-bindings/usb/core/index.html#usb.core.Device.detach_kernel_driver
[Reposting here from the PR thread in case @kindred temple finds it more convenient]
This is a reasonable idea. I didn't go for it immediately as I was not sure what would be the best interface for it and just tried the simplest thing that came to mind first (and was easy enough to try even without deep knowledge of the codebase).
Intuitively it currently seems to me that a reasonably clean solution would be to have some kind of a M5StackCardputerKeyboard class, exposed as board.KEYBOARD, which could a DemuxKeypad with the extra functions:
- attach_serial/detach_serial that would enable/disable routing of the keyboard events to stdin.
- translate_key (because the mapping between key numbers and characters is useful and would be worth exposing to the Python codebase).
The class could also expose the character ringbuffer for the user to consume (say char_events), which might be a convenient alternative to events due to the built-in key id -> character mapping (once it is done anyway).
I'm not super-sure how this class would be best exposed to the python codebase and documented. Putting it into shared-bindings does not seem very useful, due to the (currently) rather limited scope. Should it be kept in the board-specific build files but exposed as a non-instantiatiable M5StackCardputerKeyboard class in Python? Where should the docs go to make users aware of this existence? Am I overengineering this? 🙂
Not sure the discord thread is a useful place to discuss PRs (e.g. I don't know how to even find it in the mobile app), but just in case, @mild field, ping. Could you take a look if the current solution is mergeable perhaps?
(Given the repository seems to be evolving quite actively and I already had to struggle for quite a while to rebase & rebuild after the recent upgrade of esp-idf (was a bit surprising and non-obvious, especially given that the codebase is still new to me), I'd prefer to merge before other such potential changes happen)
Please ping me on github so I can have the context
Context is the PR at the start of the thread (https://github.com/adafruit/circuitpython/pull/9529). Pinged.