[GPGX] Add offscreen shot control, make lightgun inputs always use the correct screen width/height

Fixes #4120
This commit is contained in:
CasualPokePlayer 2024-11-23 22:21:26 -08:00
parent 2b900b6e50
commit c9666a5647
5 changed files with 18 additions and 7 deletions

View File

@ -133,6 +133,7 @@ namespace BizHawk.Emulation.Common
["Lightgun Start"] = 'S',
["Lightgun B"] = 'B',
["Lightgun C"] = 'C',
["Lightgun Offscreen Shot"] = 'O',
["Microphone"] = 'M',
["Star"] = '*',

View File

@ -59,8 +59,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
// if (!Core.gpgx_get_control(input, inputsize))
// throw new Exception("gpgx_get_control() failed!");
ControlConverter.ScreenWidth = _vwidth;
ControlConverter.ScreenHeight = _vheight;
Core.gpgx_get_video(out var screenWidth, out var screenHeight, out _, out _);
ControlConverter.ScreenWidth = screenWidth;
ControlConverter.ScreenHeight = screenHeight;
ControlConverter.Convert(controller, _input);
if (controller.IsPressed("Pause"))

View File

@ -96,8 +96,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
using (_elf.EnterExit())
{
var src = IntPtr.Zero;
Core.gpgx_get_video(out var gpwidth, out var gpheight, out var gppitch, ref src);
Core.gpgx_get_video(out var gpwidth, out var gpheight, out var gppitch, out var src);
_vwidth = gpwidth;
_vheight = gpheight;

View File

@ -78,6 +78,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
new("Lightgun Start", LibGPGX.INPUT_KEYS.INPUT_MENACER_START),
new("Lightgun B", LibGPGX.INPUT_KEYS.INPUT_MENACER_B),
new("Lightgun C", LibGPGX.INPUT_KEYS.INPUT_MENACER_C),
new("Lightgun Offscreen Shot", LibGPGX.INPUT_KEYS.INPUT_MENACER_TRIGGER),
];
private static readonly CName[] Activator =
@ -164,12 +165,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
{
// lightgun needs to be transformed to match the current screen resolution
ControllerDef.AddXYPair($"P{player} Lightgun {{0}}", AxisPairOrientation.RightAndUp, 0.RangeTo(10000), 5000); //TODO verify direction against hardware
var no = $"P{player} Lightgun Offscreen Shot";
var nx = $"P{player} Lightgun X";
var ny = $"P{player} Lightgun Y";
_converts.Add(() =>
{
_target.analog[(2 * idx) + 0] = (short)(_source.AxisValue(nx) / 10000.0f * (ScreenWidth - 1));
_target.analog[(2 * idx) + 1] = (short)(_source.AxisValue(ny) / 10000.0f * (ScreenHeight - 1));
if (_source.IsPressed(no))
{
_target.analog[(2 * idx) + 0] = 512;
_target.analog[(2 * idx) + 1] = 512;
}
else
{
_target.analog[(2 * idx) + 0] = (short)(_source.AxisValue(nx) / 10000.0f * (ScreenWidth - 1));
_target.analog[(2 * idx) + 1] = (short)(_source.AxisValue(ny) / 10000.0f * (ScreenHeight - 1));
}
});
}

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public abstract class LibGPGX
{
[BizImport(CallingConvention.Cdecl)]
public abstract void gpgx_get_video(out int w, out int h, out int pitch, ref IntPtr buffer);
public abstract void gpgx_get_video(out int w, out int h, out int pitch, out IntPtr buffer);
[BizImport(CallingConvention.Cdecl)]
public abstract void gpgx_get_audio(ref int n, ref IntPtr buffer);