Android Question Bluetooth Or Wireless Control

Big Dave

Member
Licensed User
Longtime User
Hello

I am going to write a game for which I would like to have some control of using some sort of bluetooth or wireless device. Basically something that has a few buttons on it which can be identified within the program and appropriate action taken. Does anyone know of anything that may be suitable for my requirements.

Thanks.

Big Dave
 

Big Dave

Member
Licensed User
Longtime User
Erel

I am writing a quiz game which will run on a tablet which will be connected to a large tv using an hdmi cable. In order for me to interact with the game I would need to hold the tablet in my hand which is not ideal. So I thought I could use some Bluetooth/wireless device to represent the click/long click etc where button "A" does one thing and button "B" does something else. At the moment I am going to try using a Bluetooth keyboard and see if that will work for me. Something with a smaller number of buttons on it would be better but for £6 for the keyboard it is worth having a go.

May be back with questions on using Bluetooth but for the moment I see no need to progress this question further.

As always a big thanks. Great software, love using it.

Big Dave
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
In that case both options are possible. Wireless is more reliable than Bluetooth.
Erel

Please let me know if you want me to post this as a new question

I have got the Bluetooth keyboard and paired it with the tablet... and now not sure what I need to do.

Basically I want to trap the keyboard input, only one key will be pressed at a time, and take the appropriate action based on the key pressed. How do I identify and trap a Bluetooth keyboard key press. I have looked at other posts and find references to the Reflections library but I am not sure what I need to do.

Many thanks.

Big Dave
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
Erel

Not sure you have understood what I want to do. As an example...

I have 26 squares each with a letter of the alphabet in them. Rather than press the letter on the tablet I want to press the corresponding key on the keyboard. I want the program to trap the key input and take the appropriate action for that letter. Therefore the keyboard input needs to be caught as it is not being used for entry in edit fields.

I hope that makes sense. The example you give where someone presses the back key and you can trap it and ignore it is what I want, just for a lot more keys.

Big Dave
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
Erel

Not sure you have understood what I want to do. As an example...

I have 26 squares each with a letter of the alphabet in them. Rather than press the letter on the tablet I want to press the corresponding key on the keyboard. I want the program to trap the key input and take the appropriate action for that letter. Therefore the keyboard input needs to be caught as it is not being used for entry in edit fields.

I hope that makes sense. The example you give where someone presses the back key and you can trap it and ignore it is what I want, just for a lot more keys.

Big Dave
Hi

If you use the keyboard "at it is" then any time you press one key the result would be exactly the same as if you pressed the same key on the virtual keyboard.

Now to inferface with "non standard devices" you have plenty of options; but you will certainly need a microcontroller to perform the electrical interface between the "buttons" and the bluetooth or Wifi dongle.

So your interface could be :
buttons or potentiometers <-> microcontroller inputs <-> microcontroller serial UART <> bluetooth dongle <> Android bluetooth <-> android code

or

buttons or potentiometers <-> microcontroller inputs <-> microcontroller serial UART <-> wifi dongle <> Android wifi <-> android code

As for bluetooth dongle this one works like a charm : http://www.ebay.com/itm/Wireless-Se...178?pt=LH_DefaultDomain_0&hash=item2ec80c03a2

As for the wifi module I recently tested this one and it works also very well : http://www.dx.com/p/dmdg-serial-por...ielding-cover-blue-silver-309598#.U8KlipR_t8E

Both devices are quite easy to interface both on MCU side and on Android B4A one

As Erel said I would recommand to go with the wifi module (for 10$ more it's better !)
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
JP

Thanks for your reply. Not sure if you understand that the squares I was referring to are text fields on a tablet that when you click on one of them the program will do something. I just want to "emulate" the click by a key press on a Bluetooth keyboard. The tablet I am using (Acer B1-A71) has a micro usb port for data transfer and charging so not sure what use extra electronics will do for it and it adds an extra layer of complexity. If, as I believe I read in one post, you can create a hidden edit field and the key press from the Bluetooth keyboard is input there then I can handle that and write my code accordingly. I was hoping that I could use something similar to the code for catching the back press ie...

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean

    If KeyCode = KeyCodes.KEYCODE_BACK Then
      Return True   ' Do some action
    Else
      Return False
    End If
   
End Sub

At the moment I have managed to pair the keyboard to the tablet but cannot get it to type anything, inside or outside B4A.

Big Dave
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
Simply give focus to an edit text and your keyboard will of course be able to enter keys.

I mean that your letters on the tablet will be "buttons" and buttons cannot be emulated by a keyboard
On the contrary if you input some text in a edittext then the keyboard (and the code given as exemple ) will work
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
JP

Thanks for the prompt reply. I have used text fields as they each sit on top of a hexagon shape and I found it easier to code this way. But I understand where you are coming from now. I am going to have a go at creating a hidden edittext field and see what can be done. Will let you know how I get on. As I said I have paired the keyboard to the tablet yet cannot get it to type anything, even in anything outside of B4A so I could be a little while!!

Big Dave
 
Upvote 0
Top