geneis: fix lightguns with variable screen resolutions

This commit is contained in:
goyuken 2014-06-27 02:55:14 +00:00
parent c0da15b002
commit 8b1735ce24
2 changed files with 17 additions and 6 deletions
BizHawk.Emulation.Cores/Consoles/Sega/gpgx

View File

@ -372,6 +372,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
if (!LibGPGX.gpgx_get_control(input, inputsize))
throw new Exception("gpgx_get_control() failed!");
ControlConverter.ScreenWidth = vwidth;
ControlConverter.ScreenHeight = vheight;
ControlConverter.Convert(Controller, input);
if (!LibGPGX.gpgx_put_control(input, inputsize))

View File

@ -66,8 +66,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
};
static ControllerDefinition.FloatRange MouseRange = new ControllerDefinition.FloatRange(-512, 0, 511);
static ControllerDefinition.FloatRange LightgunX = new ControllerDefinition.FloatRange(0, 160, 319);
static ControllerDefinition.FloatRange LightgunY = new ControllerDefinition.FloatRange(0, 112, 223);
// lightgun needs to be transformed to match the current screen resolution
static ControllerDefinition.FloatRange LightgunRange = new ControllerDefinition.FloatRange(0, 5000, 10000);
LibGPGX.InputData target = null;
IController source = null;
@ -112,12 +112,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
string NY = string.Format("P{0} Lightgun Y", player);
ControllerDef.FloatControls.Add(NX);
ControllerDef.FloatControls.Add(NY);
ControllerDef.FloatRanges.Add(LightgunX);
ControllerDef.FloatRanges.Add(LightgunY);
ControllerDef.FloatRanges.Add(LightgunRange);
ControllerDef.FloatRanges.Add(LightgunRange);
Converts.Add(delegate()
{
target.analog[(2 * idx) + 0] = (short)source.GetFloat(NX);
target.analog[(2 * idx) + 1] = (short)source.GetFloat(NY);
target.analog[(2 * idx) + 0] = (short)(source.GetFloat(NX) / 10000.0f * (ScreenWidth - 1));
target.analog[(2 * idx) + 1] = (short)(source.GetFloat(NY) / 10000.0f * (ScreenHeight - 1));
});
}
@ -180,5 +180,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
this.target = null;
}
/// <summary>
/// must be set for proper lightgun operation
/// </summary>
public int ScreenWidth { get; set; }
/// <summary>
/// must be set for proper lightgun operation
/// </summary>
public int ScreenHeight { get; set; }
}
}