input learn window fix

This commit is contained in:
stax76
2023-11-01 08:16:37 +01:00
parent 4baa26d7a0
commit aa0e88129b

View File

@@ -66,9 +66,6 @@ public partial class LearnWindow : Window
firstEmpty = ret == ""; firstEmpty = ret == "";
if (ret.Length == 1 && ret[0] < 32)
return "";
if (firstEmpty) if (firstEmpty)
{ {
keys[VK_LCONTROL] = keys[VK_RCONTROL] = keys[VK_CONTROL] = 0; keys[VK_LCONTROL] = keys[VK_RCONTROL] = keys[VK_CONTROL] = 0;
@@ -76,6 +73,9 @@ public partial class LearnWindow : Window
ret = ToUnicode(vk, scanCode, keys); ret = ToUnicode(vk, scanCode, keys);
} }
if (ret.Length == 1 && ret[0] < 32)
return "";
return ret; return ret;
} }
@@ -117,7 +117,7 @@ public partial class LearnWindow : Window
switch (text) switch (text)
{ {
case "#": text = "SHARP"; break; case "#": text = "Sharp"; break;
case "´´": text = "´"; break; case "´´": text = "´"; break;
case "``": text = "`"; break; case "``": text = "`"; break;
case "^^": text = "^"; break; case "^^": text = "^"; break;
@@ -174,7 +174,7 @@ public partial class LearnWindow : Window
if (isAlt && !isCtrl) if (isAlt && !isCtrl)
text = "Alt+" + text; text = "Alt+" + text;
if (isShift && keyString == "") if (isShift && (keyString == "" || keyString == " "))
text = "Shift+" + text; text = "Shift+" + text;
if (isCtrl && isAlt && firstEmpty) if (isCtrl && isAlt && firstEmpty)
@@ -232,9 +232,9 @@ public partial class LearnWindow : Window
void Window_MouseWheel(object sender, MouseWheelEventArgs e) void Window_MouseWheel(object sender, MouseWheelEventArgs e)
{ {
if (e.Delta > 0) if (e.Delta > 0)
SetKey("WHEEL_UP"); SetKey(GetModifierText() + "WHEEL_UP");
else else
SetKey("WHEEL_DOWN"); SetKey(GetModifierText() + "WHEEL_DOWN");
} }
void Window_MouseUp(object sender, MouseButtonEventArgs e) void Window_MouseUp(object sender, MouseButtonEventArgs e)
@@ -245,22 +245,22 @@ public partial class LearnWindow : Window
if (BlockMBTN_LEFT) if (BlockMBTN_LEFT)
BlockMBTN_LEFT = false; BlockMBTN_LEFT = false;
else else
SetKey("MBTN_LEFT"); SetKey(GetModifierText() + "MBTN_LEFT");
break; break;
case MouseButton.Right: case MouseButton.Right:
if (BlockMBTN_RIGHT) if (BlockMBTN_RIGHT)
BlockMBTN_RIGHT = false; BlockMBTN_RIGHT = false;
else else
SetKey("MBTN_RIGHT"); SetKey(GetModifierText() + "MBTN_RIGHT");
break; break;
case MouseButton.Middle: case MouseButton.Middle:
SetKey("MBTN_MID"); SetKey(GetModifierText() + "MBTN_MID");
break; break;
case MouseButton.XButton1: case MouseButton.XButton1:
SetKey("MBTN_BACK"); SetKey(GetModifierText() + "MBTN_BACK");
break; break;
case MouseButton.XButton2: case MouseButton.XButton2:
SetKey("MBTN_FORWARD"); SetKey(GetModifierText() + "MBTN_FORWARD");
break; break;
} }
} }
@@ -269,13 +269,13 @@ public partial class LearnWindow : Window
{ {
if (e.ChangedButton == MouseButton.Left) if (e.ChangedButton == MouseButton.Left)
{ {
SetKey("MBTN_LEFT_DBL"); SetKey(GetModifierText() + "MBTN_LEFT_DBL");
BlockMBTN_LEFT = true; BlockMBTN_LEFT = true;
} }
if (e.ChangedButton == MouseButton.Right) if (e.ChangedButton == MouseButton.Right)
{ {
SetKey("MBTN_RIGHT_DBL"); SetKey(GetModifierText() + "MBTN_RIGHT_DBL");
BlockMBTN_RIGHT = true; BlockMBTN_RIGHT = true;
} }
} }
@@ -288,4 +288,20 @@ public partial class LearnWindow : Window
e.Handled = true; e.Handled = true;
} }
} }
string GetModifierText()
{
string ret = "";
if (Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
ret = "Alt+" + ret;
if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
ret = "Ctrl+" + ret;
if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
ret = "Shift+" + ret;
return ret;
}
} }