Skip to content

Commit

Permalink
Wii: Further fixes
Browse files Browse the repository at this point in the history
- Improve button mapping and comments
- Write SDL1 config in a different file
  • Loading branch information
Ghabry committed Jan 16, 2025
1 parent 212aa5a commit cdac650
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ if(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL2")
elseif(NINTENDO_WII)
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_NINTENDO)
target_sources(${PROJECT_NAME} PRIVATE
src/platform/wii/clock.cpp
src/platform/wii/clock.h
src/platform/wii/input_buttons.cpp)
elseif(NINTENDO_WIIU)
Expand All @@ -620,7 +619,6 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL1")
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_NINTENDO)
target_include_directories(${PROJECT_NAME} PUBLIC ${SDL_INCLUDE_DIR})
target_sources(${PROJECT_NAME} PRIVATE
src/platform/wii/clock.cpp
src/platform/wii/clock.h
src/platform/wii/input_buttons.cpp)
else()
Expand Down
6 changes: 5 additions & 1 deletion src/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ namespace {
std::string config_path;
std::string soundfont_path;
std::string font_path;
#if USE_SDL == 1
// For SDL1 hardcode a different config file because it uses a completely different mapping for gamepads
StringView config_name = "config_sdl1.ini";
#else
StringView config_name = EASYRPG_CONFIG_NAME;
#endif
}

void Game_ConfigPlayer::Hide() {
Expand Down Expand Up @@ -93,7 +98,6 @@ Game_Config Game_Config::Create(CmdlineParser& cp) {
cfg.input.gamepad_swap_ab_and_xy.Set(true);
#endif


cp.Rewind();

config_path = GetConfigPath(cp);
Expand Down
54 changes: 42 additions & 12 deletions src/platform/wii/input_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ Input::ButtonMappingArray Input::GetDefaultButtonMappings() {
{DOWN, Keys::JOY_DPAD_DOWN},
{LEFT, Keys::JOY_DPAD_LEFT},
{RIGHT, Keys::JOY_DPAD_RIGHT},
{DECISION, Keys::JOY_B},
{CANCEL, Keys::JOY_A},
{CANCEL, Keys::JOY_Y},
{SHIFT, Keys::JOY_X},
{N0, Keys::JOY_LSTICK},
{N5, Keys::JOY_RSTICK},
{DECISION, Keys::JOY_A},
{CANCEL, Keys::JOY_B},
{CANCEL, Keys::JOY_X},
{SHIFT, Keys::JOY_Y},
{DEBUG_ABORT_EVENT, Keys::JOY_SHOULDER_LEFT},
{TOGGLE_FPS, Keys::JOY_SHOULDER_RIGHT},
{SETTINGS_MENU, Keys::JOY_START},
{RESET, Keys::JOY_BACK},
{SETTINGS_MENU, Keys::JOY_BACK},
{RESET, Keys::JOY_GUIDE},
{N5, Keys::N5},
#endif

#if defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)
Expand Down Expand Up @@ -109,26 +108,57 @@ Input::ButtonMappingArray Input::GetDefaultButtonMappings() {

Input::KeyNamesArray Input::GetInputKeyNames() {
return {
// SDL1
{Keys::JOY_OTHER_0, "A (Wiimote / CC)"},
{Keys::JOY_OTHER_1, "B (Wiimote / CC)"},
{Keys::JOY_OTHER_2, "1 (Wiimote"},
{Keys::JOY_OTHER_2, "1 (Wiimote)"},
{Keys::JOY_OTHER_3, "2 (Wiimote)"},
{Keys::JOY_OTHER_4, "- (Wiimote /CC )"},
{Keys::JOY_OTHER_4, "- (Wiimote / CC)"},
{Keys::JOY_OTHER_5, "+ (Wiimote / CC)"},
{Keys::JOY_OTHER_6, "Home (Wiimote / CC)"},
{Keys::JOY_OTHER_7, "Z (Nunchuck)"},
{Keys::JOY_OTHER_8, "C (Wiimote)"},
{Keys::JOY_OTHER_8, "C (Nunchuck)"},
{Keys::JOY_OTHER_9, "X (CC)"},
{Keys::JOY_OTHER_10, "Y (CC)"},
{Keys::JOY_OTHER_11, "L (CC)"},
{Keys::JOY_OTHER_12, "R (CC)"},
{Keys::JOY_OTHER_13, "ZL (CC)"},
{Keys::JOY_OTHER_14, "ZR (CC)"},

// SDL2
// FIXME: The ABXY buttons are swapped when a CC is connected, automatically handle this?
// For Wiimote the reported buttons change depending whether a Nunchuck is connected
// When only a Wiimote is connected it is handled like a sideways Wiimote
// With Nunchuck/CC connected the buttons 1 and 2 report nothing
{Keys::JOY_A, "A"}, // 1 (Wiimote), A (+Nunchuck), B (+CC)
{Keys::JOY_B, "B"}, // 2 (Wiimote), B (+Nunchuck), A (+CC)
{Keys::JOY_X, "X (CC) / Z (Nunchuck)"}, // B (Wiimote)
{Keys::JOY_Y, "Y (CC) / C (Nunchuck)"}, // A (Wiimote)
{Keys::JOY_BACK, "HOME"},
{Keys::JOY_START, "+"},
{Keys::JOY_GUIDE, "-"},
{Keys::JOY_SHOULDER_LEFT, "L"},
{Keys::JOY_SHOULDER_RIGHT, "R"},
{Keys::JOY_LTRIGGER_FULL, "ZL"},
{Keys::JOY_RTRIGGER_FULL, "ZR"},

// Shared
{Keys::JOY_DPAD_UP, "D-Pad Up"},
{Keys::JOY_DPAD_DOWN, "D-Pad Down"},
{Keys::JOY_DPAD_LEFT, "D-Pad Left"},
{Keys::JOY_DPAD_RIGHT, "D-Pad Up"}
{Keys::JOY_DPAD_RIGHT, "D-Pad Up"},

{Keys::JOY_LSTICK, "Left Stick Press"},
{Keys::JOY_LSTICK_UP, "Left Stick Up"},
{Keys::JOY_LSTICK_DOWN, "Left Stick Down"},
{Keys::JOY_LSTICK_LEFT, "Left Stick Left"},
{Keys::JOY_LSTICK_RIGHT, "Left Stick Right"},

{Keys::JOY_RSTICK, "Right Stick Press"},
{Keys::JOY_RSTICK_UP, "Right Stick Up"},
{Keys::JOY_RSTICK_DOWN, "Right Stick Down"},
{Keys::JOY_RSTICK_LEFT, "Right Stick Left"},
{Keys::JOY_RSTICK_RIGHT, "Right Stick Right"},
};
}

Expand Down

0 comments on commit cdac650

Please sign in to comment.