Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: third_party/wayland-protocols/include/protocol/gamepads-unstable-v1-client-protocol.h

Issue 2093803002: wayland-protocols: Add gaming-input-unstable-v1 protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@migration
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The Chromium Authors.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 #ifndef GAMEPADS_UNSTABLE_V1_CLIENT_PROTOCOL_H
25 #define GAMEPADS_UNSTABLE_V1_CLIENT_PROTOCOL_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #include <stdint.h>
32 #include <stddef.h>
33 #include "wayland-client.h"
34
35 struct wl_client;
36 struct wl_resource;
37
38 struct zwp_gamepads_v1;
39
40 extern const struct wl_interface zwp_gamepads_v1_interface;
41
42 /**
43 * zwp_gamepads_v1 - gamepad support
44 * @connected: A new gamepad connected
45 * @disconnected: A gamepad disconnected
46 * @axis: Gamepad analog axis changed
47 * @button: Gamepad button changed
48 * @frame: Notifies end of a series of gamepad changes.
49 *
50 * A global interface to notify the client of any gamepads connected to
51 * the server. All gamepads axes and buttons follow the W3C definition of a
52 * 'Standard Gamepad' as specified in:
53 * https://w3c.github.io/gamepad/#remapping
54 */
55 struct zwp_gamepads_v1_listener {
56 /**
57 * connected - A new gamepad connected
58 * @id: id of the gamepad
59 *
60 * Every gamepad gets an assigned an incrementing id, starting
61 * with 0. This event is called before any other event for the
62 * gamepad will be sent.
63 */
64 void (*connected)(void *data,
65 struct zwp_gamepads_v1 *zwp_gamepads_v1,
66 int32_t id);
67 /**
68 * disconnected - A gamepad disconnected
69 * @id: id of the gamepad
70 *
71 * Called after a gamepad is disconnected, no further events for
72 * this gamepad shall be sent by the server.
73 */
74 void (*disconnected)(void *data,
75 struct zwp_gamepads_v1 *zwp_gamepads_v1,
76 int32_t id);
77 /**
78 * axis - Gamepad analog axis changed
79 * @id: id of the gamepad
80 * @axis: id of axis
81 * @value: new value of axis
82 *
83 * Sent when a gamepad axis changed. Follows the W3C
84 * specification of gamepad axes, which has 2 analog sticks
85 * resulting in 4 axes, which are identified by the axis argument.
86 *
87 * The value is normalized and calibrated, with 0 in the resting
88 * state, -1 at the left/top corner of the stick and 1 at the
89 * right/bottom corner.
90 *
91 * This event should not cause any changes to the client until the
92 * frame event is received.
93 */
94 void (*axis)(void *data,
95 struct zwp_gamepads_v1 *zwp_gamepads_v1,
96 int32_t id,
97 int32_t axis,
98 wl_fixed_t value);
99 /**
100 * button - Gamepad button changed
101 * @id: id of the gamepad
102 * @button: id of button
103 * @pressed: boolean state of the button
104 * @value: new analog value of button
105 *
106 * Sent when a gamepad button state changed. Follows the W3C
107 * specification of gamepad buttons, which has 17 possible buttons.
108 *
109 * All buttons have a boolean state and an analog value. The analog
110 * value is normalized from 0 (not pressed) to 1 (fully pressed),
111 * if a button does not support an analog value, the value will be
112 * derived from the boolean state.
113 *
114 * This event should not cause any changes to the client until the
115 * frame event is received.
116 */
117 void (*button)(void *data,
118 struct zwp_gamepads_v1 *zwp_gamepads_v1,
119 int32_t id,
120 int32_t button,
121 int32_t pressed,
122 wl_fixed_t value);
123 /**
124 * frame - Notifies end of a series of gamepad changes.
125 * @time: timestamp with millisecond granularity
126 *
127 * Sent after a series of axis and button events that logically
128 * belong together.
129 */
130 void (*frame)(void *data,
131 struct zwp_gamepads_v1 *zwp_gamepads_v1,
132 uint32_t time);
133 };
134
135 static inline int
136 zwp_gamepads_v1_add_listener(struct zwp_gamepads_v1 *zwp_gamepads_v1,
137 const struct zwp_gamepads_v1_listener *listener, vo id *data)
138 {
139 return wl_proxy_add_listener((struct wl_proxy *) zwp_gamepads_v1,
140 (void (**)(void)) listener, data);
141 }
142
143 #define ZWP_GAMEPADS_V1_DESTROY 0
144
145 static inline void
146 zwp_gamepads_v1_set_user_data(struct zwp_gamepads_v1 *zwp_gamepads_v1, void *use r_data)
147 {
148 wl_proxy_set_user_data((struct wl_proxy *) zwp_gamepads_v1, user_data);
149 }
150
151 static inline void *
152 zwp_gamepads_v1_get_user_data(struct zwp_gamepads_v1 *zwp_gamepads_v1)
153 {
154 return wl_proxy_get_user_data((struct wl_proxy *) zwp_gamepads_v1);
155 }
156
157 static inline void
158 zwp_gamepads_v1_destroy(struct zwp_gamepads_v1 *zwp_gamepads_v1)
159 {
160 wl_proxy_marshal((struct wl_proxy *) zwp_gamepads_v1,
161 ZWP_GAMEPADS_V1_DESTROY);
162
163 wl_proxy_destroy((struct wl_proxy *) zwp_gamepads_v1);
164 }
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698