summaryrefslogtreecommitdiffstats
path: root/include/VBox/RemoteDesktop/VRDEInput.h
blob: 378520ec944c34bb46959bd6429a8f589258f437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/** @file
 * VBox Remote Desktop Extension (VRDE) - Input interface.
 */

/*
 * Copyright (C) 2013-2022 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */

#ifndef VBOX_INCLUDED_RemoteDesktop_VRDEInput_h
#define VBOX_INCLUDED_RemoteDesktop_VRDEInput_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <VBox/RemoteDesktop/VRDE.h>

/*
 * Interface for receiving input events from the client.
 */

/* All structures in this file are packed.
 * Everything is little-endian.
 */
#pragma pack(1)

/*
 * The application interface between VirtualBox and the VRDE server.
 */

#define VRDE_INPUT_INTERFACE_NAME "VRDE::INPUT"

/*
 * Supported input methods.
 */
#define VRDE_INPUT_METHOD_TOUCH 1

/*
 * fu32Flags for VRDEInputSetup
 */
#define VRDE_INPUT_F_ENABLE 1

/* The interface entry points. Interface version 1. */
typedef struct VRDEINPUTINTERFACE
{
    /* The header. */
    VRDEINTERFACEHDR header;

    /* Tell the server that an input method will be used or disabled, etc.
     * VRDECallbackInputSetup will be called with a result.
     *
     * @param hServer   The VRDE server instance.
     * @param u32Method The method VRDE_INPUT_METHOD_*.
     * @param fu32Flags What to do with the method VRDE_INPUT_F_*.
     * @param pvSetup   Method specific parameters (optional).
     * @param cbSetup   Size of method specific parameters (optional).
     */
    DECLR3CALLBACKMEMBER(void, VRDEInputSetup, (HVRDESERVER hServer,
                                                uint32_t u32Method,
                                                uint32_t fu32Flags,
                                                const void *pvSetup,
                                                uint32_t cbSetup));
} VRDEINPUTINTERFACE;


/* Interface callbacks. */
typedef struct VRDEINPUTCALLBACKS
{
    /* The header. */
    VRDEINTERFACEHDR header;

    /* VRDPInputSetup async result.
     *
     * @param pvCallback The callbacks context specified in VRDEGetInterface.
     * @param rcSetup    The result code of the request.
     * @param u32Method  The method VRDE_INPUT_METHOD_*.
     * @param pvResult   The result information.
     * @param cbResult   The size of buffer pointed by pvResult.
     */
    DECLR3CALLBACKMEMBER(void, VRDECallbackInputSetup,(void *pvCallback,
                                                      int rcRequest,
                                                      uint32_t u32Method,
                                                      const void *pvResult,
                                                      uint32_t cbResult));

    /* Input event.
     *
     * @param pvCallback The callbacks context specified in VRDEGetInterface.
     * @param u32Method  The method VRDE_INPUT_METHOD_*.
     * @param pvEvent    The event data.
     * @param cbEvent    The size of buffer pointed by pvEvent.
     */
    DECLR3CALLBACKMEMBER(void, VRDECallbackInputEvent,(void *pvCallback,
                                                       uint32_t u32Method,
                                                       const void *pvEvent,
                                                       uint32_t cbEvent));
} VRDEINPUTCALLBACKS;


/*
 * Touch input definitions VRDE_INPUT_METHOD_TOUCH.
 */

/* pvResult is not used */

/* RDPINPUT_HEADER */
typedef struct VRDEINPUTHEADER
{
    uint16_t u16EventId;
    uint32_t u32PDULength;
} VRDEINPUTHEADER;

/* VRDEINPUTHEADER::u16EventId */
#define VRDEINPUT_EVENTID_SC_READY                 0x0001
#define VRDEINPUT_EVENTID_CS_READY                 0x0002
#define VRDEINPUT_EVENTID_TOUCH                    0x0003
#define VRDEINPUT_EVENTID_SUSPEND_TOUCH            0x0004
#define VRDEINPUT_EVENTID_RESUME_TOUCH             0x0005
#define VRDEINPUT_EVENTID_DISMISS_HOVERING_CONTACT 0x0006

/* RDPINPUT_SC_READY_PDU */
typedef struct VRDEINPUT_SC_READY_PDU
{
    VRDEINPUTHEADER header;
    uint32_t u32ProtocolVersion;
} VRDEINPUT_SC_READY_PDU;

#define VRDEINPUT_PROTOCOL_V1 0x00010000
#define VRDEINPUT_PROTOCOL_V101 0x00010001

/* RDPINPUT_CS_READY_PDU */
typedef struct VRDEINPUT_CS_READY_PDU
{
    VRDEINPUTHEADER header;
    uint32_t u32Flags;
    uint32_t u32ProtocolVersion;
    uint16_t u16MaxTouchContacts;
} VRDEINPUT_CS_READY_PDU;

#define VRDEINPUT_READY_FLAGS_SHOW_TOUCH_VISUALS 0x00000001
#define VRDEINPUT_READY_FLAGS_DISABLE_TIMESTAMP_INJECTION 0x00000002

/* RDPINPUT_CONTACT_DATA */
typedef struct VRDEINPUT_CONTACT_DATA
{
    uint8_t u8ContactId;
    uint16_t u16FieldsPresent;
    int32_t i32X;
    int32_t i32Y;
    uint32_t u32ContactFlags;
    int16_t i16ContactRectLeft;
    int16_t i16ContactRectTop;
    int16_t i16ContactRectRight;
    int16_t i16ContactRectBottom;
    uint32_t u32Orientation;
    uint32_t u32Pressure;
} VRDEINPUT_CONTACT_DATA;

#define VRDEINPUT_CONTACT_DATA_CONTACTRECT_PRESENT 0x0001
#define VRDEINPUT_CONTACT_DATA_ORIENTATION_PRESENT 0x0002
#define VRDEINPUT_CONTACT_DATA_PRESSURE_PRESENT 0x0004

#define VRDEINPUT_CONTACT_FLAG_DOWN 0x0001
#define VRDEINPUT_CONTACT_FLAG_UPDATE 0x0002
#define VRDEINPUT_CONTACT_FLAG_UP 0x0004
#define VRDEINPUT_CONTACT_FLAG_INRANGE 0x0008
#define VRDEINPUT_CONTACT_FLAG_INCONTACT 0x0010
#define VRDEINPUT_CONTACT_FLAG_CANCELED 0x0020

/* RDPINPUT_TOUCH_FRAME */
typedef struct VRDEINPUT_TOUCH_FRAME
{
    uint16_t u16ContactCount;
    uint64_t u64FrameOffset;
    VRDEINPUT_CONTACT_DATA aContacts[1];
} VRDEINPUT_TOUCH_FRAME;

/* RDPINPUT_TOUCH_EVENT_PDU */
typedef struct VRDEINPUT_TOUCH_EVENT_PDU
{
    VRDEINPUTHEADER header;
    uint32_t u32EncodeTime;
    uint16_t u16FrameCount;
    VRDEINPUT_TOUCH_FRAME aFrames[1];
} VRDEINPUT_TOUCH_EVENT_PDU;

/* RDPINPUT_SUSPEND_TOUCH_PDU */
typedef struct VRDEINPUT_SUSPEND_TOUCH_PDU
{
    VRDEINPUTHEADER header;
} VRDEINPUT_SUSPEND_TOUCH_PDU;

/* RDPINPUT_RESUME_TOUCH_PDU */
typedef struct VRDEINPUT_RESUME_TOUCH_PDU
{
    VRDEINPUTHEADER header;
} VRDEINPUT_RESUME_TOUCH_PDU;

/* RDPINPUT_DISMISS_HOVERING_CONTACT_PDU */
typedef struct VRDEINPUT_DISMISS_HOVERING_CONTACT_PDU
{
    VRDEINPUTHEADER header;
    uint8_t u8ContactId;
} VRDEINPUT_DISMISS_HOVERING_CONTACT_PDU;

#pragma pack()

#endif /* !VBOX_INCLUDED_RemoteDesktop_VRDEInput_h */