Sec, blogmal! - tidbits - android-remote-input

Categories:

Everything

September '17

FrFrFrFrFrFrFr
28293031123
45678910
11121314151617
18192021222324
2526272829301

Archive:

Tue, 25 Jan 2011

Android remote input

As most of you already know, I own an android mobile. Recently I wanted to add an RSS feed URL to my android podcast client, but was annoyed by the fact that I had to copy this long URL by hand. I would rather copy&paste it.

As I have rooted my phone, it had to be possible one way or another. Looking around, I found no usable solutions.

The most general solution would be to simulate keyboard input. Digging around a bit in Linux internals I found a way to inject key-presses via /dev/input/events* so I wrote a little program: btype.c. For those not wanting to compile it themselves, you can download the binary here.

It will accept text on the command-line, or read interactively from stdin.

Writing it was actually more difficult than I expected - I didn't want to hardcode the keyboard scancodes, so I had to read&parse the keymap and keylayout files which is always onerous in C. Also I learned funny ioctl%s to find the correct device in %/dev/input and to switch a tty to single-character input. Last but not least I had to find out how to get an android property value in C. – Hopefully all this made the program more portable to other android devices.

I hope someone finds a good use for it, let me know if you like it,
Sec


posted at: 20:04 | Category: /tidbits | permanent link to this entry | 0 comments (trackback)
 

Your Comment
 
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Comment:
Save my Name and URL/Email for next time
(Note that comments will be rejected unless you enter 42 in the following box: )

powered by blosxom
in 1.00 s