ObjFW  Diff

Differences From Artifact [c7833087c0]:

To Artifact [f60cc4462d]:


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
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







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-




-
+





-
+




-
+




-
+




-
+




-
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
+




-
+




-
+




-
+




-
+




-
+




-
+




-
+




-
+

















-
+

-
+




-
+
+










-
+







@class OFSet OF_GENERIC(ObjectType);

/**
 * @brief A button on a controller.
 *
 * Possible values are:
 *
 *   * @ref OFGameControllerButtonA
 *   * @ref OFGameControllerButtonB
 *   * @ref OFGameControllerButtonC
 *   * @ref OFGameControllerButtonX
 *   * @ref OFGameControllerButtonY
 *   * @ref OFGameControllerButtonZ
 *   * @ref OFGameControllerButtonL
 *   * @ref OFGameControllerButtonR
 *   * @ref OFGameControllerButtonZL
 *   * @ref OFGameControllerButtonZR
 *   * @ref OFGameControllerButtonSelect
 *   * @ref OFGameControllerButtonStart
 *   * @ref OFGameControllerButtonHome
 *   * @ref OFGameControllerButtonCapture
 *   * @ref OFGameControllerButtonLeftStick
 *   * @ref OFGameControllerButtonRightStick
 *   * @ref OFGameControllerButtonDPadUp
 *   * @ref OFGameControllerButtonDPadDown
 *   * @ref OFGameControllerButtonDPadLeft
 *   * @ref OFGameControllerButtonDPadRight
 *   * @ref OFGameControllerButtonCPadUp
 *   * @ref OFGameControllerButtonCPadDown
 *   * @ref OFGameControllerButtonCPadLeft
 *   * @ref OFGameControllerButtonCPadRight
 *   * @ref OFGameControllerButtonSL
 *   * @ref OFGameControllerButtonSR
 *   * @ref OFGameControllerButtonMode
 *  * @ref OFGameControllerNorthButton
 *  * @ref OFGameControllerSouthButton
 *  * @ref OFGameControllerWestButton
 *  * @ref OFGameControllerEastButton
 *  * @ref OFGameControllerLeftTriggerButton
 *  * @ref OFGameControllerRightTriggerButton
 *  * @ref OFGameControllerLeftShoulderButton
 *  * @ref OFGameControllerRightShoulderButton
 *  * @ref OFGameControllerLeftStickButton
 *  * @ref OFGameControllerRightStickButton
 *  * @ref OFGameControllerDPadUpButton
 *  * @ref OFGameControllerDPadDownButton
 *  * @ref OFGameControllerDPadLeftButton
 *  * @ref OFGameControllerDPadRightButton
 *  * @ref OFGameControllerStartButton
 *  * @ref OFGameControllerSelectButton
 *  * @ref OFGameControllerHomeButton
 *  * @ref OFGameControllerCaptureButton
 *  * @ref OFGameControllerAButton
 *  * @ref OFGameControllerBButton
 *  * @ref OFGameControllerCButton
 *  * @ref OFGameControllerXButton
 *  * @ref OFGameControllerYButton
 *  * @ref OFGameControllerZButton
 *  * @ref OFGameControllerCPadUpButton
 *  * @ref OFGameControllerCPadDownButton
 *  * @ref OFGameControllerCPadLeftButton
 *  * @ref OFGameControllerCPadRightButton
 *  * @ref OFGameControllerPlusButton
 *  * @ref OFGameControllerMinusButton
 *  * @ref OFGameControllerSLButton
 *  * @ref OFGameControllerSRButton
 *  * @ref OFGameControllerModeButton
 */
typedef OFConstantString *OFGameControllerButton;

#ifdef __cplusplus
extern "C" {
#endif
/**
 * @brief The A button on a game controller.
 * @brief The north button on a game controller's diamond pad.
 */
extern const OFGameControllerButton OFGameControllerButtonA;
extern const OFGameControllerButton OFGameControllerNorthButton;

/**
 * @brief The B button on a game controller.
 * @brief The south button on a game controller's diamond pad.
 */
extern const OFGameControllerButton OFGameControllerButtonB;
extern const OFGameControllerButton OFGameControllerSouthButton;

/**
 * @brief The C button on a game controller.
 * @brief The west button on a game controller's diamond pad.
 */
extern const OFGameControllerButton OFGameControllerButtonC;
extern const OFGameControllerButton OFGameControllerWestButton;

/**
 * @brief The X button on a game controller.
 * @brief The east button on a game controller's diamond pad.
 */
extern const OFGameControllerButton OFGameControllerButtonX;
extern const OFGameControllerButton OFGameControllerEastButton;

/**
 * @brief The Y button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonY;

/**
 * @brief The Z button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonZ;

/**
 * @brief The L button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonL;

/**
 * @brief The R button on a game controller.
 * @brief The left trigger button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonR;
extern const OFGameControllerButton OFGameControllerLeftTriggerButton;

/**
 * @brief The ZL button on a game controller.
 * @brief The right trigger button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonZL;
extern const OFGameControllerButton OFGameControllerRightTriggerButton;

/**
 * @brief The ZR button on a game controller.
 * @brief The left shoulder button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonZR;
extern const OFGameControllerButton OFGameControllerLeftShoulderButton;

/**
 * @brief The Select button on a game controller.
 * @brief The right shoulder button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonSelect;
extern const OFGameControllerButton OFGameControllerRightShoulderButton;

/**
 * @brief The Start button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonStart;

/**
 * @brief The Home button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonHome;

/**
 * @brief The Capture button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonCapture;

/**
 * @brief The left stick button (pressing the left stick) on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonLeftStick;
extern const OFGameControllerButton OFGameControllerLeftStickButton;

/**
 * @brief The right stick button (pressing the right stick) on a game
 *	  controller.
 */
extern const OFGameControllerButton OFGameControllerButtonRightStick;
extern const OFGameControllerButton OFGameControllerRightStickButton;

/**
 * @brief The D-Pad Up button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonDPadUp;
extern const OFGameControllerButton OFGameControllerDPadUpButton;

/**
 * @brief The D-Pad Down button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonDPadDown;
extern const OFGameControllerButton OFGameControllerDPadDownButton;

/**
 * @brief The D-Pad Left button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonDPadLeft;
extern const OFGameControllerButton OFGameControllerDPadLeftButton;

/**
 * @brief The D-Pad Right button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonDPadRight;
extern const OFGameControllerButton OFGameControllerDPadRightButton;

/**
 * @brief The Start button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerStartButton;

/**
 * @brief The Select button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerSelectButton;

/**
 * @brief The Home button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerHomeButton;

/**
 * @brief The Capture button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerCaptureButton;

/**
 * @brief The A button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerAButton;

/**
 * @brief The B button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerBButton;

/**
 * @brief The C button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerCButton;

/**
 * @brief The X button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerXButton;

/**
 * @brief The Y button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerYButton;

/**
 * @brief The Z button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerZButton;

/**
 * @brief The C-Pad Up button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonCPadUp;
extern const OFGameControllerButton OFGameControllerCPadUpButton;

/**
 * @brief The C-Pad Down button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonCPadDown;
extern const OFGameControllerButton OFGameControllerCPadDownButton;

/**
 * @brief The C-Pad Left button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonCPadLeft;
extern const OFGameControllerButton OFGameControllerCPadLeftButton;

/**
 * @brief The C-Pad Right button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonCPadRight;
extern const OFGameControllerButton OFGameControllerCPadRightButton;

/**
 * @brief The + button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonPlus;
extern const OFGameControllerButton OFGameControllerPlusButton;

/**
 * @brief The - button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonMinus;
extern const OFGameControllerButton OFGameControllerMinusButton;

/**
 * @brief The SL button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonSL;
extern const OFGameControllerButton OFGameControllerSLButton;

/**
 * @brief The SR button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonSR;
extern const OFGameControllerButton OFGameControllerSRButton;

/**
 * @brief The Mode button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonMode;
extern const OFGameControllerButton OFGameControllerModeButton;
#ifdef __cplusplus
}
#endif

/**
 * @brief A class for reading state from a game controller.
 */
OF_SUBCLASSING_RESTRICTED
@interface OFGameController: OFObject
{
#if defined(OF_LINUX)
	OFString *_path;
	int _fd;
	uint16_t _vendorID, _productID;
	OFString *_name;
	OFMutableSet *_buttons, *_pressedButtons;
	bool _hasLeftAnalogStick, _hasRightAnalogStick;
	bool _hasZLPressure, _hasZRPressure;
	bool _hasLeftTriggerPressure, _hasRightTriggerPressure;
	OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition;
	float _ZLPressure, _ZRPressure;
	float _leftTriggerPressure, _rightTriggerPressure;
	int32_t _leftAnalogStickMinX, _leftAnalogStickMaxX;
	int32_t _leftAnalogStickMinY, _leftAnalogStickMaxY;
	int32_t _rightAnalogStickMinX, _rightAnalogStickMaxX;
	int32_t _rightAnalogStickMinY, _rightAnalogStickMaxY;
	int32_t _ZLMinPressure, _ZLMaxPressure, _ZRMinPressure, _ZRMaxPressure;
	int32_t _leftTriggerMinPressure, _leftTriggerMaxPressure;
	int32_t _rightTriggerMinPressure, _rightTriggerMaxPressure;
#elif defined(OF_NINTENDO_DS)
	OFMutableSet *_pressedButtons;
#elif defined(OF_NINTENDO_3DS)
	OFMutableSet *_pressedButtons;
	OFPoint _leftAnalogStickPosition;
#elif defined(OF_WINDOWS)
	DWORD _index;
	OFNumber *_Nullable _vendorID, *_Nullable productID;
	OFMutableSet *_pressedButtons;
	OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition;
	float _ZLPressure, _ZRPressure;
	float _leftTriggerPressure, _rightTriggerPressure;
#endif
}

#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
    OFArray <OFGameController *> *controllers;
#endif
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
339
340
341
342
343
344
345
























346
347
348
349
350
351
352







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







/**
 * @brief The position of the right analog stick.
 *
 * The range is from (-1, -1) to (1, 1).
 */
@property (readonly, nonatomic) OFPoint rightAnalogStickPosition;

/**
 * @brief The north button on the right diamond pad or `nil` if there is none.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
    OFGameControllerButton northButton;

/**
 * @brief The south button on the right diamond pad or `nil` if there is none.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
    OFGameControllerButton southButton;

/**
 * @brief The west button on the right diamond pad or `nil` if there is none.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
    OFGameControllerButton westButton;

/**
 * @brief The east button on the right diamond pad or `nil` if there is none.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
    OFGameControllerButton eastButton;

/**
 * @brief Returns the available controllers.
 *
 * @return The available controllers
 */
+ (OFArray OF_GENERIC(OFGameController *) *)controllers;