Fix MAME controller order changing on Android
First prove whether the Android port exposes MAME's Input Devices menu, controller configuration path, and `-ctrlr` support. In a full MAME build, copy each device ID and use `mapdevice` entries in a selected controller configuration file to map them to `JOYCODE_1`, `JOYCODE_2`, and so on. This works only when the Android input provider supplies stable unique IDs and all mapped devices are connected at startup; otherwise use the port's own player assignment or a documented connection order.
Do this in order
- 01
Record the Android app or frontend, its exact MAME/core revision, input provider, and whether it exposes Input Devices, `ctrlrpath`, and the `ctrlr` option.
- 02
Start with all intended pads connected and capture each device ID from Input Devices or verbose `Input: Adding…` log output where the port supports it.
- 03
Confirm the IDs remain unique and unchanged across one clean restart; stop if the provider reports identical or unstable IDs.
- 04
In a full MAME build, create a controller `.cfg` under the configured `ctrlrpath`, put `mapdevice` entries in the first applicable default system section, and select it with `-ctrlr` or the equivalent option.
- 05
Restart with every mapped device connected and confirm verbose output reports the intended remapping before changing per-game buttons.
- 06
If the Android port omits controller files or stable IDs, use its own player assignment or a fixed connection sequence and record the limitation instead of editing unsupported XML.
Decision and diagnostic table
| Evidence | Can stable mapping work? | Action |
|---|---|---|
| Unique device IDs plus `-ctrlr` support | Potentially yes | Use one selected controller file and verify logs |
| IDs change after restart | No reliable `mapdevice` match | Use port assignment or fixed connection order |
| Identical pads expose identical IDs | Not individually distinguishable | Keep physical ports/order fixed |
| Android port has no `ctrlrpath` or controller-file UI | Full-MAME method unavailable | Do not paste desktop XML into guessed folders |
Joy numbers normally follow enumeration
MAME documents that input device numbers are not stable by default. USB or Bluetooth reconnection, hub changes, and a restart can change the order in which the input provider enumerates devices.
A saved per-game button assignment that refers to Joy 1 can therefore follow the number rather than the physical pad unless a stable mapping layer exists.
mapdevice belongs only in a controller file
MAME applies `mapdevice` elements from the selected controller configuration file. It ignores them in ordinary system and default configuration files, so editing `default.cfg` cannot solve enumeration.
All explicitly mapped devices must be present at startup for numbering to behave as expected. Verify the log before trusting the layout.
Android ports define the practical boundary
An app branded with MAME may wrap or modify upstream configuration, and a libretro core uses the frontend's input system. Neither guarantees direct access to upstream `-ctrlr`, `ctrlrpath`, verbose logs, or clipboard-based device IDs.
Treat absent controls as a platform boundary, not an invitation to invent a filesystem path. Use the port's documented UI and keep a reversible connection-order note.
Controller configuration contains no game license. Test with a lawful dump, a rightsholder-authorized release, or project-original input fixture, and do not bundle commercial ROM or BIOS data with controller profiles.