ObjFW  Check-in [978e3bfb1e]

Overview
Comment:OFGameController: Quirks for Xbox 360 controller
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: 978e3bfb1ec0cdb9d597ab4d6fab89ecf807ddf815f2553f1e35c7712cf4cbae
User & Date: js on 2024-05-09 18:13:57
Other Links: branch diff | manifest | tags
Context
2024-05-09
19:05
OFGameController: Add constants for buttons check-in: f02049612e user: js tags: gamecontroller
18:13
OFGameController: Quirks for Xbox 360 controller check-in: 978e3bfb1e user: js tags: gamecontroller
18:01
OFGameController: Add quirks for N64 controller check-in: 21c872dbb0 user: js tags: gamecontroller
Changes

Modified src/platform/Linux/OFGameController.m from [c15cf8d62a] to [470c008fba].

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







+

+
+
















-
+
+
+
+
+
+
+
+








#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"

static const uint16_t vendorIDMicrosoft = 0x045E;
static const uint16_t vendorIDNintendo = 0x057E;

static const uint16_t productIDXbox360Controller = 0x028E;
static const uint16_t productIDN64Controller = 0x2019;

@interface OFGameController ()
- (instancetype)of_initWithPath: (OFString *)path OF_METHOD_FAMILY(init);
- (void)of_processEvents;
@end

static const uint16_t buttons[] = {
	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
};

static OFString *
buttonToName(uint16_t button, uint16_t vendorID, uint16_t productID)
{
	if (vendorID == vendorIDNintendo &&
	if (vendorID == vendorIDMicrosoft &&
	    productID == productIDXbox360Controller) {
		switch (button) {
		case BTN_C:
		case BTN_Z:
			return nil;
		}
	} else if (vendorID == vendorIDNintendo &&
	    productID == productIDN64Controller) {
		switch (button) {
		case BTN_TL2:
			return @"Z";
		case BTN_Y:
			return @"C-Stick Left";
		case BTN_C:
100
101
102
103
104
105
106
107

108
109

110
111

112
113
114
115
116
117
118
110
111
112
113
114
115
116

117
118

119
120

121
122
123
124
125
126
127
128







-
+

-
+

-
+







	case BTN_TR2:
		return @"ZR";
	case BTN_SELECT:
		return @"Select";
	case BTN_START:
		return @"Start";
	case BTN_MODE:
		return @"Mode";
		return @"Home";
	case BTN_THUMBL:
		return @"Thumb L";
		return @"Left Stick";
	case BTN_THUMBR:
		return @"Thumb R";
		return @"Right Stick";
	case BTN_DPAD_UP:
		return @"D-Pad Up";
	case BTN_DPAD_DOWN:
		return @"D-Pad Down";
	case BTN_DPAD_LEFT:
		return @"D-Pad Left";
	case BTN_DPAD_RIGHT: