1# Add mouse & keyboard
2device add my-mouse /dev/input/by-id/usb-MyCoolMouse-if01-event-mouse
3device add my-kbd /dev/input/by-id/usb-MyCoolKeyboard-event-kbd
4
5# Add my the laptop toutput:
6output add laptop exec:ssh myuser@mylaptop netevent create
7
8# Create local device clones, with recognizable names
9device rename my-mouse vm0-mouse
10device rename my-kbd vm0-kbd
11# Run a 'create' in the background (--daemon) so devices don't vanish if the
12# main daemon is stopped (since qemu's '-object input-linux' won't find it
13# again at runtime automatically, although we could instead send hmp commands
14# to re-add them at startup as an alternative setup)
15# Since we want to be able to reconnect, let it use a socket (--listen=@vm0),
16# tell it to accept new connections after EOF (--on-close=accept) and that new
17# connections should simply resume existing input devices (--duplicates=resume)
18# and finally that it should try to connect to an already existing instance
19# (--connect) before starting a new one.
20output add vm0 exec:netevent create --duplicates=resume --on-close=accept --listen=@vm0 --connect --daemonize
21# Afterwards we can reset the names, but this is optional as it only affects
22# netevent's internal state of the device names used when adding new outputs.
23device reset-name my-mouse
24device reset-name my-kbd
25
26# Add hotkeys to switch between host, laptop and the VM
27hotkey add my-kbd key:188:1 use vm0\; grab on
28hotkey add my-kbd key:188:0 nop
29hotkey add my-kbd key:187:1 use laptop\; grab on
30hotkey add my-kbd key:187:0 nop
31hotkey add my-kbd key:186:1 grab off
32hotkey add my-kbd key:186:0 nop
33