Mame32 v.113
Could you test with a current mame or mameUI (0.128 or even down to ~0.124)? MameUI is the new name for mame32. Make sure mouse is enabled and multiple mouse is
disabled.
I
think what's happening is the keyboard is being seen also as a mouse (is it a media center keyboard?), and IIRC, at that mame version era, mame was forcing -multimouse enabled, and had problems remapping mice. Looks like the keyboard is mouse 1, TB is mouse 2, and spinner is mouse 3 (or higher). When the keyboard is unplugged, then all mice numbers decrease by one, so that's why your TB is working and the spinner not.
I'm not sure on the version numbers that multiple mouse support was first added (and forced), and when it became an option, and when remapping mice because possible, though.
If you really want to keep using 0.113, try starting a mouse or spinner game, tab, input (this game), go to trackball or dial analog port, enter, and then spin TB or spinner. If it works, you can remap the TB and spinner as needed. If it doesn't, try it a couple more times with faster and slow spins and see if that works. I'd remap in Input (general), and map your TB to only the player 1 TB analog ports, and your spinner to only the p1 dial analog port. Do
not map the analog devices (TB or spinner) to the Inc/Dec ports. If it still doesn't, you'll have to try a different version.
You can also try two player TB or spinner games (I suggest cabal or marble madnes) and see if the TB is player 2 with the keyboard plugged in, and if the spinner is p2 with the keyboard unplugged, instead of trying the remapping. But this is only a test to confirm the cause, and doesn't fix anything.