Skip to content

Commit

Permalink
Remove Wii U (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
briaguya-ai authored Apr 29, 2024
1 parent 6f978e0 commit 04066de
Show file tree
Hide file tree
Showing 68 changed files with 19 additions and 6,440 deletions.
20 changes: 5 additions & 15 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
target_include_directories(ImGui PRIVATE ${DEVKITPRO}/portlibs/switch/include/)
endif()

if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_sources(ImGui
PRIVATE
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/backends/imgui_impl_sdl2.cpp
)
endif()
target_sources(ImGui
PRIVATE
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/backends/imgui_impl_sdl2.cpp
)

if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_sources(ImGui
Expand All @@ -67,12 +65,6 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
PRIVATE
${IMGUI_DIR}/backends/imgui_impl_metal.mm
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_sources(ImGui
PRIVATE
${IMGUI_DIR}/backends/wiiu/imgui_impl_wiiu.cpp
${IMGUI_DIR}/backends/wiiu/imgui_impl_gx2.cpp
)
endif()

target_include_directories(ImGui PUBLIC ${IMGUI_DIR} ${IMGUI_DIR}/backends PRIVATE ${SDL2_INCLUDE_DIRS})
Expand All @@ -86,8 +78,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(ImGui PUBLIC SDL2::SDL2 SDL2::SDL2main)
elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS")
target_link_libraries(ImGui PUBLIC SDL2::SDL2-static SDL2::SDL2main)
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_link_libraries(ImGui PUBLIC SDL2::SDL2-static)
else()
target_link_libraries(ImGui PUBLIC SDL2::SDL2)
endif()
Expand Down
2 changes: 1 addition & 1 deletion extern/spdlog/include/spdlog/details/os-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
return offset;
#else

# if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE)) || defined(__WIIU__)
# if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
struct helper
{
Expand Down
3 changes: 0 additions & 3 deletions include/libultraship/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,5 @@
#ifdef __SWITCH__
#include "port/switch/SwitchImpl.h"
#endif
#ifdef __WIIU__
#include "port/wiiu/WiiUImpl.h"
#endif
#endif
#endif
62 changes: 4 additions & 58 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ target_sources(libultraship PRIVATE ${Source_Files__Audio})

file(GLOB_RECURSE Source_Files__Controller RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "controller/*.h" "controller/*.cpp")

if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
list(FILTER Source_Files__Controller EXCLUDE REGEX "controller/controldevice/controller/mapping/keyboard/*")
list(FILTER Source_Files__Controller EXCLUDE REGEX "controller/controldevice/controller/mapping/sdl/*")
list(FILTER Source_Files__Controller EXCLUDE REGEX "controller/deviceindex/ShipDeviceIndexToSDLDeviceIndexMapping.*")
else()
list(FILTER Source_Files__Controller EXCLUDE REGEX "controller/controldevice/controller/mapping/wiiu/*")
list(FILTER Source_Files__Controller EXCLUDE REGEX "controller/deviceindex/ShipDeviceIndexToWiiUDeviceIndexMapping.*")
endif()

source_group("controller" FILES ${Source_Files__Controller})
target_sources(libultraship PRIVATE ${Source_Files__Controller})

Expand Down Expand Up @@ -120,12 +111,7 @@ target_sources(libultraship PRIVATE ${Source_Files__Utils__BinaryTools})

#=================== Port ===================

if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(Source_Files__Port
${CMAKE_CURRENT_SOURCE_DIR}/port/wiiu/WiiUImpl.h
${CMAKE_CURRENT_SOURCE_DIR}/port/wiiu/WiiUImpl.cpp
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(Source_Files__Port
${CMAKE_CURRENT_SOURCE_DIR}/port/switch/SwitchImpl.h
${CMAKE_CURRENT_SOURCE_DIR}/port/switch/SwitchImpl.cpp
Expand Down Expand Up @@ -175,14 +161,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/gfx_opengl*")
endif()

if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/gfx_wiiu*")
list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/gx2*")
else()
list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/gfx_opengl*")
list(FILTER Source_Files__Graphic EXCLUDE REGEX "graphic/Fast3D/gfx_sdl*")
endif()

source_group("graphic" FILES ${Source_Files__Graphic})
target_sources(libultraship PRIVATE ${Source_Files__Graphic})

Expand All @@ -192,35 +170,16 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
target_include_directories(libultraship PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../extern/metal-cpp)
endif()

#=================== STB ===================
# hack: no idea why wii u doesn't want to link this when we build it
# as a separate static lib
if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(Source_Files__Lib__stb
"${CMAKE_CURRENT_SOURCE_DIR}/../extern/stb/stb_image.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../extern/stb/stb_image_write.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../extern/stb/stb_impl.c"
)
source_group("extern/stb" FILES ${Source_Files__Lib__stb})
target_sources(libultraship PRIVATE ${Source_Files__Lib__stb})
endif()

#=================== Packages & Includes ===================

target_include_directories(libultraship
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../extern ${CMAKE_CURRENT_BINARY_DIR} $<$<BOOL:${GFX_DEBUG_DISASSEMBLER}>:${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/libgfxd>
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../extern/spdlog/include ${CMAKE_CURRENT_SOURCE_DIR}/../extern/stb ${ADDITIONAL_LIB_INCLUDES}
)

if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_include_directories(${PROJECT_NAME} PRIVATE
${DEVKITPRO}/portlibs/wiiu/include/
)
endif()

#=================== Linking ===================

if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS" AND NOT CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
if (NOT CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(libultraship PUBLIC "$<LINK_LIBRARY:WHOLE_ARCHIVE,storm>")
else()
target_link_libraries(libultraship PUBLIC storm)
Expand All @@ -230,11 +189,7 @@ target_link_libraries(libultraship
PUBLIC ZAPDUtils ImGui tinyxml2
)

# hack cont.: wii u just includes these files, everyone
# else handles linking it just fine
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_link_libraries(libultraship PRIVATE stb)
endif()
target_link_libraries(libultraship PRIVATE stb)

if (GFX_DEBUG_DISASSEMBLER)
target_link_libraries(libultraship PRIVATE libgfxd)
Expand Down Expand Up @@ -287,16 +242,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
)
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_compile_definitions(libultraship PRIVATE
$<$<CONFIG:Debug>:_DEBUG>
$<$<NOT:$<CONFIG:Debug>>:NDEBUG>
SPDLOG_NO_THREAD_ID
SPDLOG_NO_TLS
STBI_NO_THREAD_LOCALS
SPDLOG_ACTIVE_LEVEL=3
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS")
if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
target_compile_definitions(libultraship PRIVATE
$<$<CONFIG:Debug>:_DEBUG>
$<$<NOT:$<CONFIG:Debug>>:NDEBUG>
Expand Down
12 changes: 1 addition & 11 deletions src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "utils/AppleFolderManager.h"
#elif defined(__SWITCH__)
#include "port/switch/SwitchImpl.h"
#elif defined(__WIIU__)
#include "port/wiiu/WiiUImpl.h"
#endif

namespace Ship {
Expand Down Expand Up @@ -100,7 +98,7 @@ void Context::InitLogging() {
spdlog::init_thread_pool(8192, 1);
std::vector<spdlog::sink_ptr> sinks;

#if (!defined(_WIN32) && !defined(__WIIU__)) || defined(_DEBUG)
#if (!defined(_WIN32)) || defined(_DEBUG)
#if defined(_DEBUG) && defined(_WIN32)
// LLVM on Windows allocs a hidden console in its entrypoint function.
// We free that console here to create our own.
Expand Down Expand Up @@ -137,7 +135,6 @@ void Context::InitLogging() {
sinks.push_back(systemConsoleSink);
#endif

#ifndef __WIIU__
auto logPath = GetPathRelativeToAppDirectory(("logs/" + GetName() + ".log"));
auto fileSink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(logPath, 1024 * 1024 * 10, 10);
#ifdef _DEBUG
Expand All @@ -146,7 +143,6 @@ void Context::InitLogging() {
fileSink->set_level(spdlog::level::debug);
#endif
sinks.push_back(fileSink);
#endif

mLogger = std::make_shared<spdlog::async_logger>(GetName(), sinks.begin(), sinks.end(), spdlog::thread_pool(),
spdlog::async_overflow_policy::block);
Expand All @@ -160,11 +156,7 @@ void Context::InitLogging() {
GetLogger()->flush_on(spdlog::level::trace);
#endif

#ifndef __WIIU__
GetLogger()->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%@] [%l] %v");
#else
GetLogger()->set_pattern("[%s:%#] [%l] %v");
#endif

spdlog::register_logger(GetLogger());
spdlog::set_default_logger(GetLogger());
Expand Down Expand Up @@ -210,8 +202,6 @@ void Context::InitResourceManager(const std::vector<std::string>& otrFiles,
if (!GetResourceManager()->DidLoadSuccessfully()) {
#if defined(__SWITCH__)
printf("Main OTR file not found!\n");
#elif defined(__WIIU__)
Ship::WiiU::ThrowMissingOTR(mMainPath.c_str());
#else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OTR file not found",
"Main OTR file not found. Please generate one", nullptr);
Expand Down
3 changes: 0 additions & 3 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ WindowBackend Config::GetWindowBackend() {
#ifdef ENABLE_DX11
return WindowBackend::DX11;
#endif
#ifdef __WIIU__
return WindowBackend::GX2;
#endif
#ifdef __APPLE__
if (Metal_IsSupported()) {
return WindowBackend::SDL_METAL;
Expand Down
6 changes: 0 additions & 6 deletions src/controller/controldeck/ControlDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ void ControlDeck::Init(uint8_t* controllerBits) {
}
}

#ifndef __WIIU__
// if we don't have a config for controller 1, set default keyboard bindings
if (!mPorts[0]->GetConnectedController()->HasConfig()) {
mPorts[0]->GetConnectedController()->AddDefaultMappings(ShipDeviceIndex::Keyboard);
}
#endif

Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Controller Reordering")->Show();
}

#ifndef __WIIU__
bool ControlDeck::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
bool result = false;
for (auto port : mPorts) {
Expand All @@ -61,7 +58,6 @@ bool ControlDeck::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancod

return result;
}
#endif

bool ControlDeck::AllGameInputBlocked() {
return !mGameInputBlockers.empty();
Expand All @@ -78,9 +74,7 @@ bool ControlDeck::KeyboardGameInputBlocked() {
}

void ControlDeck::WriteToPad(OSContPad* pad) {
#ifndef __WIIU__
SDL_PumpEvents();
#endif

if (AllGameInputBlocked()) {
return;
Expand Down
2 changes: 0 additions & 2 deletions src/controller/controldeck/ControlDeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class ControlDeck {
void SetSinglePlayerMappingMode(bool singlePlayer);
bool IsSinglePlayerMappingMode();

#ifndef __WIIU__
bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
#endif

std::shared_ptr<ShipDeviceIndexMappingManager> GetDeviceIndexMappingManager();

Expand Down
2 changes: 0 additions & 2 deletions src/controller/controldevice/controller/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ void Controller::ReadToPad(OSContPad* pad) {
}
}

#ifndef __WIIU__
bool Controller::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode) {
bool result = false;
for (auto [bitmask, button] : GetAllButtons()) {
Expand All @@ -183,7 +182,6 @@ bool Controller::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScanc
result = GetRightStick()->ProcessKeyboardEvent(eventType, scancode) || result;
return result;
}
#endif

bool Controller::HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex) {
for (auto [bitmask, button] : GetAllButtons()) {
Expand Down
2 changes: 0 additions & 2 deletions src/controller/controldevice/controller/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class Controller : public ControlDevice {
uint8_t GetPortIndex();
std::vector<std::shared_ptr<ControllerMapping>> GetAllMappings();

#ifndef __WIIU__
bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
#endif

bool HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex);
void MoveMappingsToDifferentController(std::shared_ptr<Controller> newController, ShipDeviceIndex lusIndex);
Expand Down
34 changes: 0 additions & 34 deletions src/controller/controldevice/controller/ControllerButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,39 +170,6 @@ bool ControllerButton::HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex) {
[lusIndex](const auto& mapping) { return mapping.second->GetShipDeviceIndex() == lusIndex; });
}

#ifdef __WIIU__
bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bitmask, std::string id) {
std::shared_ptr<ControllerButtonMapping> mapping =
ButtonMappingFactory::CreateButtonMappingFromWiiUInput(mPortIndex, bitmask);

if (mapping == nullptr) {
return false;
}

if (id != "") {
ClearButtonMapping(id);
}

AddButtonMapping(mapping);
mapping->SaveToConfig();
SaveButtonMappingIdsToConfig();
const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
}

void ControllerButton::AddDefaultMappings(ShipDeviceIndex shipDeviceIndex) {
for (auto mapping : ButtonMappingFactory::CreateDefaultWiiUButtonMappings(shipDeviceIndex, mPortIndex, mBitmask)) {
AddButtonMapping(mapping);
}

for (auto [id, mapping] : mButtonMappings) {
mapping->SaveToConfig();
}
SaveButtonMappingIdsToConfig();
}
#else
bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bitmask, std::string id) {
std::shared_ptr<ControllerButtonMapping> mapping = nullptr;

Expand Down Expand Up @@ -270,5 +237,4 @@ void ControllerButton::AddDefaultMappings(ShipDeviceIndex shipDeviceIndex) {
}
SaveButtonMappingIdsToConfig();
}
#endif
} // namespace Ship
2 changes: 0 additions & 2 deletions src/controller/controldevice/controller/ControllerButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class ControllerButton {

void UpdatePad(CONTROLLERBUTTONS_T& padButtons);

#ifndef __WIIU__
bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
#endif

bool HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex);

Expand Down
20 changes: 0 additions & 20 deletions src/controller/controldevice/controller/ControllerGyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@ void ControllerGyro::SetGyroMapping(std::shared_ptr<ControllerGyroMapping> mappi
mGyroMapping = mapping;
}

#ifdef __WIIU__
bool ControllerGyro::SetGyroMappingFromRawPress() {
std::shared_ptr<ControllerGyroMapping> mapping = nullptr;

mapping = GyroMappingFactory::CreateGyroMappingFromWiiUInput(mPortIndex);

if (mapping == nullptr) {
return false;
}

SetGyroMapping(mapping);
mapping->SaveToConfig();
SaveGyroMappingIdToConfig();
const std::string hasConfigCvarKey = StringHelper::Sprintf("gControllers.Port%d.HasConfig", mPortIndex + 1);
CVarSetInteger(hasConfigCvarKey.c_str(), true);
CVarSave();
return true;
}
#else
bool ControllerGyro::SetGyroMappingFromRawPress() {
std::shared_ptr<ControllerGyroMapping> mapping = nullptr;

Expand All @@ -55,7 +36,6 @@ bool ControllerGyro::SetGyroMappingFromRawPress() {
CVarSave();
return true;
}
#endif

void ControllerGyro::UpdatePad(float& x, float& y) {
if (mGyroMapping == nullptr) {
Expand Down
Loading

0 comments on commit 04066de

Please sign in to comment.