2012-12-12 18:17:30 +00:00
|
|
|
|
using System;
|
2013-11-04 01:39:19 +00:00
|
|
|
|
|
2012-12-12 18:17:30 +00:00
|
|
|
|
using EMU7800.Core;
|
2013-11-04 01:39:19 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2012-12-12 18:17:30 +00:00
|
|
|
|
|
2013-11-13 03:32:25 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Atari.Atari7800
|
2012-12-12 18:17:30 +00:00
|
|
|
|
{
|
|
|
|
|
public class Atari7800Control
|
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
private static readonly ControllerDefinition Joystick = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 Joystick Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
|
|
|
|
"BW", // should be "Color"??
|
|
|
|
|
"Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Trigger",
|
|
|
|
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Trigger"
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly ControllerDefinition Paddles = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 Paddle Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
|
|
|
|
"BW", // should be "Color"??
|
|
|
|
|
"Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
"P1 Trigger",
|
|
|
|
|
"P2 Trigger",
|
|
|
|
|
"P3 Trigger",
|
|
|
|
|
"P4 Trigger"
|
|
|
|
|
},
|
|
|
|
|
FloatControls = // should be in [0..700000]
|
|
|
|
|
{
|
|
|
|
|
"P1 Paddle",
|
|
|
|
|
"P2 Paddle",
|
|
|
|
|
"P3 Paddle",
|
|
|
|
|
"P4 Paddle"
|
2013-07-18 16:18:17 +00:00
|
|
|
|
},
|
|
|
|
|
FloatRanges =
|
|
|
|
|
{
|
|
|
|
|
// what is the center point supposed to be here?
|
2017-04-24 15:32:45 +00:00
|
|
|
|
new[] { 0.0f, 0.0f, 700000.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 700000.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 700000.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 700000.0f }
|
2012-12-12 18:37:40 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly ControllerDefinition Keypad = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 Keypad Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
|
|
|
|
"BW", // should be "Color"??
|
2016-11-11 21:03:34 +00:00
|
|
|
|
"Toggle Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Toggle Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
"P1 Keypad1", "P1 Keypad2", "P1 Keypad3",
|
|
|
|
|
"P1 Keypad4", "P1 Keypad5", "P1 Keypad6",
|
|
|
|
|
"P1 Keypad7", "P1 Keypad8", "P1 Keypad9",
|
|
|
|
|
"P1 KeypadA", "P1 Keypad0", "P1 KeypadP",
|
|
|
|
|
"P2 Keypad1", "P2 Keypad2", "P2 Keypad3",
|
|
|
|
|
"P2 Keypad4", "P2 Keypad5", "P2 Keypad6",
|
|
|
|
|
"P2 Keypad7", "P2 Keypad8", "P2 Keypad9",
|
|
|
|
|
"P2 KeypadA", "P2 Keypad0", "P2 KeypadP",
|
|
|
|
|
"P3 Keypad1", "P3 Keypad2", "P3 Keypad3",
|
|
|
|
|
"P3 Keypad4", "P3 Keypad5", "P3 Keypad6",
|
|
|
|
|
"P3 Keypad7", "P3 Keypad8", "P3 Keypad9",
|
|
|
|
|
"P3 KeypadA", "P3 Keypad0", "P3 KeypadP",
|
|
|
|
|
"P4 Keypad1", "P4 Keypad2", "P4 Keypad3",
|
|
|
|
|
"P4 Keypad4", "P4 Keypad5", "P4 Keypad6",
|
|
|
|
|
"P4 Keypad7", "P4 Keypad8", "P4 Keypad9",
|
|
|
|
|
"P4 KeypadA", "P4 Keypad0", "P4 KeypadP"
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly ControllerDefinition Driving = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 Driving Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
|
|
|
|
"BW", // should be "Color"??
|
2016-11-11 21:03:34 +00:00
|
|
|
|
"Toggle Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Toggle Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
"P1 Trigger",
|
|
|
|
|
"P2 Trigger"
|
|
|
|
|
},
|
|
|
|
|
FloatControls = // should be in [0..3]
|
|
|
|
|
{
|
|
|
|
|
"P1 Driving",
|
|
|
|
|
"P2 Driving"
|
2013-07-18 16:18:17 +00:00
|
|
|
|
},
|
|
|
|
|
FloatRanges =
|
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
new[] { 0.0f, 0.0f, 3.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 3.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 3.0f }
|
2012-12-12 18:37:40 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly ControllerDefinition BoosterGrip = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 Booster Grip Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
|
|
|
|
"BW", // should be "Color"??
|
2016-11-11 21:03:34 +00:00
|
|
|
|
"Toggle Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Toggle Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
// NB: as referenced by the emu, p1t2 = p1t2, p1t3 = p2t2, p2t2 = p3t2, p2t3 = p4t2
|
|
|
|
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Trigger", "P1 Trigger 2", "P1 Trigger 3",
|
|
|
|
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Trigger", "P2 Trigger 2", "P2 Trigger 3"
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly ControllerDefinition ProLineJoystick = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 ProLine Joystick Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
2012-12-15 18:11:54 +00:00
|
|
|
|
"Pause",
|
2016-11-11 21:03:34 +00:00
|
|
|
|
"Toggle Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Toggle Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Trigger", "P1 Trigger 2",
|
|
|
|
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Trigger", "P2 Trigger 2"
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly ControllerDefinition Lightgun = new ControllerDefinition
|
2012-12-12 18:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
Name = "Atari 7800 Light Gun Controller",
|
|
|
|
|
BoolButtons =
|
|
|
|
|
{
|
2012-12-16 15:15:54 +00:00
|
|
|
|
// hard reset, not passed to EMU7800
|
|
|
|
|
"Power",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// on the console
|
|
|
|
|
"Reset",
|
|
|
|
|
"Select",
|
2012-12-15 18:11:54 +00:00
|
|
|
|
"Pause",
|
2017-05-05 13:17:05 +00:00
|
|
|
|
"Left Difficulty", // better not put P# on these as they might not correspond to player numbers
|
|
|
|
|
"Right Difficulty",
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-12 18:37:40 +00:00
|
|
|
|
// ports
|
|
|
|
|
"P1 Trigger",
|
|
|
|
|
"P2 Trigger"
|
|
|
|
|
},
|
|
|
|
|
FloatControls = // vpos should be actual scanline number. hpos should be in [0..319]??
|
|
|
|
|
{
|
|
|
|
|
"P1 VPos", "P1 HPos",
|
|
|
|
|
"P2 VPos", "P2 HPos"
|
2013-07-18 16:18:17 +00:00
|
|
|
|
},
|
|
|
|
|
FloatRanges =
|
|
|
|
|
{
|
|
|
|
|
// how many scanlines are there again??
|
2017-04-24 15:32:45 +00:00
|
|
|
|
new[] { 0.0f, 0.0f, 240.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 319.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 240.0f },
|
|
|
|
|
new[] { 0.0f, 0.0f, 319.0f }
|
2012-12-12 18:37:40 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2012-12-15 00:58:55 +00:00
|
|
|
|
|
2017-04-24 15:32:45 +00:00
|
|
|
|
private struct ControlAdapter
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
public readonly ControllerDefinition Type;
|
|
|
|
|
public readonly Controller Left;
|
|
|
|
|
public readonly Controller Right;
|
|
|
|
|
public readonly Action<IController, InputState> Convert;
|
|
|
|
|
|
|
|
|
|
public ControlAdapter(ControllerDefinition type, Controller left, Controller right, Action<IController, InputState> convert)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
Type = type;
|
|
|
|
|
Left = left;
|
|
|
|
|
Right = right;
|
|
|
|
|
Convert = convert;
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-24 15:32:45 +00:00
|
|
|
|
private static readonly ControlAdapter[] Adapters =
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
|
|
|
|
new ControlAdapter(Joystick, Controller.Joystick, Controller.Joystick, ConvertJoystick),
|
|
|
|
|
new ControlAdapter(Paddles, Controller.Paddles, Controller.Paddles, ConvertPaddles),
|
|
|
|
|
new ControlAdapter(Keypad, Controller.Keypad, Controller.Keypad, ConvertKeypad),
|
|
|
|
|
new ControlAdapter(Driving, Controller.Driving, Controller.Driving, ConvertDriving),
|
|
|
|
|
new ControlAdapter(BoosterGrip, Controller.BoosterGrip, Controller.BoosterGrip, ConvertBoosterGrip),
|
|
|
|
|
new ControlAdapter(ProLineJoystick, Controller.ProLineJoystick, Controller.ProLineJoystick, ConvertProLineJoystick),
|
|
|
|
|
new ControlAdapter(Lightgun, Controller.Lightgun, Controller.Lightgun, ConvertLightgun),
|
|
|
|
|
};
|
|
|
|
|
|
2017-04-24 15:32:45 +00:00
|
|
|
|
private static void ConvertConsoleButtons(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(0, MachineInput.Reset, c.IsPressed("Reset"));
|
|
|
|
|
s.RaiseInput(0, MachineInput.Select, c.IsPressed("Select"));
|
|
|
|
|
s.RaiseInput(0, MachineInput.Color, c.IsPressed("BW"));
|
2017-04-24 15:32:45 +00:00
|
|
|
|
if (c.IsPressed("Toggle Left Difficulty"))
|
|
|
|
|
{
|
|
|
|
|
s.RaiseInput(0, MachineInput.LeftDifficulty, c.IsPressed("Toggle Left Difficulty"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c.IsPressed("Toggle Right Difficulty"))
|
|
|
|
|
{
|
|
|
|
|
s.RaiseInput(0, MachineInput.RightDifficulty, c.IsPressed("Toggle Right Difficulty"));
|
|
|
|
|
}
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertConsoleButtons7800(IController c, InputState s)
|
2012-12-15 18:11:54 +00:00
|
|
|
|
{
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(0, MachineInput.Reset, c.IsPressed("Reset"));
|
|
|
|
|
s.RaiseInput(0, MachineInput.Select, c.IsPressed("Select"));
|
|
|
|
|
s.RaiseInput(0, MachineInput.Color, c.IsPressed("Pause"));
|
2017-04-24 15:32:45 +00:00
|
|
|
|
if (c.IsPressed("Toggle Left Difficulty"))
|
|
|
|
|
{
|
|
|
|
|
s.RaiseInput(0, MachineInput.LeftDifficulty, c.IsPressed("Toggle Left Difficulty"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c.IsPressed("Toggle Right Difficulty"))
|
|
|
|
|
{
|
|
|
|
|
s.RaiseInput(0, MachineInput.RightDifficulty, c.IsPressed("Toggle Right Difficulty"));
|
|
|
|
|
}
|
2012-12-15 18:11:54 +00:00
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertDirections(IController c, InputState s, int p)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
string ps = $"P{p + 1} ";
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(p, MachineInput.Up, c.IsPressed(ps + "Up"));
|
|
|
|
|
s.RaiseInput(p, MachineInput.Down, c.IsPressed(ps + "Down"));
|
|
|
|
|
s.RaiseInput(p, MachineInput.Left, c.IsPressed(ps + "Left"));
|
|
|
|
|
s.RaiseInput(p, MachineInput.Right, c.IsPressed(ps + "Right"));
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertTrigger(IController c, InputState s, int p)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
string ps = $"P{p + 1} ";
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(p, MachineInput.Fire, c.IsPressed(ps + "Trigger"));
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-24 15:32:45 +00:00
|
|
|
|
private static void ConvertJoystick(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertConsoleButtons(c, s);
|
|
|
|
|
ConvertDirections(c, s, 0);
|
|
|
|
|
ConvertDirections(c, s, 1);
|
|
|
|
|
ConvertTrigger(c, s, 0);
|
|
|
|
|
ConvertTrigger(c, s, 1);
|
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertPaddles(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertConsoleButtons(c, s);
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
string ps = $"P{i + 1} ";
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertTrigger(c, s, i);
|
|
|
|
|
s.RaisePaddleInput(i, 700000, (int)c.GetFloat(ps + "Trigger"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertKeypad(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertConsoleButtons(c, s);
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
2017-04-24 15:32:45 +00:00
|
|
|
|
string ps = $"P{i + 1} ";
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad1, c.IsPressed(ps + "Keypad1"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad2, c.IsPressed(ps + "Keypad2"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad3, c.IsPressed(ps + "Keypad3"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad4, c.IsPressed(ps + "Keypad4"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad5, c.IsPressed(ps + "Keypad5"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad6, c.IsPressed(ps + "Keypad6"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad7, c.IsPressed(ps + "Keypad7"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad8, c.IsPressed(ps + "Keypad8"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad9, c.IsPressed(ps + "Keypad9"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPadMult, c.IsPressed(ps + "KeypadA"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPad0, c.IsPressed(ps + "Keypad0"));
|
|
|
|
|
s.RaiseInput(i, MachineInput.NumPadHash, c.IsPressed(ps + "KeypadP"));
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static readonly MachineInput[] Drvlut =
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
|
|
|
|
MachineInput.Driving0,
|
|
|
|
|
MachineInput.Driving1,
|
|
|
|
|
MachineInput.Driving2,
|
|
|
|
|
MachineInput.Driving3
|
|
|
|
|
};
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertDriving(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertConsoleButtons(c, s);
|
|
|
|
|
ConvertTrigger(c, s, 0);
|
|
|
|
|
ConvertTrigger(c, s, 1);
|
2017-04-24 15:32:45 +00:00
|
|
|
|
s.RaiseInput(0, Drvlut[(int)c.GetFloat("P1 Driving")], true);
|
|
|
|
|
s.RaiseInput(1, Drvlut[(int)c.GetFloat("P2 Driving")], true);
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertBoosterGrip(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertConsoleButtons(c, s);
|
|
|
|
|
ConvertDirections(c, s, 0);
|
|
|
|
|
ConvertDirections(c, s, 1);
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
2012-12-15 00:58:55 +00:00
|
|
|
|
// weird mapping is intentional
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(0, MachineInput.Fire, c.IsPressed("P1 Trigger"));
|
|
|
|
|
s.RaiseInput(0, MachineInput.Fire2, c.IsPressed("P1 Trigger 2"));
|
|
|
|
|
s.RaiseInput(1, MachineInput.Fire2, c.IsPressed("P1 Trigger 3"));
|
|
|
|
|
s.RaiseInput(1, MachineInput.Fire, c.IsPressed("P2 Trigger"));
|
|
|
|
|
s.RaiseInput(2, MachineInput.Fire2, c.IsPressed("P2 Trigger 2"));
|
|
|
|
|
s.RaiseInput(3, MachineInput.Fire2, c.IsPressed("P2 Trigger 3"));
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertProLineJoystick(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 18:11:54 +00:00
|
|
|
|
ConvertConsoleButtons7800(c, s);
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertDirections(c, s, 0);
|
|
|
|
|
ConvertDirections(c, s, 1);
|
2016-12-14 18:42:15 +00:00
|
|
|
|
s.RaiseInput(0, MachineInput.Fire, c.IsPressed("P1 Trigger"));
|
|
|
|
|
s.RaiseInput(0, MachineInput.Fire2, c.IsPressed("P1 Trigger 2"));
|
|
|
|
|
s.RaiseInput(1, MachineInput.Fire, c.IsPressed("P2 Trigger"));
|
|
|
|
|
s.RaiseInput(1, MachineInput.Fire2, c.IsPressed("P2 Trigger 2"));
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
private static void ConvertLightgun(IController c, InputState s)
|
2012-12-15 00:58:55 +00:00
|
|
|
|
{
|
2016-11-11 14:44:28 +00:00
|
|
|
|
s.ClearControllerInput();
|
2012-12-15 18:11:54 +00:00
|
|
|
|
ConvertConsoleButtons7800(c, s);
|
2012-12-15 00:58:55 +00:00
|
|
|
|
ConvertTrigger(c, s, 0);
|
|
|
|
|
ConvertTrigger(c, s, 1);
|
|
|
|
|
s.RaiseLightgunPos(0, (int)c.GetFloat("P1 VPos"), (int)c.GetFloat("P1 HPos"));
|
|
|
|
|
s.RaiseLightgunPos(1, (int)c.GetFloat("P2 VPos"), (int)c.GetFloat("P2 HPos"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Action<IController, InputState> Convert { get; private set; }
|
|
|
|
|
|
|
|
|
|
public ControllerDefinition ControlType { get; private set; }
|
|
|
|
|
|
|
|
|
|
public Atari7800Control(MachineBase mac)
|
|
|
|
|
{
|
|
|
|
|
var l = mac.InputState.LeftControllerJack;
|
|
|
|
|
var r = mac.InputState.RightControllerJack;
|
|
|
|
|
|
|
|
|
|
foreach (var a in Adapters)
|
|
|
|
|
{
|
|
|
|
|
if (a.Left == l && a.Right == r)
|
|
|
|
|
{
|
|
|
|
|
Convert = a.Convert;
|
|
|
|
|
ControlType = a.Type;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-24 15:32:45 +00:00
|
|
|
|
|
|
|
|
|
throw new Exception($"Couldn't connect Atari 7800 controls \"{l}\" and \"{r}\"");
|
2012-12-15 00:58:55 +00:00
|
|
|
|
}
|
2012-12-12 18:17:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|