diff --git a/libultraship b/libultraship index d60e8475..433bc7e6 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit d60e84754a7a1226d6b3c2a515e21f8990b7a5b4 +Subproject commit 433bc7e63b9e2ee475b25a7af8ecce5a808f35ff diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 8fa33ccf..6433ad4f 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -4,6 +4,7 @@ #include "extractor/GameExtractor.h" #include "libultraship/src/Context.h" +#include "libultraship/src/controller/controldevice/controller/mapping/ControllerDefaultMappings.h" #include "resource/type/ResourceType.h" #include "resource/importers/AnimFactory.h" #include "resource/importers/ColPolyFactory.h" @@ -121,7 +122,36 @@ GameEngine::GameEngine() { this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in // ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig() - auto controlDeck = std::make_shared(); + auto defaultMappings = std::make_shared( + // KeyboardKeyToButtonMappings - use built-in LUS defaults + std::unordered_map>(), + // KeyboardKeyToAxisDirectionMappings - use built-in LUS defaults + std::unordered_map>>(), + // SDLButtonToButtonMappings + std::unordered_map>{ + { BTN_A, { SDL_CONTROLLER_BUTTON_A } }, + { BTN_B, { SDL_CONTROLLER_BUTTON_X } }, + { BTN_START, { SDL_CONTROLLER_BUTTON_START } }, + { BTN_CLEFT, { SDL_CONTROLLER_BUTTON_Y } }, + { BTN_CDOWN, { SDL_CONTROLLER_BUTTON_B } }, + { BTN_DUP, { SDL_CONTROLLER_BUTTON_DPAD_UP } }, + { BTN_DDOWN, { SDL_CONTROLLER_BUTTON_DPAD_DOWN } }, + { BTN_DLEFT, { SDL_CONTROLLER_BUTTON_DPAD_LEFT } }, + { BTN_DRIGHT, { SDL_CONTROLLER_BUTTON_DPAD_RIGHT } }, + { BTN_R, { SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } }, + { BTN_Z, { SDL_CONTROLLER_BUTTON_LEFTSHOULDER } } + }, + // SDLButtonToAxisDirectionMappings - use built-in LUS defaults + std::unordered_map>>(), + // SDLAxisDirectionToButtonMappings + std::unordered_map>>{ + { BTN_R, { { SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 1 } } }, + { BTN_Z, { { SDL_CONTROLLER_AXIS_TRIGGERLEFT, 1 } } } + }, + // SDLAxisDirectionToAxisDirectionMappings - use built-in LUS defaults + std::unordered_map>>>() + ); + auto controlDeck = std::make_shared(std::vector(), defaultMappings); this->context->InitResourceManager(archiveFiles, {}, 3); // without this line InitWindow fails in Gui::Init() this->context->InitConsole(); // without this line the GuiWindow constructor fails in ConsoleWindow::InitElement()