This is an old revision of the document!


Scripting Function Keys

Many input devices nowadays include dedicated function keys for particular (usually hardware-related) functions, such as volume adjustment, brightness adjustment, power off, etc. Batocera supports the scripting of these function keys to certain commands, and includes most common function keys for various platforms. But it is possible that your device in particular doesn't have these coded in yet, or you simply want to change what the function key does. This can be achieved via the configuration of triggerhappy.

You can create a custom mapping that is overlaid on top of the default function keys.

  1. Connect to your Batocera machine either by SSH or by WinSCP (any method that lets you see the root of the system).
  2. Navigate to /etc/triggerhappy/triggers.d/ and find the multimedia_key_<device name>.conf for your device.
  3. Copy the contents of that to /userdata/system/configs/multimedia_keys.conf.
  4. Make your appropriate edits to it and save it.

Your custom multimedia_keys.conf file's configuration will be overlaid on top of the default profile. If there are conflicting settings, the one in /userdata/system/configs/multimedia_keys.conf will take priority.

If you want to customize hotkeys, just create a file in your data here :

/userdata/system/configs/multimedia_keys.conf

It can be empty, but in this case, it will do nothing. The best is to start for the current config and modifiying it.

So, for example on odroid go super, to copy the current configuration and modify it, for example to enable suspend mode,

  • copy /etc/triggerhappy/triggers.d/multimedia_keys_Hardkernel_ODROID_GO3.conf to /userdata/system/configs/multimedia_keys.conf
  • then modify the line :
KEY_POWER       1               /sbin/shutdown -h now

by

KEY_POWER       1               /usr/sbin/pm-suspend
  • reboot.

How to guess which value correspond to which button ?

Easy.

  • Run in a terminal the command :
evtest
  • choose your controller
  • press the button
Event: time 1614795871.549381, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 0
  • In this example, the button i pressed on my keyboard was : KEY_SYSRQ

Default multimedia keys mapping is configured in one file here : /etc/triggerhappy/triggers.d.

There are several files, depending on your board, but only one is used at once.

It is generally multimedia_keys.conf, but on some boards like odroid go advance or super, there is a specific file, mainly to manage the extra actions.

  • scripting_function_keys.1638248068.txt.gz
  • Last modified: 5 years ago
  • by atari