Input mapping for cross-platform development

Managing inputs in a relatively complex game that targets several platforms with different peripherals can become a massive headache. Keys, touch, mouse, gestures, analog sticks, on-screen sticks, and so on, the variety is just too overwhelming, not to mention that controllers by different manufacturers do not have the same button codes. Sometimes, device codes vary even across platforms!

Without an additional system to aid us in user-input issues, the game's logic code will become a sea of conditional blocks to handle each possibility.

Quite rapidly, an additional layer becomes imperative to spare us the need to worry about which user input peripheral is currently being used and to gain a few years of ...

Get Libgdx Cross-platform Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.