From upstream 83306ee321e127368a41068f32bd4899ae00223e
From upstream 9e9c8ffafe465b907ed0d22bcb1ba4df06803b8b
From upstream 9d65a68c61d0503e05e2cbe80447af0d619161e4 Note that ScummVM doesn't have a TEXT_INPUT event, so this change and following ones will be mostly to keep in sync with the standalone codebase even if they're not directly used