ObjFW  Diff

Differences From Artifact [67cdfbaf35]:

To Artifact [379635704c]:


17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34







+



-







 * <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#import "OHDualShock4Gamepad.h"
#import "OFDictionary.h"
#import "OHEmulatedGameControllerTriggerButton.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerDirectionalPad.h"
#import "OHGameControllerEmulatedTriggerButton.h"

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include <linux/input.h>
#endif

static OFString *const buttonNames[] = {
	@"Triangle", @"Cross", @"Square", @"Circle", @"L1", @"R1", @"L3", @"R3",
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70

71
72
73
74
75
76
77
56
57
58
59
60
61
62

63
64
65
66
67
68
69

70
71
72
73
74
75
76
77







-
+






-
+







			button = [[[OHGameControllerButton alloc]
			    initWithName: buttonNames[i]] autorelease];
			[buttons setObject: button forKey: buttonNames[i]];
		}

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"L2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"L2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"L2"];

		axis = [[[OHGameControllerAxis alloc]
		    initWithName: @"R2"] autorelease];
		button = [[[OHGameControllerEmulatedTriggerButton alloc]
		button = [[[OHEmulatedGameControllerTriggerButton alloc]
		    initWithName: @"R2"
			    axis: axis] autorelease];
		[buttons setObject: button forKey: @"R2"];

		[buttons makeImmutable];
		_buttons = [buttons retain];

273
274
275
276
277
278
279
280

281
282
283

284
285
286
287
288
289
290
273
274
275
276
277
278
279

280
281
282

283
284
285
286
287
288
289
290







-
+


-
+







	case ABS_RY:
		return [[_directionalPads objectForKey: @"Right Stick"] yAxis];
	case ABS_HAT0X:
		return [[_directionalPads objectForKey: @"D-Pad"] xAxis];
	case ABS_HAT0Y:
		return [[_directionalPads objectForKey: @"D-Pad"] yAxis];
	case ABS_Z:
		return ((OHGameControllerEmulatedTriggerButton *)
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"L2"]).axis;
	case ABS_RZ:
		return ((OHGameControllerEmulatedTriggerButton *)
		return ((OHEmulatedGameControllerTriggerButton *)
		    [_buttons objectForKey: @"R2"]).axis;
	default:
		return nil;
	}
}
#endif
@end