Android: How to control input devices remotely from your PC

Hey !

Nowadays, buying a mini-a usb cable or at least find one is complicated. You spend a lot of time trying to get one. Personally, the only one I found was on amazon, and the price was, honestly not interesting at all (seriously, that’s 5 pins, 5 wires and a plug…) ! However, without such cable, you cannot use input devices, because they must be powered and controlled by the board. A normal mini-usb cable won’t work (the mini-a plug is for master devices, mini-b plug is for slave devices).

Moreover, for a lot of these boards, when you plug a mini-a cable because you want to use input devices, you cannot use adb… you can still use it over the network, but it means you have working network devices for your board (This is not necessary the case…). The bitrate is also different, so if you planned to upload a big file to your board or if you just planned to install a package, adb over usb is preferable.

I decided to develop a tool to control input devices remotely over the network or over the USB OTG port (with the same cable used to power the device and use adb). The component of the linux kernel for input devices handling is called evdev (for event device). Basically, the input subsystem receives events from hardware-specific drivers and translates them into a generic structure. Finally, this generic event goes up to userspace and can easily be adapted into another input events (like X11 events for example). The linux kernel also provides a “uinput” driver, which allows userspace applications to inject data into the linux input subsystem and control virtual input devices.

In order to control an input device remotely you need to:

  • Create an application which captures evdev events from /dev/input/event[N] and sends them to a daemon running on your board
  • Create a daemon which receives events from this client and forwards them to /dev/uinput
  • Handle Communication through a TCP socket, in this way you can control your virtual input device locally or remotely over a network
  •  

    This is exactly what I did. The project is called AIB (for Android Input Bridge), the code is distributed under the terms of the GPLv3 license and it’s available on github.

    $ git clone git://github.com/rperier/android_input_bridge.git

    You need to build “aibd” (the daemon running on the board) either within android or with the linaro toolchain from the native development kit.
    Then build the client which will capture and send evdev events from your PC to your board :

    $ gcc -Wall -Wextra -O2 aib.c common.c -DAPPNAME="aib" -o aib

    Start the daemon

    you need to upload the binary to your board, then start it:

    $ aibd 4242

    Finally just start the client either to use it over the network or locally over the USB OTG port.

    Over the network


    $ sudo aib board_ip_addr 4242 /dev/input/by-id/your_input_mouse

    Over the USB OTG port

    On the android side:

    $ setprop service.adb.tcp.port ""
    $ stop adbd
    $ start adbd

    On the PC side:

    $ adb kill-server
    $ adb start-server
    $ adb forward tcp:4242 tcp:4242
    $ sudo aib 127.0.0.1 4242 /dev/input/by-id/your_input_mouse

    Once these steps are done, you should be able to control the cursor remotely using the mouse from your pc !
    For now, aib has only support for mice. Support for keyboards is coming soon.

    Technically speaking, these tools have nothing to do with android itself, I mean it can work perfectly between two linux machines.
    I just developed it for linaro-android because I need it for my board in order to use android without any extra input devices (well, except a mini-b cable which can be bought at anyplace).

    Have a nice day ;)

    How to build a android image for vexpress target from scratch and start it with qemu

    Hey folks,

    Firstly I have to introduce myself. My name is Romain, I am a French embedded system engineer and a new contributor to the linaro community.
    For those, like me, who want to participate to this awesome community, I will show you how to build the lastest android ICS from scratch, and then we will boot it using qemu.

    First of all, you need to download and build QEMU, I used Linaro QEMU but feel free to use QEMU from upstream (both are great).

    Build and install QEMU


    $ cd Devel/linaro
    $ wget https://launchpad.net/qemu-linaro/trunk/2012.06/+download/qemu-linaro-1.1.0-2012.06.tar.gz
    $ tar xavpf qemu-linaro-1.1.0-2012.06.tar.gz

    Then , patch QEMU to adjust the start addr of where the initrd gets loaded (this is required for vexpress targets, see this link).


    $ sed -i "s/#define INITRD_LOAD_ADDR 0x00d00000/#define INITRD_LOAD_ADDR 0x01d00000/" qemu-linaro-1.1.0-2012.06/hw/arm_boot.c

    Now build and install it.


    $ mkdir qemu-install
    $ cd qemu-linaro-1.1.0-2012.06
    $ ./configure --prefix=$(readlink -f `pwd`/../qemu-install) --target-list=arm-softmmu
    $ make -j`getconf _NPROCESSORS_ONLN`
    $ make install
    $ cd ..

    Now, you have to change your PATH env variable to export qemu-install/bin and it’s done !

    Get Linaro android source code and built it

    Don’t forget to install build dependencies, as explained here.

    And you just need to download a script that will do everything for you automatically ! (even for rebuilding the code after an update !)


    $ wget http://snapshots.linaro.org/android/~linaro-android/vexpress-ics-gcc47-armlt-tracking-open/lastSuccessful/linaro_android_build_cmds.sh
    $ chmod u+x linaro_android_build_cmds.sh
    $ ./linaro_android_build_cmds.sh

    This step is a quite long, basically, it will download the tool “repo” and checkout all android repositories from git.linaro.org, these repositories are big. Once the repositories are cloned, the build will start. Personnally, I recommand some episodes of phd comics and a coffee during this step :) .

    If this step completes without any issues, congrats you’ve built a fresh linaro android from scratch !!

    Create the image and extract kernel image

    For this step, another script will do everything automatically for you !


    $ wget http://ftp.romainperier.org/linaro/linaro_android_build_image.sh
    $ chmod u+x linaro_android_build_image.sh
    $ ./ linaro_android_build_image.sh

    Boot the image with QEMU

    Finally, start qemu and … it’s done !!


    $ qemu-system-arm -M vexpress-a9 -m 1024 -smp 1 -snapshot -serial stdio -no-reboot -kernel vmlinuz -initrd initrd.gz -drive file=vexpress-ics-gcc47-armlt-daily-build.img,if=sd,cache=writeback --append "console=tty0 console=ttyAMA0,38400n8 rootwait ro init=/init androidboot.console=ttyAMA0"

    Please note that with qemu-arm android is emulated and not virtualized, which means that all the hardware, including CPU, MMU are handled in pure software, so don’t expect great performance like virtualbox (it has nothing to do with android here but just how qemu emulates hardware). It’s a bit slow on first boot but it’s really fun and cool to be able to use linaro android without any cost and hardware !

    For the next post, I will show you how to build and boot a snowball board !! (I’m so excited to do so …)

    Have a nice evening ;)

    Flash 11: It contains a kcmodule for KDE !

    Flash 11 beta is distributed with a kcm module to configure the player through systemsettings.
    For all the skeptics, here are some screenshots :

    The entry in systemsettings :

    The entry in systemsettings

    The first tab:

    The first tab

    The second tab:
    The second tab

    This is a great effort from adobe, so I would like to point it out.

    Hello Ubuntu Planet !

    This is my first post to Planet!
    My name is Romain Perier, I am a young french system engineer and I got my kubuntu membership yesterday.
    What about me ? I am an active kubuntu contributor, I do some packaging, bugs fixing and programming when it’s required. For example, I’ve helped the kubuntu team to package kde 4.7 recently, and there was a lot of works, I’ve rewritten language-selector for KDE, and many other contributions.
    On the KDE side, I am an upstream phonon developer, I program the phonon-gstreamer backend with the rocking Trever Fischer, I program also phonon itself.

    I will post many other contributions to planet really soon. Have a nice day ;)

    Hello Planet KDE !

    Hi there,
    This is my first post to planet, so I should like to ask your indulgence :) .
    I am a french kubuntu and KDE contributor. On the kubuntu side, I spend my time doing some packaging and help to make the kubuntu desktop better. On the KDE side, I’ve only few contributions for now (everything has a beginning). These days, I am working on phonon, especially on phonon-gstreamer, I am the person in charge of adding the subtitle feature to the backend (external and embedded subtitles). I will post more about phonon and about my other contributions later.

    have a nice day ! ;)

    Kubuntu and KDE SC 4.7

    This is it!! After a long period around 2 weeks of packaging, kde 4.7 is in kubuntu! Thanks to the awesome kubuntu team!
    See harald sitter’s blog for more details

    KDE 4.7 RC1 into archives!

    KDE 4.6.90 has been packaged and is moving into archives for oneiric. We’re already on the road for packaging the RC2, which should be available really soon.
    For natty users, we first plan to package KDE 4.7 RC2 and then we will backport it into kubuntu-ppa.

    The KDE 4.7 status in kubuntu is available on the wiki

    Help needed

    With kde 4.7 a lot of packages have been splitted, which means that a lot of packages rules have to be written from scratch and increases our work significantly.
    As the rocking Valorie Zimmerman said, Jonathan Riddell is off, he is working on Bazaar for Canonical for the entire oneiric release. This significant amont of works is completly done by the kubuntu team and the community.

    We need your help! Are you learning packaging and do you want to improve your skills ? join #kubuntu-devel and propose your help, I am sure that we will find something to do for you.

    Dedicated server deployed, domain name reserved, www under construction

    My dedicated server is installed and configured properly, I have installed cherokee and deployed django on www.
    The plan now is to programme a simple website in python using the django framework

    kDebug() << “Hello world!”;

    Welcome to my developer blog! This is my first post, I will try to post some news about Kubuntu and also my KDE contributions.