[mythtv-users] "media keys" in mythtv-light launched from text console on raspberry pi 3

faginbagin mythtv at hbuus.com
Sun Dec 20 15:32:34 UTC 2020


On 12/19/2020 19:31, Stephen Worthington wrote:
> On Sat, 19 Dec 2020 14:11:28 -0500, you wrote:
> 
>> On 12/18/2020 19:01, R. G. Newbury wrote:
>>> On 2020-12-18 11:28 a.m., Stephen Worthington wrote:
>>>> On Fri, 18 Dec 2020 16:04:18 +0100, you wrote:
>>>>
>>>>> I have a logitech bluetooth keyboard (Logitech K810) that has some
>>>>> "media keys", volumeup, volumedown, mute etc. When I try to map theese
>>>>> in the mythtv frontend, myth says something like "unknown key". Mapping
>>>>> has no effect. At the moment I'm launching the frontend from a text
>>>>> console. The keys have keycodes and scancodes in the the console
>>>>> according to showkey(1) from the kbd package. Are there codes I can give
>>>>> to setkeycodes(1) to allow the frontend to understand the media keys, or
>>>>> will I have to get X working? The most convenient option would be if I
>>>>> could just issue "loadkeys <keymap>" I think. Is it possible to create a
>>>>> keymap that mythfrontend would be able to understand?
>>>>>
>>>>> P.S: Logitech K810 works really well as a media keyboard. Small,
>>>>> backlight that goes to sleep when idle, really fast wake-up.
>>>>
>>>> I am not familiar with mythtv-light or RPis, but in mythfrontend, the
>>>> keystrokes need to be normal keyboard keys to be recognised.  For
>>>> infrared remotes when using them directly with mythfrontend instead of
>>>> via lirc, this means that if you want the Info button to work, it
>>>> normally produces a keystroke like KEY_INFO, which mythfrontend does
>>>> not recognise.  So you need to remap it to KEY_I which is the normal
>>>> keyboard I key.
>>>>
>>>> I would think you are having the same problem with the media keys -
>>>> they are producing KEY_ values that mythtv-light does not recognise.
>>>> So for example, with mythfrontend the volume up and down default to [
>>>> and ] characters, which are KEY_LEFTBRACE and KEY_RIGHTBRACE.  But
>>>> your keyboard will likely be producing KEY_VOLUMEDOWN and KEY_VOLUMEUP
>>>> for the media volume keys, so you will need to remap them to
>>>> KEY_LEFTBRACE and KEY_RIGHTBRACE.  Be aware that the media keys are
>>>> often already being used by the system.  In Ubuntu, the KEY_VOLUMEDOWN
>>>> and KEY_VOLUMEUP keystrokes are captured by the desktop and used to
>>>> adjust the system volume.  And if you remap keys, other programs that
>>>> do recognise them will no longer work properly.  So you may want to
>>>> wrap your frontend program in a script that sets up the keystroke
>>>> remappings you want, runs the frontend, then when it exits, remaps the
>>>> keystrokes back to their standard values.  The script will probably
>>>> need to use a "trap" command to capture Ctrl-C and the like so that
>>>> the keycodes get remapped back to standard if the script is killed
>>>> with Ctrl-C.
>>>>
>>>> The full list of valid keystrokes and buttons in Ubuntu is found in:
>>>>
>>>> /usr/src/linux-headers-<kernel-version>/include/uapi/linux/input-event-codes.h
>>>>
>>>> If the RPi has the kernel header files available, you may have a copy
>>>> of that file or a similar one somewhere.  You can find it by searching
>>>> for a unique keystroke name, such as KEY_LEFTBRACE.
>>>>
>>>> If you want to see the exact keystrokes your keyboard uses in KEY_
>>>> name format, you may be able to use evtest as described here:
>>>>
>>>> https://askubuntu.com/questions/1197651/ubuntu-show-what-keys-are-pressed-in-real-time
>>>
>>> There is a wiki page which describes how this is done at:
>>>
>>> https://www.mythtv.org/wiki/HID_Remotes
>>>
>>> That page describes 3 different methods of remapping keycodes. I use the ir-keytable method to map my IR remote to imon-pad communications to the keycodes which a keyboard like device would send. These are remapped in a file in /etc/rc_keymaps  (Fedora).
>>>
>>> If you are running X you can use xev otherwise ev-test to see the keycodes that the keyboard sends. evtest and then the dev/inputX number will list the keycodes that the system knows. My mythbox has no entries for the media volume up/down/mute keys, while my desktop (with Logitech Dinovo media keyboard) maps those as:
>>> Event code 121 (KEY_KPCOMMA)
>>> Event code 122 (KEY_HANGUEL)
>>> Event code 123 (KEY_HANJA)
>>>
>>> There is a very useful page at: https://askubuntu.com/questions/69804/how-do-i-change-the-keymap-of-a-single-device-logitech-presenter
>>>
>>> which tells you how to change the keymap file to add any missing keycodes.
>>>
>>> Good luck.
>>> Geoff
>>
>> Yet another approach:
>> If tools like xev (and maybe showkey although I'm not familiar with that tool) show that the keys are recognize as media keys, you can indeed use the frontend's key mapping editor, Setup->Edit Keys. The problem I suspect you're having is not knowing the correct names for the keys. They are determined by QT and you can find them in the source file:
>> https://code.woboq.org/qt5/qtbase/src/gui/kernel/qkeysequence.cpp.html
>>
>> One example, when you run xev and press the media play key, xev shows it as XF86AudioPlay. Qt maps it to "Media Play" and that's what the frontend will recognize in the key mapping table.
>>
>> HTH
> 
> Actually, in Edit Keys, there is the option to just press the key you
> want to assign.  When you do that with media keys or IR buttons that
> do not match normal keyboard key values, mythfrontend ignores the key
> - it does not see it as a valid key.  That is the problem that seems
> to be happening here.  So you need to use external tools to map the
> key value to a normal keyboard key value that mythfrontend can
> recognise.

All I can say is that media keys on multimedia keyboards and on my remotes and receivers that look like multimedia keyboards work without any external tools mapping those keys to something else. And it's been working that way for me for years. Here are the records from the keybindings table that make it possible.

"Global","PAGETOP","Page to top of list","Q,Media Next","myhost"
"Global","PAGEMIDDLE","Page to middle of list","T,Media Stop","myhost"
"Global","PAGEBOTTOM","Page to bottom of list","Z,Media Previous","myhost"
"Browser","ZOOMIN","Zoom in on browser window",">,.,Ctrl+F,Media Fast Forward","myhost"
"Browser","ZOOMOUT","Zoom out on browser window",",,<,Ctrl+B,Media Rewind","myhost"
"Browser","NEXTLINK","Move selection to next link","Q,End,Media Next","myhost"
"Browser","PREVIOUSLINK","Move selection to previous link","Z,Home,Media Previous","myhost"
"TV Frontend","PLAYBACK","Play Program","P,Media Play","myhost"
"TV Frontend","DAYLEFT","Page the program guide back one day","Z,Home,Media Previous","myhost"
"TV Frontend","DAYRIGHT","Page the program guide forward one day","Q,End,Media Next","myhost"
"TV Frontend","PAGELEFT","Page the program guide left",",,<,Ctrl+B,Media Rewind","myhost"
"TV Frontend","PAGERIGHT","Page the program guide right",">,.,Ctrl+F,Media Fast Forward","myhost"
"TV Playback","FFWDSTICKY","Fast Forward (Sticky) or Forward one second while paused",">,.,Ctrl+F,Media Fast Forward","myhost"
"TV Playback","RWNDSTICKY","Rewind (Sticky) or Rewind one second while paused",",,<,Ctrl+B,Media Rewind","myhost"
"TV Playback","SKIPCOMMERCIAL","Skip Commercial","Q,End,Media Next","myhost"
"TV Playback","SKIPCOMMBACK","Skip Commercial (Reverse)","Z,Home,Media Previous","myhost"
"TV Playback","TOGGLECC","Toggle any captions","T,Media Stop","myhost"
"TV Playback","PLAY","Play","Ctrl+P,Media Play,;","myhost"
"TV Editing","CLEARMAP","Clear editing cut points","C,Z,Home,Media Previous","myhost"
"TV Editing","LOADCOMMSKIP","Load cuts from detected commercials","Q,End,Media Next","myhost"
"TV Editing","BIGJUMPREW","Jump back 10x the normal amount",",,<,Ctrl+B,Media Rewind","myhost"
"TV Editing","BIGJUMPFWD","Jump forward 10x the normal amount",">,.,Ctrl+F,Media Fast Forward","myhost"
"Teletext Menu","TOGGLETT","Toggle Teletext","T,Media Stop","myhost"

So, unless mythtv-light is not using QT to get keyboard input, I don't see why this wouldn't work for Hakon.


More information about the mythtv-users mailing list