From 554fde7a9da95a5597a3173e9b27236a86697b09 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 18 Aug 2023 15:34:13 +0200 Subject: [PATCH] port: fix rumble --- port/src/input.c | 9 ++++++--- port/src/libultra.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index b47767e8f..5e3d0bd21 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -262,11 +262,14 @@ void inputRumble(s32 idx, f32 strength, f32 time) return; } if (SDL_GameControllerHasRumble(pads[idx])) { - if (strength < 0.f) { + if (strength <= 0.f) { strength = 0.f; + time = 0.f; + } else { + strength *= 65535.f; + time *= 1000.f; } - strength *= 65535.f; - SDL_GameControllerRumble(pads[idx], (u16)strength, (u16)strength, (u32)(time * 1000.f)); + SDL_GameControllerRumble(pads[idx], (u16)strength, (u16)strength, (u32)time); } } diff --git a/port/src/libultra.c b/port/src/libultra.c index 952a21207..815ab2d92 100644 --- a/port/src/libultra.c +++ b/port/src/libultra.c @@ -207,7 +207,7 @@ void osContGetQuery(OSContStatus *status) if (inputControllerConnected(i)) { status->errnum = 0; status->type = CONT_ABSOLUTE; - status->status = 1; + status->status = CONT_CARD_ON; } else { status->errnum = CONT_NO_RESPONSE_ERROR; status->type = 0; @@ -287,13 +287,19 @@ s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern) { if (pattern) { *pattern = 0; + for (s32 i = 0; i < MAXCONTROLLERS; ++i) { + if (inputRumbleSupported(i)) { + *pattern |= 1 << i; + } + } } return 0; } s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel, s32 *arg3) { - return PFS_ERR_NOPACK; + // if rumble is supported, indicate that we have a rumble pak instead + return inputRumbleSupported(channel) ? PFS_ERR_DEVICE : PFS_ERR_NOPACK; } s32 osPfsChecker(OSPfs *pfs)