I'll go into details, but basically you got it:
Default -> OS specific (coded) -> ctrlr -> cfg/default.cfg -> driver coded non-defaults -> cfg/[game].cfgMame has two seperate input mapping lists; I'll call them "general" and "local". They have been this way from before ctrlr files were added, so things might seem not well planned.

Each list is seperate and while local overrides general (general -> local in the above format), edits to one list does not change what's in the other list.
General's part of the whole is:
Default -> OS specific (coded) -> ctrlr -> cfg/default.cfg -> ...
To most people, the OS specific part is part of the "default" default, since it is hard coded. However, other OS variants that don't use official mame's src/osd/windows/input.c (or a copy of
osd_customize_inputport_list() function therein) can have different "defaults". Both the ctrlr and cfg/default.cfg files change the general input map, the latter overriding the former. The general list is complete with all input ports included.
Local's part of the whole is:
...
-> driver coded non-defaults -> cfg/[game].cfgThis list is not complete, and includes only the gaming inputs in the specific game's inputs. The defaults for each input in the list is "default". IOW, this tells mame to "look the the general list". If it's not "default", then mame uses that setting and ignores the general list. You can tell if it's set to "default" by looking into the tab, inputs this game, and seeing if it's highlighted or not: highlighted = not "default", not highlighted = "default".
However, sometimes (examples: rotary joysticks, toobin') the driver is coded to set it something besides "default". This not only makes the vanilla setup (aka default) not set to "default", but also negates any changes in ctrlr file (game specific or not). Since cfg/
game.cfg overrides the driver coded inputs, however, you can reassign that input back to "default" by pressing enter, esc [pause], enter, esc in the tab inputs this game menu.
I hope this helps. If I glossed over anything, was unclear, or forgot something, please ask. (I totally skipped the ctrlr file order, for example: it's not order depend
anymore, just the order they're put in the ctrlr file.)
edit: added ctrlr file not listed note.