Backport https://github.com/libretro/fceu-next/commit/fcf25136d8996dacd35370d0232a2fa7b223cef2