27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OHEvdevGamepad.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerProfile.h"
#include <sys/ioctl.h>
#include <linux/input.h>
|
>
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OHEvdevDualSense.h"
#import "OHEvdevGamepad.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerProfile.h"
#include <sys/ioctl.h>
#include <linux/input.h>
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
static const uint16_t axisIDs[] = {
ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ, ABS_THROTTLE, ABS_RUDDER,
ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X,
ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y, ABS_HAT3X, ABS_HAT3Y
};
static OFString *
buttonToName(uint16_t button)
{
switch (button) {
case BTN_A:
return @"A";
case BTN_B:
return @"B";
case BTN_C:
return @"C";
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
static const uint16_t axisIDs[] = {
ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ, ABS_THROTTLE, ABS_RUDDER,
ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X,
ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y, ABS_HAT3X, ABS_HAT3Y
};
static OFString *
buttonToName(uint16_t button, uint16_t vendorID, uint16_t productID)
{
if (vendorID == OHVendorIDSony && productID == OHProductIDDualSense) {
switch (button) {
case BTN_NORTH:
return @"Triangle";
case BTN_SOUTH:
return @"Cross";
case BTN_WEST:
return @"Square";
case BTN_EAST:
return @"Circle";
case BTN_TL:
return @"L1";
case BTN_TR:
return @"R1";
case BTN_TL2:
return @"L2";
case BTN_TR2:
return @"R2";
case BTN_THUMBL:
return @"L3";
case BTN_THUMBR:
return @"R3";
case BTN_START:
return @"Options";
case BTN_SELECT:
return @"Create";
case BTN_MODE:
return @"PS";
}
}
switch (button) {
case BTN_A:
return @"A";
case BTN_B:
return @"B";
case BTN_C:
return @"C";
|
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
buttons = [OFMutableDictionary dictionary];
for (size_t i = 0; i < sizeof(buttonIDs) / sizeof(*buttonIDs);
i++) {
if (OFBitSetIsSet(_keyBits, buttonIDs[i])) {
OFString *buttonName;
OHGameControllerButton *button;
buttonName = buttonToName(buttonIDs[i]);
if (buttonName == nil)
continue;
button = [[[OHGameControllerButton alloc]
initWithName: buttonName] autorelease];
[buttons setObject: button forKey: buttonName];
|
|
>
|
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
buttons = [OFMutableDictionary dictionary];
for (size_t i = 0; i < sizeof(buttonIDs) / sizeof(*buttonIDs);
i++) {
if (OFBitSetIsSet(_keyBits, buttonIDs[i])) {
OFString *buttonName;
OHGameControllerButton *button;
buttonName = buttonToName(buttonIDs[i],
_vendorID, _productID);
if (buttonName == nil)
continue;
button = [[[OHGameControllerButton alloc]
initWithName: buttonName] autorelease];
[buttons setObject: button forKey: buttonName];
|
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
i++) {
OFString *name;
OHGameControllerButton *button;
if (!OFBitSetIsSet(_keyBits, buttonIDs[i]))
continue;
name = buttonToName(buttonIDs[i]);
if (name == nil)
continue;
button = [_rawProfile.buttons objectForKey: name];
if (button == nil)
continue;
|
|
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
i++) {
OFString *name;
OHGameControllerButton *button;
if (!OFBitSetIsSet(_keyBits, buttonIDs[i]))
continue;
name = buttonToName(buttonIDs[i], _vendorID, _productID);
if (name == nil)
continue;
button = [_rawProfile.buttons objectForKey: name];
if (button == nil)
continue;
|
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
|
case EV_SYN:
if (event.value == SYN_DROPPED) {
_discardUntilReport = true;
continue;
}
break;
case EV_KEY:
name = buttonToName(event.code);
if (name == nil)
continue;
button = [_rawProfile.buttons objectForKey: name];
if (button == nil)
continue;
|
|
|
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
case EV_SYN:
if (event.value == SYN_DROPPED) {
_discardUntilReport = true;
continue;
}
break;
case EV_KEY:
name = buttonToName(event.code, _vendorID, _productID);
if (name == nil)
continue;
button = [_rawProfile.buttons objectForKey: name];
if (button == nil)
continue;
|
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
|
}
}
}
- (OHGamepad *)gamepad
{
@try {
return [[[OHEvdevGamepad alloc]
initWithController: self] autorelease];
} @catch (OFInvalidArgumentException *e) {
return nil;
}
}
- (OFComparisonResult)compare: (OHEvdevGameController *)otherController
{
|
>
>
>
>
>
|
|
|
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
}
}
}
- (OHGamepad *)gamepad
{
@try {
if (_vendorID == OHVendorIDSony &&
_productID == OHProductIDDualSense)
return [[[OHEvdevDualSense alloc]
initWithController: self] autorelease];
else
return [[[OHEvdevGamepad alloc]
initWithController: self] autorelease];
} @catch (OFInvalidArgumentException *e) {
return nil;
}
}
- (OFComparisonResult)compare: (OHEvdevGameController *)otherController
{
|