ObjFW  Diff

Differences From Artifact [c2e9c0c45a]:

To Artifact [453f7a0173]:


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>







>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"

#import "OHEvdevDualSense.h"
#import "OHEvdevDualShock4.h"
#import "OHEvdevGamepad.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerProfile.h"

#include <sys/ioctl.h>
#include <linux/input.h>
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
	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";







>
|







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	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 ||
	    productID == OHProductIDDualShock4)) {
		switch (button) {
		case BTN_NORTH:
			return @"Triangle";
		case BTN_SOUTH:
			return @"Cross";
		case BTN_WEST:
			return @"Square";
106
107
108
109
110
111
112
113
114
115
116
117
118







119
120
121
122
123
124
125
			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:







<
<




>
>
>
>
>
>
>







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
			return @"R2";
		case BTN_THUMBL:
			return @"L3";
		case BTN_THUMBR:
			return @"R3";
		case BTN_START:
			return @"Options";


		case BTN_MODE:
			return @"PS";
		}
	}

	if (vendorID == OHVendorIDSony && productID == OHProductIDDualSense)
		if (button == BTN_SELECT)
			return @"Create";
	if (vendorID == OHVendorIDSony && productID == OHProductIDDualShock4)
		if (button == BTN_SELECT)
			return @"Share";

	switch (button) {
	case BTN_A:
		return @"A";
	case BTN_B:
		return @"B";
	case BTN_C:
631
632
633
634
635
636
637




638
639
640
641
642
643
644

- (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;
	}







>
>
>
>







638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655

- (OHGamepad *)gamepad
{
	@try {
		if (_vendorID == OHVendorIDSony &&
		    _productID == OHProductIDDualSense)
			return [[[OHEvdevDualSense alloc]
			    initWithController: self] autorelease];
		else if (_vendorID == OHVendorIDSony &&
		    _productID == OHProductIDDualShock4)
			return [[[OHEvdevDualShock4 alloc]
			    initWithController: self] autorelease];
		else
			return [[[OHEvdevGamepad alloc]
			    initWithController: self] autorelease];
	} @catch (OFInvalidArgumentException *e) {
		return nil;
	}