Specifically for MAME on PC, I’ve had plenty of issues getting my X-Arcade tank stick to recognize my trackball. Literally none of the yt tutorials helped, but the link below provided a fix for most games.
https://support.xgaming.com/support/solutions/articles/12000003052-configuring-mame-for-x-arcade-use-the-easy-way
Another fix:
There are several other fixes, but without my PC in front of me its hard to recall the exact process. If you haven’t already, hopefully this fixes your issue. If for some reason it doesn’t work let me know, and I’ll try to find links to the other resources I used.