Sending Generic.kl key commands

Hello,

I am trying to send keyevent commands from my Leonardo to my Android tablet, part of a head unit. I can send the commands via ADB shell on my laptop, but I cannot figure out how to send them via the arduino.

I have been looking for weeks on how to do this, I have gotten some close hits (http://www.instructables.com/id/USB-Ped … -Leonardo/) but they are in the area of sending the standard ASCII keyboard codes, and I am looking to send screen diming/brighten and sleep/wake.

Thanks,

-Erik

There is an Arduino board that is designed to work with Android devices:

https://store.arduino.cc/usa/arduino-mega-adk-rev3

Thank you. Yes, I have looked into the ADK board but my impression was that it worked well for cases where you were trying to control an Arduino via the Android. I chose Leonardo since it appears as a HID to the Android, so I thought I could send keyevents to the Android. Correct me if I am wrong.

Thanks,

-Erik

The Mega ADK is basically a Mega with a USB host port. The documentation for it is at https://developer.android.com/adk/adk.html.

The Leonardo can emulate an HID Keyboard. I don’t think it’s what you’re looking for.

Thanks for the info. I am a little confused as to how I emulate a keypress (for brightness and wake/sleep) via the ADK, I read through the doc at the link but I am not getting a picture as to how to do it. Do have any guidance?

-Erik

I’m not familiar with how to do these things, but I’m pretty sure that keypress emulation isn’t the way to do it. You’ll need to explore the ADK library code and documentation to find the function calls you need to do what you want.

You are correct the keypress emulation did not work as needed. I bought an ADK and will see what I can do with that.

Thanks,

-Erik