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

Håkon Alstadheim hakon at alstadheim.priv.no
Sun Dec 20 11:01:18 UTC 2020


Den 20.12.2020 01:31, skrev Stephen Worthington:
> 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.

Yes, correct :-) . Thanks for pointers from ppl like 
stephen_agent at jsw.gen.nz.  I might also  see about getting mythfrontend 
to run on top of X. At the moment the whole raspberry pi goes down 
without a trace when I try that. Login to mate desktop is ok, but 
launching mythfronend crashes. I used to have mythfrontend able to 
launch on X, but with horrible stuttering, so I did:

- ran the setup according to https://github.com/MikeB2013/pi-utils.git
- some random messing around
- found out I needed to pay attention
- found and set the correct rendering profile
- launched mythfronted from the text console.

Playback is now mostly very smooth, but no X. I think maybe the "random 
messing around"-step was a mistake. :-# . I don't want to start from 
scratch because I had a hell of a time getting the PI to act as a 
bluetooth speaker, which is really neat :-). Don't want to lose that set-up.

If I find a set-up that is nice and tidy and works, I'll try to 
summarize for the record. No promises though.




More information about the mythtv-users mailing list