mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 21:33:40 -07:00
Check if controller can rumble to insert rumble pak
This commit is contained in:
parent
038757a9b6
commit
21e4e5a140
6 changed files with 15 additions and 5 deletions
|
@ -19,6 +19,7 @@ namespace Ship {
|
||||||
void Read(OSContPad* pad);
|
void Read(OSContPad* pad);
|
||||||
virtual void ReadFromSource() = 0;
|
virtual void ReadFromSource() = 0;
|
||||||
virtual void WriteToSource(ControllerCallback* controller) = 0;
|
virtual void WriteToSource(ControllerCallback* controller) = 0;
|
||||||
|
virtual bool CanRumble() const = 0;
|
||||||
bool isRumbling;
|
bool isRumbling;
|
||||||
|
|
||||||
void SetButtonMapping(const std::string& szButtonName, int32_t dwScancode);
|
void SetButtonMapping(const std::string& szButtonName, int32_t dwScancode);
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace Ship {
|
||||||
|
|
||||||
void ReadFromSource();
|
void ReadFromSource();
|
||||||
void WriteToSource(ControllerCallback* controller);
|
void WriteToSource(ControllerCallback* controller);
|
||||||
|
bool CanRumble() const { return false; }
|
||||||
|
|
||||||
bool PressButton(int32_t dwScancode);
|
bool PressButton(int32_t dwScancode);
|
||||||
bool ReleaseButton(int32_t dwScancode);
|
bool ReleaseButton(int32_t dwScancode);
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace Ship {
|
||||||
|
|
||||||
void ReadFromSource();
|
void ReadFromSource();
|
||||||
void WriteToSource(ControllerCallback* controller);
|
void WriteToSource(ControllerCallback* controller);
|
||||||
|
bool CanRumble() const { return SDL_GameControllerHasRumble(Cont); }
|
||||||
|
|
||||||
std::string GetGuid() { return guid; };
|
std::string GetGuid() { return guid; };
|
||||||
|
|
||||||
|
|
|
@ -814,3 +814,13 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) {
|
||||||
OTRGlobals::Instance->context->GetWindow()->GetAudioPlayer()->Play(buf, 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;
|
||||||
|
}
|
||||||
|
|
|
@ -64,4 +64,5 @@ int AudioPlayer_Buffered(void);
|
||||||
int AudioPlayer_GetDesiredBuffered(void);
|
int AudioPlayer_GetDesiredBuffered(void);
|
||||||
void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
||||||
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
||||||
|
int Controller_CanRumble(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -304,11 +304,7 @@ void PadMgr_HandleRetraceMsg(PadMgr* padMgr) {
|
||||||
osRecvMesg(queue, NULL, OS_MESG_BLOCK);
|
osRecvMesg(queue, NULL, OS_MESG_BLOCK);
|
||||||
osContGetReadData(padMgr->pads);
|
osContGetReadData(padMgr->pads);
|
||||||
|
|
||||||
if (CVar_GetS32("gRumbleEnabled", 0) != 0) {
|
padMgr->padStatus[0].status = (CVar_GetS32("gRumbleEnabled", 0) != 0) && Controller_CanRumble();
|
||||||
padMgr->padStatus[0].status = 1;
|
|
||||||
} else {
|
|
||||||
padMgr->padStatus[0].status = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (padMgr->preNMIShutdown) {
|
if (padMgr->preNMIShutdown) {
|
||||||
memset(padMgr->pads, 0, sizeof(padMgr->pads));
|
memset(padMgr->pads, 0, sizeof(padMgr->pads));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue