For some reason, I have had this problem with various builds of Mame. For example, I was going crazy trying to get all three mouse buttons to work, but as you said, two of my buttons kept coming up as Mouse 0. I was using an Optimized build at the time. When I went back to straight Mame, the problem went away.
Let me know if you have tried a different build of mame to see if this fixes it. I am curious as to whether this was what fixed mine, or a combination of things that I did.