Rework some input stuff in preparation for moving it to common
This commit is contained in:
parent
82c82b681a
commit
302e71edc3
|
@ -84,5 +84,9 @@ namespace BizHawk.Client.Common
|
||||||
public static SimpleController MovieOutputController = new SimpleController();
|
public static SimpleController MovieOutputController = new SimpleController();
|
||||||
|
|
||||||
public static Controller ClientControls;
|
public static Controller ClientControls;
|
||||||
|
|
||||||
|
// Input state which has been estine for game controller inputs are coalesce here
|
||||||
|
// This relies on a client specific implementation!
|
||||||
|
public static SimpleController ControllerInputCoalescer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,13 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
protected WorkingDictionary<string, bool> Buttons = new WorkingDictionary<string, bool>();
|
protected WorkingDictionary<string, bool> Buttons = new WorkingDictionary<string, bool>();
|
||||||
protected WorkingDictionary<string, float> Floats = new WorkingDictionary<string, float>();
|
protected WorkingDictionary<string, float> Floats = new WorkingDictionary<string, float>();
|
||||||
|
|
||||||
|
public virtual void Clear()
|
||||||
|
{
|
||||||
|
Buttons = new WorkingDictionary<string, bool>();
|
||||||
|
Floats = new WorkingDictionary<string, float>();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool this[string button]
|
public virtual bool this[string button]
|
||||||
{
|
{
|
||||||
get { return Buttons[button]; } set { Buttons[button] = value; }
|
get { return Buttons[button]; } set { Buttons[button] = value; }
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public static DisplayManager DisplayManager = new DisplayManager();
|
public static DisplayManager DisplayManager = new DisplayManager();
|
||||||
|
|
||||||
//input state which has been destined for game controller inputs are coalesced here
|
//input state which has been destined for game controller inputs are coalesced here
|
||||||
public static ControllerInputCoalescer ControllerInputCoalescer = new ControllerInputCoalescer();
|
//public static ControllerInputCoalescer ControllerInputCoalescer = new ControllerInputCoalescer();
|
||||||
//input state which has been destined for client hotkey consumption are colesced here
|
//input state which has been destined for client hotkey consumption are colesced here
|
||||||
public static InputCoalescer HotkeyCoalescer = new InputCoalescer();
|
public static InputCoalescer HotkeyCoalescer = new InputCoalescer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public MainForm(string[] args)
|
public MainForm(string[] args)
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm = this;
|
GlobalWin.MainForm = this;
|
||||||
|
Global.ControllerInputCoalescer = new ControllerInputCoalescer();
|
||||||
Global.FirmwareManager = new FirmwareManager();
|
Global.FirmwareManager = new FirmwareManager();
|
||||||
Global.MovieSession = new MovieSession
|
Global.MovieSession = new MovieSession
|
||||||
{
|
{
|
||||||
|
@ -397,10 +398,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// handle events and dispatch as a hotkey action, or a hotkey button, or an input button
|
// handle events and dispatch as a hotkey action, or a hotkey button, or an input button
|
||||||
ProcessInput();
|
ProcessInput();
|
||||||
Global.ClientControls.LatchFromPhysical(GlobalWin.HotkeyCoalescer);
|
Global.ClientControls.LatchFromPhysical(GlobalWin.HotkeyCoalescer);
|
||||||
Global.ActiveController.LatchFromPhysical(GlobalWin.ControllerInputCoalescer);
|
Global.ActiveController.LatchFromPhysical(Global.ControllerInputCoalescer);
|
||||||
|
|
||||||
Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController);
|
Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController);
|
||||||
Global.AutoFireController.LatchFromPhysical(GlobalWin.ControllerInputCoalescer);
|
Global.AutoFireController.LatchFromPhysical(Global.ControllerInputCoalescer);
|
||||||
|
|
||||||
if (Global.ClientControls["Autohold"])
|
if (Global.ClientControls["Autohold"])
|
||||||
{
|
{
|
||||||
|
@ -517,8 +518,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public void ProcessInput()
|
public void ProcessInput()
|
||||||
{
|
{
|
||||||
|
ControllerInputCoalescer conInput = Global.ControllerInputCoalescer as ControllerInputCoalescer;
|
||||||
|
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
|
|
||||||
// loop through all available events
|
// loop through all available events
|
||||||
var ie = Input.Instance.DequeueEvent();
|
var ie = Input.Instance.DequeueEvent();
|
||||||
if (ie == null) { break; }
|
if (ie == null) { break; }
|
||||||
|
@ -561,7 +565,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0: // Both allowed
|
case 0: // Both allowed
|
||||||
GlobalWin.ControllerInputCoalescer.Receive(ie);
|
conInput.Receive(ie);
|
||||||
|
|
||||||
handled = false;
|
handled = false;
|
||||||
if (ie.EventType == Input.InputEventType.Press)
|
if (ie.EventType == Input.InputEventType.Press)
|
||||||
|
@ -577,7 +581,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1: // Input overrides Hokeys
|
case 1: // Input overrides Hokeys
|
||||||
GlobalWin.ControllerInputCoalescer.Receive(ie);
|
conInput.Receive(ie);
|
||||||
if (!Global.ActiveController.HasBinding(ie.LogicalButton.ToString()))
|
if (!Global.ActiveController.HasBinding(ie.LogicalButton.ToString()))
|
||||||
{
|
{
|
||||||
handled = false;
|
handled = false;
|
||||||
|
@ -604,7 +608,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
GlobalWin.HotkeyCoalescer.Receive(ie);
|
GlobalWin.HotkeyCoalescer.Receive(ie);
|
||||||
GlobalWin.ControllerInputCoalescer.Receive(ie);
|
conInput.Receive(ie);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -613,7 +617,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
} // foreach event
|
} // foreach event
|
||||||
|
|
||||||
// also handle floats
|
// also handle floats
|
||||||
GlobalWin.ControllerInputCoalescer.AcceptNewFloats(Input.Instance.GetFloats());
|
conInput.AcceptNewFloats(Input.Instance.GetFloats());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RebootCore()
|
public void RebootCore()
|
||||||
|
@ -3016,7 +3020,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private static void RewireInputChain() // Move to Client.Common
|
private static void RewireInputChain() // Move to Client.Common
|
||||||
{
|
{
|
||||||
GlobalWin.ControllerInputCoalescer = new ControllerInputCoalescer { Type = Global.ActiveController.Type };
|
Global.ControllerInputCoalescer.Clear();
|
||||||
|
Global.ControllerInputCoalescer.Type = Global.ActiveController.Type;
|
||||||
|
|
||||||
Global.OrControllerAdapter.Source = Global.ActiveController;
|
Global.OrControllerAdapter.Source = Global.ActiveController;
|
||||||
Global.OrControllerAdapter.SourceOr = Global.AutoFireController;
|
Global.OrControllerAdapter.SourceOr = Global.AutoFireController;
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public LuaTable input_get()
|
public LuaTable input_get()
|
||||||
{
|
{
|
||||||
var buttons = _lua.NewTable();
|
var buttons = _lua.NewTable();
|
||||||
foreach (var kvp in GlobalWin.ControllerInputCoalescer.BoolButtons().Where(kvp => kvp.Value))
|
foreach (var kvp in Global.ControllerInputCoalescer.BoolButtons().Where(kvp => kvp.Value))
|
||||||
{
|
{
|
||||||
buttons[kvp.Key] = true;
|
buttons[kvp.Key] = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue