ObjFW  Diff

Differences From Artifact [5dde4675ee]:

To Artifact [ac863f7de3]:


29
30
31
32
33
34
35

36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43







+







#include <3ds.h>
#undef id

static OFArray OF_GENERIC(OFGameController *) *controllers;

@implementation OFNintendo3DSGameController
@synthesize leftAnalogStickPosition = _leftAnalogStickPosition;
@synthesize rightAnalogStickPosition = _rightAnalogStickPosition;

+ (void)initialize
{
	void *pool;

	if (self != [OFNintendo3DSGameController class])
		return;
53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68







-
+







}

- (instancetype)init
{
	self = [super init];

	@try {
		_pressedButtons = [[OFMutableSet alloc] initWithCapacity: 18];
		_pressedButtons = [[OFMutableSet alloc] initWithCapacity: 14];

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

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
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







-
-
-
-
-
-
-
-












+
+
+







		[_pressedButtons addObject: OFGameControllerDPadLeftButton];
	if (keys & KEY_DRIGHT)
		[_pressedButtons addObject: OFGameControllerDPadRightButton];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerStartButton];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerSelectButton];
	if (keys & KEY_CSTICK_UP)
		[_pressedButtons addObject: OFGameControllerCPadUpButton];
	if (keys & KEY_CSTICK_DOWN)
		[_pressedButtons addObject: OFGameControllerCPadDownButton];
	if (keys & KEY_CSTICK_LEFT)
		[_pressedButtons addObject: OFGameControllerCPadLeftButton];
	if (keys & KEY_CSTICK_RIGHT)
		[_pressedButtons addObject: OFGameControllerCPadRightButton];

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

	_leftAnalogStickPosition = OFMakePoint(
	    (float)pos.dx / 150, -(float)pos.dy / 150);
	_rightAnalogStickPosition = OFMakePoint(
	    -!!(keys & KEY_CSTICK_LEFT) + !!(keys & KEY_CSTICK_RIGHT),
	    -!!(keys & KEY_CSTICK_UP) + !!(keys & KEY_CSTICK_DOWN));
}

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

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
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







-
+
-
-
-
-














-
+


	    OFGameControllerRightShoulderButton,
	    OFGameControllerLeftShoulderButton,
	    OFGameControllerDPadUpButton,
	    OFGameControllerDPadDownButton,
	    OFGameControllerDPadLeftButton,
	    OFGameControllerDPadRightButton,
	    OFGameControllerStartButton,
	    OFGameControllerSelectButton,
	    OFGameControllerSelectButton, nil];
	    OFGameControllerCPadRightButton,
	    OFGameControllerCPadLeftButton,
	    OFGameControllerCPadUpButton,
	    OFGameControllerCPadDownButton, nil];
}

- (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons
{
	return [[_pressedButtons copy] autorelease];
}

- (bool)hasLeftAnalogStick
{
	return true;
}

- (bool)hasRightAnalogStick
{
	return false;
	return true;
}
@end