saturnus: get rid of the round-tripping of analogs through the mednafen input system.
This commit is contained in:
parent
9ff2da5265
commit
37b285fe8d
|
@ -98,7 +98,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
|
||||
private abstract class ButtonedDevice : IDevice
|
||||
{
|
||||
private static readonly FloatRange AnalogFloatRange = new FloatRange(-32767, 0, 32767);
|
||||
private static readonly FloatRange AnalogFloatRange = new FloatRange(0, 128, 255);
|
||||
|
||||
protected ButtonedDevice()
|
||||
{
|
||||
|
@ -164,13 +164,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
int pos = offset + AnalogByteOffset;
|
||||
for (int i = 0; i < _bakedAnalogNames.Length; i++)
|
||||
{
|
||||
var data = (int)controller.GetFloat(_bakedAnalogNames[i]);
|
||||
var datal = (short)Math.Max(-data, 0);
|
||||
var datar = (short)Math.Max(data, 0);
|
||||
dest[pos++] = (byte)datal;
|
||||
dest[pos++] = (byte)(datal >> 8);
|
||||
dest[pos++] = (byte)datar;
|
||||
dest[pos++] = (byte)(datar >> 8);
|
||||
var data = (byte)(int)controller.GetFloat(_bakedAnalogNames[i]);
|
||||
dest[pos++] = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,11 +228,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
{
|
||||
"Stick Horizontal",
|
||||
"Stick Vertical",
|
||||
"Third Axis"
|
||||
"Left Shoulder",
|
||||
"Right Shoulder"
|
||||
};
|
||||
|
||||
protected override string[] AnalogNames => _analogNames;
|
||||
|
||||
public ThreeDeeGamepad()
|
||||
{
|
||||
Definition.FloatRanges[2] = new FloatRange(0, 0, 255);
|
||||
Definition.FloatRanges[3] = new FloatRange(0, 0, 255);
|
||||
}
|
||||
|
||||
public override void Update(IController controller, byte[] dest, int offset)
|
||||
{
|
||||
base.Update(controller, dest, offset);
|
||||
|
@ -248,37 +250,19 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
|
||||
private class Mouse : ButtonedDevice
|
||||
{
|
||||
private static readonly FloatRange MouseFloatRange = new FloatRange(-32768, 0, 32767);
|
||||
|
||||
private static readonly string[] _buttonNames =
|
||||
{
|
||||
"Left", "Right", "Middle", "Start"
|
||||
};
|
||||
|
||||
protected override string[] ButtonNames => _buttonNames;
|
||||
protected override int ButtonByteOffset => 8;
|
||||
|
||||
public Mouse()
|
||||
private static readonly string[] _analogNames =
|
||||
{
|
||||
Definition.FloatControls.AddRange(new[] { "0X", "0Y" });
|
||||
Definition.FloatRanges.AddRange(new[] { MouseFloatRange, MouseFloatRange });
|
||||
}
|
||||
"X", "Y"
|
||||
};
|
||||
|
||||
private void SetMouseAxis(float value, byte[] dest, int offset)
|
||||
{
|
||||
var data = (short)value;
|
||||
dest[offset++] = 0;
|
||||
dest[offset++] = 0;
|
||||
dest[offset++] = (byte)data;
|
||||
dest[offset++] = (byte)(data >> 8);
|
||||
}
|
||||
|
||||
public override void Update(IController controller, byte[] dest, int offset)
|
||||
{
|
||||
base.Update(controller, dest, offset);
|
||||
SetMouseAxis(controller.GetFloat("0X"), dest, offset + 0);
|
||||
SetMouseAxis(controller.GetFloat("0Y"), dest, offset + 4);
|
||||
}
|
||||
protected override string[] AnalogNames => _analogNames;
|
||||
}
|
||||
|
||||
private class Wheel : ButtonedDevice
|
||||
|
@ -319,7 +303,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
};
|
||||
|
||||
protected override string[] AnalogNames => _analogNames;
|
||||
protected override int AnalogByteOffset => 3;
|
||||
protected override int AnalogByteOffset => 4;
|
||||
}
|
||||
|
||||
private class DualMission : Mission
|
||||
|
|
Binary file not shown.
|
@ -42,32 +42,24 @@ void IODevice_3DPad::Power(void)
|
|||
data_out = 0x01;
|
||||
}
|
||||
|
||||
void IODevice_3DPad::UpdateInput(const uint8* data, const int32 time_elapsed)
|
||||
void IODevice_3DPad::UpdateInput(const uint8 *data, const int32 time_elapsed)
|
||||
{
|
||||
const uint16 dtmp = MDFN_de16lsb(&data[0]);
|
||||
|
||||
dbuttons = (dbuttons & 0x8800) | (dtmp & 0x0FFF);
|
||||
mode = (bool)(dtmp & 0x1000);
|
||||
|
||||
for(unsigned axis = 0; axis < 2; axis++)
|
||||
thumb[0] = data[2];
|
||||
thumb[1] = data[3];
|
||||
shoulder[0] = data[4];
|
||||
shoulder[1] = data[5];
|
||||
|
||||
for (unsigned w = 0; w < 2; w++)
|
||||
{
|
||||
int32 tmp = 32767 + MDFN_de16lsb(&data[0x2 + (axis << 2) + 2]) - MDFN_de16lsb(&data[0x2 + (axis << 2) + 0]);
|
||||
|
||||
if(tmp >= (32767 - 128) && tmp < 32767)
|
||||
tmp = 32767;
|
||||
|
||||
tmp = (tmp * 255 + 32767) / 65534;
|
||||
thumb[axis] = tmp;
|
||||
}
|
||||
|
||||
for(unsigned w = 0; w < 2; w++)
|
||||
{
|
||||
shoulder[w] = (MDFN_de16lsb(&data[0xA + (w << 1)]) * 255 + 16383) / 32767;
|
||||
|
||||
// May not be right for digital mode, but shouldn't matter too much:
|
||||
if(shoulder[w] <= 0x55)
|
||||
if (shoulder[w] <= 0x55)
|
||||
dbuttons &= ~(0x0800 << (w << 2));
|
||||
else if(shoulder[w] >= 0x8E)
|
||||
else if (shoulder[w] >= 0x8E)
|
||||
dbuttons |= 0x0800 << (w << 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void IODevice_Mission::Power(void)
|
|||
afphase = false;
|
||||
}
|
||||
|
||||
void IODevice_Mission::UpdateInput(const uint8* data, const int32 time_elapsed)
|
||||
void IODevice_Mission::UpdateInput(const uint8 *data, const int32 time_elapsed)
|
||||
{
|
||||
const uint32 dtmp = MDFN_de32lsb(&data[0]);
|
||||
|
||||
|
@ -60,13 +60,12 @@ void IODevice_Mission::UpdateInput(const uint8* data, const int32 time_elapsed)
|
|||
afeswitches = ((dtmp >> 12) & 0x8FF) << 4;
|
||||
afspeed = (dtmp >> 20) & 0x7;
|
||||
|
||||
for(unsigned stick = 0; stick < (dual ? 2 : 1); stick++)
|
||||
int offs = 4;
|
||||
for (unsigned stick = 0; stick < (dual ? 2 : 1); stick++)
|
||||
{
|
||||
for(unsigned axis = 0; axis < 3; axis++)
|
||||
for (unsigned axis = 0; axis < 3; axis++)
|
||||
{
|
||||
int32 tmp = 32767 + MDFN_de16lsb(&data[0x3 + ((axis + (stick * 3)) * 4) + 2]) - MDFN_de16lsb(&data[0x3 + ((axis + (stick * 3)) * 4) + 0]);
|
||||
|
||||
axes[stick][axis] = (tmp * 255 + 32767) / 65534;
|
||||
axes[stick][axis] = data[offs++];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ void IODevice_Mouse::Power(void)
|
|||
|
||||
void IODevice_Mouse::UpdateInput(const uint8* data, const int32 time_elapsed)
|
||||
{
|
||||
accum_xdelta += MDFN_de32lsb(&data[0]);
|
||||
accum_ydelta -= MDFN_de32lsb(&data[4]);
|
||||
buttons = data[8] & 0xF;
|
||||
accum_xdelta += data[1];
|
||||
accum_ydelta -= data[2];
|
||||
buttons = data[0] & 0xF;
|
||||
}
|
||||
|
||||
uint8 IODevice_Mouse::UpdateBus(const uint8 smpc_out, const uint8 smpc_out_asserted)
|
||||
|
|
|
@ -42,26 +42,19 @@ void IODevice_Wheel::Power(void)
|
|||
data_out = 0x01;
|
||||
}
|
||||
|
||||
void IODevice_Wheel::UpdateInput(const uint8* data, const int32 time_elapsed)
|
||||
void IODevice_Wheel::UpdateInput(const uint8 *data, const int32 time_elapsed)
|
||||
{
|
||||
dbuttons = (dbuttons & 0xC) | (MDFN_de16lsb(&data[0]) & 0x07F3);
|
||||
|
||||
//
|
||||
{
|
||||
int32 tmp = 32767 + MDFN_de16lsb(&data[0x2 + 2]) - MDFN_de16lsb(&data[0x2 + 0]);
|
||||
|
||||
wheel = 1 + tmp * 253 / 65534;
|
||||
|
||||
if(wheel >= 0x6F)
|
||||
wheel = data[2];
|
||||
if (wheel >= 0x6F)
|
||||
dbuttons &= ~0x4;
|
||||
else if(wheel <= 0x67)
|
||||
else if (wheel <= 0x67)
|
||||
dbuttons |= 0x4;
|
||||
|
||||
if(wheel <= 0x8F)
|
||||
if (wheel <= 0x8F)
|
||||
dbuttons &= ~0x8;
|
||||
else if(wheel >= 0x97)
|
||||
else if (wheel >= 0x97)
|
||||
dbuttons |= 0x8;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 IODevice_Wheel::UpdateBus(const uint8 smpc_out, const uint8 smpc_out_asserted)
|
||||
|
|
Loading…
Reference in New Issue