diff --git a/DS4Windows/DS4Forms/RecordBox.xaml.cs b/DS4Windows/DS4Forms/RecordBox.xaml.cs index 1e28a7f..29ac8bd 100644 --- a/DS4Windows/DS4Forms/RecordBox.xaml.cs +++ b/DS4Windows/DS4Forms/RecordBox.xaml.cs @@ -278,16 +278,12 @@ 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) - + Key tempKey = e.SystemKey == Key.None ? e.Key : e.SystemKey; + int value = KeyInterop.VirtualKeyFromKey(tempKey); recordBoxVM.KeysdownMap.TryGetValue(value, out bool isdown); if (!isdown) { - DS4Windows.MacroStep step = new DS4Windows.MacroStep(value, ( (e.Key != Key.System || value == 0) ? e.Key.ToString() : e.SystemKey.ToString() ), + DS4Windows.MacroStep step = new DS4Windows.MacroStep(value, tempKey.ToString(), DS4Windows.MacroStep.StepType.ActDown, DS4Windows.MacroStep.StepOutput.Key); recordBoxVM.AddMacroStep(step); recordBoxVM.KeysdownMap.Add(value, true); @@ -308,15 +304,12 @@ 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) - + Key tempKey = e.SystemKey == Key.None ? e.Key : e.SystemKey; + int value = KeyInterop.VirtualKeyFromKey(tempKey); recordBoxVM.KeysdownMap.TryGetValue(value, out bool isdown); if (isdown) { - DS4Windows.MacroStep step = new DS4Windows.MacroStep(value, ( (e.Key != Key.System || value == 0) ? e.Key.ToString() : e.SystemKey.ToString() ), + DS4Windows.MacroStep step = new DS4Windows.MacroStep(value, tempKey.ToString(), DS4Windows.MacroStep.StepType.ActUp, DS4Windows.MacroStep.StepOutput.Key); recordBoxVM.AddMacroStep(step); recordBoxVM.KeysdownMap.Remove(value);