docs: update gofurther/evdev

This commit is contained in:
lukas 2024-05-15 19:20:17 +00:00
parent eae02738f7
commit dcec5c96d8

View File

@ -2,7 +2,7 @@
title: Share an input device with a guest using evdev
description:
published: true
date: 2023-05-13T16:00:21.759Z
date: 2024-05-15T19:20:16.023Z
tags:
editor: markdown
dateCreated: 2022-08-13T00:26:02.801Z
@ -10,20 +10,26 @@ dateCreated: 2022-08-13T00:26:02.801Z
# Share an input device
In this section, we focus on sharing a locally attached input device with a guest virtual machine.
In this section, we'll explore how to share a locally attached input device with a guest virtual machine.
## Using Evdev
## With evdev
Since version 7.4.0, Libvirt added a low-latency local-only way to share an input device with a guest, using the [Linux evdev event interface](https://www.kernel.org/doc/html/latest/input/input.html?highlight=evdev#evdev).
As of libvirt version 7.4.0, the [Linux evdev event interface](https://www.kernel.org/doc/html/latest/input/input.html?highlight=evdev#evdev) can be used to share an input device physically attached to the host with a guest, in a low-latency manner.
### Configuration
### Preparation
- List input devices based on their identification, only listing those with an *event* in their name and excluding these with *if*:
Before sharing an input device, follow these steps:
- List available input devices on your host system, excluding those containing `if` in their name, including those containing `event` in their name:
```
ls /dev/input/by-id/* | grep event | grep -v if
```
This command should output the names of eligible devices.
Example output:
```
/dev/input/by-id/usb-Corsair_CORSAIR_HARPOON_RGB_PRO_Gaming_Mouse_1902B02BAF5E04655DEB612AF5001C05-event-mouse
/dev/input/by-id/usb-Logitech_G513_RGB_MECHANICAL_GAMING_KEYBOARD_156930783132-event-kbd
@ -31,20 +37,24 @@ ls /dev/input/by-id/* | grep event | grep -v if
/dev/input/by-id/usb-Logitech_USB_Optical_Mouse-event-mouse
```
- Make sure that the correct one is selected by registering its inputs in the console:
- Make sure that the correct one is selected by registering its inputs in your console:
```
cat /dev/input/by-id/usb-Logitech_G513_RGB_MECHANICAL_GAMING_KEYBOARD_156930783132-event-kbd
```
- Clicking or typing on the device you wish to share should display gibberish characters on the screen:
This step ensures you're working with the desired input device.
- Test the device by interacting with it on the host system. You should see gibberish characters displayed on your screen:
```
<EFBFBD><EFBFBD>c $
<EFBFBD><EFBFBD>c<EFBFBD><EFBFBD><EFBFBD>c<EFBFBD><EFBFBD><EFBFBD>c<EFBFBD>$<24><>c<EFBFBD>$<24><><63><D78F><63><D78F>c
```
- Add the following snippet to the XML domain definition of an existing virtual machine, inside the `<device>` section:
### Adding the input device to your virtual machine
- To share the input device with your virtual machine, add the following XML snippet to its domain definition (inside the <device> section):
```
<input type='evdev'>
@ -54,6 +64,8 @@ cat /dev/input/by-id/usb-Logitech_G513_RGB_MECHANICAL_GAMING_KEYBOARD_1569307831
### Usage
Once the virtual machine is started, the input device will be captured by the guest system.
> Press <kbd>Left Ctrl + Right Ctrl</kbd> simultaneously to switch your devices between the guest and the host.
{.is-info}