ObjFW  Diff

Differences From Artifact [90a7f9c337]:

To Artifact [0639ff2a5d]:


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
47
48
49
50
51
52
53

54
55
56
57
58
59
60







-







{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFDictionary *leftButtons, *rightButtons;
		OFMutableDictionary *buttons, *directionalPads;
		OHGameControllerDirectionalPad *directionalPad;

		if (leftJoyCon.vendorID.unsignedShortValue !=
		    OHVendorIDNintendo ||
		    rightJoyCon.vendorID.unsignedShortValue !=
		    OHVendorIDNintendo)
			@throw [OFInvalidArgumentException exception];

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
111
112
113
114
115
116
117
118
119
120
121
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







-
-
-
-







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







		leftButtons = _leftJoyCon.buttons;
		rightButtons = _rightJoyCon.buttons;

		buttons = [OFMutableDictionary dictionaryWithCapacity:
		    leftButtons.count + rightButtons.count];
		[buttons addEntriesFromDictionary: leftButtons];
		[buttons addEntriesFromDictionary: rightButtons];
		[buttons removeObjectForKey: @"D-Pad Up"];
		[buttons removeObjectForKey: @"D-Pad Down"];
		[buttons removeObjectForKey: @"D-Pad Left"];
		[buttons removeObjectForKey: @"D-Pad Right"];
		[buttons removeObjectForKey: @"SL"];
		[buttons removeObjectForKey: @"SR"];
		[buttons makeImmutable];
		_buttons = [buttons retain];

		directionalPads =
		    [OFMutableDictionary dictionaryWithCapacity: 3];

		[directionalPads addEntriesFromDictionary:
		directionalPad = [[[OHGameControllerDirectionalPad alloc]
		    initWithName: @"Left Thumbstick"
			   xAxis: [_leftJoyCon.axes objectForKey: @"X"]
			   yAxis: [_leftJoyCon.axes objectForKey: @"Y"]]
		    autorelease];
		[directionalPads setObject: directionalPad
		    _leftJoyCon.directionalPads];
				    forKey: @"Left Thumbstick"];

		[directionalPads addEntriesFromDictionary:
		directionalPad = [[[OHGameControllerDirectionalPad alloc]
		    initWithName: @"Right Thumbstick"
			   xAxis: [_rightJoyCon.axes objectForKey: @"RX"]
			   yAxis: [_rightJoyCon.axes objectForKey: @"RY"]]
		    autorelease];
		[directionalPads setObject: directionalPad
		    _rightJoyCon.directionalPads];
				    forKey: @"Right Thumbstick"];

		directionalPad = [[[OHGameControllerDirectionalPad alloc]
		    initWithName: @"D-Pad"
			      up: [leftButtons objectForKey: @"D-Pad Up"]
			    down: [leftButtons objectForKey: @"D-Pad Down"]
			    left: [leftButtons objectForKey: @"D-Pad Left"]
			   right: [leftButtons objectForKey: @"D-Pad Right"]]
		    autorelease];
		[directionalPads setObject: directionalPad forKey: @"D-Pad"];

		[directionalPads makeImmutable];
		_directionalPads = [directionalPads retain];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;