Thanks for the reply Sébastien. Sorry about not being clearer, hope this helps.
All I am really trying to do is execute some of the key codes specified in the androids Generic.kl file via the Leonardo.
The reason I am confused is that if I send the command via my windows laptop to the android I need to enter a shell in the android via adb (adb shell input keyevent ), and then I can send the keycode via input.
I was not sure how this would work if an Android was driving, do I first need to setup an android shell entry command and then send the keycode? I will try the links that you sent.
Since the Leonardo can present itself as a USB HID device, a simple solution would be to make it do just that,. If your Android device can work as a USB host you can then simply connect your Leonardo by USB to the smart device.
For example, if you make the Leonardo work as an external keyboard then you can most likely simply send key codes as needed directly to whatever is the current interface.
I tried that last night and I can get the android to sleep but it will not wake up. My PC will sleep and wake up but not the android. Do you know if an android can wake up from S3 via the keyboard, I guess this might be android specific.
To be honest, I have not tried to do anything related to sleep/waking with Android. It would probably be best for you to post about this on an Android specific forum (or at least first search there for more info).
Do post back here if you figure out anything else though, as this will certainly be interesting to the RobotShop community as a whole!
We did search a bit, but mostly found hardware-specific information that is not helpful for your situation. We also found plenty of people who were trying to prevent wake-up from keyboards (usually wireless/Bluetooth) on Android devices!
It may be worth looking into the various hardware and software related solutions, as this situation may yet be more complex than a simple command being sent.