ObjFW  Check-in [6b3b47c1f4]

Overview
Comment:OHEvdevGameController: Default to Xbox buttons

The vast majority of controllers out there are Xbox 360-compatible
controllers, so let's use those button names by default.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6b3b47c1f4ef73b94f1585c68448e198228e4406a9562802020578d3b67128a6
User & Date: js on 2024-06-08 22:47:11
Other Links: manifest | tags
Context
2024-06-08
22:59
ObjFWHID: Improve test for gamepad profile check-in: c7a5bfe9e6 user: js tags: trunk
22:47
OHEvdevGameController: Default to Xbox buttons check-in: 6b3b47c1f4 user: js tags: trunk
22:40
ObjFWHID: Add support for DualSense via evdev check-in: 3d8deae83e user: js tags: trunk
Changes

Modified src/hid/OHEvdevGameController.m from [34e73fdaa7] to [c2e9c0c45a].

127
128
129
130
131
132
133
134

135
136

137
138

139
140

141
142

143
144
145
146

147
148

149
150

151
152
153
154
155
156
157
127
128
129
130
131
132
133

134
135

136
137

138
139

140
141

142
143
144
145

146
147

148
149

150
151
152
153
154
155
156
157







-
+

-
+

-
+

-
+

-
+



-
+

-
+

-
+







	case BTN_X:
		return @"X";
	case BTN_Y:
		return @"Y";
	case BTN_Z:
		return @"Z";
	case BTN_TL:
		return @"TL";
		return @"LB";
	case BTN_TR:
		return @"TR";
		return @"RB";
	case BTN_TL2:
		return @"TL2";
		return @"LT";
	case BTN_TR2:
		return @"TR2";
		return @"RT";
	case BTN_SELECT:
		return @"Select";
		return @"Back";
	case BTN_START:
		return @"Start";
	case BTN_MODE:
		return @"Mode";
		return @"Guide";
	case BTN_THUMBL:
		return @"Thumb L";
		return @"LSB";
	case BTN_THUMBR:
		return @"Thumb R";
		return @"RSB";
	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:

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

70
71
72
73
74
75
76
77

78
79
80

81
82
83
84
85
86
87
70
71
72
73
74
75
76

77
78
79

80
81
82
83
84
85
86
87







-
+


-
+








	[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"];
		[buttons setObject: self.leftTriggerButton forKey: @"LT"];

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

	[buttons makeImmutable];

	return buttons;
}

- (OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *)axes
130
131
132
133
134
135
136
137

138
139
140
141
142

143
144
145
146
147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
163
164

165
166
167
168
169

170
171
172
173
174

175
176
177
178
179
180
181
182
183
184

185
186
187
188
189

190
191
192
193
194
195
196
130
131
132
133
134
135
136

137
138
139
140
141

142
143
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
160
161
162
163

164
165
166
167
168

169
170
171
172
173

174
175
176
177
178
179
180
181
182
183

184
185
186
187
188

189
190
191
192
193
194
195
196







-
+




-
+










-
+










-
+




-
+




-
+









-
+




-
+







- (OHGameControllerButton *)eastButton
{
	return [_rawProfile.buttons objectForKey: @"B"];
}

- (OHGameControllerButton *)leftShoulderButton
{
	return [_rawProfile.buttons objectForKey: @"TL"];
	return [_rawProfile.buttons objectForKey: @"LB"];
}

- (OHGameControllerButton *)rightShoulderButton
{
	return [_rawProfile.buttons objectForKey: @"TR"];
	return [_rawProfile.buttons objectForKey: @"RB"];
}

- (OHGameControllerButton *)leftTriggerButton
{
	OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"Z"];

	if (axis != nil)
		return [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithAxis: axis] autorelease];

	return [_rawProfile.buttons objectForKey: @"TL2"];
	return [_rawProfile.buttons objectForKey: @"LT"];
}

- (OHGameControllerButton *)rightTriggerButton
{
	OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"RZ"];

	if (axis != nil)
		return [[[OHGameControllerEmulatedTriggerButton alloc]
		    initWithAxis: axis] autorelease];

	return [_rawProfile.buttons objectForKey: @"TR2"];
	return [_rawProfile.buttons objectForKey: @"RT"];
}

- (OHGameControllerButton *)leftThumbstickButton
{
	return [_rawProfile.buttons objectForKey: @"Thumb L"];
	return [_rawProfile.buttons objectForKey: @"LSB"];
}

- (OHGameControllerButton *)rightThumbstickButton
{
	return [_rawProfile.buttons objectForKey: @"Thumb R"];
	return [_rawProfile.buttons objectForKey: @"RSB"];
}

- (OHGameControllerButton *)menuButton
{
	return [_rawProfile.buttons objectForKey: @"Start"];
}

- (OHGameControllerButton *)optionsButton
{
	return [_rawProfile.buttons objectForKey: @"Select"];
	return [_rawProfile.buttons objectForKey: @"Back"];
}

- (OHGameControllerButton *)homeButton
{
	return [_rawProfile.buttons objectForKey: @"Mode"];
	return [_rawProfile.buttons objectForKey: @"Guide"];
}

- (OHGameControllerDirectionalPad *)leftThumbstick
{
	OHGameControllerAxis *xAxis = [_rawProfile.axes objectForKey: @"X"];
	OHGameControllerAxis *yAxis = [_rawProfile.axes objectForKey: @"Y"];