Skip to content

Applications allowing to control a Linux PC with an Android phone over wi-fi, using kernel drivers to simulate virtual mouse and keyboard.

License

Notifications You must be signed in to change notification settings

AlvinCheng/Android-Virtual-Input-for-Linux

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

githalytics.com alpha

Android Virtual Input for Linux


The project aims at creating a way to control a Linux-based system with an Android phone over wi-fi. It differs from existing projects by simulating input at kernel level so that from system's perspective the virtual input should be identical to that generated by physical mouse and keyboard.

Project consists of following parts:

AndClient - an Android app used to provide input (keyboard and mouse/touchpad) to be sent over wifi to the computer you want to steer.

AndServer - server application, which receives input from the client and relays it to kernel modules via /dev nodes.

avms and avkbd - kernel modules, registered in Linux input subsystem, used to report events received from the server to the system.

Thanks to the modules, input events are created at low level and work in both console and graphical X. The connection between AndServer and AndClient is encrypted using OpenSSL library.

The project is not finished yet and not full keyboard functionality is available.

INSTALLATION

Instructions only tested on Gentoo and Ubuntu, appropriate configuration files for other distributions may be different.

  • AndClient

To install you have to copy AndClient.apk (either one from the bin subfolder or compiled yourself) to the phone sd card and install it from there. If your phone does not support installing applications from .apk files by default you'll have to use application like AppInstaller, available at Google Play. It is also required to enable option: Settings->Application settings->Unknown sources.

  • AndServer

To compile AndServer requires g++ and an OpenSSL library (also the development package, in Ubuntu it is called libssl-dev). Server parametres are configured in a file. By default it is '/etc/andserver.cfg'.

You will also need Java Virtual Machine and Bouncy Castle API (http://www.bouncycastle.org/) to create a 'bks' file. You can use version provided (1.45 for java 1.6) or download the latest version from their website and change the name accordingly.

There is a makefile in the AndServer main directory with following targets:

all - default, compiling the entire application. Output program will be an AndServer file, created inthe main directory.

certificate - create a self-signed server certificate and private key used to encrypt the connection. Both the certificate and the key will be placed in the 'Cert' directory in a single file named 'server.pem. You will be asked several questions. The password you type should be identical every time. Additional options 'Challenge password' should be left empty.

clientcert - create a self-signed client certificate and private key. Both the certificate and the key will be placed in the 'Cert' directory. File client.pkcs12 will contain storage to be later converted to an Android .bks format. The client.crt file is the client certificate alone and should be placed alongside server.pem so that the server can verify client which uses this certificate. Everything else from previous step applies here.

androidbks - puts the server certificate in a .bks file, so that a secure connection can be created with the server. The file, named 'andserver.bks' will be put in the 'Cert' directory. The file should then be copied to the phone SD card main directory.

clean - removes all object files from the 'Bin' folder.

certclean - removes .pem and .bks files from the 'Cert' folder.

install - copies 'AndServer' file to the '/usr/bin' directory and 'andserver.conf.example' to '/etc/andserver.conf'

distclean - deletes '/usr/bin/AndServer' and '/etc/andserver.conf'.

Correct order of installation is: install, certificate, androidbks.

If you are using Gentoo or Ubuntu distribution there are also targets, allowing you to set up the server for automatic start at boot. These are gentoo-install,gentoo-uninstall and ubuntu-install,ubuntu-uninstall. These install targets should be used after make install and after you placed paths to the private key file and certificate file in 'andserver.cfg'.

  • avms/avkbd

To compile the drivers require kernel sources (or at least headers) of the running kernel to be present in /usr/src/ (e.g. gentoo-sources on Gentoo or linux-headers on Ubuntu distributions). On kernel update you'll need to reinstall the drivers.

To install the drivers you have to cd to their directories, type 'make', and then 'make install'. To load the drivers type 'modprobe avms' or 'modprobe avkbd'.

To set up the modules to autoload at startup in Ubuntu use 'echo "avms" >> /etc/modules' command as root or with sudo. In Gentoo you have to manually add 'avms' and 'avkbd' to modules="" list in '/etc/conf.d/modules', e.g. modules="nvidia avms avkbd".

USAGE

To use the applications, modules have to be loaded and the server application running before you connect with your phone. Also, the phone and the computer should be connected to the same network.

  • AndServer

The server application should be run as root (some options like changing process priority are reserved only for root). It can be started with the following options:

AndServer [-s] [-d] [-h] [-u] [-o CONFIGFILE] [-k KPORT] [-m MPORT] [-l MAXCONNECTIONS] [-C CERTFILE] [-P KEYFILE] [-V CLIENTCERTFILE] [-M MSFILE] [-K KBDFILE]

-s - do not run as daemon (all messages will be printed to stderr instead of syslog)
-d - turns debug output on
-h - display this text -u - do NOT verify client certificate (not recommended) -o - use [CONFIGFILE] to read configuration from
-k - change keyboard listening port to KPORT (default port is 6780) -m - change mouse listening port to MPORT (default port is 6781)
-l - set max connection (default value is 2)
-C - set SSL certificate path
-P - set SSL private key path
-M - set mouse driver dev node path (default is "/dev/avms")
-K - set keyboard driver dev node path (default is "/dev/avkbd")

You can close the program by sending SIGINT or SIGKILL (kill PID).

Options passed on startup overwrite those in the configuration file (if any). SSL private key file and certificate file are required for the application to start. Other options, if not provided, will be completed with the default options.

  • AndClient

Once the server is running and modules loaded you can connect to your computer. Also make certain that the 'andserver.bks' is placed in the main folder of your phone's SD card. Before connecting for the first time you need to set the address of your computer, by providing IP and listening ports (by default 6781 for mouse and 6780 for keyboard). Once done and the settings are saved, press [back] on your phone and connect with the 'Connect' button. Once connected you can display the touchpad and keyboard screens, used to send input.

To switch between the screens you can use menu, displayed upon pressing [menu] button on your phone.

On the touchpad screen right and bottom borders of the touchpad are used for vertical and horizontal scrolling respectively.

On the keyboard screen to send text, you have to type it in the box and then press 'send'. Button clicks for the buttons below are sent immediately. 'Mod' keys (Alt, Ctrl, Shift and Win) will be 'pressed' only for the duration of your input, and only those that have been activated. Here's how it works on an example of Alt-F4:

  1. 'Turn on' the 'Alt' button (so that it's highlighted)
  2. Press the 'F4' button. Upon pressing it, combination sent to the computer will be Alt-F4.

When you press either 'Send' or the keys below (not counting Mod keys) the applications checks if any modifiers are turned on, and in such case will keep them 'pressed' for the entire duration of the input (be it a text message or a single button click). 'Mod' buttons will be automatically released immediately after the input, with the exception of the Tab button, after which release is delayed to allow you to easily use the popular Alt-Tab shortcut.

To view more of the available keys you have to switch to another 'screen' of keys. To do that press 'next keyboard page' button, located in top or top-right part of the screen, depending on the layout.

BUGS AND PROBLEMS

The project has been tested only on a limited number of machines so if it does not work for you, please send me an e-mail to zintelpiotr@gmail.com and I'll try to fix it.

AndClient application has been tested on Samsung i5700 with 320x480 resolution and Samsung i9070 with 480x800 resolution, but should work on any resolution.

LIMITATIONS

As of now, due to lack of place on a single screen, only a limited number of keys are displayed on the AndClient keyboard screen. The server and avkbd driver support most of standard PC102 keyboard and some multimedia keys (volume control, play/pause, next/prev song and stop-playing). Full support for the remaining keys will hopefully be added in future releases.

update 22.10.2012

added play/pause, next/prev, volume control and directional arrow keys. To switch to another 'screen' of keys press 'next keyboard page' button

Also, multitouch is not yet supported, so you can't 'drag' anything with the mouse, although minimum required Android version is 2.1, so that multitouch support may be added in future.

About

Applications allowing to control a Linux PC with an Android phone over wi-fi, using kernel drivers to simulate virtual mouse and keyboard.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published