itchio / itch

🎮 The best way to play your itch.io games
https://itch.io/app
MIT License
2.39k stars 213 forks source link

Per-game custom controller configuration. #786

Open bowlercaptain opened 8 years ago

bowlercaptain commented 8 years ago

Proposed new feature: per-game or totally modular controller configuration. Some games only support keyboard controls where being able to use a game controller would be convenient, and vice-versa. Also, some game controllers have differing internal configurations, meaning that the button prompts and expected axes in some games are wrong - a particularly annoying common problem is switching one of the Axes of the right stick with the triggers.

Solutions to these problems do exist to some extent in some places: Steam Big Picture's Controller configuration system for the Steam controller allows the user to rebind all of the controls per game, and save, switch out, and share these configurations. Starting a new major game often requires no significant work on the part of the user - one simply looks at the list of community configd for the most popular item and uses it, ready to play in mmoments.

Some software such as JoyToKey and Xpadder can assist with varying controller layouts and keyboard only games by binding controller actions to keyboard and mouse movements. This does not allow the controller to be detected as such (a problem for multiplayer games) and often loses the precision of the control stick.

Ideally this feature would capture input from a controller, multiple controllers, or a user-defined set of mouse and keyboard inputs, and output that data to a different set of game-controller, keyboard, and mouse "inputs". This mapping would be dependent on game and type of controller, and portable in some way so that multiple users can benefit from one user's work.

Capturing input from the myriad of obscure and badly-implemented game controllers that exist may be difficult, but game-to-game configuration would be a useful feature even if only "normal" controllers were supported.

Controller test-cases worth considering include the normal Xbox controller, the common Logitech wired USB controller, a Mayflash converter with a console controller, the WiiU GameCube to USB hub (useable on PC with no small software installation, and the USB NES controller.

fasterthanlime commented 8 years ago

Not sure if possible to integrate with itch app but posting this anyway for future reference: https://github.com/kozec/sc-controller

icculus commented 8 years ago

This is a brain dump and not something to act on specifically, but here are my thoughts:

Don't get bogged down in a universal solution to map devices. That can come later (or maybe not come at all?). I think getting to parity with Steam's offerings is the most immediate need here, and that looks like:

1) A controller configuration UI 2) A means to pass that configuration on to the launched app 3) Crowdsourcing the configs so that before long, itch knows what to do with your controller when you plug it in without you configuring anything.

The most obvious way to handle this (definitely on Linux and to lesser degrees on Mac and Windows) is to use SDL's game controller API; this is what Steam Big Picture Mode does, too.

You can see (a really simplistic) example of the UI involved in SDL's test programs:

https://hg.libsdl.org/SDL/file/c3fbfa229d71/test/controllermap.c

(That particular file is public domain, so steal what you like from it, if anything.)

Notable room for improvement over Steam: Steam's config UI is specific to Big Picture Mode. It won't just pop up a window when using the usual Steam desktop mode.

To pass the information on to the launched game, export the SDL_GAMECONTROLLERCONFIG environment variable. Multiple controllers can be specified in this variable (newline delimited) and SDL will deal with configuring the controller based on what devices it sees that match GUID values in this environment variable.

Note that this will only help games that a) use SDL and b) use SDL's game controller API (as opposed to SDL's lower-level joystick API). It won't help games that talk directly to OS-specific interfaces, and it doesn't map joysticks to look like keyboards and such. It's meant to make it easy for games that want something that looks like an XBox360 controller to get a consistent, plug-it-in-and-play experience. So it's a 90% solution, but it's pretty good.

As for crowdsourcing, there are several options here. itch could keep its own database, or there is a public database that is maintained elsewhere on github that is good (but probably won't get crazy coverage like SNES-to-USB converters you would buy on the street in Hong Kong), or maybe we could convince Valve to publish their database with some sort of simple HTTP query (ask for a specific device GUID, it returns a text/plain string with the environment variable needed). There are options to explore here, but getting a UI and exposing that info to the launched games is the easiest and biggest win available here before we cross that bridge.