Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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 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 ===== 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). - 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. 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. For example: <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 1 /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> You could also check for various hardware states, such as if there is a device plugged into the headphone jack: <file bash multimedia_keys.conf> SW_HEADPHONE_INSERT 0 batocera-audio set headphone SW_HEADPHONE_INSERT 1 batocera-audio set speakers </file> Reboot the device to apply the new triggerhappy configuration. ===== Identifying key names ===== Open a terminal and type the following command: <code> evtest </code> Then select your intended controller and press the button on your controller. The detected input will then be displayed like so: <code> Event: time 1614795871.549381, type 1 (EV_KEY), code 99 (KEY_SYSRQ), value 0 </code> 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''. A list of most existing events can also be found in [[:evmapy#keys|the keys section of the evmapy page]]. ===== What is the default mapping? ===== 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.txt Last modified: 22 months agoby atari