Remap Keyboard.cpp

Hi;
I´ve been triying to remap the Keyboard.cpp to make an spanish keyboard, and i found that the Hex code on the original Keyboard.cpp don´t match with any code i`d found; in example:
.cpp original just a part of it;

const uint8_t _asciimap[128] =
{
...
0x20,          // 3
....

this is on pos uint8_t _asciimap[41]
so, if i send :

    Keyboard.press(41);
    delay(50);
    Keyboard.releaseAll();

Keyboard function find at 41 pos, Hex value is 0x20,
and arduino send a "3" to the Serial Monitor or any other text program.

ok nice, but ASCII Hex code for the "3" is 0x33 on pos 51;
so when i remap Keyboard.cpp, the Hex codes change and now,
pos 41 have 0x33 that arduino still understanding,and printing as a ";"

My question is if there are some way to use the arduino as a Spanish keyboard that can input the 256 ISO8859-1 or ASCCii extended?
Or some place where find the internal Hex code for the missing characteres like "ñ";"Ñ";"á"... that arduino use?

I use an:
Arduino micro pro 5v
programed on Arduino IDE 1.8.4

Thanks

this is on pos uint8_t _asciimap[41]

In my version of Keyboard.cpp this is at position 51 of the array. Did you already change that file?

On postion 41 I have

0x27|SHIFT,    // )

My question is if there are some way to use the arduino as a Spanish keyboard that can input the 256 ISO8859-1 or ASCCii extended?

Yes, but you have to modify the code quite heavily as the code in Keyboard.cpp uses the codes above 128 to send modifiers and the like. The values in the _asciimap array are key codes and are the translation of a US keyboard layout. So to get the key code for your ñ key, lookup what character is on the same position on the US keyboard, go to the _asciimap and send that keycode.

In my version of Keyboard.cpp this is at position 51 of the array. Did you already change that file?

Yes, it`s right, math problems... :cold_sweat: ;
I´ve already make a modified copy of the Keyboard.cpp, and it works; but the problem is that i use the ISO8859-1 Hexa codes in order to add the characteres that doesn´t exist on the 128 arduino version; and it doesn´t match.

The values in the _asciimap array are key codes and are the translation of a US keyboard layout

I think i need these "Translator" if exist...
or some way to found every "code" from the arduino,
I try with this:

for (int i=0; i <= 255; i++){
Keyboard.press(i);
    delay(50);
    Keyboard.releaseAll();
    Keyboard.end();
    Keyboard.begin();
}

And it was a biiig mesh; not only send characters, enter, pgdown,del, windows key...
everything straight to my windows :grin: funny, but nothing usefull... maybe put it on my boss pc...

These is a part of my keyboard.cpp modifications, if it could be usefull

const uint8_t _asciimap[256] =
{
0x00,         // INT 000; null
0x10,         // INT 001; start of heading
0x20,         // INT 002; start of text
0x30,         // INT 003; end of text
0x40,         // INT 004; end of transmission
0x50,         // INT 005; enquiry
0x60,         // INT 006; acknowledge
0x70,         // INT 007; bell
0x80,         // INT 008; backpace
0x90,         // INT 009; horizontal tab
0x0A,         // INT 010; line feed, new line
0x0B,         // INT 011; vertical tab
0x0C,         // INT 012; form feed, new page
0x0D,         // INT 013; carriage return
0x0E,         // INT 014; shift out
0x0F,         // INT 015; shift in
0x10,         // INT 016; data link escape
0x11,         // INT 017; device control 1
0x12,         // INT 018; device control 2
0x13,         // INT 019; device control 3
0x14,         // INT 020; device control 4
0x15,         // INT 021; negative acknowledge
0x16,         // INT 022; synchonous idle
0x17,         // INT 023; end of transmission block
0x18,         // INT 024; cancel
0x19,         // INT 025; end of medium
0x1A,         // INT 026; substitute
0x1B,         // INT 027; escape
0x1C,         // INT 028; file separator
0x1D,         // INT 029; group separator
0x1E,         // INT 030; record separator
0x1F,         // INT 031; unit separator
0x20,         // INT 032; space
0x21,         // INT 033; exclamation mark
0x22,         // INT 034; double quotation mark
0x23,         // INT 035; number sign, pound
0x24,         // INT 036; dollar sign
0x25,         // INT 037; percent sign
0x26,         // INT 038; ampersand
0x27,         // INT 039; apostrophe, single quote mark
0x28,         // INT 040; left parenthesis
0x29,         // INT 041; right parenthesis
0x2A,         // INT 042; asterisk
0x2B,         // INT 043; plus sign
0x2C,         // INT 044; comma
0x2D,         // INT 045; minus sign, hyphen
0x2E,         // INT 046; period, decimal point, full stop
0x2F,         // INT 047; slash, virgule, solidus
0x30,         // INT 048; digit 0
0x31,         // INT 049; digit 1
0x32,         // INT 050; digit 2
0x33,         // INT 051; digit 3
0x34,         // INT 052; digit 4
0x35,         // INT 053; digit 5
0x36,         // INT 054; digit 6
0x37,         // INT 055; digit 7
0x38,         // INT 056; digit 8
0x39,         // INT 057; digit 9
0x3A,         // INT 058; colon
0x3B,         // INT 059; semicolon
0x3C,         // INT 060; less-than sign
0x3D,         // INT 061; equal sign
0x3E,         // INT 062; greater-than sign
0x3F,         // INT 063; question mark
0x40,         // INT 064; commercial at sign
0x41,         // INT 065; capital A
0x42,         // INT 066; capital B
0x43,         // INT 067; capital C
0x44,         // INT 068; capital D
0x45,         // INT 069; capital E
0x46,         // INT 070; capital F
0x47,         // INT 071; capital G
0x48,         // INT 072; capital H
0x49,         // INT 073; capital I
0x4A,         // INT 074; capital J
0x4B,         // INT 075; capital K
0x4C,         // INT 076; capital L

Anyway, thanks for your time an speed replying!!

I think i need these "Translator" if exist...
or some way to found every "code" from the arduino,

You didn't understand my answer. The content of the _asciimap array are not ASCII codes! The ASCII code is the position inside the array, the content is a key code or scan code which only says which position on the keyboard was hit. For example key code 0x1c is the position between the 'u' key and the 't' key, so it's 'y' on the US keyboard but it's 'z' on my Swiss keyboard (and probably the same on your Spanish keyboard). So to enable to send all ISO-8859-1 characters (are all possible with your keyboard layout?) you cannot just modify the _asciimap array but you have to completely rewrite the Keyboard.cpp file to use other input (not bytes but 16 bit integers to have the same functionality available).
Unfortunately the Keyboard library doesn't have a method to simply send a key/scan code but only that limited ASCII set of characters. But that's how an American sees the world: it's the US, everything outside the borders is uncivilized jungle :wink: (to be fair: not every American has that limited view of the world but there are too many).