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/11/30 05:54] – major cleanup (wip) atariscripting_function_keys [2022/07/10 07:48] (current) – [Create a custom mapping] atari
Line 1: Line 1:
 ====== Scripting Function Keys ====== ====== 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]].+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 does. This can be achieved via the configuration of triggerhappy.
  
 ===== Create a custom mapping ===== ===== Create a custom mapping =====
  
-You can create a custom mapping that is overlaid on top of the [[#|default function keys]].+To create a custom configuration that is overlaid on top of the [[#what_is_the_default_mapping_|default function keys]]:
  
 +  - 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'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).   - 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.   - Navigate to ''/etc/triggerhappy/triggers.d/'' and find the ''multimedia_key_<device name>.conf'' for your device.
-  - Copy the contents of that to ''/userdata/system/configs/multimedia_keys.conf''.+</WRAP> 
 +  - Copy the file to ''/userdata/system/configs/multimedia_keys.conf''.
   - Make your appropriate edits to it and save it.   - 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. 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.
  
-===== Create my own mapping ===== +For example:
-If you want to customize hotkeys, just create a file in your data here :+
  
-  /userdata/system/configs/multimedia_keys.conf+<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 off, switch 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>
  
-It can be emptybut in this case, it will do nothing. +You could also check for various hardware statessuch as if there is a device plugged into the headphone jack:
-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> 
 +SW_HEADPHONE_INSERT 0           batocera-audio set headphone 
 +SW_HEADPHONE_INSERT 1           batocera-audio set speakers 
 +</file>
  
-   * copy /etc/triggerhappy/triggers.d/multimedia_keys_Hardkernel_ODROID_GO3.conf to /userdata/system/configs/multimedia_keys.conf +Reboot the device to apply the new triggerhappy configuration.
-   * then modify the line :+
  
-  KEY_POWER                     /sbin/shutdown -h now+===== Identifying key names =====
  
-by+Open a terminal and type the following command:
  
-  KEY_POWER                     /usr/sbin/pm-suspend+<code> 
 +evtest 
 +</code>
  
-   * reboot.+Then select your intended controller and press the button on your controllerThe detected input will then be displayed like so:
  
-===== Find the mapping key name ===== +<code> 
-How to guess which value correspond to which button ?+Event: time 1614795871.549381, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 
 +</code>
  
-Easy.+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''.
  
-   * Run in a terminal the command :+A list of most existing events can also be found in [[:evmapy#keys|the keys section of the evmapy page]].
  
-  evtest +===== What is the default mapping=====
- +
-   * 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 +
- +
-===== What is the default mapping ===== +
- +
-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.+
  
 +All default configurations are at https://github.com/batocera-linux/batocera.linux/tree/master/package/batocera/core/batocera-triggerhappy/conf, but 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.1638248068.txt.gz
  • Last modified: 2 years ago
  • by atari