Game development for Apple platforms

Thinking about input handling

Today over lunch I spent some time thinking about how to approach handling game input across different devices (touch/keyboard+mouse/gamepads).

You can see it here: https://youtu.be/cHhCoqMQ0MA

I was eager to use Combine initially, but quickly realized there's no real need for it.

The gist of the initial approach will be:

So it is very similar to how input is handled already in SpriteKit, just with a minimal normalization layer in between.

One thing to note is that it is not enough to just normalize the underlying input events (e.g. gamepad "A" or keyboard "Return" both map to "GameInputEvent.confirm") but we also need to forward some metadata about what originated the event (e.g. keyboard or gamepad, and which gamepad, etc.). This will help us adapt the UI to better match the input device being used.