Skip to content

Commit 3eb9cb9

Browse files
authored
fix: moving markers in TAStudio by alt-dragging would focus the menu (#4668)
1 parent 1f4c27a commit 3eb9cb9

3 files changed

Lines changed: 46 additions & 36 deletions

File tree

src/BizHawk.Bizware.Input/HostInputType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public enum HostInputType
99
Mouse = 1,
1010
Keyboard = 2,
1111
Pad = 4,
12+
Ignored = 8,
1213
}
1314
}

src/BizHawk.Client.Common/inputAdapters/InputManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ public void ProcessInput(IPhysicalInputSource source, Func<string, bool> process
162162
// useful debugging:
163163
// Console.WriteLine(ie);
164164

165+
if (ie.Source == Bizware.Input.HostInputType.Ignored)
166+
{
167+
processSpecialInput(ie, false);
168+
continue;
169+
}
170+
165171
// TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing
166172

167173
HostInputCoalescer.Receive(ie);

src/BizHawk.Client.EmuHawk/Input/Input.cs

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,31 @@ private void EnqueueEvent(InputEvent ie)
174174
}
175175
}
176176

177+
private void EnqueueNewEvents(bool prohibitInput = false)
178+
{
179+
if (_newEvents.Count != 0)
180+
{
181+
//WHAT!? WE SHOULD NOT BE SO NAIVELY TOUCHING MAINFORM FROM THE INPUTTHREAD. ITS BUSY RUNNING.
182+
AllowInput allowInput = prohibitInput ? AllowInput.None : MainFormInputAllowedCallback();
183+
184+
foreach (var ie in _newEvents)
185+
{
186+
if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie.Source))
187+
{
188+
EnqueueEvent(new InputEvent() {
189+
EventType = ie.EventType,
190+
LogicalButton = ie.LogicalButton,
191+
Source = HostInputType.Ignored, // no input or hotkey will happen, but special processing such as alt menuing may apply
192+
});
193+
continue;
194+
}
195+
196+
EnqueueEvent(ie);
197+
}
198+
}
199+
_newEvents.Clear();
200+
}
201+
177202
public KeyValuePair<string, int>[] GetAxisValues()
178203
{
179204
lock (_axisValues)
@@ -205,8 +230,6 @@ private void UpdateThreadProc()
205230
//this block is going to massively modify data structures that the binding method uses, so we have to lock it all
206231
lock (this)
207232
{
208-
_newEvents.Clear();
209-
210233
//analyze keys
211234
foreach (var ke in keyEvents)
212235
{
@@ -217,9 +240,14 @@ private void UpdateThreadProc()
217240
{
218241
//_axisValues.Clear();
219242
Adapter.ProcessHostGamepads(HandleButton, HandleAxis);
243+
}
244+
EnqueueNewEvents();
220245

221-
// analyze moose
222-
if (_wantingMouseFocus.Contains(Form.ActiveForm))
246+
// analyze moose
247+
bool wantsMouse = _wantingMouseFocus.Contains(Form.ActiveForm);
248+
if (wantsMouse)
249+
{
250+
lock (_axisValues)
223251
{
224252
var mousePos = Control.MousePosition;
225253
if (_trackDeltas)
@@ -235,44 +263,19 @@ private void UpdateThreadProc()
235263
_axisValues["WMouse X"] = mousePos.X;
236264
_axisValues["WMouse Y"] = mousePos.Y;
237265

238-
var mouseBtns = Control.MouseButtons;
239-
HandleButton("WMouse L", (mouseBtns & MouseButtons.Left) != 0, HostInputType.Mouse);
240-
HandleButton("WMouse M", (mouseBtns & MouseButtons.Middle) != 0, HostInputType.Mouse);
241-
HandleButton("WMouse R", (mouseBtns & MouseButtons.Right) != 0, HostInputType.Mouse);
242-
HandleButton("WMouse 1", (mouseBtns & MouseButtons.XButton1) != 0, HostInputType.Mouse);
243-
HandleButton("WMouse 2", (mouseBtns & MouseButtons.XButton2) != 0, HostInputType.Mouse);
244-
245266
// raw (relative) mouse input
246267
_axisValues["RMouse X"] = mouseDeltaX + _axisValues.GetValueOrDefault("RMouse X");
247268
_axisValues["RMouse Y"] = mouseDeltaY + _axisValues.GetValueOrDefault("RMouse Y");
248269
}
249-
else
250-
{
251-
#if false // don't do this: for now, it will interfere with the virtualpad. don't do something similar for the mouse position either
252-
// unpress all buttons
253-
HandleButton("WMouse L", false, ClientInputFocus.Mouse);
254-
HandleButton("WMouse M", false, ClientInputFocus.Mouse);
255-
HandleButton("WMouse R", false, ClientInputFocus.Mouse);
256-
HandleButton("WMouse 1", false, ClientInputFocus.Mouse);
257-
HandleButton("WMouse 2", false, ClientInputFocus.Mouse);
258-
#endif
259-
}
260270
}
261271

262-
if (_newEvents.Count != 0)
263-
{
264-
//WHAT!? WE SHOULD NOT BE SO NAIVELY TOUCHING MAINFORM FROM THE INPUTTHREAD. ITS BUSY RUNNING.
265-
AllowInput allowInput = MainFormInputAllowedCallback();
266-
267-
foreach (var ie in _newEvents)
268-
{
269-
//events are swallowed in some cases:
270-
if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie.Source))
271-
continue;
272-
273-
EnqueueEvent(ie);
274-
}
275-
}
272+
var mouseBtns = Control.MouseButtons;
273+
HandleButton("WMouse L", (mouseBtns & MouseButtons.Left) != 0, HostInputType.Mouse);
274+
HandleButton("WMouse M", (mouseBtns & MouseButtons.Middle) != 0, HostInputType.Mouse);
275+
HandleButton("WMouse R", (mouseBtns & MouseButtons.Right) != 0, HostInputType.Mouse);
276+
HandleButton("WMouse 1", (mouseBtns & MouseButtons.XButton1) != 0, HostInputType.Mouse);
277+
HandleButton("WMouse 2", (mouseBtns & MouseButtons.XButton2) != 0, HostInputType.Mouse);
278+
EnqueueNewEvents(prohibitInput: !wantsMouse);
276279

277280
_ignoreEventsNextPoll = false;
278281
} //lock(this)

0 commit comments

Comments
 (0)