Inputs
Gamepad Mapping
This section should aboard these different problems:
- mapping a physical gamepad to some standard gamepad
- mapping the standard gamepad to some non standard gamepad or another kind of input
- mapping a physical gamepad to some non standard gamepad or another kind of input
- showing to the user which physical button correspond to which target input
Ports and Players
This section should aboard these different how inputs are assigned to an emulated consol port or a player.
The problem: emulators have ports which can accept one or no gamepad, and controllers can be plugged into one or no port, we want the user to be able to reassign the controllers to the ports. Ports roughly map to players as typically there is one controller per player, though in rare cases a controller could be shared by multiple players and multiple controllers could can be used by one player.
Following is a proposal to fix this problem.
When starting a game, each gamepad should be assigned to a port (gamepad one to port one… etc.).
A button showing a gamepad icon should be on the right part of the header bar, clicking it would display a popover containing the following:
- a list of the controllers showing:
- an icon describing the type of the controller
- the controller's name
- the port (player?) number it is assigned to or "Unassigned"
- optionally a button to tweak the how the controller is used:
- change the mapping from the standard gamepad to the emulated gamepad (use the "west" and "south" buttons instead of "south" and "east" for 2-buttons controllers, …)
- use the mouse as a lightgun
- use the keyboard as a gamepad
- a "Reassign" button
Clicking the reassign button would trigger a dialog showing the list of all controllers as "Unassigned", the dialog would ask "Press a button on controller for port (player?) x, then x+1, etc… until all controllers are assigned or the process is validated early, making the remaining controllers unassigned. A button could allow to skip a port, another could allow to assign the mouse.
The following tweaks could be possible in the popover:
- change the mapping from the standard gamepad to the emulated gamepad (cardinal points are used as gamepad button position):
- use the W and S buttons instead of S and E for 2-buttons controllers
- use the N, W and S buttons instead of W, S and E for 3-buttons controllers
- use the mouse as a lightgun
- use the keyboard as a gamepad
Navigation
This section should aboard how the GUI could be controlled with other inputs than a keyboard and a mouse, such as gamepads. This would avoid the player to switch between different input types when using Games.
Accessing Gamepads
There are two APIs provided by the linux kernel:
- evdev : Modern API. We are mostly going to use this.
Helper library libevdev - https://www.freedesktop.org/software/libevdev/doc/latest/
- Joystick API: Old API. Not supported by SDL2 so we are mostly not using this
Other references:
Retroarch : https://github.com/libretro/RetroArch/tree/master/input/drivers_joypad
SDL : https://github.com/spurious/SDL-mirror/blob/release-2.0.4/src/joystick/linux/
Resources
https://www.w3.org/TR/gamepad/ - W3C gamepad specification
https://github.com/taalas/RetroPie-Artwork/tree/master/Source_Graphics - handheld console and gamepad vector graphics (see also OpenEmu's high-fidelity gamepad visuals)
https://github.com/OpenEmu/OpenEmu/wiki/User-guide:-Preferences:-Controls - Controller Mapping in OpenEmu - Relevant Art (see also in video)
Relevant Art
OpenEmu
Concepts