Fix #3087 hotkeys triggering accidentally in Virtual Pad... again
This commit is contained in:
parent
af2d8da36e
commit
9ac0f9258e
|
@ -45,7 +45,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private readonly PadSchema _schema;
|
||||
private readonly InputManager _inputManager;
|
||||
private readonly EventHandler _setLastFocusedNud;
|
||||
private readonly EventHandler _setLastFocusedNUD;
|
||||
private bool _readOnly;
|
||||
|
||||
public void UpdateValues()
|
||||
|
@ -80,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Dock = DockStyle.Top | DockStyle.Left;
|
||||
_schema = schema;
|
||||
_inputManager = inputManager;
|
||||
_setLastFocusedNud = setLastFocusedNUD;
|
||||
_setLastFocusedNUD = setLastFocusedNUD;
|
||||
}
|
||||
|
||||
private void VirtualPadControl_Load(object sender, EventArgs e)
|
||||
|
@ -133,7 +133,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
},
|
||||
AnalogSchema analog => new VirtualPadAnalogStick(
|
||||
_inputManager,
|
||||
_setLastFocusedNud,
|
||||
_setLastFocusedNUD,
|
||||
analog.Name,
|
||||
analog.SecondaryName,
|
||||
analog.Spec,
|
||||
|
@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
},
|
||||
TargetedPairSchema targetedPair => new VirtualPadTargetScreen(
|
||||
_inputManager.StickyXorAdapter,
|
||||
_setLastFocusedNud,
|
||||
_setLastFocusedNUD,
|
||||
targetedPair.Name,
|
||||
targetedPair.SecondaryName,
|
||||
targetedPair.MaxX,
|
||||
|
|
|
@ -24,15 +24,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private Control _lastFocusedNUD = null;
|
||||
|
||||
public override bool BlocksInputWhenFocused
|
||||
{
|
||||
get
|
||||
{
|
||||
// >:( `NumericUpDown.Focused` doesn't work on Windows (the REFERENCE IMPLEMENTATION), a fact that goes UNMENTIONED in the docs https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.updownbase.focused?view=netframework-4.8
|
||||
if (!OSTailoredCode.IsUnixHost) return true; // ...and I can't think of another hack that isn't extremely convoluted, so the Virtual Pad can just block all input. --yoshi
|
||||
return _lastFocusedNUD?.Focused is true; // on Mono, simple hack to check if typing in a NUD
|
||||
}
|
||||
}
|
||||
public override bool BlocksInputWhenFocused => _lastFocusedNUD is not null;
|
||||
|
||||
private List<VirtualPad> Pads =>
|
||||
ControllerPanel.Controls
|
||||
|
@ -80,6 +72,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
Pads.ForEach(pad => pad.BumpAnalog(x, y));
|
||||
}
|
||||
|
||||
private void SetLastFocusedNUD(object sender, EventArgs args)
|
||||
=> _lastFocusedNUD = (Control) sender;
|
||||
|
||||
private void CreatePads()
|
||||
{
|
||||
ControllerPanel.Controls.Clear();
|
||||
|
@ -122,10 +117,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
EventHandler setLastFocusedNUD = OSTailoredCode.IsUnixHost
|
||||
? (sender, _) => _lastFocusedNUD = (Control) sender
|
||||
: (_, _) => {}; // see BlocksInputWhenFocused implementation
|
||||
ControllerPanel.Controls.AddRange(padSchemata.Select(s => (Control) new VirtualPad(s, InputManager, setLastFocusedNUD)).Reverse().ToArray());
|
||||
ControllerPanel.Controls.AddRange(padSchemata.Select(s => (Control) new VirtualPad(s, InputManager, SetLastFocusedNUD)).Reverse().ToArray());
|
||||
}
|
||||
|
||||
public void ScrollToPadSchema(string padSchemaName)
|
||||
|
|
|
@ -78,16 +78,24 @@ namespace BizHawk.Client.EmuHawk
|
|||
AnalogStick.ClearCallback = ClearCallback;
|
||||
manualR.Maximum = Math.Max(RectToPolarHelper(RangeX.Max, RangeY.Max).R, RectToPolarHelper(RangeX.Min, RangeY.Min).R);
|
||||
|
||||
void UnsetLastFocusedNUD(object sender, EventArgs eventArgs)
|
||||
=> setLastFocusedNUD(null, null);
|
||||
ManualX.ValueChanged += ManualXY_ValueChanged;
|
||||
ManualX.GotFocus += setLastFocusedNUD;
|
||||
ManualX.LostFocus += UnsetLastFocusedNUD;
|
||||
ManualY.ValueChanged += ManualXY_ValueChanged;
|
||||
ManualY.GotFocus += setLastFocusedNUD;
|
||||
ManualY.LostFocus += UnsetLastFocusedNUD;
|
||||
manualR.ValueChanged += PolarNumeric_Changed;
|
||||
manualR.GotFocus += setLastFocusedNUD;
|
||||
manualR.LostFocus += UnsetLastFocusedNUD;
|
||||
manualTheta.ValueChanged += PolarNumeric_Changed;
|
||||
manualTheta.GotFocus += setLastFocusedNUD;
|
||||
manualTheta.LostFocus += UnsetLastFocusedNUD;
|
||||
MaxXNumeric.GotFocus += setLastFocusedNUD;
|
||||
MaxXNumeric.LostFocus += UnsetLastFocusedNUD;
|
||||
MaxYNumeric.GotFocus += setLastFocusedNUD;
|
||||
MaxYNumeric.LostFocus += UnsetLastFocusedNUD;
|
||||
|
||||
AnalogStick.Init(
|
||||
_inputManager.StickyXorAdapter,
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public VirtualPadTargetScreen(
|
||||
StickyXorAdapter stickyXorAdapter,
|
||||
EventHandler setLastFocusedNud,
|
||||
EventHandler setLastFocusedNUD,
|
||||
string nameX,
|
||||
string nameY,
|
||||
int maxX,
|
||||
|
@ -37,8 +37,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
InitializeComponent();
|
||||
|
||||
XNumeric.GotFocus += setLastFocusedNud;
|
||||
YNumeric.GotFocus += setLastFocusedNud;
|
||||
void UnsetLastFocusedNUD(object sender, EventArgs eventArgs)
|
||||
=> setLastFocusedNUD(null, null);
|
||||
XNumeric.GotFocus += setLastFocusedNUD;
|
||||
XNumeric.LostFocus += UnsetLastFocusedNUD;
|
||||
YNumeric.GotFocus += setLastFocusedNUD;
|
||||
YNumeric.LostFocus += UnsetLastFocusedNUD;
|
||||
}
|
||||
|
||||
private void VirtualPadTargetScreen_Load(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue