ObjFW  Check-in [48e6a99f7b]

Overview
Comment:OHEvdevGamepad: Filter buttons/axes

This is instead of replacing them altogether, which means the button
names are kept and extra buttons are not removed.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 48e6a99f7b2baaae00b6edd0ed16fe8ff2627ab74ada14d4758c389873856948
User & Date: js on 2024-06-08 22:16:16
Other Links: manifest | tags
Context
2024-06-08
22:40
ObjFWHID: Add support for DualSense via evdev check-in: 3d8deae83e user: js tags: trunk
22:16
OHEvdevGamepad: Filter buttons/axes check-in: 48e6a99f7b user: js tags: trunk
21:25
ObjFWHID: Restore Nintendo DS support check-in: 6a6c86237d user: js tags: trunk
Changes

Modified src/hid/OHEvdevGamepad.m from [00711b94af] to [fbbf92a317].

38
39
40
41
42
43
44
45

46
47
48
49

50
51
52
53
54
55
56
38
39
40
41
42
43
44

45




46
47
48
49
50
51
52
53







-
+
-
-
-
-
+







		_rawProfile = [controller.rawProfile retain];

		if (self.northButton == nil || self.southButton == nil ||
		    self.westButton == nil || self.eastButton == nil ||
		    self.leftShoulderButton == nil ||
		    self.rightShoulderButton == nil ||
		    self.leftTriggerButton == nil ||
		    self.rightTriggerButton == nil ||
		    self.rightTriggerButton == nil || self.menuButton == nil ||
		    self.leftThumbstickButton == nil ||
		    self.rightThumbstickButton == nil ||
		    self.menuButton == nil || self.optionsButton == nil ||
		    self.homeButton == nil || self.leftThumbstick == nil ||
		    self.optionsButton == nil || self.leftThumbstick == nil ||
		    self.rightThumbstick == nil || self.dPad == nil)
			@throw [OFInvalidArgumentException exception];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

















85
86
87
88














89

90
91
92
93
94
95
96
61
62
63
64
65
66
67














68
69
70
71
72
73
74
75
76
77
78
79
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







-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+







	[_rawProfile release];

	[super dealloc];
}

- (OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *)buttons
{
	return [OFDictionary dictionaryWithKeysAndObjects:
	    @"North", self.northButton,
	    @"South", self.southButton,
	    @"West", self.westButton,
	    @"East", self.eastButton,
	    @"Left Shoulder", self.leftShoulderButton,
	    @"Right Shoulder", self.rightShoulderButton,
	    @"Left Trigger", self.leftTriggerButton,
	    @"Right Trigger", self.rightTriggerButton,
	    @"Left Thumbstick", self.leftThumbstickButton,
	    @"Right Thumbstick", self.rightThumbstickButton,
	    @"Menu", self.menuButton,
	    @"Options", self.optionsButton,
	    @"Home", self.homeButton, nil];
	OFMutableDictionary *buttons =
	    [[_rawProfile.buttons mutableCopy] autorelease];

	[buttons removeObjectForKey: @"D-Pad Up"];
	[buttons removeObjectForKey: @"D-Pad Down"];
	[buttons removeObjectForKey: @"D-Pad Left"];
	[buttons removeObjectForKey: @"D-Pad Right"];

	if ([_rawProfile.axes objectForKey: @"Z"] != nil)
		[buttons setObject: self.leftTriggerButton forKey: @"TL2"];

	if ([_rawProfile.axes objectForKey: @"RZ"] != nil)
		[buttons setObject: self.rightTriggerButton forKey: @"TR2"];

	[buttons makeImmutable];

	return buttons;
}

- (OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *)axes
{
	OFMutableDictionary *axes =
	    [[_rawProfile.axes mutableCopy] autorelease];

	[axes removeObjectForKey: @"X"];
	[axes removeObjectForKey: @"Y"];
	[axes removeObjectForKey: @"RX"];
	[axes removeObjectForKey: @"RY"];
	[axes removeObjectForKey: @"Z"];
	[axes removeObjectForKey: @"RZ"];
	[axes removeObjectForKey: @"HAT0X"];
	[axes removeObjectForKey: @"HAT0Y"];

	[axes makeImmutable];

	return [OFDictionary dictionary];
	return axes;
}

- (OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *) *)
    directionalPads
{
	return [OFDictionary dictionaryWithKeysAndObjects:
	    @"Left Thumbstick", self.leftThumbstick,

Modified src/hid/OHXInputGamepad.m from [c3e1b2216e] to [f110678448].

51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
68
69
70
51
52
53
54
55
56
57


58




59
60
61
62
63
64
65







-
-
+
-
-
-
-








			if ([buttonNames[i] isEqual: @"Guide"] &&
			    OHXInputVersion == 910)
				continue;

			button = [[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]];
			@try {
				[buttons setObject: button
			[buttons setObject: button forKey: buttonNames[i]];
					    forKey: buttonNames[i]];
			} @finally {
				[button release];
			}
		}
		[buttons makeImmutable];
		_buttons = [buttons retain];

		_axes = [[OFDictionary alloc] init];

		directionalPads =