uidevices_resources/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Resource definitions for UI devices.
5
6#![forbid(unsafe_code)]
7
8use mesh::MeshPayload;
9use vm_resource::Resource;
10use vm_resource::ResourceId;
11use vm_resource::kind::FramebufferHandleKind;
12use vm_resource::kind::KeyboardInputHandleKind;
13use vm_resource::kind::MouseInputHandleKind;
14use vm_resource::kind::VmbusDeviceHandleKind;
15
16/// Handle for a synthetic keyboard device.
17#[derive(MeshPayload)]
18pub struct SynthKeyboardHandle {
19    /// The source of keyboard input.
20    pub source: Resource<KeyboardInputHandleKind>,
21}
22
23impl ResourceId<VmbusDeviceHandleKind> for SynthKeyboardHandle {
24    const ID: &'static str = "keyboard";
25}
26
27/// Handle for a synthetic mouse device.
28#[derive(MeshPayload)]
29pub struct SynthMouseHandle {
30    /// The source of mouse moves and clicks.
31    pub source: Resource<MouseInputHandleKind>,
32}
33
34impl ResourceId<VmbusDeviceHandleKind> for SynthMouseHandle {
35    const ID: &'static str = "mouse";
36}
37
38/// Handle for a synthetic video device.
39#[derive(MeshPayload)]
40pub struct SynthVideoHandle {
41    /// The framebuffer memory to map into the guest for rendering.
42    pub framebuffer: Resource<FramebufferHandleKind>,
43}
44
45impl ResourceId<VmbusDeviceHandleKind> for SynthVideoHandle {
46    const ID: &'static str = "video";
47}