Skip to content

Commit 662aadd

Browse files
committed
make 3ds keys work
1 parent 9fe4790 commit 662aadd

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed

platforms/build-3ds.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ if [ ! -d "$ROMFS" ]; then
240240

241241
mkdir -p "$ROMFS"
242242

243-
cp -r assets "$ROMFS"
243+
cp -r assets "$ROMFS/"
244244

245245
fi
246246

platforms/build-switch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ if [ ! -d "$ROMFS" ]; then
137137

138138
mkdir -p "$ROMFS"
139139

140-
cp -r assets "$ROMFS"
140+
cp -r assets "$ROMFS/"
141141

142142
fi
143143

src/manager/event_dispatcher.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct EventDispatcher final {
3838

3939
SDL_Event event;
4040
while (SDL_PollEvent(&event) != 0) {
41-
4241
if (m_input_activated) {
4342
switch (event.type) {
4443
case SDL_KEYDOWN:

src/platform/capabilities.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ namespace {
127127

128128
const std::vector<i64> needed_events = utils::key_map.at(static_cast<u8>(action));
129129
for (const auto& needed_event : needed_events) { // NOLINT(readability-use-anyofallof)
130-
#if defined(__SWITCH__)
130+
#if defined(__SWITCH__) or defined(__3DS__)
131+
//TODO: some events use the SDL_JOYAXISMOTION event, but that needs to be done in the next reiteration of these helpers!
131132
if (event.type == SDL_JOYBUTTONDOWN and event.jbutton.button == needed_event) {
132133
return true;
133134
}
@@ -213,6 +214,29 @@ namespace {
213214
default:
214215
utils::unreachable();
215216
}
217+
#elif defined(__3DS__)
218+
switch (action) {
219+
case CrossPlatformAction::OK:
220+
return "A";
221+
case CrossPlatformAction::PAUSE:
222+
case CrossPlatformAction::UNPAUSE:
223+
return "Y";
224+
case CrossPlatformAction::CLOSE:
225+
case CrossPlatformAction::EXIT:
226+
return "X";
227+
case CrossPlatformAction::DOWN:
228+
return "Down";
229+
case CrossPlatformAction::UP:
230+
return "Up";
231+
case CrossPlatformAction::LEFT:
232+
return "Left";
233+
case CrossPlatformAction::RIGHT:
234+
return "Right";
235+
case CrossPlatformAction::OPEN_SETTINGS:
236+
return "Select";
237+
default:
238+
utils::unreachable();
239+
}
216240
#else
217241
switch (action) {
218242
case CrossPlatformAction::OK:

src/platform/capabilities.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ namespace utils {
7373
#elif defined(__3DS__)
7474
{
7575
{ static_cast<u8>(CrossPlatformAction::OK),{ JOYCON_A } },
76-
{ static_cast<u8>(CrossPlatformAction::PAUSE), { JOYCON_SELECT }},
77-
{ static_cast<u8>(CrossPlatformAction::UNPAUSE), { JOYCON_SELECT }},
78-
{ static_cast<u8>(CrossPlatformAction::EXIT), { JOYCON_START }},
76+
{ static_cast<u8>(CrossPlatformAction::PAUSE), { JOYCON_Y }},
77+
{ static_cast<u8>(CrossPlatformAction::UNPAUSE), { JOYCON_Y }},
78+
{ static_cast<u8>(CrossPlatformAction::EXIT), { JOYCON_X }},
7979
{ static_cast<u8>(CrossPlatformAction::DOWN),
8080
{ JOYCON_DPAD_DOWN, JOYCON_CSTICK_DOWN, JOYCON_CPAD_DOWN } },
8181
{ static_cast<u8>(CrossPlatformAction::UP), { JOYCON_DPAD_UP, JOYCON_CSTICK_UP, JOYCON_CPAD_UP }},
8282
{ static_cast<u8>(CrossPlatformAction::LEFT),
8383
{ JOYCON_DPAD_LEFT, JOYCON_CSTICK_LEFT, JOYCON_CPAD_LEFT } },
8484
{ static_cast<u8>(CrossPlatformAction::RIGHT),
8585
{ JOYCON_DPAD_RIGHT, JOYCON_CSTICK_RIGHT, JOYCON_CPAD_RIGHT } },
86-
{ static_cast<u8>(CrossPlatformAction::CLOSE), { JOYCON_X }},
87-
{static_cast<u8>(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }},
86+
{ static_cast<u8>(CrossPlatformAction::CLOSE), { JOYCON_X }},
87+
{static_cast<u8>(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_SELECT }},
8888
{ static_cast<u8>(CrossPlatformAction::TAB), {}}, // no tab support
8989
};
9090
#else

src/platform/console_input.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ helper::optional<InputEvent> JoystickInput::sdl_event_to_input_event(const SDL_E
7878
helper::optional<InputEvent> JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const {
7979
if (event.type == SDL_JOYBUTTONDOWN) {
8080
const auto button = event.jbutton.button;
81-
if (button == JOYCON_Y) {
81+
if (button == JOYCON_L) {
8282
return InputEvent::RotateLeftPressed;
8383
}
84-
if (button == JOYCON_X) {
84+
if (button == JOYCON_R) {
8585
return InputEvent::RotateRightPressed;
8686
}
8787
if (button == JOYCON_DPAD_DOWN or button == JOYCON_CSTICK_DOWN) {
@@ -101,10 +101,10 @@ helper::optional<InputEvent> JoystickInput::sdl_event_to_input_event(const SDL_E
101101
}
102102
} else if (event.type == SDL_JOYBUTTONUP) {
103103
const auto button = event.jbutton.button;
104-
if (button == JOYCON_Y) {
104+
if (button == JOYCON_L) {
105105
return InputEvent::RotateLeftReleased;
106106
}
107-
if (button == JOYCON_X) {
107+
if (button == JOYCON_R) {
108108
return InputEvent::RotateRightReleased;
109109
}
110110
if (button == JOYCON_DPAD_DOWN or button == JOYCON_CSTICK_DOWN) {

0 commit comments

Comments
 (0)