Android Question IR (Infrared) Receiver in TV-Box - HowTo research and Hook

Herbert32

Active Member
Licensed User
Longtime User
Hi together,

there are many Android-based TV-Boxes having an IR-Receiver which sends Keycodes like from a Keyboard.

How can I find out how their IR-Interface exactly acts? - Is there a way to find out which application or service sends the Keycode to the OS ?

While my research I found only api's regarding IR-Transmitters - but since Android-TV, I think that IR-receivers are more common than transmitters - maybe I searched by the wrong terms... :-/ - help is really welcome here

In my actual case, I have to limit or modify these transmissions to avoid that some codes are sended to the OS or reuse keys for my app-specific purpose - so I need to find out where the Hardware-based circuit commits its signal to Android or where they are placed/defined and configured as HID-Device.

Is someone out who has some experiences with keyboard-hooks in android and is willing to share them?

best regards
Herbert
 

Herbert32

Active Member
Licensed User
Longtime User
Does the IR receiver raise the Activity_KeyPress event?

I wrote a small utility to display the Keycodes. From there I can say:

For some Keys, 'yes' (arrow up,down,left,right or numbers 0-9)

For some Keys, 'no' (Volume+/- or 'settings' or 'open browser')
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
I think the IR/OS does pass these through as a keypress.
I cant say for sure which ones are detectable but I wrote a TV app and can confirm that (for my TV at least) I test for the following keys:

B4X:
    KeyCode = KeyCodes.KEYCODE_BACK
    KeyCode = KeyCodes.KEYCODE_DPAD_DOWN
    KeyCode = KeyCodes.KEYCODE_DPAD_UP
    KeyCode = KeyCodes.KEYCODE_DPAD_LEFT
    KeyCode = KeyCodes.KEYCODE_DPAD_RIGHT

Your best bet is to write a small TV app and see if/what each button exposes as a keycode.
Looking at my old code it looks like they invoke the following sub, and according to my comments returning True consumes the event.

B4X:
Sub EventName_KeyPress (KeyCode As Int) As Boolean
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…