Since ^^^ up there was asking in private earlier, thought I'd just paste the same reply I gave them for everyone else reading:
MAME's mouse position handling is very dumb, and just uses the entire output screen to map to the game screen - meaning no matter how you stretch or squash the image, the edge of the TV screen correlates to the edge of the game screen.
Libretro, on the other hand, treats the game screen 1:1 with the display - so if you click in the game play area, it'll click in that position, and clicking on the black border area will be a screen edge/off screen shot. This will actually respect the game screen output; whether that be integer scaling or aspect ratio difference, so the gun can continue to operate in its normal mode.
It's not just Libretro that does this, FWIW: PCSX2-nightly does the same thing, both for mouse inputs and a gamepad stick acting as an absolute position surrogate mouse. Others like Model 2 emu, or Flycast (both standalone & libretro core) respect this too, though the former has no real off-screen detection and uses a hack to get around it lol. Most others that use a fullscreen window in
native desktop resolution should respect this. That is why I tend to say that MAME is doing it wrong.
Of course, that doesn't mean the 4:3 restrictor in gun firmware is useless - at least
on Windows, it is necessary due to how fullscreen apps often take over the screen resolution, and idiosyncrasies with absolute mouse positioning if the game doesn't use the same aspect ratio and... it's a lot. That's why 4:3 mode would be necessary. On Linux w/ Proton, or a version of Wine with the
fshack, none of this is necessary since everything scales up to desktop resolution so the accuracy of the mouse cursor doesn't change, much like Libretro et al.
That said, this is mostly talking wrt lightgun systems like GUN4ALL and GUN4IR. No idea how that applies to VR-tracking-on-pancake screens. This is mostly why I lean towards using RetroArch whenever possible.