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

Side by Side Diff: third_party/wayland-protocols/include/protocol/gaming-input-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: moved destructor to top of interface Created 4 years, 5 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 GAMING_INPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
25 #define GAMING_INPUT_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_gaming_input_v1;
39 struct zwp_gamepad_v1;
40
41 extern const struct wl_interface zwp_gaming_input_v1_interface;
42 extern const struct wl_interface zwp_gamepad_v1_interface;
43
44 #define ZWP_GAMING_INPUT_V1_GET_GAMEPAD 0
45
46 static inline void
47 zwp_gaming_input_v1_set_user_data(struct zwp_gaming_input_v1 *zwp_gaming_input_v 1, void *user_data)
48 {
49 wl_proxy_set_user_data((struct wl_proxy *) zwp_gaming_input_v1, user_dat a);
50 }
51
52 static inline void *
53 zwp_gaming_input_v1_get_user_data(struct zwp_gaming_input_v1 *zwp_gaming_input_v 1)
54 {
55 return wl_proxy_get_user_data((struct wl_proxy *) zwp_gaming_input_v1);
56 }
57
58 static inline void
59 zwp_gaming_input_v1_destroy(struct zwp_gaming_input_v1 *zwp_gaming_input_v1)
60 {
61 wl_proxy_destroy((struct wl_proxy *) zwp_gaming_input_v1);
62 }
63
64 static inline struct zwp_gamepad_v1 *
65 zwp_gaming_input_v1_get_gamepad(struct zwp_gaming_input_v1 *zwp_gaming_input_v1, struct wl_seat *seat)
66 {
67 struct wl_proxy *id;
68
69 id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_gaming_input_v 1,
70 ZWP_GAMING_INPUT_V1_GET_GAMEPAD, &zwp_gamepad_v1_interf ace, NULL, seat);
71
72 return (struct zwp_gamepad_v1 *) id;
73 }
74
75 #ifndef ZWP_GAMEPAD_V1_GAMEPAD_STATE_ENUM
76 #define ZWP_GAMEPAD_V1_GAMEPAD_STATE_ENUM
77 /**
78 * zwp_gamepad_v1_gamepad_state - connection state
79 * @ZWP_GAMEPAD_V1_GAMEPAD_STATE_OFF: gamepad is off or not connected.
80 * @ZWP_GAMEPAD_V1_GAMEPAD_STATE_ON: gamepad is connected.
81 *
82 *
83 */
84 enum zwp_gamepad_v1_gamepad_state {
85 ZWP_GAMEPAD_V1_GAMEPAD_STATE_OFF = 0,
86 ZWP_GAMEPAD_V1_GAMEPAD_STATE_ON = 1,
87 };
88 #endif /* ZWP_GAMEPAD_V1_GAMEPAD_STATE_ENUM */
89
90 #ifndef ZWP_GAMEPAD_V1_BUTTON_STATE_ENUM
91 #define ZWP_GAMEPAD_V1_BUTTON_STATE_ENUM
92 /**
93 * zwp_gamepad_v1_button_state - physical button state
94 * @ZWP_GAMEPAD_V1_BUTTON_STATE_RELEASED: the button is not pressed
95 * @ZWP_GAMEPAD_V1_BUTTON_STATE_PRESSED: the button is pressed
96 *
97 * Describes the physical state of a button that produced the button
98 * event.
99 */
100 enum zwp_gamepad_v1_button_state {
101 ZWP_GAMEPAD_V1_BUTTON_STATE_RELEASED = 0,
102 ZWP_GAMEPAD_V1_BUTTON_STATE_PRESSED = 1,
103 };
104 #endif /* ZWP_GAMEPAD_V1_BUTTON_STATE_ENUM */
105
106 /**
107 * zwp_gamepad_v1 - gamepad input device
108 * @state_change: state change event
109 * @axis: axis change event
110 * @button: Gamepad button changed
111 * @frame: Notifies end of a series of gamepad changes.
112 *
113 * The zwp_gamepad_v1 interface representsa gamepad input devices, which
114 * is reported as a normalized 'Standard Gamepad' as it is specified by the
115 * W3C Gamepad API at: https://w3c.github.io/gamepad/#remapping
116 */
117 struct zwp_gamepad_v1_listener {
118 /**
119 * state_change - state change event
120 * @state: new state
121 *
122 * Notification that this seat's connection state has changed.
123 */
124 void (*state_change)(void *data,
125 struct zwp_gamepad_v1 *zwp_gamepad_v1,
126 uint32_t state);
127 /**
128 * axis - axis change event
129 * @time: timestamp with millisecond granularity
130 * @axis: axis that produced this event
131 * @value: new value of axis
132 *
133 * Notification of axis change.
134 *
135 * The axis id specifies which axis has changed as defined by the
136 * W3C 'Standard Gamepad'.
137 *
138 * The value is calibrated and normalized to the -1 to 1 range.
139 */
140 void (*axis)(void *data,
141 struct zwp_gamepad_v1 *zwp_gamepad_v1,
142 uint32_t time,
143 uint32_t axis,
144 wl_fixed_t value);
145 /**
146 * button - Gamepad button changed
147 * @time: timestamp with millisecond granularity
148 * @button: id of button
149 * @state: digital state of the button
150 * @analog: analog value of the button
151 *
152 * Notification of button change.
153 *
154 * The button id specifies which button has changed as defined by
155 * the W3C 'Standard Gamepad'.
156 *
157 * A button can have a digital and an analog value. The analog
158 * value is normalized to a 0 to 1 range. If a button does not
159 * provide an analog value, it will be derived from the digital
160 * state.
161 */
162 void (*button)(void *data,
163 struct zwp_gamepad_v1 *zwp_gamepad_v1,
164 uint32_t time,
165 uint32_t button,
166 uint32_t state,
167 wl_fixed_t analog);
168 /**
169 * frame - Notifies end of a series of gamepad changes.
170 * @time: timestamp with millisecond granularity
171 *
172 * Indicates the end of a set of events that logically belong
173 * together. A client is expected to accumulate the data in all
174 * events within the frame before proceeding.
175 */
176 void (*frame)(void *data,
177 struct zwp_gamepad_v1 *zwp_gamepad_v1,
178 uint32_t time);
179 };
180
181 static inline int
182 zwp_gamepad_v1_add_listener(struct zwp_gamepad_v1 *zwp_gamepad_v1,
183 const struct zwp_gamepad_v1_listener *listener, void *data)
184 {
185 return wl_proxy_add_listener((struct wl_proxy *) zwp_gamepad_v1,
186 (void (**)(void)) listener, data);
187 }
188
189 #define ZWP_GAMEPAD_V1_DESTROY 0
190
191 static inline void
192 zwp_gamepad_v1_set_user_data(struct zwp_gamepad_v1 *zwp_gamepad_v1, void *user_d ata)
193 {
194 wl_proxy_set_user_data((struct wl_proxy *) zwp_gamepad_v1, user_data);
195 }
196
197 static inline void *
198 zwp_gamepad_v1_get_user_data(struct zwp_gamepad_v1 *zwp_gamepad_v1)
199 {
200 return wl_proxy_get_user_data((struct wl_proxy *) zwp_gamepad_v1);
201 }
202
203 static inline void
204 zwp_gamepad_v1_destroy(struct zwp_gamepad_v1 *zwp_gamepad_v1)
205 {
206 wl_proxy_marshal((struct wl_proxy *) zwp_gamepad_v1,
207 ZWP_GAMEPAD_V1_DESTROY);
208
209 wl_proxy_destroy((struct wl_proxy *) zwp_gamepad_v1);
210 }
211
212 #ifdef __cplusplus
213 }
214 #endif
215
216 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698