Android Question Simulate keypress (on screen controls) from external source.

ThiagoRodrigues

Member
Licensed User
Hello,

I would like to know if it is possible to write an app that runs as a service (background) and simulates an input (keypress) in the current application, let´s say that it collects inputs from an external source (bluetooth joystick) and converts into local keypress.

Regards,
 

DonManfred

Expert
Licensed User
If your device is rooted then you can use this library.
you then can use
B4X:
Dim rc As RootCmd
If rc.haveRoot Then
        rc.execRootCmd("input tap 100 200") '
End If
'
'If you need also to simulate the "back" key:
'
simulate tap on "back" key
rc.execRootCmd("input keyevent KEYCODE_BACK")
to simulate a tap or keyinput
 

ThiagoRodrigues

Member
Licensed User
I see... well, the need to be rooted limits the solution...

I wonder how those bluetooth joysticks that some companies sell for use with tablets and phones work with any device...

Anyway, thanks for the tip.

Regards,
 

ThiagoRodrigues

Member
Licensed User
Right... I guess it is easier to work on the hardware level (use a bluetooth module used for portable keyboard), I mean, HID module...
 
Last edited:
Top