Backport https://github.com/mupen64plus/mupen64plus-core/commit/77b0327811167dde2b2f717722e13c1dfda3a311