ObjFW  Diff

Differences From Artifact [492047b1e9]:

To Artifact [6bc450a66c]:


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
122

123
124


125
126
127
128

129
130
131
132


133
134
135
136
137
138
139
	[_extendedGamepad release];

	[super dealloc];
}

- (void)retrieveState
{





	u32 keys;
	circlePosition leftPos, rightPos;


	hidScanInput();

	keys = hidKeysHeld();
	hidCircleRead(&leftPos);
	hidCstickRead(&rightPos);

	[_extendedGamepad.northButton setValue: !!(keys & KEY_X)];
	[_extendedGamepad.southButton setValue: !!(keys & KEY_B)];
	[_extendedGamepad.westButton setValue: !!(keys & KEY_Y)];
	[_extendedGamepad.eastButton setValue: !!(keys & KEY_A)];
	[_extendedGamepad.leftShoulderButton setValue: !!(keys & KEY_L)];
	[_extendedGamepad.rightShoulderButton setValue: !!(keys & KEY_R)];
	[_extendedGamepad.leftTriggerButton setValue: !!(keys & KEY_ZL)];
	[_extendedGamepad.rightTriggerButton setValue: !!(keys & KEY_ZR)];
	[_extendedGamepad.menuButton setValue: !!(keys & KEY_START)];
	[_extendedGamepad.optionsButton setValue: !!(keys & KEY_SELECT)];

	if (leftPos.dx > 150)
		leftPos.dx = 150;
	if (leftPos.dx < -150)
		leftPos.dx = -150;
	if (leftPos.dy > 150)
		leftPos.dy = 150;
	if (leftPos.dy < -150)
		leftPos.dy = -150;

	if (rightPos.dx > 150)
		rightPos.dx = 150;
	if (rightPos.dx < -150)
		rightPos.dx = -150;
	if (rightPos.dy > 150)
		rightPos.dy = 150;
	if (rightPos.dy < -150)
		rightPos.dy = -150;


	_extendedGamepad.leftThumbstick.xAxis.value = (float)leftPos.dx / 150;
	_extendedGamepad.leftThumbstick.yAxis.value = -(float)leftPos.dy / 150;


	_extendedGamepad.rightThumbstick.xAxis.value = (float)rightPos.dx / 150;
	_extendedGamepad.rightThumbstick.yAxis.value =
	    -(float)rightPos.dy / 150;


	[_extendedGamepad.dPad.up setValue: !!(keys & KEY_DUP)];
	[_extendedGamepad.dPad.down setValue: !!(keys & KEY_DDOWN)];
	[_extendedGamepad.dPad.left setValue: !!(keys & KEY_DLEFT)];
	[_extendedGamepad.dPad.right setValue: !!(keys & KEY_DRIGHT)];


}

- (OFString *)name
{
	return @"Nintendo 3DS";
}








>
>
>
>
>


>







|
|
|
|
|
|
|
|
|
|



















>
|
|
>
>
|
<
|

>
|
|
|
|
>
>







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
122
123
124
125
126
127
128
129
130
131
132
133
134

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
	[_extendedGamepad release];

	[super dealloc];
}

- (void)retrieveState
{
	void *pool = objc_autoreleasePoolPush();
	OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *)
	    *buttons = _extendedGamepad.buttons;
	OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *)
	    *directionalPads = _extendedGamepad.directionalPads;
	u32 keys;
	circlePosition leftPos, rightPos;
	OHGameControllerDirectionalPad *directionalPad;

	hidScanInput();

	keys = hidKeysHeld();
	hidCircleRead(&leftPos);
	hidCstickRead(&rightPos);

	[[buttons objectForKey: @"A"] setValue: !!(keys & KEY_A)];
	[[buttons objectForKey: @"B"] setValue: !!(keys & KEY_B)];
	[[buttons objectForKey: @"X"] setValue: !!(keys & KEY_X)];
	[[buttons objectForKey: @"Y"] setValue: !!(keys & KEY_Y)];
	[[buttons objectForKey: @"L"] setValue: !!(keys & KEY_L)];
	[[buttons objectForKey: @"R"] setValue: !!(keys & KEY_R)];
	[[buttons objectForKey: @"ZL"] setValue: !!(keys & KEY_ZL)];
	[[buttons objectForKey: @"ZR"] setValue: !!(keys & KEY_ZR)];
	[[buttons objectForKey: @"Start"] setValue: !!(keys & KEY_START)];
	[[buttons objectForKey: @"Select"] setValue: !!(keys & KEY_SELECT)];

	if (leftPos.dx > 150)
		leftPos.dx = 150;
	if (leftPos.dx < -150)
		leftPos.dx = -150;
	if (leftPos.dy > 150)
		leftPos.dy = 150;
	if (leftPos.dy < -150)
		leftPos.dy = -150;

	if (rightPos.dx > 150)
		rightPos.dx = 150;
	if (rightPos.dx < -150)
		rightPos.dx = -150;
	if (rightPos.dy > 150)
		rightPos.dy = 150;
	if (rightPos.dy < -150)
		rightPos.dy = -150;

	directionalPad = [directionalPads objectForKey: @"Circle Pad"];
	directionalPad.xAxis.value = (float)leftPos.dx / 150;
	directionalPad.yAxis.value = -(float)leftPos.dy / 150;

	directionalPad = [directionalPads objectForKey: @"C-Stick"];
	directionalPad.xAxis.value = (float)rightPos.dx / 150;

	directionalPad.yAxis.value = -(float)rightPos.dy / 150;

	directionalPad = [directionalPads objectForKey: @"D-Pad"];
	[directionalPad.up setValue: !!(keys & KEY_DUP)];
	[directionalPad.down setValue: !!(keys & KEY_DDOWN)];
	[directionalPad.left setValue: !!(keys & KEY_DLEFT)];
	[directionalPad.right setValue: !!(keys & KEY_DRIGHT)];

	objc_autoreleasePoolPop(pool);
}

- (OFString *)name
{
	return @"Nintendo 3DS";
}