summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/wayland-protocols/include/protocol/gaming-input-unstable-v2-server-protocol.h
blob: eeba3aeb93b5fd9d6fda6a4c062eb03139e2183c (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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/* Generated by wayland-scanner 1.13.0 */

#ifndef GAMING_INPUT_UNSTABLE_V2_SERVER_PROTOCOL_H
#define GAMING_INPUT_UNSTABLE_V2_SERVER_PROTOCOL_H

#include <stdint.h>
#include <stddef.h>
#include "wayland-server.h"

#ifdef  __cplusplus
extern "C" {
#endif

struct wl_client;
struct wl_resource;

/**
 * @page page_gaming_input_unstable_v2 The gaming_input_unstable_v2 protocol
 * @section page_ifaces_gaming_input_unstable_v2 Interfaces
 * - @subpage page_iface_zcr_gaming_input_v2 - extends wl_seat with gaming input devices
 * - @subpage page_iface_zcr_gaming_seat_v2 - controller object for all gaming devices of a seat
 * - @subpage page_iface_zcr_gamepad_v2 - gamepad input device
 * @section page_copyright_gaming_input_unstable_v2 Copyright
 * <pre>
 *
 * Copyright 2016 The Chromium Authors.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 * </pre>
 */
struct wl_seat;
struct zcr_gamepad_v2;
struct zcr_gaming_input_v2;
struct zcr_gaming_seat_v2;

/**
 * @page page_iface_zcr_gaming_input_v2 zcr_gaming_input_v2
 * @section page_iface_zcr_gaming_input_v2_desc Description
 *
 * A global interface to provide gaming input devices for a given seat.
 *
 * Currently only gamepad devices are supported.
 *
 * Warning! The protocol described in this file is experimental and
 * backward incompatible changes may be made. Backward compatible changes
 * may be added together with the corresponding uinterface version bump.
 * Backward incompatible changes are done by bumping the version number in
 * the protocol and uinterface names and resetting the interface version.
 * Once the protocol is to be declared stable, the 'z' prefix and the
 * version number in the protocol and interface names are removed and the
 * interface version number is reset.
 * @section page_iface_zcr_gaming_input_v2_api API
 * See @ref iface_zcr_gaming_input_v2.
 */
/**
 * @defgroup iface_zcr_gaming_input_v2 The zcr_gaming_input_v2 interface
 *
 * A global interface to provide gaming input devices for a given seat.
 *
 * Currently only gamepad devices are supported.
 *
 * Warning! The protocol described in this file is experimental and
 * backward incompatible changes may be made. Backward compatible changes
 * may be added together with the corresponding uinterface version bump.
 * Backward incompatible changes are done by bumping the version number in
 * the protocol and uinterface names and resetting the interface version.
 * Once the protocol is to be declared stable, the 'z' prefix and the
 * version number in the protocol and interface names are removed and the
 * interface version number is reset.
 */
extern const struct wl_interface zcr_gaming_input_v2_interface;
/**
 * @page page_iface_zcr_gaming_seat_v2 zcr_gaming_seat_v2
 * @section page_iface_zcr_gaming_seat_v2_desc Description
 *
 * An object that provides access to all the gaming devices of a seat.
 * When a gamepad is connected, the compositor will send gamepad_added event.
 * @section page_iface_zcr_gaming_seat_v2_api API
 * See @ref iface_zcr_gaming_seat_v2.
 */
/**
 * @defgroup iface_zcr_gaming_seat_v2 The zcr_gaming_seat_v2 interface
 *
 * An object that provides access to all the gaming devices of a seat.
 * When a gamepad is connected, the compositor will send gamepad_added event.
 */
extern const struct wl_interface zcr_gaming_seat_v2_interface;
/**
 * @page page_iface_zcr_gamepad_v2 zcr_gamepad_v2
 * @section page_iface_zcr_gamepad_v2_desc Description
 *
 * The zcr_gamepad_v2 interface represents one or more gamepad input devices,
 * which are reported as a normalized 'Standard Gamepad' as it is specified
 * by the W3C Gamepad API at: https://w3c.github.io/gamepad/#remapping
 * @section page_iface_zcr_gamepad_v2_api API
 * See @ref iface_zcr_gamepad_v2.
 */
/**
 * @defgroup iface_zcr_gamepad_v2 The zcr_gamepad_v2 interface
 *
 * The zcr_gamepad_v2 interface represents one or more gamepad input devices,
 * which are reported as a normalized 'Standard Gamepad' as it is specified
 * by the W3C Gamepad API at: https://w3c.github.io/gamepad/#remapping
 */
extern const struct wl_interface zcr_gamepad_v2_interface;

/**
 * @ingroup iface_zcr_gaming_input_v2
 * @struct zcr_gaming_input_v2_interface
 */
struct zcr_gaming_input_v2_interface {
	/**
	 * get a gaming seat
	 *
	 * Get a gaming seat object for a given seat. Gaming seat
	 * provides access to gaming devices
	 */
	void (*get_gaming_seat)(struct wl_client *client,
				struct wl_resource *resource,
				uint32_t gaming_seat,
				struct wl_resource *seat);
	/**
	 * release the memory for the gaming input object
	 *
	 * Destroy gaming_input object. Objects created from this object
	 * are unaffected and should be destroyed separately.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
};


/**
 * @ingroup iface_zcr_gaming_input_v2
 */
#define ZCR_GAMING_INPUT_V2_GET_GAMING_SEAT_SINCE_VERSION 1
/**
 * @ingroup iface_zcr_gaming_input_v2
 */
#define ZCR_GAMING_INPUT_V2_DESTROY_SINCE_VERSION 1

/**
 * @ingroup iface_zcr_gaming_seat_v2
 * @struct zcr_gaming_seat_v2_interface
 */
struct zcr_gaming_seat_v2_interface {
	/**
	 * release the memory for the gaming seat object
	 *
	 * Destroy gaming_seat object. Objects created from this object
	 * are unaffected and should be destroyed separately.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
};

#define ZCR_GAMING_SEAT_V2_GAMEPAD_ADDED 0

/**
 * @ingroup iface_zcr_gaming_seat_v2
 */
#define ZCR_GAMING_SEAT_V2_GAMEPAD_ADDED_SINCE_VERSION 1

/**
 * @ingroup iface_zcr_gaming_seat_v2
 */
#define ZCR_GAMING_SEAT_V2_DESTROY_SINCE_VERSION 1

/**
 * @ingroup iface_zcr_gaming_seat_v2
 * Sends an gamepad_added event to the client owning the resource.
 * @param resource_ The client's resource
 * @param gamepad new connected gamepad
 */
static inline void
zcr_gaming_seat_v2_send_gamepad_added(struct wl_resource *resource_, struct wl_resource *gamepad)
{
	wl_resource_post_event(resource_, ZCR_GAMING_SEAT_V2_GAMEPAD_ADDED, gamepad);
}

#ifndef ZCR_GAMEPAD_V2_BUTTON_STATE_ENUM
#define ZCR_GAMEPAD_V2_BUTTON_STATE_ENUM
/**
 * @ingroup iface_zcr_gamepad_v2
 * physical button state
 *
 * Describes the physical state of a button that produced the button
 * event.
 */
enum zcr_gamepad_v2_button_state {
	/**
	 * the button is not pressed
	 */
	ZCR_GAMEPAD_V2_BUTTON_STATE_RELEASED = 0,
	/**
	 * the button is pressed
	 */
	ZCR_GAMEPAD_V2_BUTTON_STATE_PRESSED = 1,
};
#endif /* ZCR_GAMEPAD_V2_BUTTON_STATE_ENUM */

/**
 * @ingroup iface_zcr_gamepad_v2
 * @struct zcr_gamepad_v2_interface
 */
struct zcr_gamepad_v2_interface {
	/**
	 * destroy gamepad object
	 *
	 * 
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
};

#define ZCR_GAMEPAD_V2_REMOVED 0
#define ZCR_GAMEPAD_V2_AXIS 1
#define ZCR_GAMEPAD_V2_BUTTON 2
#define ZCR_GAMEPAD_V2_FRAME 3

/**
 * @ingroup iface_zcr_gamepad_v2
 */
#define ZCR_GAMEPAD_V2_REMOVED_SINCE_VERSION 1
/**
 * @ingroup iface_zcr_gamepad_v2
 */
#define ZCR_GAMEPAD_V2_AXIS_SINCE_VERSION 1
/**
 * @ingroup iface_zcr_gamepad_v2
 */
#define ZCR_GAMEPAD_V2_BUTTON_SINCE_VERSION 1
/**
 * @ingroup iface_zcr_gamepad_v2
 */
#define ZCR_GAMEPAD_V2_FRAME_SINCE_VERSION 1

/**
 * @ingroup iface_zcr_gamepad_v2
 */
#define ZCR_GAMEPAD_V2_DESTROY_SINCE_VERSION 1

/**
 * @ingroup iface_zcr_gamepad_v2
 * Sends an removed event to the client owning the resource.
 * @param resource_ The client's resource
 */
static inline void
zcr_gamepad_v2_send_removed(struct wl_resource *resource_)
{
	wl_resource_post_event(resource_, ZCR_GAMEPAD_V2_REMOVED);
}

/**
 * @ingroup iface_zcr_gamepad_v2
 * Sends an axis event to the client owning the resource.
 * @param resource_ The client's resource
 * @param time timestamp with millisecond granularity
 * @param axis axis that produced this event
 * @param value new value of axis
 */
static inline void
zcr_gamepad_v2_send_axis(struct wl_resource *resource_, uint32_t time, uint32_t axis, wl_fixed_t value)
{
	wl_resource_post_event(resource_, ZCR_GAMEPAD_V2_AXIS, time, axis, value);
}

/**
 * @ingroup iface_zcr_gamepad_v2
 * Sends an button event to the client owning the resource.
 * @param resource_ The client's resource
 * @param time timestamp with millisecond granularity
 * @param button id of button
 * @param state digital state of the button
 * @param analog analog value of the button
 */
static inline void
zcr_gamepad_v2_send_button(struct wl_resource *resource_, uint32_t time, uint32_t button, uint32_t state, wl_fixed_t analog)
{
	wl_resource_post_event(resource_, ZCR_GAMEPAD_V2_BUTTON, time, button, state, analog);
}

/**
 * @ingroup iface_zcr_gamepad_v2
 * Sends an frame event to the client owning the resource.
 * @param resource_ The client's resource
 * @param time timestamp with millisecond granularity
 */
static inline void
zcr_gamepad_v2_send_frame(struct wl_resource *resource_, uint32_t time)
{
	wl_resource_post_event(resource_, ZCR_GAMEPAD_V2_FRAME, time);
}

#ifdef  __cplusplus
}
#endif

#endif