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

R. G. Newbury newbury at mandamus.org
Sat Dec 19 00:01:05 UTC 2020


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












--



More information about the mythtv-users mailing list