-
Notifications
You must be signed in to change notification settings - Fork 111
Keyboard layout improvement #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @bitboy85! What do you think about moving the functions to a Layout base class instead of into Keyboard? That way both en_us and de_de can subclass it and the API will stay the same for en_us. |
I fully understand that we should try to avoid script breaking changes. But i did it this way because i think its the most easy and obvious way for someone who wants to use this feature. |
I disagree with you. Keyboard is a lower-level class that sends keycodes (not characters) and is agnostic to layout. Most folks will want to use the layout class and so I think having a super-class for the Layout API is still my preference. |
I think this way makes usage more complicated than necessary. If you have a look at other implementations, all use the same object for single keypresses as for strings. Everyone who has used those before (like me) will be confused by using two different things. |
Gave a try at refactoring with ancestor and including a french layout. |
Hi, I'm glad there are people out there making layouts ! I'm not sure if it is confusing the way you think though. The keyboard is used to send keycodes, which are not translated. So on an AZERTY keyboard we would have this confusion: kbd.send(Keycode.A) # q
kbd.write("aA") # aA Also note that Arduino does not support alternate layouts that I know of (I had to copy and modify the Not loading the layout by default also allows to reduce the memory footprint if it is not needed, if you are just gonna use F keys for example. It also makes intentional the choice of the layout, associated with loading the appropriate module, which makes more sense to me than having a favored one loaded by default. Memory reduction is useful here since in my opinion a macro-button-pad is a perfect use for M0 boards like the trinket or QT PY. I made a |
Thanks for these links! It's always good to look at other implementations. These implementations aren't enough to override the way we've had this library for four years though. Changing it would invalidate all existing examples and guides. I think @Neradoc makes good points too. So, how about we integrate #61 into this? |
I agree thats confusing using the keycodes library. But this is a result of the USB specifications which rely on a us layout.
True. It does not support them by default which is sad i think. The method of using 7-bit ascii and one shift bit (which is also used in the current circuit python) does simply not work for layouts which uses latin-1 or 8-bit ascii. So requiring another layout will lead to a rewrite of this code part. To avoid this i have choosen this way. Creating new layouts is quite easy.
Memory footprint is a point. While doing this i had in mind that bioses and maybe other low level devices refer to an us layout. @tannewt |
Sounds like we have different goals. You are welcome to fork and maintain a bitboy85_hid library in the community bundle. My preference for adafruit_hid is to not include layout related functions in Keyboard. Hopefully we can add de_de into the structure @AngainorDev has done. |
My goal is to have a lib which is similar to use as on other devices (just because i have known them before) and additionally give users the ability to easy create their own layouts (just because i'm lazy and have no idea what requirement an ukrainian keyboard has). So the design decision was to not have any logic within the layout files. It should be a simple translation table. This is at the cost of memory. As my only device is a Pi Pico, i have checked and the keyboard implementation with layout eats about 12kb or 5% of the available space. So no need to be stingy here. Meanwhile i created a "standalone" lib which can be copied in its own folder within the lib directory and also included a way to add dead keys. Feel free to copy anything which is helpful. |
Yup, we're agreed on that. That's why we are switching to a shared super class with the logic. The smallest boards we run on are 32kb of RAM so it makes a big difference. The RP2040's 256k RAM is very nice. |
I used .py in my test for both, the adafruit_hid as for my keyboardext. Not sure how much memory could be saved if those are converted to mpy. |
We will continue to freeze the basic library into the Circuit Playground Express and the Trinkey-style devices. For frozen libraries, the library lives in flash, and takes very little RAM. However, it is a tight squeeze these days, so anything that grows the current library significantly will be a problem. |
Hello folks, if I am understand this correctly, and correct me if I am wrong, as space is tight we would not like to integrate this PR. However, this is more than welcome in the Community Bundle. If this is indeed the case I proposed to close this PR and move it this PR to the community bundle. Thanks :) PD: if help is needed to include this in the community library I could provide it. |
@jposada202020 Ya, you are correct. I think we want bitboy's version in the community bundle and future layouts in their own separate libraries that depend on this one. |
Is it moved to the community bundle or do i need to do something? |
No, a new library needs to be created that just contains this layout, and then that library would be added to the community bundle. And #61 needs to be polished off and merged. |
Sry, i don't really understand what needs to be done now. @jposada202020 |
Yes, sorry, they need to be reconciled. I have not proceeded due to the incompatibilities. |
FYI I'm in the process of building up a keyboard layouts repository/bundle, to make it easier to find and download keyboard layouts independently, while not requiring to create a new repository for each layout. It uses a modified KeyboardLayout class from PR 61. I converted and added your German keyboard layout to it. https://github.com/Neradoc/Circuitpython_Keyboard_Layouts |
This PR moves the write method to the keyboard class (instead of having a layout class). So its script breaking.
It supports latin-1 charset (255 chars) which is required for layouts in europe. An example for a german keyboard layout is included.
New layouts can easily added.
Known issue:
€ sign is not part of the latin-1 charset, so i cannot be used inside the write method.