Question

I am going to implement an android virtual keyboard for controlling PC. Here is scheme how I want this application to work:

  1. Phone app connects to running client on the pc.

  2. User press button on the phone.

  3. App sends to client signal indicating what button was pressed.

  4. Client handles app signal(virtually press designed button).

I know most of the classes I will use, however I am clueless about PC client handling signals from the phone(step 4). If you could tell me which class/classes should I use for those "virtual presses" it would be great. Thank you.

Was it helpful?

Solution

The app running on the PC will be a server rather than a client, if the phone connects to it.

It will not be easy to send keyboard events from a Java application (though that might be possible), doing a simple server in C or C++ is probably easier (I assume your PC is windows based). Win32 API has a SendInput method to generate a keyboard event (example: http://batchloaf.wordpress.com/2012/04/17/simulating-a-keystroke-in-win32-c-or-c-using-sendinput/).

The communication between the android app and the PC can rely on a simple TCP socket (UDP is also a valid option but if you begin in network programming TCP is probably easier to handle and more widely used). On the C/C++ server, look at the functions socket, bind, listen, accept and then recv. On the android app, Socket and DataOutputStream classes should do the job.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top