Sending Generic.kl key commands

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
Erik63
Posts: 4
Joined: Tue Oct 03, 2017 4:17 pm

Sending Generic.kl key commands

Post by Erik63 » Tue Oct 03, 2017 4:20 pm

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

User avatar
darrellg
Posts: 294
Joined: Fri Oct 17, 2014 10:02 am
Location: Southern California

Re: Sending Generic.kl key commands

Post by darrellg » Wed Oct 04, 2017 10:07 am

There is an Arduino board that is designed to work with Android devices:
https://store.arduino.cc/usa/arduino-mega-adk-rev3

Erik63
Posts: 4
Joined: Tue Oct 03, 2017 4:17 pm

Re: Sending Generic.kl key commands

Post by Erik63 » Wed Oct 04, 2017 11:44 am

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

User avatar
darrellg
Posts: 294
Joined: Fri Oct 17, 2014 10:02 am
Location: Southern California

Re: Sending Generic.kl key commands

Post by darrellg » Wed Oct 04, 2017 1:25 pm

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.

Erik63
Posts: 4
Joined: Tue Oct 03, 2017 4:17 pm

Re: Sending Generic.kl key commands

Post by Erik63 » Thu Oct 05, 2017 6:09 pm

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

User avatar
darrellg
Posts: 294
Joined: Fri Oct 17, 2014 10:02 am
Location: Southern California

Re: Sending Generic.kl key commands

Post by darrellg » Fri Oct 06, 2017 10:13 am

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.

Erik63
Posts: 4
Joined: Tue Oct 03, 2017 4:17 pm

Re: Sending Generic.kl key commands

Post by Erik63 » Thu Oct 12, 2017 5:41 pm

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

Post Reply