Skip to content

Beetle-PSX (mednafen_psx) lightgun support - #16170

Draft
TrickoUK wants to merge 3 commits into
batocera-linux:masterfrom
TrickoUK:beetle-psx-hw-lightgun
Draft

Beetle-PSX (mednafen_psx) lightgun support#16170
TrickoUK wants to merge 3 commits into
batocera-linux:masterfrom
TrickoUK:beetle-psx-hw-lightgun

Conversation

@TrickoUK

Copy link
Copy Markdown
Contributor

Disclosure, this change was done with Claude.

Lightguns currently work when using the software renderer in Beetle-PSX, this change enable them in hardware rendering paths too, and exposes more of the available core specific options via libretroOptions.py.

For gun support:

Add the missing mednafen_psx button-remap block in configureGunInputsForPlayer (parity with pcsx_rearmed) plus a gun_type == "justifier" override in the gun_mapping dict, so the real GunCon's 3-button hardware maps onto RetroArch's generic gun scheme instead of falling through to the fully generic default.

That alone isn't enough: Beetle-PSX's GunCon/Justifier emulation is hardware-accurate and samples the actual rendered pixel color at the aim position each scanline to simulate the real light-sensor photodiode. That pixel buffer is only populated under the software renderer - under the HW (Vulkan/OpenGL) renderer this fork defaults to, the position never reaches the game at all. Fix via a new source patch, 002-guncon-justifier-hw-renderer-position-fallback.patch, touching mednafen/psx/frontio.c's two *_GPULineHook functions: when the pixel buffer is unavailable (HW renderer), skip the brightness-sampling loop but still set the hit position directly from the computed aim coordinates - the same "trust the raw position" approach pcsx_rearmed/swanstation already use, applied only when real light detection isn't possible. Software renderer keeps full authentic light-sensor behavior.

For extra options:

The extra options added have been grouped how they appear in the retroach core settings themselves, I've put the four new options under a "BEETLE SPECIFIC" sub header for clarity. See attached menu.txt file for reference on how they look in terms of layout.
menu.txt

Tested on X86 build with Sinden light gun.

Enable support for lightguns in hardware rendering paths, and expose
more of the available core specific options via libretroOptions.py.

Add the missing mednafen_psx button-remap block in
configureGunInputsForPlayer (parity with pcsx_rearmed) plus a
gun_type == "justifier" override in the gun_mapping dict, so the real
GunCon's 3-button hardware maps onto RetroArch's generic gun scheme
instead of falling through to the fully generic default.

That alone isn't enough: Beetle-PSX's GunCon/Justifier emulation is
hardware-accurate and samples the actual rendered pixel color at the aim
position each scanline to simulate the real light-sensor photodiode. That
pixel buffer is only populated under the software renderer - under the
HW (Vulkan/OpenGL) renderer this fork defaults to, the position never
reaches the game at all. Fix via a new source patch,
002-guncon-justifier-hw-renderer-position-fallback.patch, touching
mednafen/psx/frontio.c's two *_GPULineHook functions: when the pixel
buffer is unavailable (HW renderer), skip the brightness-sampling loop
but still set the hit position directly from the computed aim
coordinates - the same "trust the raw position" approach
pcsx_rearmed/swanstation already use, applied only when real light
detection isn't possible. Software renderer keeps full authentic
light-sensor behavior.
@TrickoUK

Copy link
Copy Markdown
Contributor Author

@Tovarichtch , heres another light gun related change I'd like you to look at when you have chance, thanks!

@Tovarichtch

Copy link
Copy Markdown
Collaborator

I'm very busy with xemu Chihiro for the past month. I will get back to you once I'm finished with initial support and release of the first playtest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants