wiki/gofurther/evdev.md

49 lines
1.4 KiB
Markdown
Raw Normal View History

2022-08-13 00:26:05 +00:00
---
title: Share an input device with a guest using evdev
description:
published: true
2023-02-08 19:09:04 +00:00
date: 2023-02-08T19:09:01.244Z
2022-08-13 00:26:05 +00:00
tags:
editor: markdown
dateCreated: 2022-08-13T00:26:02.801Z
---
2022-08-25 10:40:46 +00:00
# Share an input device
2022-08-13 00:26:05 +00:00
2023-02-08 19:09:04 +00:00
In this section, we focus on sharing a device locally.
2023-02-08 18:57:34 +00:00
## Virtio-input
2022-08-25 10:40:46 +00:00
2023-02-08 19:09:04 +00:00
> Input grabbing on Wayland doesn't currently work as expected using Spice or VNC. Destkop environments based on the X session manager may work better.
2023-02-08 18:57:34 +00:00
{.is-warning}
2022-08-25 10:40:46 +00:00
## Event device
2023-02-08 18:57:34 +00:00
Libvirt offers a very low-latency way to share an input device device with a local virtual machine, using the linux evdev event interface.
2022-08-25 10:40:46 +00:00
Event device or simply `evdev` is a generic input event interface that is part of the Linux kernel.
2022-08-25 20:26:04 +00:00
The following is an XML snippet example for sharing a mouse and a keyboard.
2022-08-13 00:26:05 +00:00
```
<input type='evdev'>
<source dev='/dev/input/by-path/platform-i8042-serio-1-event-mouse/'>
</input>
<input type='evdev'>
<source dev='/dev/input/by-path/platform-i8042-serio-0-event-kbd' grab='all' repeat='on'/>
</input>
2022-08-25 10:40:46 +00:00
```
Replace the `platform-i8042-serio-1-event-mouse` value with the value under `/dev/input/by-path/*` or `/dev/input/by-id/*`
2022-08-25 20:26:04 +00:00
If there are multiple possible options, the input device has to have `event` in the name.
2022-08-25 10:40:46 +00:00
2022-08-25 20:26:04 +00:00
```
2023-02-08 18:58:01 +00:00
# cat /dev/input/by-path/pci-0000:09:00.0-event-mouse
2022-08-25 20:26:04 +00:00
```
2022-08-25 10:40:46 +00:00
2022-08-25 20:26:04 +00:00
```
<EFBFBD><EFBFBD>c $
2023-02-08 18:58:01 +00:00
<EFBFBD><EFBFBD>c<EFBFBD><EFBFBD><EFBFBD>c<EFBFBD><EFBFBD><EFBFBD>c<EFBFBD>$<24><>c<EFBFBD>$<24><><63><D78F><63><D78F>c
2022-08-25 20:26:04 +00:00
```