I'm using a SparkFun Pro Micro (ATmega32U4) as a keyboard emulator. Typing into e.g. Notepad on the PC it's perfect. Typing into a VM running on the PC it's perfect. Typing into a Remote Desktop session running from the VM, it sometimes fails to capitalise a character. e.g.
Hello There
Hello there
Hello There
Hello There
Hello There
Hello There
Hello There
void KbdStrByChrsPrint(char strA[]) {
int ix = 0;
char ch;
while (1) {
ch = strA[ix++];
if (ch == 0) {break;}
if (ch >= '\A' && ch <= '\Z') { // if uppercase char
ch |= 0x40; // convert to lowercase
Keyboard.press(KEY_LEFT_SHIFT); // press shift
delay(120); // wait
Keyboard.write(ch); // send lowercase char
delay(120); // wait
Keyboard.release(KEY_LEFT_SHIFT); // release shift.
} else {
Keyboard.write(ch);
}
}
}
KbdStrByChrsPrint("Hello There");
I don't know how long the delays have to be. I was seeing errors with 80 mS, but not seen any so far at 120. I've also seen a # appear as a 3, so that would need some more adjustment. I don't know what the general algorithm is because I've never seen [ or ] appear as { or }.