Jump to content


Photo

Code for android doing away with bluez-ime?

bluez-ime android keyboard

  • Please log in to reply
1 reply to this topic

#1 OFFLINE   ClockwoekRobot

ClockwoekRobot

    Member

  • Members
  • PipPip
  • 22 posts
  • Local time: 07:38 AM

Posted 20 November 2011 - 07:20 PM

Bit of a coding newbie here. I'd like to add some simple support for the ICP to a game demo I'm writing, Space Wars 3D.
There's nothing wrong with bluez-ime but I don't see why the punter should have to fiddle around with it if they don't need to.
Has anyone got a very simple example of code that'd take care of reading a key assuming it's in the icade mode that appears to work with most the apple stuff and has been added to mame4droid quite painlessly? Info appears a bit thin on the ground so far.
I did take a look at the Bluez-ime code but it all got a bit overwhelming :)

#2 OFFLINE   kennneth

kennneth

    Member

  • Members
  • PipPip
  • 24 posts
  • Local time: 08:38 AM

Posted 29 November 2011 - 01:28 PM

Each headset manufacturer fiddles with Bluetooth, and there is no public Android API call to connect, which is the first obstacle.

You need to use a bit of reflection to call the createInsecureRfcommSocket that opens the data connection when the iControlPad is in SPP mode:
http://code.google.c...Device.java#146
http://code.google.c...Device.java#203

Once you have a connection, you can read/write data using the resulting socket and getInputStream() / getOutputStream().

You can read about the format used here:
http://www.icontrolp..._operations.pdf
(Scroll down to "Using SPP mode")

I would recommend that you use "auto report mode" instead of polling,
but your app logic may lend itself to polling.

If you have a new Android device, maybe you are lucky enough to have the HID profile for Bluetooth, and in that case you can just use it as a regular keyboard (with fewer buttons of course).
But if you want to sell you app, 90%-95% of Android users have no support for HID, so you have to deal with the low-level SPP data.
This works on almost all Android devices 2.0+ (I know of no way to get it working on LG devices).


Regards, Kenneth


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users