Android input system, KeyEvent, and Bluetooth keyboards

532 views
Skip to first unread message

AgentHH

unread,
Oct 20, 2010, 4:51:11 AM10/20/10
to android-platform
So, I've been wondering about the Android input system and how it
could deal with a standard PC keyboard. (I want to use a Bluetooth
keyboard with HID and have all of the keys be useful.)

After doing some spelunking, it appears that the only way to get
keyboard input to a sandboxed app is to use the KeyEvent object.
However, this object only supports a small subset of the keys I'm used
to having on a keyboard.

Out of curiosity, why were these specific keys chosen to be support on
Android?

And the root question: given the Android input system, what would be
the best method of somehow getting a Bluetooth keyboard to work with
an Android app?

Thanks,
Hans

Dianne Hackborn

unread,
Oct 21, 2010, 3:17:18 AM10/21/10
to android-...@googlegroups.com
On Wed, Oct 20, 2010 at 1:51 AM, AgentHH <age...@gmail.com> wrote:
Out of curiosity, why were these specific keys chosen to be support on
Android?

Because those are the keys we have had so far.
 
And the root question: given the Android input system, what would be
the best method of somehow getting a Bluetooth keyboard to work with
an Android app?

It should publish as a regular input device that the standard input system will see, open, and get events from.

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Hans Nielsen

unread,
Oct 21, 2010, 3:42:10 AM10/21/10
to android-platform
On Oct 21, 12:17 am, Dianne Hackborn <hack...@android.com> wrote:
> On Wed, Oct 20, 2010 at 1:51 AM, AgentHH <agen...@gmail.com> wrote:
> > Out of curiosity, why were these specific keys chosen to be support on
> > Android?
>
> Because those are the keys we have had so far.

So, if I wanted to add support for keys such as insert / delete /
home / end, would those be added to the list of keycodes?

> > And the root question: given the Android input system, what would be
> > the best method of somehow getting a Bluetooth keyboard to work with
> > an Android app?
>
> It should publish as a regular input device that the standard input system
> will see, open, and get events from.

What I mean by best method: I want all of the various keys (including
the ones mentioned above, and maybe even control) to work with, say,
ConnectBot (which would also need modifications), and I would like to
do so in a way that's not egregiously terrible.

Thanks,
Hans

Dianne Hackborn

unread,
Oct 21, 2010, 2:16:42 PM10/21/10
to android-...@googlegroups.com
On Thu, Oct 21, 2010 at 12:42 AM, Hans Nielsen <age...@gmail.com> wrote:
So, if I wanted to add support for keys such as insert / delete /
home / end, would those be added to the list of keycodes?

Yes they would need to be added.  I think there is no need at this point, they should be in the next version of the code.
 
What I mean by best method: I want all of the various keys (including
the ones mentioned above, and maybe even control) to work with, say,
ConnectBot (which would also need modifications), and I would like to
do so in a way that's not egregiously terrible.

The keyboard should be published as a regular kernel input device, so the android framework can open it like a normal input device and dispatch events from it to apps like it does other input devices.  Not sure what I am missing here...?

jaikumar Ganesh

unread,
Oct 23, 2010, 1:30:55 AM10/23/10
to android-...@googlegroups.com
Hans:


On Thu, Oct 21, 2010 at 11:16 AM, Dianne Hackborn <hac...@android.com> wrote:
> On Thu, Oct 21, 2010 at 12:42 AM, Hans Nielsen <age...@gmail.com> wrote:
>>
>> So, if I wanted to add support for keys such as insert / delete /
>> home / end, would those be added to the list of keycodes?
>
> Yes they would need to be added.  I think there is no need at this point,
> they should be in the next version of the code.
>
>>
>> What I mean by best method: I want all of the various keys (including
>> the ones mentioned above, and maybe even control) to work with, say,
>> ConnectBot (which would also need modifications), and I would like to
>> do so in a way that's not egregiously terrible.
>
> The keyboard should be published as a regular kernel input device, so the
> android framework can open it like a normal input device and dispatch events
> from it to apps like it does other input devices.  Not sure what I am
> missing here...?

You need the HID plugin of Bluez installed and that you need to hook
up JNI and other layers.
If you want to use dbus command line arguments, you can use dbus-send
to connect.
Once connected, it will show up as a regular keyboard to the input system.

If you need all types of keyboards to work, there are some HID
specific kernel drivers that need to be switched on in the config.

> --
> Dianne Hackborn
> Android framework engineer
> hac...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
>

> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-platfo...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-platform?hl=en.
>

praneeth juturu

unread,
Oct 25, 2010, 6:38:56 AM10/25/10
to android-...@googlegroups.com
Hi,

Does BlueZ have both HID Host and HID Device functionality?

How can one go ahead in implementing the functionality of HID device ?

Thanks for your inputs

Praneeth

Pavan Savoy

unread,
Oct 25, 2010, 9:20:13 AM10/25/10
to android-...@googlegroups.com
Yes, It does.
HID host has been implemented as part of ANDROID framework @
git.omapzoom.org, feel free to have a look.
(do a grep of HID in frameworks/base and packages/apps/Settings/ projects).

Thanks,
Pavan Savoy.

--
--Pavan Savoy

Praneeth

unread,
Oct 26, 2010, 5:40:38 AM10/26/10
to android-platform
Hi,

Can the same android device behave as both HID Device and HID Host?

Thanks
Praneeth

On Oct 25, 6:20 pm, Pavan Savoy <pavan.sa...@gmail.com> wrote:
> Yes, It does.
> HID host has been implemented as part of ANDROID framework @
> git.omapzoom.org, feel free to have a look.
> (do a grep of HID in frameworks/base and packages/apps/Settings/ projects).
>
> Thanks,
> Pavan Savoy.
>
>
>
>
>
> > Praneeth
>
> > On Sat, Oct 23, 2010 at 11:00 AM, jaikumar Ganesh <jaikum...@gmail.com>
> > wrote:
>
> >> Hans:
>
> >> On Thu, Oct 21, 2010 at 11:16 AM, Dianne Hackborn <hack...@android.com>
> >> wrote:
> >> > On Thu, Oct 21, 2010 at 12:42 AM, Hans Nielsen <agen...@gmail.com>
> >> > hack...@android.com

Pavan Savoy

unread,
Oct 26, 2010, 9:19:32 AM10/26/10
to android-...@googlegroups.com

jaikumar Ganesh

unread,
Oct 26, 2010, 12:20:46 PM10/26/10
to android-...@googlegroups.com
Yes the device can support both HID device and HID host, but the Bluez
plugin supports only the HID host profile.

HID is not supported (as an official profile) in the Android Froyo
release, though as the Bluez plugin in present you can implement it
easily as shown by the links posted by Pavan.

Thanks

Pavan Savoy

unread,
Oct 26, 2010, 12:30:39 PM10/26/10
to android-...@googlegroups.com
Well I guess the core question is, Can a HID host feature be
meaningful for all phone like devices ?
(if they don't have a docking station or projector or VNC etc...)

HID device role seems more convincing.

Reply all
Reply to author
Forward
0 new messages