Closed nuuttihenriksson closed 2 years ago
Memory usage change @ 71522467cc5f97ae92dd22de3e7e1e7bfffa66d1
Board | flash | % | RAM for global variables | % |
---|---|---|---|---|
arduino:avr:leonardo | :small_red_triangle: +254 - +254 | +0.89 - +0.89 | 0 - 0 | 0.0 - 0.0 |
arduino:sam:arduino_due_x_dbg | :small_red_triangle: +168 - +168 | +0.03 - +0.03 | N/A | N/A |
arduino:samd:mkrzero | :small_red_triangle: +160 - +160 | +0.06 - +0.06 | 0 - 0 | 0.0 - 0.0 |
AltGr is already usable as
Keyboard.press(KEY_RIGHT_ALT);
How would this change make it easier? How would you use the new feature? It is not visible through the library API.
I have added the alt gr as a modifier that can be applied to the ascii map. This means that instead of having to break up print commands because of characters such as /{}$€, they are managed through the ascii map in the .cpp file.
This makes the library a lot more usable for people with keyboard layouts other than english.
As I said I implemented it in the Keyboard.cpp file. The asciimap as well as the memory map has been changed to 16bits to fit an extra check bit (as was done with shift modifier).
The shift modifier had the eith bit set as 1. Alt gr uses ninth bit set as 1. In addition to the 8bit -> 16bit change I also had to use memcpy_P to copy the number from the ascii map.
This change includes no new libraries and does not require a significant amount of resources.
I have added the alt gr as a modifier that can be applied to the ascii map.
But you have not modified the ASCII map, so it would seem the change serves no purpose. Or maybe you expect the users to modify the ASCII map themselves?
characters such as /{}$€
/
, {
, }
and $
are ASCII characters, but €
is not, thus it cannot fit in the ASCII map.
Furthermore, most computers nowadays use UTF-8 encoding for files, and “€” is then encoded as a sequence of three bytes: 0xe2
, 0x82
and 0xac
. It is not a “character” in the C++ sense (a char
), meaning that
Keyboard.write('€');
is not valid C++, and
Keyboard.print("€");
would attempt to print three characters. In this case they happen to be all invalid, but printing "ó"
for example (UTF-8: 0xc3
, 0xb3
) will be interpreted as KEY_F2
followed by KEY_TAB
.
Thus I ask again the same question: How would you use this new feature?
I have added the alt gr as a modifier that can be applied to the ascii map.
But you have not modified the ASCII map, so it would seem the change serves no purpose. Or maybe you expect the users to modify the ASCII map themselves?
characters such as /{}$€
/
,{
,}
and$
are ASCII characters, but€
is not, thus it cannot fit in the ASCII map.Furthermore, most computers nowadays use UTF-8 encoding for files, and “€” is then encoded as a sequence of three bytes:
0xe2
,0x82
and0xac
. It is not a “character” in the C++ sense (achar
), meaning thatKeyboard.write('€');
is not valid C++, and
Keyboard.print("€");
would attempt to print three characters. In this case they happen to be all invalid, but printing
"ó"
for example (UTF-8:0xc3
,0xb3
) will be interpreted asKEY_F2
followed byKEY_TAB
.Thus I ask again the same question: How would you use this new feature?
My bad. I was not suppose to include '€'. For example if I want to do print("C:\Users\Randomuser\Desktop\"); I would have to do Keyboard.print("C:"); Keyboard.press(KEY_RIGHT_ALT); Keyboard.press(what ever the hex is for plus); Keyboard.releaseAll(); Keyboard.print("Users"); ...
When the alt gr / right alt is added into the code I can just print the line without any problems.
What is the status on this?
@nuuttihenriksson @edgar-bonet was this superseded by https://github.com/arduino-libraries/Keyboard/pull/53?
@nuuttihenriksson @edgar-bonet was this superseded by #53?
Good points by @edgar-bonet, was just an early idea. #53 looks good.
Thanks for your speedy response, and for your contribution @nuuttihenriksson!
Regards, Per
Simply added possibility for non us/uk keyboards to reach characters.
Uses only libraries that were already included.