add TransformPoint impl for NDS

This commit is contained in:
CasualPokePlayer 2023-09-25 22:18:22 -07:00
parent a59e9a1ce8
commit 2b00e33560
3 changed files with 21 additions and 5 deletions

View File

@ -197,11 +197,7 @@ namespace BizHawk.Client.Common.Filters
}
public override Vector2 TransformPoint(string channel, Vector2 point)
{
// TODO
Console.WriteLine($"TODO ScreenControlNDS TransformPoint {point.X} / {point.Y}");
return base.TransformPoint(channel, point);
}
=> _nds.GetScreenCoords(point.X, point.Y);
}
/// <summary>

View File

@ -294,5 +294,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
[BizImport(CC)]
public abstract void GetTouchCoords(ref int x, ref int y);
[BizImport(CC)]
public abstract void GetScreenCoords(ref float x, ref float y);
}
}

View File

@ -71,6 +71,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
private IntPtr GetGLProcAddressCallback(string proc)
=> _openGLProvider.GetGLProcAddress(proc);
// TODO: Probably can make these into an interface (ITouchScreen with UntransformPoint/TransformPoint methods?)
// Which case the hackiness of the current screen controls wouldn't be as bad
public Vector2 GetTouchCoords(int x, int y)
{
if (_glContext != null)
@ -86,6 +88,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
return new(x, y);
}
public Vector2 GetScreenCoords(float x, float y)
{
if (_glContext != null)
{
_core.GetScreenCoords(ref x, ref y);
}
else
{
// no GL context, so nothing fancy can be applied
y = Math.Min(256, y + 192);
}
return new(x, y);
}
[CoreConstructor(VSystemID.Raw.NDS)]
public NDS(CoreLoadParameters<NDSSettings, NDSSyncSettings> lp)
: base(lp.Comm, new()