ObjFW  Check-in [d5329de5f4]

Overview
Comment:OFGameController: Support 3DS analog right stick
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: d5329de5f4f134e73dd268db933d1c97e9d417e7248456590bb345961d0de624
User & Date: js on 2024-05-20 09:53:30
Other Links: branch diff | manifest | tags
Context
2024-05-20
10:29
Move +[waitForConsoleVBlank] to OFThread check-in: 684435a48d user: js tags: gamecontroller
09:53
OFGameController: Support 3DS analog right stick check-in: d5329de5f4 user: js tags: gamecontroller
04:35
OFGameController: Map 3DS C stick to right stick check-in: f31e553ade user: js tags: gamecontroller
Changes

Modified src/hid/OFNintendo3DSGameController.m from [ac863f7de3] to [5d5a974908].

75
76
77
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94

	[super dealloc];
}

- (void)retrieveState
{
	u32 keys;
	circlePosition pos;

	hidScanInput();

	keys = hidKeysHeld();
	hidCircleRead(&pos);


	[_pressedButtons removeAllObjects];

	if (keys & KEY_X)
		[_pressedButtons addObject: OFGameControllerNorthButton];
	if (keys & KEY_B)
		[_pressedButtons addObject: OFGameControllerSouthButton];







|




|
>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

	[super dealloc];
}

- (void)retrieveState
{
	u32 keys;
	circlePosition leftPos, rightPos;

	hidScanInput();

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

	[_pressedButtons removeAllObjects];

	if (keys & KEY_X)
		[_pressedButtons addObject: OFGameControllerNorthButton];
	if (keys & KEY_B)
		[_pressedButtons addObject: OFGameControllerSouthButton];
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
	if (keys & KEY_DRIGHT)
		[_pressedButtons addObject: OFGameControllerDPadRightButton];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerStartButton];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerSelectButton];

	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";
}








|
|
|
|
|
|
|
|

>
>
>
>
>
>
>
>
>

|

<
<
>







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
	if (keys & KEY_DRIGHT)
		[_pressedButtons addObject: OFGameControllerDPadRightButton];
	if (keys & KEY_START)
		[_pressedButtons addObject: OFGameControllerStartButton];
	if (keys & KEY_SELECT)
		[_pressedButtons addObject: OFGameControllerSelectButton];

	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;

	_leftAnalogStickPosition = OFMakePoint(
	    (float)leftPos.dx / 150, -(float)leftPos.dy / 150);
	_rightAnalogStickPosition = OFMakePoint(


	    (float)rightPos.dx / 150, -(float)rightPos.dy / 150);
}

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