Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] controller rework multiplayer mode #3354

2 changes: 1 addition & 1 deletion libultraship
Submodule libultraship updated 132 files
21 changes: 15 additions & 6 deletions soh/soh/Enhancements/controls/GameControlEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ namespace GameControlEditor {
// CurrentPort is indexed started at 1 here due to the Generic tab, instead of 0 like in InputEditorWindow
// Therefore CurrentPort - 1 must always be used inside this function instead of CurrentPort
void DrawCustomButtons() {
auto inputEditorWindow = std::reinterpret_pointer_cast<LUS::InputEditorWindow>(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor"));
inputEditorWindow->DrawControllerSelect(CurrentPort - 1);
// auto inputEditorWindow = std::reinterpret_pointer_cast<LUS::InputEditorWindow>(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor"));
// inputEditorWindow->DrawControllerSelect(CurrentPort - 1);

inputEditorWindow->DrawButton("Modifier 1", BTN_MODIFIER1, CurrentPort - 1, &BtnReading);
inputEditorWindow->DrawButton("Modifier 2", BTN_MODIFIER2, CurrentPort - 1, &BtnReading);
// inputEditorWindow->DrawButton("Modifier 1", BTN_MODIFIER1, CurrentPort - 1, &BtnReading);
// inputEditorWindow->DrawButton("Modifier 2", BTN_MODIFIER2, CurrentPort - 1, &BtnReading);
}

void DrawCameraControlPanel(GameControlEditorWindow* window) {
Expand Down Expand Up @@ -389,8 +389,17 @@ namespace GameControlEditor {
DrawMiscControlPanel(this);
} else {
DrawCustomButtons();
if (CurrentPort == 1 && LUS::Context::GetInstance()->GetControlDeck()->GetDeviceFromPortIndex(0)->CanSetLed()) {
DrawLEDControlPanel(this);
if (CurrentPort == 1) {
bool showPanel = false;
for (auto [id, mapping] : LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->GetAllLEDMappings()) {
if (mapping->GetColorSource() == LED_COLOR_SOURCE_GAME) {
showPanel = true;
break;
}
}
if (showPanel) {
DrawLEDControlPanel(this);
}
}
}
}
Expand Down
30 changes: 16 additions & 14 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ OTRGlobals::OTRGlobals() {
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
context = LUS::Context::CreateInstance("Ship of Harkinian", appShortName, "shipofharkinian.json", OTRFiles, {}, 3);

// context->GetControlDeck()->SetSinglePlayerMappingMode(true);

context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Animation, "Animation", std::make_shared<LUS::AnimationFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared<LUS::PlayerAnimationFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Room, "Room", std::make_shared<LUS::SceneFactory>()); // Is room scene? maybe?
Expand Down Expand Up @@ -2050,15 +2052,15 @@ Color_RGB8 GetColorForControllerLED() {
}

extern "C" void OTRControllerCallback(uint8_t rumble) {
auto physicalDevice = LUS::Context::GetInstance()->GetControlDeck()->GetDeviceFromPortIndex(0);
// We call this every tick, SDL accounts for this use and prevents driver spam
// https://github.com/libsdl-org/SDL/blob/f17058b562c8a1090c0c996b42982721ace90903/src/joystick/SDL_joystick.c#L1114-L1144
LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetLED()->SetLEDColor(GetColorForControllerLED());

if (physicalDevice->CanSetLed()) {
// We call this every tick, SDL accounts for this use and prevents driver spam
// https://github.com/libsdl-org/SDL/blob/f17058b562c8a1090c0c996b42982721ace90903/src/joystick/SDL_joystick.c#L1114-L1144
physicalDevice->SetLedColor(0, GetColorForControllerLED());
if (rumble) {
LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StartRumble();
} else {
LUS::Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetRumble()->StopRumble();
}

physicalDevice->SetRumble(0, rumble);
}

extern "C" float OTRGetAspectRatio() {
Expand Down Expand Up @@ -2097,15 +2099,15 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) {
}

extern "C" int Controller_ShouldRumble(size_t slot) {
auto controlDeck = LUS::Context::GetInstance()->GetControlDeck();
// auto controlDeck = LUS::Context::GetInstance()->GetControlDeck();

if (slot < controlDeck->GetNumConnectedPorts()) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot);
// if (slot < controlDeck->GetNumConnectedPorts()) {
// auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot);

if (physicalDevice->GetProfile(slot)->UseRumble && physicalDevice->CanRumble()) {
return 1;
}
}
// if (physicalDevice->GetProfile(slot)->UseRumble && physicalDevice->CanRumble()) {
// return 1;
// }
// }

return 0;
}
Expand Down
Loading