I am working on emulating a keyboard with Arduino Leonardo.
I use the KeyboardAzertyFr library (based on Keyboard library).
It is working perfectly on computers (windows 7 and 10), on Galaxy Tab A (Android 7) but it not working properly on Samsung A3 (Android 7), Galaxy Tab Active (Android 5.1.1).
Sometimes (most of the time) only the first character of the string is printed.
If I loop on my buffer characters it is the same, only the first or some characters are printed.
I though it could be due to the keyboard setup but they are the same.
The OS can be the same also but it is working on Galaxy Tab A and not on Samsung A3.
I thought also it could be the power of the tablet which is too low so I added an external power with the power jack, but I still got the problem.
Did you face this problem ? Do you know how to solve it ?
I would try editing KeyboardAzertyFr.cpp's print() write() function to add a delay between the press() and release() calls. You might need to add #include <Arduino.h> to get the delay() function. The current code sends all the keystrokes super quickly and that might be the cause of the problem.
I haven't tried Keyboard on my tablet yet, but I have not had good results getting the Mouse library working reliably on my tablet, despite having a lot of experience using it successfully on my computer. I somewhat blame it on my cheapo, low performance tablet.
Perhaps the keys are typing too fast? Try putting a short delay between the key-down and the key-up.
size_t KeyboardAzertyFr_::write(uint8_t c)
{
uint8_t p = press(c); // Keydown
delay(100); // Slow down to below ten keys a second.
release(c); // Keyup
return p; // just return the result of press() since release() almost always returns 1
}
If that works, try reducing the delay to see how fast you can go and still get reliable results.