XML Modifications

In order to use evdev, we will need to remove the USB controller from our machine. Otherwise, the controller will capture the USB (and input) devices first, thus removing the files from /dev/input/by-id/.

If you really want to pass in USB devices, try utilizing a secondary USB controller for passthrough. Using USB Host Device is not recommended. QEMU’s USB Controllers are non compliant and on OS X / macOS do not provide proper functionality for basics such as iPhone Sync, and the likes.

First, let’s remove the USB controller from the virtual machine.

Now, we need to edit the XML of the virtual machine. Go to Overview > XML, and scroll down until you see the following lines:

<input type="mouse" bus="ps2"/>
<input type="keyboard" bus="ps2"/>

Now, before the mouse and keyboard XML, copy and paste the following XML to add our mouse and keyboard (replacing the paths with the actual paths to the keyboard and mouse):

<input type="evdev">
  <source dev="/dev/input/by-id/(mouse-path)">
</input>
<input type="evdev">
  <source dev="/dev/input/by-id/(keyboard-path)" grab="all" grabToggle="ctrl-ctrl" repeat="on">
</input>

The grabToggle option will be the keyboard shortcut to switch the keyboard and mouse focus from host (Linux) and guest (macOS). This can be configured to the keyboard shortcut that you prefer. By default, it will be 'ctrl-ctrl', but this option can be configured to the following options:

  • 'alt-alt'
  • 'shift-shift'
  • 'meta-meta'
  • 'scrolllock'
  • 'ctrl-scrolllock'

Remember to ‘Apply’ when you finish!

You should then see two ‘Input’ devices in the sidebar!

Sample configuration for the mouse (should be similar for keyboard as well):

Do not boot into DarwinKVM yet! We still need to configure the driver/kext for KB/M!

You can now continue to the next page.


DarwinKVM Docs Version 2.0.0~prerelease
Copyright © 2024 RoyalGraphX. Distributed by a BSD 3-Clause License.
Last Modified: Sat, 7 Sep 2024 18:00:00 CDT