Backport https://github.com/mupen64plus/mupen64plus-core/commit/7669dfe8782aa94854f9a85c50e21b95263e8fa3