Skip to content

Commit

Permalink
Some fixes (beep removal & ctrl group steal) and better alt-tab suppo…
Browse files Browse the repository at this point in the history
…rt (hanging keys)
  • Loading branch information
ivanpmartell committed Aug 15, 2024
1 parent fb4c90b commit be43fe7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion LittleWarGameClient/GameForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ private void GameForm_Activated(object sender, EventArgs e)
{
CaptureCursor();
ResizeGameWindows();
SendKeys.Send("%{F16}"); //Alt-Tab fix for game
if (kbHandler.hasHangingAltKey) //Alt-Tab fix for game
SendKeys.Send("%{F16}");

if (!OverlayForm.Instance.IsDisposed)
OverlayForm.Instance.Visible = true;
}
Expand Down
13 changes: 13 additions & 0 deletions LittleWarGameClient/KeyboardHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace LittleWarGameClient
internal class KeyboardHandler : IKeyboardHandler
{
private readonly Dictionary<Keys, MethodInfo?> hotKeys = new Dictionary<Keys, MethodInfo?>();
internal bool hasHangingAltKey = false;

internal KeyboardHandler(Settings settings)
{
Expand Down Expand Up @@ -84,6 +85,11 @@ public bool OnPreKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, i
return true;

var key = (Keys)windowsKeyCode;
if (type == KeyType.KeyUp)
{
if (key == Keys.Menu) // Alt key
hasHangingAltKey = false;
}
if (type == KeyType.RawKeyDown)
{
#if DEBUG
Expand All @@ -93,6 +99,9 @@ public bool OnPreKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, i
return true;
}
#endif
if (key == Keys.Menu) // Alt key
hasHangingAltKey = true;

if (hotKeys.ContainsKey(key))
{
var funcToCall = hotKeys[key];
Expand All @@ -106,6 +115,10 @@ public bool OnPreKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, i

public bool OnKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
{
if (isSystemKey && type == KeyType.Char)
return true;
if (windowsKeyCode == 0x7F && modifiers == CefEventFlags.AltDown)
hasHangingAltKey = false;
return false;
}
}
Expand Down
4 changes: 3 additions & 1 deletion LittleWarGameClient/js/lwg-5.0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -25902,7 +25902,9 @@ var globalLWGDebug = false;
}
}
for (const k of unitsToRemove) {
keyManager.controlGroups[j].splice(k, 1);
if (j != nr) {
keyManager.controlGroups[j].splice(k, 1);
}
}
}
}
Expand Down

0 comments on commit be43fe7

Please sign in to comment.