When I port between Desktop games and Mobile games, I find I always make a kludge out of the interaction events.
I typically end up hard-coding event handling for mobile, and event handling for the desktop in completely separate systems.
On mobile, I need to track multiple touches.
On desktop, I only have a single mouse pointer.
But on desktop, there is a concept of "hovering" above something with a mouse. There is no such thing on mobile. Or pressing a modifier key like SHIFT or CTRL while clicking a button or pressing a key.
I want to design an API that I can use on both mobile and desktop that is able to translate an interaction (by user) to an action in my game world.
Are there any design patterns that I can follow, or some abstract model I can use for this? How do people successfully marry the desktop and mobile port of a game?
So in the same code-base, maybe assign Alt+Left-Click to a certain game function, but on mobile have that done via a gesture.
On Desktop, I currently use SDL2's SDL_Event. On Apple, is use UIEvent, and on Android I use NDK's AInputEvent.
answers. I would suggest going withCommandpattern and mapping different input types to commands. Then if possible is to have aplatform-dependent compilationto avoid havingifs for every type of device input. \$\endgroup\$