57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
@interface OHEvdevGameControllerProfile: OFObject <OHGameControllerProfile>
{
OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons;
OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *_axes;
}
- (instancetype)oh_initWithButtons: (OFDictionary *)buttons
axes: (OFDictionary *)axes OF_METHOD_FAMILY(init);
@end
static const uint16_t buttonIDs[] = {
BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2,
BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR,
BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT,
BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, BTN_TRIGGER_HAPPY3,
|
|
|
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
@interface OHEvdevGameControllerProfile: OFObject <OHGameControllerProfile>
{
OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons;
OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *_axes;
}
- (instancetype)initWithButtons: (OFDictionary *)buttons
axes: (OFDictionary *)axes;
@end
static const uint16_t buttonIDs[] = {
BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2,
BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR,
BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT,
BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, BTN_TRIGGER_HAPPY3,
|
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
if (![device hasPrefix: @"event"])
continue;
path = [@"/dev/input" stringByAppendingPathComponent: device];
@try {
controller = [[[OHEvdevGameController alloc]
oh_initWithPath: path] autorelease];
} @catch (OFOpenItemFailedException *e) {
if (e.errNo == EACCES)
continue;
@throw e;
} @catch (OFInvalidArgumentException *e) {
/* Not a game controller. */
|
|
|
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
if (![device hasPrefix: @"event"])
continue;
path = [@"/dev/input" stringByAppendingPathComponent: device];
@try {
controller = [[[OHEvdevGameController alloc]
initWithPath: path] autorelease];
} @catch (OFOpenItemFailedException *e) {
if (e.errNo == EACCES)
continue;
@throw e;
} @catch (OFInvalidArgumentException *e) {
/* Not a game controller. */
|
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
[controllers makeImmutable];
objc_autoreleasePoolPop(pool);
return controllers;
}
- (instancetype)oh_initWithPath: (OFString *)path
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFStringEncoding encoding = [OFLocale encoding];
struct input_id inputID;
|
|
|
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
[controllers makeImmutable];
objc_autoreleasePoolPop(pool);
return controllers;
}
- (instancetype)initWithPath: (OFString *)path
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFStringEncoding encoding = [OFLocale encoding];
struct input_id inputID;
|
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
[axes setObject: axis forKey: axisName];
}
}
}
[axes makeImmutable];
_rawProfile = [[OHEvdevGameControllerProfile alloc]
oh_initWithButtons: buttons
axes: axes];
[self oh_pollState];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
|
|
|
|
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
[axes setObject: axis forKey: axisName];
}
}
}
[axes makeImmutable];
_rawProfile = [[OHEvdevGameControllerProfile alloc]
initWithButtons: buttons
axes: axes];
[self oh_pollState];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
|
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
|
@implementation OHEvdevGameControllerAxis
@end
@implementation OHEvdevGameControllerProfile
@synthesize buttons = _buttons, axes = _axes;
- (instancetype)oh_initWithButtons: (OFDictionary *)buttons
axes: (OFDictionary *)axes
{
self = [super init];
@try {
_buttons = [buttons retain];
_axes = [axes retain];
} @catch (id e) {
|
|
|
|
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
|
@implementation OHEvdevGameControllerAxis
@end
@implementation OHEvdevGameControllerProfile
@synthesize buttons = _buttons, axes = _axes;
- (instancetype)initWithButtons: (OFDictionary *)buttons
axes: (OFDictionary *)axes
{
self = [super init];
@try {
_buttons = [buttons retain];
_axes = [axes retain];
} @catch (id e) {
|