24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
-
+
+
+
|
#import "OFColor.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFStdIOStream.h"
#import "OFThread.h"
#import "OHCombinedJoyCons.h"
#import "OHExtendedGamepad.h"
#import "OHGameController.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerProfile.h"
#import "OHGamepad.h"
#import "OHJoyConPair.h"
#import "OHLeftJoyCon.h"
#import "OHRightJoyCon.h"
#import "OFReadFailedException.h"
#if defined(OF_NINTENDO_DS)
static size_t buttonsPerLine = 2;
#elif defined(OF_NINTENDO_3DS)
static size_t buttonsPerLine = 3;
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
+
-
+
|
consoleInit(NULL);
while (appletMainLoop()) {
#else
for (;;) {
#endif
void *pool = objc_autoreleasePoolPush();
OHLeftJoyCon *leftJoyCon = nil;
OHGameController *leftJoyCon = nil, *rightJoyCon = nil;
OHRightJoyCon *rightJoyCon = nil;
if (_lastControllersUpdate == nil ||
-[_lastControllersUpdate timeIntervalSinceNow] > 1) {
[_controllers release];
[_lastControllersUpdate release];
_controllers = [[OHGameController controllers] retain];
|
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
|
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
|
-
-
-
-
-
+
+
-
-
-
+
+
-
-
+
-
+
-
+
|
[OFStdOut setForegroundColor: [OFColor red]];
[OFStdOut writeString: e.description];
continue;
}
printProfile(profile);
if (controller.vendorID.unsignedShortValue ==
OHVendorIDNintendo) {
if (controller.productID.unsignedShortValue ==
OHProductIDLeftJoyCon)
leftJoyCon = controller;
if ([profile isKindOfClass: [OHLeftJoyCon class]])
leftJoyCon = (OHLeftJoyCon *)profile;
if (controller.productID.unsignedShortValue ==
OHProductIDRightJoyCon)
rightJoyCon = controller;
else if ([profile isKindOfClass: [OHRightJoyCon class]])
rightJoyCon = (OHRightJoyCon *)profile;
}
}
if (leftJoyCon != nil && rightJoyCon != nil) {
OHCombinedJoyCons *combinedJoyCons = [OHCombinedJoyCons
OHJoyConPair *joyConPair = [OHJoyConPair
gamepadWithLeftJoyCon: leftJoyCon
rightJoyCon: rightJoyCon];
[OFStdOut setForegroundColor: [OFColor green]];
[OFStdOut writeLine: @"Combined Joy-Cons"];
[OFStdOut writeLine: @"Joy-Con Pair"];
printProfile(combinedJoyCons);
printProfile(joyConPair);
}
#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS)
[OFThread waitForVerticalBlank];
#elif defined(OF_NINTENDO_SWITCH)
consoleUpdate(NULL);
#else
|