From cdac650c3d7d81b28f5bc424c85b88cf4d5f814c Mon Sep 17 00:00:00 2001 From: Ghabry Date: Thu, 16 Jan 2025 16:14:10 +0100 Subject: [PATCH] Wii: Further fixes - Improve button mapping and comments - Write SDL1 config in a different file --- CMakeLists.txt | 2 -- src/game_config.cpp | 6 +++- src/platform/wii/input_buttons.cpp | 54 +++++++++++++++++++++++------- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 913ca18fe0..87859f18f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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() diff --git a/src/game_config.cpp b/src/game_config.cpp index cdcd5977bf..82bd6d8f92 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -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() { @@ -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); diff --git a/src/platform/wii/input_buttons.cpp b/src/platform/wii/input_buttons.cpp index a291f84ea5..3b9feb3ac4 100644 --- a/src/platform/wii/input_buttons.cpp +++ b/src/platform/wii/input_buttons.cpp @@ -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) @@ -109,15 +108,16 @@ 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)"}, @@ -125,10 +125,40 @@ Input::KeyNamesArray Input::GetInputKeyNames() { {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"}, }; }