Inputraw method, really hard stuff to deal with!
You can go baldy with that. It should be a lua script or something to make mame echo the raw values while you press them in the terminal or screen, it would help A LOT!!
To find your default "defstat" or "inputmask" you take a look at the CPS2 driver for instance starting at L992
Look at "IPT_JOYSTICK_RIGHT" for player 1, you have '0x0001' for right, '0x0002' for left, etc. Add all those 4 values for right, left, down, up or 1 + 2 + 4 + 8 = 15, 15 hexadecimal is f or 0xf.
Do the same for player 2, 100 + 200 + 400 + 800 = f00
There you have it.
Sorry, the forum it's not helping today.