billixter / android-bluez-ime

Automatically exported from code.google.com/p/android-bluez-ime
0 stars 0 forks source link

Building Driver for 3rd party controller #189

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Is there a guideline or a short primer on how to support new controllers ?

I have a 3rd party gamepad which connects to android via bluetooth and acts as 
a keyboard and mouse, can we contribute somehow to enable functionality to 
support such gamepad ?

I have the scancodes for the device in attached file lready but can dive down 
further on that it takes to support new controllers for this project.

Original issue reported on code.google.com by adi...@eddywebs.com on 27 Oct 2012 at 8:16

Attachments:

GoogleCodeExporter commented 8 years ago
There is no guide as such, so here are some info points:
1) Each "driver" must be in its own class
2) Each driver must implement BluezDriverInterface, but really should derive 
from RfcommReader or HIDReaderBase, whichever fits the best.
3) And it should have the static methods public static int[] getButtonCodes()  
and  public static int[] getButtonNames() methods
4) After implentation, add to the list here: 
http://code.google.com/p/android-bluez-ime/source/browse/trunk/BluezIME/src/com/
hexad/bluezime/BluezService.java#33

The implementation is not fully plug-n-play so you need to add the driver to:
http://code.google.com/p/android-bluez-ime/source/browse/trunk/BluezIME/src/com/
hexad/bluezime/ButtonConfiguration.java#121
http://code.google.com/p/android-bluez-ime/source/browse/trunk/BluezIME/src/com/
hexad/bluezime/BluezService.java#324

The simplest example is the BGP100 driver:
http://code.google.com/p/android-bluez-ime/source/browse/trunk/BluezIME/src/com/
hexad/bluezime/BGP100Reader.java

All that is really done here is in the parseInputData() method:
http://code.google.com/p/android-bluez-ime/source/browse/trunk/BluezIME/src/com/
hexad/bluezime/BGP100Reader.java#110

From that example you can see that the incoming data is parsed to figure out 
what button has been pressed/released and a keypress event is then broadcasted:
http://code.google.com/p/android-bluez-ime/source/browse/trunk/BluezIME/src/com/
hexad/bluezime/BGP100Reader.java#174

That is all there is too it. Let me know if you need more info.

Original comment by kenneth@hexad.dk on 4 Nov 2012 at 11:41