Generating other key combinations

You can create several different key mappings in your file to support different programs. For instance, the events_z80 key mapping would be useful for a spectrum emulator, such as Fuse (browse to http://raspi.tv/2012/how-to-install-fuse-zx-spectrum-emulator-on-raspberry-pi for more details). The events_omx key mappings are suitable for controlling video played through the OMXPlayer using the following command:

omxplayer filename.mp4  

You can get a list of keys supported by omxplayer by using the -k parameter.

Replace the line that defines the events list with a new key mapping, and select different ones by assigning them to events using the following code:

events_dpad = (uinput.KEY_UP,uinput.KEY_DOWN,uinput.KEY_LEFT, ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.