From 22d5c2e7b552c4d16fa1f2553c0115a49bb4d1a2 Mon Sep 17 00:00:00 2001 From: mika-n Date: Fri, 3 Jan 2020 21:44:40 +0200 Subject: [PATCH] Fixed macroRecorder to properly handle LeftAlt key events. Previously LeftAlt key was not recorded at all (it was set as System key value which doesn't do anything as virtualKey code value) --- DS4Windows/DS4Forms/RecordBox.xaml.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Forms/RecordBox.xaml.cs b/DS4Windows/DS4Forms/RecordBox.xaml.cs index ac2c07e..1e28a7f 100644 --- a/DS4Windows/DS4Forms/RecordBox.xaml.cs +++ b/DS4Windows/DS4Forms/RecordBox.xaml.cs @@ -279,10 +279,15 @@ namespace DS4WinWPF.DS4Forms if (recordBoxVM.Recording) { int value = KeyInterop.VirtualKeyFromKey(e.Key); + + // If the key is System key (ie. e.Key doesnt have a real key code) then map the system key to Win32 virtualKey value (in some keyboard layouts LeftAlt is one of those problematic keys) + if (value == 0 && e.Key == Key.System && e.SystemKey == Key.LeftAlt) + value = 164; // Win32 keycode VK_LMENU (=LeftAlt) + recordBoxVM.KeysdownMap.TryGetValue(value, out bool isdown); if (!isdown) { - DS4Windows.MacroStep step = new DS4Windows.MacroStep(KeyInterop.VirtualKeyFromKey(e.Key), e.Key.ToString(), + DS4Windows.MacroStep step = new DS4Windows.MacroStep(value, ( (e.Key != Key.System || value == 0) ? e.Key.ToString() : e.SystemKey.ToString() ), DS4Windows.MacroStep.StepType.ActDown, DS4Windows.MacroStep.StepOutput.Key); recordBoxVM.AddMacroStep(step); recordBoxVM.KeysdownMap.Add(value, true); @@ -304,10 +309,14 @@ namespace DS4WinWPF.DS4Forms if (recordBoxVM.Recording) { int value = KeyInterop.VirtualKeyFromKey(e.Key); + + if (value == 0 && e.Key == Key.System && e.SystemKey == Key.LeftAlt) + value = 164; // Win32 keycode VK_LMENU (=LeftAlt) + recordBoxVM.KeysdownMap.TryGetValue(value, out bool isdown); if (isdown) { - DS4Windows.MacroStep step = new DS4Windows.MacroStep(KeyInterop.VirtualKeyFromKey(e.Key), e.Key.ToString(), + DS4Windows.MacroStep step = new DS4Windows.MacroStep(value, ( (e.Key != Key.System || value == 0) ? e.Key.ToString() : e.SystemKey.ToString() ), DS4Windows.MacroStep.StepType.ActUp, DS4Windows.MacroStep.StepOutput.Key); recordBoxVM.AddMacroStep(step); recordBoxVM.KeysdownMap.Remove(value);