this is off memory so bear with me..
go to mame's configuration file in your mame folder. i think it's a .conf file, or config.bat or something to that nature. right click it, and select edit. this opens the configuration in notepad. now scroll down until you see JOYSTICKS, TRACKBALL, LIGHTGUN, SPINNERS. across from the device it will say "mouse" for example. meaning your trackball, spinner is acting as your mouse in mame.
hope this helps, i know it's choppy, but i don't even have a spinner so i couldn't tell you, that is how you do the trackball.