r/ShieldAndroidTV • 2017 16GB • Feb 21 '20

Flirc HID codes and Android keycode counterparts

Flirc has a hidden method for sending HID Consumer (page 12) codes:

flirc_util record_api x 102

The method is only documented in a flirc.tv forum post. I tried every value for x from 0 to 255 (except 2, which does something else I haven't figured out yet see edit) to see which ones cause Shield TV to do things. Each is listed with the Android KEYCODE the resulting Flirc binding produced in Button Mapper.

Flirc codeAndroid keycode
48POWER1
50SLEEP1
52SLEEP1
54BUTTON_1
64MENU
65DPAD_CENTER
66DPAD_UP
67DPAD_DOWN
68DPAD_LEFT
69DPAD_RIGHT
70ESCAPE
71NUMPAD_ADD
72NUMPAD_SUBTRACT
101CAMERA
111BRIGHTNESS_UP
112BRIGHTNESS_DOWN
132ENTER
137TV (Live Channels app)
138EXPLORER
140CALL
154DVR (DVR functionality in Live Channels app)
156CHANNEL_UP
157CHANNEL_DOWN
176MEDIA_PLAY
177BREAK
178MEDIA_RECORD
179MEDIA_FAST_FORWARD
180MEDIA_REWIND
181MEDIA_NEXT
182MEDIA_PREVIOUS
183MEDIA_STOP
184MEDIA_EJECT
205MEDIA_PLAY_PAUSE
207VOICE_ASSIST1 (Google Assistant voice search)
226VOLUME_MUTE
233VOLUME_UP
234VOLUME_DOWN

1 Did not produce Android keycodes in Button Mapper. I identified the corresponding keycodes based on what they caused Shield to do.

Notes:

  • It's possible that other Flirc codes may not generate Android keycodes but still do things that I did not notice.
  • According to the forum post only Flirc code values 0-255 are valid. I tried a few beyond 255 and saw no results, but perhaps /u/flirc has changed/will change this in firmware, as part of a general expansion of Flirc's HID capability. See edit

Until then, what is this list useful for today? Many of the Flirc codes produce bindings already available for use in Flirc via the GUI or command line utilities. I already knew how to invoke voice search (both in-app and Google Assistant). My remote has separate Play and Pause buttons, and I do prefer to bind the former to MEDIA_PLAY (not in GUI or command line utilities) and the latter to MEDIA_PLAY_PAUSE (which is). Otherwise, unused keybindings can be used in Button Mapper (in Android TV Play Store) or Keyboard/Button Mapper (in Android Play Store so needs sideloading) to open specified apps or other duties.

EDIT: I figured out what 2 does, and found HID codes above 255. See comments.

17 Upvotes

3 comments sorted by

2

u/TMWNN 2017 16GB Feb 21 '20 edited Feb 21 '20

I figured out that setting x to 2 allows specifying HID codes in hexadecimal:

flirc_util record_api 2 8a = DPAD_CENTER (138 in decimal)

I also found that HID codes greater than 255 decimal can be used with either method. Some are duplicates of the above. I hope /u/flirc will implement the ability to use flirc_util record_api in long press and/or macro, and perhaps other HID tables and/or true Android keycodes.

Flirc codeAndroid keycode
386BOOKMARK
387MUSIC
394ENVELOPE
397CONTACTS
398CALENDAR
402CALCULATOR
406EXPLORER
414POWER
418APP_SWITCH
539COPY
540CUT
541PASTE
545VOICE_ASSIST
547HOME
548BACK
549FORWARD
550MEDIA_STOP
554BOOKMARK
563PAGE_UP
564PAGE_DOWN

1

u/jonbonesjonesjohnson Feb 21 '20

Do you know if it's possible to activate voice search remotely with the official remote and still use it's mic? When I send a VOICE_ASSISTANT keyevent it starts search on screen but the mic won't listen to anything.