Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
scripting_function_keys [2021/08/23 11:45] – ↷ Page name changed from customize_hotkeys to scripting_function_keys atariscripting_function_keys [2022/07/10 05:48] (current) – [Create a custom mapping] atari
Line 1: Line 1:
-===== What are hotkeys / multimedia keys ===== +====== Scripting Function Keys ======
-You can map some keyboards button (or button of a board, or any specific button from a controller) +
-to specific actions on your system, like muting the sound or shutting down.+
  
-===== What is the default mapping ===== +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 any key to any command, 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 doesThis can be achieved via the configuration of triggerhappy.
-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.+===== Create a custom mapping =====
  
-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.+To create a custom configuration that is overlaid on top of the [[#what_is_the_default_mapping_|default function keys]]:
  
-===== Create my own mapping ===== +  - Refer to the list of existing configurations at https://github.com/batocera-linux/batocera.linux/tree/master/package/batocera/core/batocera-triggerhappy/conf and place the ones you'd like to edit into a file named ''multimedia_keys.conf''.<WRAP center round tip> 
-If you want to customize hotkeys, just create a file in your data here :+If you'd like to see these files on your local installation: 
 +  - Connect to your Batocera machine either [[access_the_batocera_via_ssh|by SSH]] or by [[WinSCP]] (any method that lets you see the root of the system). 
 +  - Navigate to ''/etc/triggerhappy/triggers.d/'' and find the ''multimedia_key_<device name>.conf'' for your device. 
 +</WRAP> 
 +  - Copy the file to ''/userdata/system/configs/multimedia_keys.conf''
 +  - Make your appropriate edits to it and save it.
  
-  /userdata/system/configs/multimedia_keys.conf+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.
  
-It can be empty, but in this case, it will do nothing. +For example:
-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,+<file bash multimedia_keys.conf> 
 +BTN_TRIGGER_HAPPY3 1            batocera-brightness - 5 
 +BTN_TRIGGER_HAPPY4 1            batocera-brightness + 5 
 +KEY_MUTE 1                      batocera-audio setSystemVolume mute-toggle 
 +KEY_VOLUMEUP 1                  batocera-audio setSystemVolume +5 
 +KEY_VOLUMEDOWN 1                batocera-audio setSystemVolume -5 
 +# power offswitch command to "/usr/sbin/pm-suspend" to go into suspend mode instead (suspend mode is currently unused in Batocera) 
 +KEY_POWER                     /sbin/shutdown -h now 
 +# display some information on X displays 
 +KEY_F2          1               /usr/bin/batocera-info --short | HOME=/userdata/system XAUTHORITY=/var/lib/.Xauthority DISPLAY=:0.0 osd_cat -f -*-*-bold-*-*-*-38-120-*-*-*-*-*-* -cred -s 3 -d 4 
 +</file>
  
-   * copy /etc/triggerhappy/triggers.d/multimedia_keys_Hardkernel_ODROID_GO3.conf to /userdata/system/configs/multimedia_keys.conf +You could also check for various hardware states, such as if there is a device plugged into the headphone jack:
-   * then modify the line :+
  
-  KEY_POWER                     /sbin/shutdown -h now+<file bash multimedia_keys.conf> 
 +SW_HEADPHONE_INSERT 0           batocera-audio set headphone 
 +SW_HEADPHONE_INSERT           batocera-audio set speakers 
 +</file>
  
-by+Reboot the device to apply the new triggerhappy configuration.
  
-  KEY_POWER                     /usr/sbin/pm-suspend+===== Identifying key names =====
  
-   * reboot.+Open a terminal and type the following command:
  
-===== Find the mapping key name ===== +<code> 
-How to guess which value correspond to which button ?+evtest 
 +</code>
  
-Easy.+Then select your intended controller and press the button on your controllerThe detected input will then be displayed like so:
  
-   * Run in a terminal the command :+<code> 
 +Eventtime 1614795871.549381, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 0 
 +</code>
  
-  evtest+Look for the key name in parenthesis and its value when depressed after the "code" number. In this example, the key name would be ''KEY_SYSRQ'' and its value would be ''0''.
  
-   * choose your controller +A list of most existing events can also be found in [[:evmapy#keys|the keys section of the evmapy page]].
-   * press the button+
  
-  Event: time 1614795871.549381, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 0+===== What is the default mapping? =====
  
-   * In this example, the button i pressed on my keyboard was : KEY_SYSRQ+All default configurations are at https://github.com/batocera-linux/batocera.linux/tree/master/package/batocera/core/batocera-triggerhappy/confbut in case either you can't figure out which one applies to your machine or you'd just like some security you can check the file on your machine at ''/etc/triggerhappy/triggers.d''.
  
  • scripting_function_keys.1629719129.txt.gz
  • Last modified: 5 years ago
  • by atari