Backport Lioncash's changes - https://github.com/libretro/RetroArch/pull/1170