Implemented autohold for autofire keys
This commit is contained in:
parent
e7b5f57a01
commit
a075f21af6
|
@ -535,6 +535,13 @@ namespace BizHawk.MultiClient
|
|||
disp.Append(' ');
|
||||
}
|
||||
|
||||
foreach (string s in Global.AutofireStickyXORAdapter.CurrentStickies)
|
||||
{
|
||||
disp.Append("Auto-");
|
||||
disp.Append(s);
|
||||
disp.Append(' ');
|
||||
}
|
||||
|
||||
g.DrawString(disp.ToString(), MessageFont, Color.White, GetX(g, 0, 3, MessageFont, disp.ToString()), 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,6 +177,8 @@ namespace BizHawk.MultiClient
|
|||
/// </summary>
|
||||
public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter();
|
||||
|
||||
public static AutoFireStickyXORAdapter AutofireStickyXORAdapter = new AutoFireStickyXORAdapter();
|
||||
|
||||
/// <summary>
|
||||
/// will OR together two IControllers
|
||||
/// </summary>
|
||||
|
|
|
@ -1932,7 +1932,7 @@
|
|||
this.changeDMGPalettesToolStripMenuItem});
|
||||
this.gBToolStripMenuItem.Name = "gBToolStripMenuItem";
|
||||
this.gBToolStripMenuItem.Size = new System.Drawing.Size(34, 19);
|
||||
this.gBToolStripMenuItem.Text = "GB";
|
||||
this.gBToolStripMenuItem.Text = "&GB";
|
||||
this.gBToolStripMenuItem.DropDownOpened += new System.EventHandler(this.gBToolStripMenuItem_DropDownOpened);
|
||||
//
|
||||
// changeDMGPalettesToolStripMenuItem
|
||||
|
|
|
@ -462,8 +462,16 @@ namespace BizHawk.MultiClient
|
|||
ProcessInput();
|
||||
Global.ClientControls.LatchFromPhysical(Global.HotkeyCoalescer);
|
||||
Global.ActiveController.LatchFromPhysical(Global.ControllerInputCoalescer);
|
||||
|
||||
Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController);
|
||||
Global.AutoFireController.LatchFromPhysical(Global.ControllerInputCoalescer);
|
||||
|
||||
if (Global.ClientControls["Autohold"])
|
||||
{
|
||||
Global.StickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons);
|
||||
Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.AutoFireController.PressedButtons);
|
||||
}
|
||||
|
||||
Global.ClickyVirtualPadController.FrameTick();
|
||||
|
||||
#if WINDOWS
|
||||
|
@ -573,7 +581,8 @@ namespace BizHawk.MultiClient
|
|||
"LoadSlot7","LoadSlot8","LoadSlot9", "ToolBox", "Previous Slot", "Next Slot", "Ram Watch", "Ram Search", "Ram Poke", "Hex Editor",
|
||||
"Lua Console", "Cheats", "Open ROM", "Close ROM", "Display FPS", "Display FrameCounter", "Display LagCounter", "Display Input", "Toggle Read Only",
|
||||
"Play Movie", "Record Movie", "Stop Movie", "Play Beginning", "Volume Up", "Volume Down", "Toggle MultiTrack", "Record All", "Record None", "Increment Player",
|
||||
"Soft Reset", "Decrement Player", "Record AVI/WAV", "Stop AVI/WAV", "Toggle Menu", "Increase Speed", "Decrease Speed", "Toggle Background Input"}
|
||||
"Soft Reset", "Decrement Player", "Record AVI/WAV", "Stop AVI/WAV", "Toggle Menu", "Increase Speed", "Decrease Speed", "Toggle Background Input",
|
||||
"Autohold", "Clear Autohold"}
|
||||
};
|
||||
|
||||
private void InitControls()
|
||||
|
@ -659,6 +668,8 @@ namespace BizHawk.MultiClient
|
|||
controls.BindMulti("Record AVI/WAV", Global.Config.AVIRecordBinding);
|
||||
controls.BindMulti("Stop AVI/WAV", Global.Config.AVIStopBinding);
|
||||
controls.BindMulti("Toggle Menu", Global.Config.ToggleMenuBinding);
|
||||
controls.BindMulti("Autohold", Global.Config.AutoholdBinding);
|
||||
controls.BindMulti("Clear Autohold", Global.Config.AutoholdClear);
|
||||
|
||||
Global.ClientControls = controls;
|
||||
|
||||
|
@ -1193,8 +1204,9 @@ namespace BizHawk.MultiClient
|
|||
Global.UD_LR_ControllerAdapter.Source = Global.OrControllerAdapter;
|
||||
|
||||
Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter;
|
||||
Global.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter;
|
||||
|
||||
Global.MultitrackRewiringControllerAdapter.Source = Global.StickyXORAdapter;
|
||||
Global.MultitrackRewiringControllerAdapter.Source = Global.AutofireStickyXORAdapter;
|
||||
Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringControllerAdapter;
|
||||
Global.ControllerOutput.Source = Global.MovieOutputHardpoint;
|
||||
|
||||
|
@ -1489,6 +1501,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
CaptureRewindState();
|
||||
|
||||
Global.StickyXORAdapter.ClearStickies();
|
||||
Global.AutofireStickyXORAdapter.ClearStickies();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1709,6 +1724,14 @@ namespace BizHawk.MultiClient
|
|||
|
||||
}
|
||||
|
||||
private void ClearAutohold()
|
||||
{
|
||||
Global.StickyXORAdapter.ClearStickies();
|
||||
Global.AutofireStickyXORAdapter.ClearStickies();
|
||||
TAStudio1.ClearVirtualPadHolds();
|
||||
Global.OSD.AddMessage("Autohold keys cleared");
|
||||
}
|
||||
|
||||
bool CheckHotkey(string trigger)
|
||||
{
|
||||
//todo - could have these in a table somehow ?
|
||||
|
@ -1716,6 +1739,9 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
default:
|
||||
return false;
|
||||
case "Clear Autohold":
|
||||
ClearAutohold();
|
||||
break;
|
||||
case "IncreaseWindowSize":
|
||||
IncreaseWindowSize();
|
||||
break;
|
||||
|
|
|
@ -190,6 +190,125 @@ namespace BizHawk.MultiClient
|
|||
private List<string> JustPressed = new List<string>();
|
||||
}
|
||||
|
||||
public class AutoFireStickyXORAdapter : IController
|
||||
{
|
||||
public int On { get; set; }
|
||||
public int Off { get; set; }
|
||||
public WorkingDictionary<string, int> buttonStarts = new WorkingDictionary<string, int>();
|
||||
|
||||
private HashSet<string> stickySet = new HashSet<string>();
|
||||
|
||||
public IController Source;
|
||||
|
||||
public AutoFireStickyXORAdapter()
|
||||
{
|
||||
//On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn;
|
||||
//Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff;
|
||||
On = 1;
|
||||
Off = 1;
|
||||
}
|
||||
|
||||
public bool IsPressed(string button)
|
||||
{
|
||||
if (stickySet.Contains(button))
|
||||
{
|
||||
int a = (Global.Emulator.Frame - buttonStarts[button]) % (On + Off);
|
||||
if (a < On)
|
||||
return this[button];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Source[button];
|
||||
}
|
||||
}
|
||||
|
||||
public bool this[string button]
|
||||
{
|
||||
get
|
||||
{
|
||||
bool source = Source[button];
|
||||
if (source)
|
||||
{
|
||||
}
|
||||
if (stickySet.Contains(button))
|
||||
{
|
||||
|
||||
|
||||
int a = (Global.Emulator.Frame - buttonStarts[button]) % (On + Off);
|
||||
if (a < On)
|
||||
{
|
||||
source ^= true;
|
||||
}
|
||||
else
|
||||
{
|
||||
source ^= false;
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
set { throw new InvalidOperationException(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
|
||||
public bool Locked = false; //Pretty much a hack,
|
||||
|
||||
|
||||
public float GetFloat(string name) { return 0.0f; } //TODO
|
||||
public void UpdateControls(int frame) { }
|
||||
|
||||
public void SetSticky(string button, bool isSticky)
|
||||
{
|
||||
if (isSticky)
|
||||
stickySet.Add(button);
|
||||
else stickySet.Remove(button);
|
||||
}
|
||||
|
||||
public bool IsSticky(string button)
|
||||
{
|
||||
return stickySet.Contains(button);
|
||||
}
|
||||
|
||||
public HashSet<string> CurrentStickies
|
||||
{
|
||||
get
|
||||
{
|
||||
return stickySet;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearStickies()
|
||||
{
|
||||
stickySet.Clear();
|
||||
}
|
||||
|
||||
public void MassToggleStickyState(List<string> buttons)
|
||||
{
|
||||
foreach (string button in buttons)
|
||||
{
|
||||
if (!JustPressed.Contains(button))
|
||||
{
|
||||
if (stickySet.Contains(button))
|
||||
{
|
||||
stickySet.Remove(button);
|
||||
}
|
||||
else
|
||||
{
|
||||
stickySet.Add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
JustPressed = buttons;
|
||||
}
|
||||
|
||||
private List<string> JustPressed = new List<string>();
|
||||
}
|
||||
|
||||
public class MnemonicsGenerator
|
||||
{
|
||||
IController Source;
|
||||
|
|
|
@ -502,7 +502,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void ClearVirtualPadHolds()
|
||||
public void ClearVirtualPadHolds()
|
||||
{
|
||||
foreach (var controller in ControllerBox.Controls)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue