diff --git a/libultraship/libultraship/Controller.h b/libultraship/libultraship/Controller.h index c78142af4..9deb912dc 100644 --- a/libultraship/libultraship/Controller.h +++ b/libultraship/libultraship/Controller.h @@ -19,6 +19,7 @@ namespace Ship { void Read(OSContPad* pad); virtual void ReadFromSource() = 0; virtual void WriteToSource(ControllerCallback* controller) = 0; + virtual bool CanRumble() const = 0; bool isRumbling; void SetButtonMapping(const std::string& szButtonName, int32_t dwScancode); diff --git a/libultraship/libultraship/KeyboardController.h b/libultraship/libultraship/KeyboardController.h index ab0f98e64..1a97065d5 100644 --- a/libultraship/libultraship/KeyboardController.h +++ b/libultraship/libultraship/KeyboardController.h @@ -10,6 +10,7 @@ namespace Ship { void ReadFromSource(); void WriteToSource(ControllerCallback* controller); + bool CanRumble() const { return false; } bool PressButton(int32_t dwScancode); bool ReleaseButton(int32_t dwScancode); diff --git a/libultraship/libultraship/SDLController.h b/libultraship/libultraship/SDLController.h index 5c71c50a9..f7b538cba 100644 --- a/libultraship/libultraship/SDLController.h +++ b/libultraship/libultraship/SDLController.h @@ -12,6 +12,7 @@ namespace Ship { void ReadFromSource(); void WriteToSource(ControllerCallback* controller); + bool CanRumble() const { return SDL_GameControllerHasRumble(Cont); } std::string GetGuid() { return guid; }; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 007afd702..8bb2490b9 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -814,3 +814,13 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { OTRGlobals::Instance->context->GetWindow()->GetAudioPlayer()->Play(buf, len); } } + +extern "C" int Controller_CanRumble(void) { + for (const auto& controller : Ship::Window::Controllers.at(0)) { + if (controller->CanRumble()) { + return 1; + } + } + + return 0; +} diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 4f62f0694..0af73716c 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -64,4 +64,5 @@ int AudioPlayer_Buffered(void); int AudioPlayer_GetDesiredBuffered(void); void AudioPlayer_Play(const uint8_t* buf, uint32_t len); void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); +int Controller_CanRumble(void); #endif diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index ccb4b17ac..d473b47ad 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -304,11 +304,7 @@ void PadMgr_HandleRetraceMsg(PadMgr* padMgr) { osRecvMesg(queue, NULL, OS_MESG_BLOCK); osContGetReadData(padMgr->pads); - if (CVar_GetS32("gRumbleEnabled", 0) != 0) { - padMgr->padStatus[0].status = 1; - } else { - padMgr->padStatus[0].status = 0; - } + padMgr->padStatus[0].status = (CVar_GetS32("gRumbleEnabled", 0) != 0) && Controller_CanRumble(); if (padMgr->preNMIShutdown) { memset(padMgr->pads, 0, sizeof(padMgr->pads));