arduino-libraries / Keyboard

GNU Lesser General Public License v3.0
231 stars 160 forks source link

International keyboard #25

Closed Hans-MartinHannibalLauridsen closed 2 years ago

Hans-MartinHannibalLauridsen commented 5 years ago

Could we get support for international keyboards? Or atleast a refactor witch would make it possible for the community to create there own keyboard layouts with support for multicharacters/special characters?

dotto59 commented 4 years ago

I think it's not so hard to implement, just need a few directives to let us choose from different files where we can store different versions of current _asciimap[] array of Keybpoard.cpp (default), thus allowing to have external "KeyboardXX.h" files (e.g. "KeyboardFR.h", "Keyboard IT.h" and so on) to be included, depending on language setting (a specific KEY_LANGUAGE symbol, e.g. "#define KEY_LANGUAGE IT"). What's a bit hard to do is create KeyboardXX.h files with proper language-specific keycodes, but the community could help with that... Another thing could be to use an extended ASCII table for specific language characters, i.e. by expanding _asciimap[] to a full 256 elements, or by adding an _extendedasciimap[] with upper 128 characters.

Hans-MartinHannibalLauridsen commented 4 years ago

I don't believe it is that simple, there need to be a fundamental change to the way characters are mappped, as most special characters simply does not fit into a char, the C implementationer only allocates 1byte! Which does not make room for much other that ASCII, unicode or what ever does not fit into a single byte.

ljq29 commented 4 years ago

I think it's not so hard to implement, just need a few directives to let us choose from different files where we can store different versions of current _asciimap[] array of Keybpoard.cpp (default), thus allowing to have external "KeyboardXX.h" files (e.g. "KeyboardFR.h", "Keyboard IT.h" and so on) to be included, depending on language setting (a specific KEY_LANGUAGE symbol, e.g. "#define KEY_LANGUAGE IT"). What's a bit hard to do is create KeyboardXX.h files with proper language-specific keycodes, but the community could help with that... Another thing could be to use an extended ASCII table for specific language characters, i.e. by expanding _asciimap[] to a full 256 elements, or by adding an _extendedasciimap[] with upper 128 characters.

In this issue https://github.com/arduino-libraries/Keyboard/issues/26, I want to send KEYCODE_VOLUME_UP and KEYCODE_VOLUME_DOWN, how should they be sent to the host through arduino?

Hans-MartinHannibalLauridsen commented 4 years ago

I extend the library, or change the ascii table if you are Lucky enough that those media Keys fit into one byte, which I expect they don`t. Or use the much better lib https://github.com/NicoHood/Hid.

ljq29 commented 4 years ago

I extend the library, or change the ascii table if you are Lucky enough that those media Keys fit into one byte, which I expect they don`t. Or use the much better lib https://github.com/NicoHood/Hid.

Hi. I am trying to write a sketch controlling an android device. Right-clicking an ordinary mouse generates a back event. But AbsoluteMouse.click(MOUSE_RIGHT); not working for me. Also, I was not able to find a key combination or key code for the events "Back" and "Home". Could you please help me?

PS. It seems that the "Back" event can be obtained using Win + Backspace, but I still did not understand how to get it.

edgar-bonet commented 2 years ago

This issue has been fixed in version 1.0.3, with some limitations:

  1. Only ASCII characters are supported.
  2. While both the Shift and AltGr modifiers are supported, using both simultaneously for typing a single character is not supported.
  3. Characters requiring hitting multiple keys consecutively (like dead circumflex + space → ^ on some layouts) are not supported.

Lifting those limitations would significantly increase the size and/or complexity of the library. See PR #53 for details.

The currently supported keyboard layouts are: da_DK, de_DE, en_US, es_ES, fr_FR, it_IT and sv_SE. If you want to contribute another layout, please see the comments in the file src/KeyboardLayout.h.

per1234 commented 2 years ago

Closing as resolved by https://github.com/arduino-libraries/Keyboard/pull/53 Thanks @edgar-bonet!