ObjFW  Check-in [2c2412d3df]

Overview
Comment:OFGameController: Use more generic button names
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: 2c2412d3df2a3d7707631c826f88d164dd4f6a8d97edd3de13d12a6f7ec15e0c
User & Date: js on 2024-05-14 20:41:28
Other Links: branch diff | manifest | tags
Context
2024-05-14
20:56
OFGameController: Try all XInput versions check-in: 6032aeea55 user: js tags: gamecontroller
20:41
OFGameController: Use more generic button names check-in: 2c2412d3df user: js tags: gamecontroller
2024-05-13
22:07
Fix ObjFWTest on Nintendo (3)DS check-in: f75c7058f7 user: js tags: gamecontroller
Changes

Modified src/hid/OFGameController.h from [c7833087c0] to [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
@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
 */
typedef OFConstantString *OFGameControllerButton;

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

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

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

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

/**
 * @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.
 */
extern const OFGameControllerButton OFGameControllerButtonR;

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

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

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

/**
 * @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;

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

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

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

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

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

/**


















































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

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

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

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

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

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

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

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

/**
 * @brief The Mode button on a game controller.
 */
extern const OFGameControllerButton OFGameControllerButtonMode;
#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;
	OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition;
	float _ZLPressure, _ZRPressure;
	int32_t _leftAnalogStickMinX, _leftAnalogStickMaxX;
	int32_t _leftAnalogStickMinY, _leftAnalogStickMaxY;
	int32_t _rightAnalogStickMinX, _rightAnalogStickMaxX;
	int32_t _rightAnalogStickMinY, _rightAnalogStickMaxY;
	int32_t _ZLMinPressure, _ZLMaxPressure, _ZRMinPressure, _ZRMaxPressure;

#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;
#endif
}

#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
    OFArray <OFGameController *> *controllers;
#endif







|
|
|
|
>
>
>
>
|
>
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







|

|


|

|


|

|


|

|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

|

|


|

|


|

|


|

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




|





|




|




|




|




|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|




|




|




|




|




|




|




|




|

















|

|




|
>










|







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 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 north button on a game controller's diamond pad.
 */
extern const OFGameControllerButton OFGameControllerNorthButton;

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

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

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
















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

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

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

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
















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

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

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

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

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

/**
 * @brief The D-Pad Right button on a game controller.
 */
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 OFGameControllerCPadUpButton;

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

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

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

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

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

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

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

/**
 * @brief The Mode button on a game controller.
 */
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 _hasLeftTriggerPressure, _hasRightTriggerPressure;
	OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition;
	float _leftTriggerPressure, _rightTriggerPressure;
	int32_t _leftAnalogStickMinX, _leftAnalogStickMaxX;
	int32_t _leftAnalogStickMinY, _leftAnalogStickMaxY;
	int32_t _rightAnalogStickMinX, _rightAnalogStickMaxX;
	int32_t _rightAnalogStickMinY, _rightAnalogStickMaxY;
	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 _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
/**
 * @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;








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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 Returns the available controllers.
 *
 * @return The available controllers
 */
+ (OFArray OF_GENERIC(OFGameController *) *)controllers;

Modified src/hid/OFGameController.m from [c4bdc74964] to [7d1cdb7cca].

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

#include "config.h"

#import "OFGameController.h"
#import "OFArray.h"

const OFGameControllerButton OFGameControllerButtonA = @"A";
const OFGameControllerButton OFGameControllerButtonB = @"B";
const OFGameControllerButton OFGameControllerButtonC = @"C";
const OFGameControllerButton OFGameControllerButtonX = @"X";
const OFGameControllerButton OFGameControllerButtonY = @"Y";

const OFGameControllerButton OFGameControllerButtonZ = @"Z";

const OFGameControllerButton OFGameControllerButtonL = @"L";

const OFGameControllerButton OFGameControllerButtonR = @"R";

const OFGameControllerButton OFGameControllerButtonZL = @"ZL";
const OFGameControllerButton OFGameControllerButtonZR = @"ZR";
const OFGameControllerButton OFGameControllerButtonSelect = @"Select";
const OFGameControllerButton OFGameControllerButtonStart = @"Start";
const OFGameControllerButton OFGameControllerButtonHome = @"Home";

const OFGameControllerButton OFGameControllerButtonCapture = @"Capture";
const OFGameControllerButton OFGameControllerButtonLeftStick = @"Left Stick";
const OFGameControllerButton OFGameControllerButtonRightStick = @"Right Stick";
const OFGameControllerButton OFGameControllerButtonDPadUp = @"D-Pad Up";
const OFGameControllerButton OFGameControllerButtonDPadDown = @"D-Pad Down";
const OFGameControllerButton OFGameControllerButtonDPadLeft = @"D-Pad Left";
const OFGameControllerButton OFGameControllerButtonDPadRight = @"D-Pad Right";
const OFGameControllerButton OFGameControllerButtonCPadUp = @"C-Pad Up";
const OFGameControllerButton OFGameControllerButtonCPadDown = @"C-Pad Down";
const OFGameControllerButton OFGameControllerButtonCPadLeft = @"C-Pad Left";
const OFGameControllerButton OFGameControllerButtonCPadRight = @"C-Pad Right";
const OFGameControllerButton OFGameControllerButtonPlus = @"+";



const OFGameControllerButton OFGameControllerButtonMinus = @"-";
const OFGameControllerButton OFGameControllerButtonSL = @"SL";
const OFGameControllerButton OFGameControllerButtonSR = @"SR";
const OFGameControllerButton OFGameControllerButtonMode = @"Mode";

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include "platform/Linux/OFGameController.m"
#elif defined(OF_WINDOWS)
# include "platform/Windows/OFGameController.m"
#elif defined(OF_NINTENDO_DS)
# include "platform/NintendoDS/OFGameController.m"
#elif defined(OF_NINTENDO_3DS)
# include "platform/Nintendo3DS/OFGameController.m"
#else
@implementation OFGameController
@dynamic name, buttons, pressedButtons, hasLeftAnalogStick;
@dynamic leftAnalogStickPosition, hasRightAnalogStick, rightAnalogStickPosition;
@dynamic northButton, southButton, westButton, eastButton;

+ (OFArray OF_GENERIC(OFGameController *) *)controllers
{
	return [OFArray array];
}

- (instancetype)init







|
|
|
|
|
>
|
>
|
>
|
>
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|













<







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

#include "config.h"

#import "OFGameController.h"
#import "OFArray.h"

const OFGameControllerButton OFGameControllerNorthButton = @"North";
const OFGameControllerButton OFGameControllerSouthButton = @"South";
const OFGameControllerButton OFGameControllerWestButton = @"West";
const OFGameControllerButton OFGameControllerEastButton = @"East";
const OFGameControllerButton OFGameControllerLeftTriggerButton =
    @"Left Trigger";
const OFGameControllerButton OFGameControllerRightTriggerButton =
    @"Right Trigger";
const OFGameControllerButton OFGameControllerLeftShoulderButton =
    @"Left Shoulder";
const OFGameControllerButton OFGameControllerRightShoulderButton =
    @"Right Shoulder";
const OFGameControllerButton OFGameControllerLeftStickButton = @"Left Stick";
const OFGameControllerButton OFGameControllerRightStickButton = @"Right Stick";
const OFGameControllerButton OFGameControllerDPadUpButton = @"D-Pad Up";
const OFGameControllerButton OFGameControllerDPadDownButton = @"D-Pad Down";
const OFGameControllerButton OFGameControllerDPadLeftButton = @"D-Pad Left";
const OFGameControllerButton OFGameControllerDPadRightButton = @"D-Pad Right";
const OFGameControllerButton OFGameControllerStartButton = @"Start";
const OFGameControllerButton OFGameControllerSelectButton = @"Select";
const OFGameControllerButton OFGameControllerHomeButton = @"Home";
const OFGameControllerButton OFGameControllerCaptureButton = @"Capture";
const OFGameControllerButton OFGameControllerAButton = @"A";
const OFGameControllerButton OFGameControllerBButton = @"B";
const OFGameControllerButton OFGameControllerCButton = @"C";
const OFGameControllerButton OFGameControllerXButton = @"X";
const OFGameControllerButton OFGameControllerYButton = @"Y";
const OFGameControllerButton OFGameControllerZButton = @"Z";
const OFGameControllerButton OFGameControllerCPadUpButton = @"C-Pad Up";
const OFGameControllerButton OFGameControllerCPadDownButton = @"C-Pad Down";
const OFGameControllerButton OFGameControllerCPadLeftButton = @"C-Pad Left";
const OFGameControllerButton OFGameControllerCPadRightButton = @"C-Pad Right";
const OFGameControllerButton OFGameControllerPlusButton = @"+";
const OFGameControllerButton OFGameControllerMinusButton = @"-";
const OFGameControllerButton OFGameControllerSLButton = @"SL";
const OFGameControllerButton OFGameControllerSRButton = @"SR";
const OFGameControllerButton OFGameControllerModeButton = @"Mode";

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include "platform/Linux/OFGameController.m"
#elif defined(OF_WINDOWS)
# include "platform/Windows/OFGameController.m"
#elif defined(OF_NINTENDO_DS)
# include "platform/NintendoDS/OFGameController.m"
#elif defined(OF_NINTENDO_3DS)
# include "platform/Nintendo3DS/OFGameController.m"
#else
@implementation OFGameController
@dynamic name, buttons, pressedButtons, hasLeftAnalogStick;
@dynamic leftAnalogStickPosition, hasRightAnalogStick, rightAnalogStickPosition;


+ (OFArray OF_GENERIC(OFGameController *) *)controllers
{
	return [OFArray array];
}

- (instancetype)init

Modified src/hid/platform/Linux/OFGameController.m from [cec84b63cd] to [91b0510999].

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
static OFGameControllerButton
buttonToName(uint16_t button, uint16_t vendorID, uint16_t productID)
{
	if (vendorID == vendorIDNintendo &&
	    productID == productIDLeftJoycon) {
		switch (button) {
		case BTN_SELECT:
			return OFGameControllerButtonMinus;
		case BTN_Z:
			return OFGameControllerButtonCapture;
		case BTN_TR:
			return OFGameControllerButtonSL;
		case BTN_TR2:
			return OFGameControllerButtonSR;
		}
	} else if (vendorID == vendorIDNintendo &&
	    productID == productIDRightJoycon) {
		switch (button) {
		case BTN_B:
			return OFGameControllerButtonA;
		case BTN_A:
			return OFGameControllerButtonB;
		case BTN_START:
			return OFGameControllerButtonPlus;
		case BTN_TL:
			return OFGameControllerButtonSL;
		case BTN_TL2:
			return OFGameControllerButtonSR;
		}
	} else if (vendorID == vendorIDNintendo &&
	    productID == productIDN64Controller) {
		switch (button) {
		case BTN_TL2:
			return OFGameControllerButtonZ;
		case BTN_Y:
			return OFGameControllerButtonCPadLeft;
		case BTN_C:
			return OFGameControllerButtonCPadRight;
		case BTN_SELECT:
			return OFGameControllerButtonCPadUp;
		case BTN_X:
			return OFGameControllerButtonCPadDown;
		case BTN_MODE:
			return OFGameControllerButtonHome;
		case BTN_Z:
			return OFGameControllerButtonCapture;
		}
	}

	switch (button) {
	case BTN_A:
		return OFGameControllerButtonA;
	case BTN_B:
		return OFGameControllerButtonB;
	case BTN_C:
		return OFGameControllerButtonC;
	case BTN_X:
		return OFGameControllerButtonX;
	case BTN_Y:
		return OFGameControllerButtonY;
	case BTN_Z:
		return OFGameControllerButtonZ;
	case BTN_TL:
		return OFGameControllerButtonL;
	case BTN_TR:
		return OFGameControllerButtonR;
	case BTN_TL2:
		return OFGameControllerButtonZL;
	case BTN_TR2:
		return OFGameControllerButtonZR;
	case BTN_SELECT:
		return OFGameControllerButtonSelect;
	case BTN_START:
		return OFGameControllerButtonStart;
	case BTN_MODE:
		return OFGameControllerButtonHome;
	case BTN_THUMBL:
		return OFGameControllerButtonLeftStick;
	case BTN_THUMBR:
		return OFGameControllerButtonRightStick;
	case BTN_DPAD_UP:
		return OFGameControllerButtonDPadUp;
	case BTN_DPAD_DOWN:
		return OFGameControllerButtonDPadDown;
	case BTN_DPAD_LEFT:
		return OFGameControllerButtonDPadLeft;
	case BTN_DPAD_RIGHT:
		return OFGameControllerButtonDPadRight;
	}

	return nil;
}

static float
scale(float value, float min, float max)







|

|

|

|




|
|
|
|

|

|

|




|
|
|
|
|
|
|
|
|
|
|
|

|




|
|
|
|
|
|
|
|
|
|
|
|

|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







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
static OFGameControllerButton
buttonToName(uint16_t button, uint16_t vendorID, uint16_t productID)
{
	if (vendorID == vendorIDNintendo &&
	    productID == productIDLeftJoycon) {
		switch (button) {
		case BTN_SELECT:
			return OFGameControllerMinusButton;
		case BTN_Z:
			return OFGameControllerCaptureButton;
		case BTN_TR:
			return OFGameControllerSLButton;
		case BTN_TR2:
			return OFGameControllerSRButton;
		}
	} else if (vendorID == vendorIDNintendo &&
	    productID == productIDRightJoycon) {
		switch (button) {
		case BTN_X:
			return OFGameControllerNorthButton;
		case BTN_Y:
			return OFGameControllerWestButton;
		case BTN_START:
			return OFGameControllerPlusButton;
		case BTN_TL:
			return OFGameControllerSLButton;
		case BTN_TL2:
			return OFGameControllerSRButton;
		}
	} else if (vendorID == vendorIDNintendo &&
	    productID == productIDN64Controller) {
		switch (button) {
		case BTN_A:
			return OFGameControllerAButton;
		case BTN_B:
			return OFGameControllerBButton;
		case BTN_SELECT:
			return OFGameControllerCPadUpButton;
		case BTN_X:
			return OFGameControllerCPadDownButton;
		case BTN_Y:
			return OFGameControllerCPadLeftButton;
		case BTN_C:
			return OFGameControllerCPadRightButton;
		case BTN_Z:
			return OFGameControllerCaptureButton;
		}
	}

	switch (button) {
	case BTN_Y:
		return OFGameControllerNorthButton;
	case BTN_A:
		return OFGameControllerSouthButton;
	case BTN_X:
		return OFGameControllerWestButton;
	case BTN_B:
		return OFGameControllerEastButton;
	case BTN_TL2:
		return OFGameControllerLeftTriggerButton;
	case BTN_TR2:
		return OFGameControllerRightTriggerButton;
	case BTN_TL:
		return OFGameControllerLeftShoulderButton;
	case BTN_TR:
		return OFGameControllerRightShoulderButton;
	case BTN_THUMBL:
		return OFGameControllerLeftStickButton;
	case BTN_THUMBR:
		return OFGameControllerRightStickButton;
	case BTN_DPAD_UP:
		return OFGameControllerDPadUpButton;
	case BTN_DPAD_DOWN:
		return OFGameControllerDPadDownButton;
	case BTN_DPAD_LEFT:
		return OFGameControllerDPadLeftButton;
	case BTN_DPAD_RIGHT:
		return OFGameControllerDPadRightButton;
	case BTN_START:
		return OFGameControllerStartButton;
	case BTN_SELECT:
		return OFGameControllerSelectButton;
	case BTN_MODE:
		return OFGameControllerHomeButton;
	case BTN_C:
		return OFGameControllerCButton;
	case BTN_Z:
		return OFGameControllerZButton;
	}

	return nil;
}

static float
scale(float value, float min, float max)
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
350
351
352
353
354
355
356

357
358
359
360
361
362
363
				_rightAnalogStickMinY = infoY.minimum;
				_rightAnalogStickMaxY = infoY.maximum;
			}

			if (OFBitSetIsSet(absBits, ABS_HAT0X) &&
			    OFBitSetIsSet(absBits, ABS_HAT0Y)) {
				[_buttons addObject:
				    OFGameControllerButtonDPadLeft];
				[_buttons addObject:
				    OFGameControllerButtonDPadRight];
				[_buttons addObject:
				    OFGameControllerButtonDPadUp];
				[_buttons addObject:
				    OFGameControllerButtonDPadDown];
			}

			if (OFBitSetIsSet(absBits, ABS_Z)) {
				struct input_absinfo info;

				_hasZLPressure = true;

				if (ioctl(_fd, EVIOCGABS(ABS_Z), &info) == -1)
					@throw [OFInitializationFailedException
					    exception];

				_ZLMinPressure = info.minimum;
				_ZLMaxPressure = info.maximum;

				[_buttons addObject: OFGameControllerButtonZL];

			}

			if (OFBitSetIsSet(absBits, ABS_RZ)) {
				struct input_absinfo info;

				_hasZRPressure = true;

				if (ioctl(_fd, EVIOCGABS(ABS_RZ), &info) == -1)
					@throw [OFInitializationFailedException
					    exception];

				_ZRMinPressure = info.minimum;
				_ZRMaxPressure = info.maximum;

				[_buttons addObject: OFGameControllerButtonZR];

			}
		}

		[_buttons makeImmutable];

		[self retrieveState];
	} @catch (id e) {







|

|

|

|





|





|
|

|
>





|





|
|

|
>







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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
				_rightAnalogStickMinY = infoY.minimum;
				_rightAnalogStickMaxY = infoY.maximum;
			}

			if (OFBitSetIsSet(absBits, ABS_HAT0X) &&
			    OFBitSetIsSet(absBits, ABS_HAT0Y)) {
				[_buttons addObject:
				    OFGameControllerDPadLeftButton];
				[_buttons addObject:
				    OFGameControllerDPadRightButton];
				[_buttons addObject:
				    OFGameControllerDPadUpButton];
				[_buttons addObject:
				    OFGameControllerDPadDownButton];
			}

			if (OFBitSetIsSet(absBits, ABS_Z)) {
				struct input_absinfo info;

				_hasLeftTriggerPressure = true;

				if (ioctl(_fd, EVIOCGABS(ABS_Z), &info) == -1)
					@throw [OFInitializationFailedException
					    exception];

				_leftTriggerMinPressure = info.minimum;
				_leftTriggerMaxPressure = info.maximum;

				[_buttons addObject:
				    OFGameControllerLeftTriggerButton];
			}

			if (OFBitSetIsSet(absBits, ABS_RZ)) {
				struct input_absinfo info;

				_hasRightTriggerPressure = true;

				if (ioctl(_fd, EVIOCGABS(ABS_RZ), &info) == -1)
					@throw [OFInitializationFailedException
					    exception];

				_rightTriggerMinPressure = info.minimum;
				_rightTriggerMaxPressure = info.maximum;

				[_buttons addObject:
				    OFGameControllerRightTriggerButton];
			}
		}

		[_buttons makeImmutable];

		[self retrieveState];
	} @catch (id e) {
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478

479
480
481
482
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
				_rightAnalogStickPosition.y = scale(event.value,
				    _rightAnalogStickMinY,
				    _rightAnalogStickMaxY);
				break;
			case ABS_HAT0X:
				if (event.value < 0) {
					[_pressedButtons addObject:
					    OFGameControllerButtonDPadLeft];
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadRight];
				} else if (event.value > 0) {
					[_pressedButtons addObject:
					    OFGameControllerButtonDPadRight];
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadLeft];
				} else {
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadLeft];
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadRight];
				}
				break;
			case ABS_HAT0Y:
				if (event.value < 0) {
					[_pressedButtons addObject:
					    OFGameControllerButtonDPadUp];
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadDown];
				} else if (event.value > 0) {
					[_pressedButtons addObject:
					    OFGameControllerButtonDPadDown];
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadUp];
				} else {
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadUp];
					[_pressedButtons removeObject:
					    OFGameControllerButtonDPadDown];
				}
				break;
			case ABS_Z:
				_ZLPressure = scale(event.value,

				    _ZLMinPressure, _ZLMaxPressure);

				if (_ZLPressure > 0)
					[_pressedButtons addObject:
					    OFGameControllerButtonZL];
				else
					[_pressedButtons removeObject:
					    OFGameControllerButtonZL];
				break;
			case ABS_RZ:
				_ZRPressure = scale(event.value,

				    _ZRMinPressure, _ZRMaxPressure);

				if (_ZRPressure > 0)
					[_pressedButtons addObject:
					    OFGameControllerButtonZR];
				else
					[_pressedButtons removeObject:
					    OFGameControllerButtonZR];
				break;
			}

			break;
		}
	}
}







|

|


|

|


|

|





|

|


|

|


|

|



|
>
|

|

|


|


|
>
|

|

|


|







439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
				_rightAnalogStickPosition.y = scale(event.value,
				    _rightAnalogStickMinY,
				    _rightAnalogStickMaxY);
				break;
			case ABS_HAT0X:
				if (event.value < 0) {
					[_pressedButtons addObject:
					    OFGameControllerDPadLeftButton];
					[_pressedButtons removeObject:
					    OFGameControllerDPadRightButton];
				} else if (event.value > 0) {
					[_pressedButtons addObject:
					    OFGameControllerDPadRightButton];
					[_pressedButtons removeObject:
					    OFGameControllerDPadLeftButton];
				} else {
					[_pressedButtons removeObject:
					    OFGameControllerDPadLeftButton];
					[_pressedButtons removeObject:
					    OFGameControllerDPadRightButton];
				}
				break;
			case ABS_HAT0Y:
				if (event.value < 0) {
					[_pressedButtons addObject:
					    OFGameControllerDPadUpButton];
					[_pressedButtons removeObject:
					    OFGameControllerDPadDownButton];
				} else if (event.value > 0) {
					[_pressedButtons addObject:
					    OFGameControllerDPadDownButton];
					[_pressedButtons removeObject:
					    OFGameControllerDPadUpButton];
				} else {
					[_pressedButtons removeObject:
					    OFGameControllerDPadUpButton];
					[_pressedButtons removeObject:
					    OFGameControllerDPadDownButton];
				}
				break;
			case ABS_Z:
				_leftTriggerPressure = scale(event.value,
				    _leftTriggerMinPressure,
				    _leftTriggerMaxPressure);

				if (_leftTriggerPressure > 0)
					[_pressedButtons addObject:
					    OFGameControllerLeftTriggerButton];
				else
					[_pressedButtons removeObject:
					    OFGameControllerLeftTriggerButton];
				break;
			case ABS_RZ:
				_rightTriggerPressure = scale(event.value,
				    _rightTriggerMinPressure,
				    _rightTriggerMaxPressure);

				if (_rightTriggerPressure > 0)
					[_pressedButtons addObject:
					    OFGameControllerRightTriggerButton];
				else
					[_pressedButtons removeObject:
					    OFGameControllerRightTriggerButton];
				break;
			}

			break;
		}
	}
}
525
526
527
528
529
530
531
532
533

534
535

536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
- (OFSet *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	if (button == OFGameControllerButtonZL && _hasZLPressure)
		return _ZLPressure;

	if (button == OFGameControllerButtonZR && _hasZRPressure)
		return _ZRPressure;


	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}

- (OFGameControllerButton)northButton
{
	if (_vendorID == vendorIDNintendo && _productID == productIDLeftJoycon)
		return nil;
	if (_vendorID == vendorIDNintendo && _productID == productIDRightJoycon)
		return OFGameControllerButtonX;
	if (_vendorID == vendorIDNintendo &&
	    _productID == productIDN64Controller)
		return nil;

	return OFGameControllerButtonY;
}

- (OFGameControllerButton)southButton
{
	if (_vendorID == vendorIDNintendo && _productID == productIDLeftJoycon)
		return nil;
	if (_vendorID == vendorIDNintendo && _productID == productIDRightJoycon)
		return OFGameControllerButtonB;
	if (_vendorID == vendorIDNintendo &&
	    _productID == productIDN64Controller)
		return nil;

	return OFGameControllerButtonA;
}

- (OFGameControllerButton)westButton
{
	if (_vendorID == vendorIDNintendo && _productID == productIDLeftJoycon)
		return nil;
	if (_vendorID == vendorIDNintendo && _productID == productIDRightJoycon)
		return OFGameControllerButtonY;
	if (_vendorID == vendorIDNintendo &&
	    _productID == productIDN64Controller)
		return nil;

	return OFGameControllerButtonX;
}

- (OFGameControllerButton)eastButton
{
	if (_vendorID == vendorIDNintendo && _productID == productIDLeftJoycon)
		return nil;
	if (_vendorID == vendorIDNintendo && _productID == productIDRightJoycon)
		return OFGameControllerButtonA;
	if (_vendorID == vendorIDNintendo &&
	    _productID == productIDN64Controller)
		return nil;

	return OFGameControllerButtonB;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end







|
|
>
|
|
>




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545




















































546
547
548
549
550
- (OFSet *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	if (button == OFGameControllerLeftTriggerButton &&
	    _hasLeftTriggerPressure)
		return _leftTriggerPressure;
	if (button == OFGameControllerRightTriggerButton &&
	    _hasRightTriggerPressure)
		return _rightTriggerPressure;

	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}





















































- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end

Modified src/hid/platform/Nintendo3DS/OFGameController.m from [4e207caf2f] to [f3681e2d31].

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
	hidScanInput();

	keys = hidKeysHeld();
	hidCircleRead(&pos);

	[_pressedButtons removeAllObjects];

	if (keys & KEY_A)
		[_pressedButtons addObject: OFGameControllerButtonA];
	if (keys & KEY_B)
		[_pressedButtons addObject: OFGameControllerButtonB];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerButtonSelect];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerButtonStart];
	if (keys & KEY_DRIGHT)
		[_pressedButtons addObject: OFGameControllerButtonDPadRight];
	if (keys & KEY_DLEFT)
		[_pressedButtons addObject: OFGameControllerButtonDPadLeft];
	if (keys & KEY_DUP)
		[_pressedButtons addObject: OFGameControllerButtonDPadUp];
	if (keys & KEY_DDOWN)
		[_pressedButtons addObject: OFGameControllerButtonDPadDown];
	if (keys & KEY_R)
		[_pressedButtons addObject: OFGameControllerButtonR];
	if (keys & KEY_L)
		[_pressedButtons addObject: OFGameControllerButtonL];
	if (keys & KEY_X)
		[_pressedButtons addObject: OFGameControllerButtonX];
	if (keys & KEY_Y)
		[_pressedButtons addObject: OFGameControllerButtonY];
	if (keys & KEY_ZL)
		[_pressedButtons addObject: OFGameControllerButtonZL];
	if (keys & KEY_ZR)
		[_pressedButtons addObject: OFGameControllerButtonZR];
	if (keys & KEY_CSTICK_RIGHT)
		[_pressedButtons addObject: OFGameControllerButtonCPadRight];
	if (keys & KEY_CSTICK_LEFT)
		[_pressedButtons addObject: OFGameControllerButtonCPadLeft];
	if (keys & KEY_CSTICK_UP)
		[_pressedButtons addObject: OFGameControllerButtonCPadUp];
	if (keys & KEY_CSTICK_DOWN)
		[_pressedButtons addObject: OFGameControllerButtonCPadDown];





	_leftAnalogStickPosition = OFMakePoint(
	    (float)pos.dx / (pos.dx < 0 ? -INT16_MIN : INT16_MAX),
	    (float)pos.dy / (pos.dy < 0 ? -INT16_MIN : INT16_MAX));
}

- (OFString *)name







|
|

|
|
|
|
|
|
|
|
|
|
|
<
<

|
<
|
|
|
|
|
|
|
|
|
|
|
|
|

|

|
>
>
>
>







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
	hidScanInput();

	keys = hidKeysHeld();
	hidCircleRead(&pos);

	[_pressedButtons removeAllObjects];

	if (keys & KEY_X)
		[_pressedButtons addObject: OFGameControllerNorthButton];
	if (keys & KEY_B)
		[_pressedButtons addObject: OFGameControllerSouthButton];
	if (keys & KEY_Y)
		[_pressedButtons addObject: OFGameControllerWestButton];
	if (keys & KEY_A)
		[_pressedButtons addObject: OFGameControllerEastButton];
	if (keys & KEY_ZL)
		[_pressedButtons addObject: OFGameControllerLeftTriggerButton];
	if (keys & KEY_ZR)
		[_pressedButtons addObject: OFGameControllerRightTriggerButton];
	if (keys & KEY_L)
		[_pressedButtons addObject: OFGameControllerLeftShoulderButton];


	if (keys & KEY_R)
		[_pressedButtons addObject:

		    OFGameControllerRightShoulderButton];
	if (keys & KEY_DUP)
		[_pressedButtons addObject: OFGameControllerDPadUpButton];
	if (keys & KEY_DDOWN)
		[_pressedButtons addObject: OFGameControllerDPadDownButton];
	if (keys & KEY_DLEFT)
		[_pressedButtons addObject: OFGameControllerDPadLeftButton];
	if (keys & KEY_DRIGHT)
		[_pressedButtons addObject: OFGameControllerDPadRightButton];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerStartButton];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerSelectButton];
	if (keys & KEY_CSTICK_UP)
		[_pressedButtons addObject: OFGameControllerCPadUpButton];
	if (keys & KEY_CSTICK_DOWN)
		[_pressedButtons addObject: OFGameControllerCPadDownButton];
	if (keys & KEY_CSTICK_LEFT)
		[_pressedButtons addObject: OFGameControllerCPadLeftButton];
	if (keys & KEY_CSTICK_RIGHT)
		[_pressedButtons addObject: OFGameControllerCPadRightButton];

	_leftAnalogStickPosition = OFMakePoint(
	    (float)pos.dx / (pos.dx < 0 ? -INT16_MIN : INT16_MAX),
	    (float)pos.dy / (pos.dy < 0 ? -INT16_MIN : INT16_MAX));
}

- (OFString *)name
154
155
156
157
158
159
160
161
162
163
164
165




166



167
168

169
170

171
172
173
174
175
176
177
- (OFNumber *)productID
{
	return nil;
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)buttons
{
	return [OFSet setWithObjects: OFGameControllerButtonA,
	    OFGameControllerButtonB, OFGameControllerButtonSelect,
	    OFGameControllerButtonStart, OFGameControllerButtonDPadRight,
	    OFGameControllerButtonDPadLeft, OFGameControllerButtonDPadUp,
	    OFGameControllerButtonDPadDown, OFGameControllerButtonR,




	    OFGameControllerButtonL, OFGameControllerButtonX,



	    OFGameControllerButtonY, OFGameControllerButtonZL,
	    OFGameControllerButtonZR, OFGameControllerButtonCPadRight,

	    OFGameControllerButtonCPadLeft, OFGameControllerButtonCPadUp,
	    OFGameControllerButtonCPadDown, nil];

}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}








|
|
|
|
|
>
>
>
>
|
>
>
>
|
|
>
|
|
>







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
- (OFNumber *)productID
{
	return nil;
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)buttons
{
	return [OFSet setWithObjects:
	    OFGameControllerNorthButton,
	    OFGameControllerSouthButton,
	    OFGameControllerWestButton,
	    OFGameControllerEastButton,
	    OFGameControllerLeftTriggerButton,
	    OFGameControllerRightTriggerButton,
	    OFGameControllerRightShoulderButton,
	    OFGameControllerLeftShoulderButton,
	    OFGameControllerDPadUpButton,
	    OFGameControllerDPadDownButton,
	    OFGameControllerDPadLeftButton,
	    OFGameControllerDPadRightButton,
	    OFGameControllerStartButton,
	    OFGameControllerSelectButton,
	    OFGameControllerCPadRightButton,
	    OFGameControllerCPadLeftButton,
	    OFGameControllerCPadUpButton,
	    OFGameControllerCPadDownButton, nil];
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

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
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}

- (OFGameControllerButton)northButton
{
	return OFGameControllerButtonX;
}

- (OFGameControllerButton)southButton
{
	return OFGameControllerButtonB;
}

- (OFGameControllerButton)westButton
{
	return OFGameControllerButtonY;
}

- (OFGameControllerButton)eastButton
{
	return OFGameControllerButtonA;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





196
197
198
199
200
201
202




















203
204
205
206
207
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}





















- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end

Modified src/hid/platform/NintendoDS/OFGameController.m from [2d083ad50e] to [4b910e9db0].

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
	uint32 keys;

	scanKeys();
	keys = keysCurrent();

	[_pressedButtons removeAllObjects];

	if (keys & KEY_A)
		[_pressedButtons addObject: OFGameControllerButtonA];
	if (keys & KEY_B)
		[_pressedButtons addObject: OFGameControllerButtonB];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerButtonSelect];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerButtonStart];
	if (keys & KEY_RIGHT)
		[_pressedButtons addObject: OFGameControllerButtonDPadRight];
	if (keys & KEY_LEFT)
		[_pressedButtons addObject: OFGameControllerButtonDPadLeft];

	if (keys & KEY_UP)
		[_pressedButtons addObject: OFGameControllerButtonDPadUp];
	if (keys & KEY_DOWN)
		[_pressedButtons addObject: OFGameControllerButtonDPadDown];
	if (keys & KEY_R)
		[_pressedButtons addObject: OFGameControllerButtonR];
	if (keys & KEY_L)
		[_pressedButtons addObject: OFGameControllerButtonL];
	if (keys & KEY_X)
		[_pressedButtons addObject: OFGameControllerButtonX];
	if (keys & KEY_Y)
		[_pressedButtons addObject: OFGameControllerButtonY];
}

- (OFString *)name
{
	return @"Nintendo DS";
}

- (OFNumber *)vendorID
{
	return nil;
}

- (OFNumber *)productID
{
	return nil;
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)buttons
{
	return [OFSet setWithObjects: OFGameControllerButtonA,
	    OFGameControllerButtonB, OFGameControllerButtonSelect,
	    OFGameControllerButtonStart, OFGameControllerButtonDPadRight,
	    OFGameControllerButtonDPadLeft, OFGameControllerButtonDPadUp,
	    OFGameControllerButtonDPadDown, OFGameControllerButtonR,


	    OFGameControllerButtonL, OFGameControllerButtonX,



	    OFGameControllerButtonY, nil];

}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}








|
|

|
|
|
|
|
|
|
|
|
>

|

|
|
|
|
|
|
|
|
|



















|
|
|
|
|
>
>
|
>
>
>
|
>







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
	uint32 keys;

	scanKeys();
	keys = keysCurrent();

	[_pressedButtons removeAllObjects];

	if (keys & KEY_X)
		[_pressedButtons addObject: OFGameControllerNorthButton];
	if (keys & KEY_B)
		[_pressedButtons addObject: OFGameControllerSouthButton];
	if (keys & KEY_Y)
		[_pressedButtons addObject: OFGameControllerWestButton];
	if (keys & KEY_A)
		[_pressedButtons addObject: OFGameControllerEastButton];
	if (keys & KEY_L)
		[_pressedButtons addObject: OFGameControllerLeftShoulderButton];
	if (keys & KEY_R)
		[_pressedButtons addObject:
		    OFGameControllerRightShoulderButton];
	if (keys & KEY_UP)
		[_pressedButtons addObject: OFGameControllerDPadUpButton];
	if (keys & KEY_DOWN)
		[_pressedButtons addObject: OFGameControllerDPadDownButton];
	if (keys & KEY_LEFT)
		[_pressedButtons addObject: OFGameControllerDPadLeftButton];
	if (keys & KEY_RIGHT)
		[_pressedButtons addObject: OFGameControllerDPadRightButton];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerStartButton];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerSelectButton];
}

- (OFString *)name
{
	return @"Nintendo DS";
}

- (OFNumber *)vendorID
{
	return nil;
}

- (OFNumber *)productID
{
	return nil;
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)buttons
{
	return [OFSet setWithObjects:
	    OFGameControllerNorthButton,
	    OFGameControllerSouthButton,
	    OFGameControllerWestButton,
	    OFGameControllerEastButton,
	    OFGameControllerLeftShoulderButton,
	    OFGameControllerRightShoulderButton,
	    OFGameControllerDPadUpButton,
	    OFGameControllerDPadDownButton,
	    OFGameControllerDPadLeftButton,
	    OFGameControllerDPadRightButton,
	    OFGameControllerStartButton,
	    OFGameControllerSelectButton, nil];
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

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
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}

- (OFGameControllerButton)northButton
{
	return OFGameControllerButtonX;
}

- (OFGameControllerButton)southButton
{
	return OFGameControllerButtonB;
}

- (OFGameControllerButton)westButton
{
	return OFGameControllerButtonY;
}

- (OFGameControllerButton)eastButton
{
	return OFGameControllerButtonA;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





170
171
172
173
174
175
176




















177
178
179
180
181
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}





















- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end

Modified src/hid/platform/Windows/OFGameController.m from [ff51d408df] to [c31f521172].

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
	if (XInputGetStateFuncPtr(_index, &state) != ERROR_SUCCESS)
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: sizeof(state)
							    errNo: 0];

	[_pressedButtons removeAllObjects];

	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
		[_pressedButtons addObject: OFGameControllerButtonDPadUp];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
		[_pressedButtons addObject: OFGameControllerButtonDPadDown];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
		[_pressedButtons addObject: OFGameControllerButtonDPadLeft];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
		[_pressedButtons addObject: OFGameControllerButtonDPadRight];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_START)
		[_pressedButtons addObject: OFGameControllerButtonStart];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK)
		[_pressedButtons addObject: OFGameControllerButtonSelect];

	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB)
		[_pressedButtons addObject: OFGameControllerButtonLeftStick];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB)
		[_pressedButtons addObject: OFGameControllerButtonRightStick];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER)
		[_pressedButtons addObject: OFGameControllerButtonL];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER)
		[_pressedButtons addObject: OFGameControllerButtonR];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
		[_pressedButtons addObject: OFGameControllerButtonA];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_B)
		[_pressedButtons addObject: OFGameControllerButtonB];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_X)
		[_pressedButtons addObject: OFGameControllerButtonX];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_Y)
		[_pressedButtons addObject: OFGameControllerButtonY];

	_ZLPressure = (float)state.Gamepad.bLeftTrigger / 255;
	_ZRPressure = (float)state.Gamepad.bRightTrigger / 255;

	if (_ZLPressure > 0)
		[_pressedButtons addObject: OFGameControllerButtonZL];
	if (_ZRPressure > 0)
		[_pressedButtons addObject: OFGameControllerButtonZR];

	_leftAnalogStickPosition = OFMakePoint(
	    (float)state.Gamepad.sThumbLX /
	    (state.Gamepad.sThumbLX < 0 ? -INT16_MIN : INT16_MAX),
	    -(float)state.Gamepad.sThumbLY /
	    (state.Gamepad.sThumbLY < 0 ? -INT16_MIN : INT16_MAX));
	_rightAnalogStickPosition = OFMakePoint(







|
|
|
|
|
|
|
|
|
|
|
|
>

|

|
|
|
|
|
|
|
|
|
|
|
|
|

|
|

|
|
|
|







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
	if (XInputGetStateFuncPtr(_index, &state) != ERROR_SUCCESS)
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: sizeof(state)
							    errNo: 0];

	[_pressedButtons removeAllObjects];

	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_Y)
		[_pressedButtons addObject: OFGameControllerNorthButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
		[_pressedButtons addObject: OFGameControllerSouthButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_X)
		[_pressedButtons addObject: OFGameControllerWestButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_B)
		[_pressedButtons addObject: OFGameControllerEastButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER)
		[_pressedButtons addObject: OFGameControllerLeftShoulderButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER)
		[_pressedButtons addObject:
		    OFGameControllerRightShoulderButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB)
		[_pressedButtons addObject: OFGameControllerLeftStickButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB)
		[_pressedButtons addObject: OFGameControllerRightStickButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
		[_pressedButtons addObject: OFGameControllerDPadUpButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
		[_pressedButtons addObject: OFGameControllerDPadDownButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
		[_pressedButtons addObject: OFGameControllerDPadLeftButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
		[_pressedButtons addObject: OFGameControllerDPadRightButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_START)
		[_pressedButtons addObject: OFGameControllerStartButton];
	if (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK)
		[_pressedButtons addObject: OFGameControllerSelectButton];

	_leftTriggerPressure = (float)state.Gamepad.bLeftTrigger / 255;
	_rightTriggerPressure = (float)state.Gamepad.bRightTrigger / 255;

	if (_leftTriggerPressure > 0)
		[_pressedButtons addObject: OFGameControllerLeftTriggerButton];
	if (_rightTriggerPressure > 0)
		[_pressedButtons addObject: OFGameControllerRightTriggerButton];

	_leftAnalogStickPosition = OFMakePoint(
	    (float)state.Gamepad.sThumbLX /
	    (state.Gamepad.sThumbLX < 0 ? -INT16_MIN : INT16_MAX),
	    -(float)state.Gamepad.sThumbLY /
	    (state.Gamepad.sThumbLY < 0 ? -INT16_MIN : INT16_MAX));
	_rightAnalogStickPosition = OFMakePoint(
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
{
	return @"XInput 1.3";
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)buttons
{
	return [OFSet setWithObjects:
	    OFGameControllerButtonA, OFGameControllerButtonB,
	    OFGameControllerButtonX, OFGameControllerButtonY,
	    OFGameControllerButtonL, OFGameControllerButtonR,
	    OFGameControllerButtonZL, OFGameControllerButtonZR,






	    OFGameControllerButtonStart, OFGameControllerButtonSelect,

	    OFGameControllerButtonLeftStick, OFGameControllerButtonRightStick,
	    OFGameControllerButtonDPadLeft, OFGameControllerButtonDPadRight,
	    OFGameControllerButtonDPadUp, OFGameControllerButtonDPadDown, nil];

}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

- (bool)hasLeftAnalogStick
{
	return true;
}

- (bool)hasRightAnalogStick
{
	return true;
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	if (button == OFGameControllerButtonZL)
		return _ZLPressure;
	if (button == OFGameControllerButtonZR)
		return _ZRPressure;

	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}

- (OFGameControllerButton)northButton
{
	return OFGameControllerButtonY;
}

- (OFGameControllerButton)southButton
{
	return OFGameControllerButtonA;
}

- (OFGameControllerButton)westButton
{
	return OFGameControllerButtonX;
}

- (OFGameControllerButton)eastButton
{
	return OFGameControllerButtonB;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end







|
|
|
|
>
>
>
>
>
>
|
>
|
|
|
>



















|
|
|
|




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





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
{
	return @"XInput 1.3";
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)buttons
{
	return [OFSet setWithObjects:
	    OFGameControllerNorthButton,
	    OFGameControllerSouthButton,
	    OFGameControllerWestButton,
	    OFGameControllerEastButton,
	    OFGameControllerLeftTriggerButton,
	    OFGameControllerRightTriggerButton,
	    OFGameControllerLeftShoulderButton,
	    OFGameControllerRightShoulderButton,
	    OFGameControllerLeftStickButton,
	    OFGameControllerRightStickButton,
	    OFGameControllerDPadLeftButton,
	    OFGameControllerDPadRightButton,
	    OFGameControllerDPadUpButton,
	    OFGameControllerDPadDownButton,
	    OFGameControllerStartButton,
	    OFGameControllerSelectButton, nil];
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

- (bool)hasLeftAnalogStick
{
	return true;
}

- (bool)hasRightAnalogStick
{
	return true;
}

- (float)pressureForButton: (OFGameControllerButton)button
{
	if (button == OFGameControllerLeftTriggerButton)
		return _leftTriggerPressure;
	if (button == OFGameControllerRightTriggerButton)
		return _rightTriggerPressure;

	return ([self.pressedButtons containsObject: button] ? 1 : 0);
}





















- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name];
}
@end

Modified src/test/OTAppDelegate.m from [57fda2dee1] to [3474e8e70a].

330
331
332
333
334
335
336
337

338
339
340
341
342
343
344
		[OFStdOut writeLine: @"Press A to continue"];

		for (;;) {
			void *pool = objc_autoreleasePoolPush();
			OFGameController *controller =
			    [[OFGameController controllers] objectAtIndex: 0];

			if ([controller.pressedButtons containsObject: @"A"])

				break;

# if defined(OF_NINTENDO_DS)
			swiWaitForVBlank();
# elif defined(OF_NINTENDO_3DS)
			gspWaitForVBlank();
# endif







|
>







330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
		[OFStdOut writeLine: @"Press A to continue"];

		for (;;) {
			void *pool = objc_autoreleasePoolPush();
			OFGameController *controller =
			    [[OFGameController controllers] objectAtIndex: 0];

			if ([controller.pressedButtons containsObject:
			    OFGameControllerEastButton])
				break;

# if defined(OF_NINTENDO_DS)
			swiWaitForVBlank();
# elif defined(OF_NINTENDO_3DS)
			gspWaitForVBlank();
# endif

Modified tests/gamecontroller/GameControllerTests.m from [2e38947e29] to [77c7b12639].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
			    controller.productID != nil) {
				[OFStdOut setForegroundColor: [OFColor teal]];
				[OFStdOut writeFormat: @" [%04X:%04X]",
				    controller.vendorID.unsignedShortValue,
				    controller.productID.unsignedShortValue];
			}

			[OFStdOut setForegroundColor: [OFColor blue]];
			[OFStdOut writeFormat:
			    @"\nNorth: %@  South: %@  West: %@  East: %@\n",
			    controller.northButton, controller.southButton,
			    controller.westButton, controller.eastButton];

			[controller retrieveState];

			for (OFGameControllerButton button in buttons) {
				float pressure =
				    [controller pressureForButton: button];








<
|
<
<
<







55
56
57
58
59
60
61

62



63
64
65
66
67
68
69
			    controller.productID != nil) {
				[OFStdOut setForegroundColor: [OFColor teal]];
				[OFStdOut writeFormat: @" [%04X:%04X]",
				    controller.vendorID.unsignedShortValue,
				    controller.productID.unsignedShortValue];
			}


			[OFStdOut writeString: @"\n"];




			[controller retrieveState];

			for (OFGameControllerButton button in buttons) {
				float pressure =
				    [controller pressureForButton: button];