Synced with libemulation upstream changes.