From 3b926d71b562c245873e6d7b9d913cecdf7ef238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 24 Mar 2019 18:38:40 +0100 Subject: [PATCH] Honor modifiers in multitap detection Fixes Issue #15577. --- OpenRA.Platforms.Default/MultiTapDetection.cs | 12 ++++++------ OpenRA.Platforms.Default/Sdl2Input.cs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenRA.Platforms.Default/MultiTapDetection.cs b/OpenRA.Platforms.Default/MultiTapDetection.cs index 1031afaa11..0f783bf89d 100644 --- a/OpenRA.Platforms.Default/MultiTapDetection.cs +++ b/OpenRA.Platforms.Default/MultiTapDetection.cs @@ -16,8 +16,8 @@ namespace OpenRA.Platforms.Default { static class MultiTapDetection { - static Cache keyHistoryCache = - new Cache(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); + static Cache, TapHistory> keyHistoryCache = + new Cache, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); static Cache clickHistoryCache = new Cache(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); @@ -31,14 +31,14 @@ namespace OpenRA.Platforms.Default return clickHistoryCache[button].LastTapCount(); } - public static int DetectFromKeyboard(Keycode key) + public static int DetectFromKeyboard(Keycode key, Modifiers mods) { - return keyHistoryCache[key].GetTapCount(int2.Zero); + return keyHistoryCache[Pair.New(key, mods)].GetTapCount(int2.Zero); } - public static int InfoFromKeyboard(Keycode key) + public static int InfoFromKeyboard(Keycode key, Modifiers mods) { - return keyHistoryCache[key].LastTapCount(); + return keyHistoryCache[Pair.New(key, mods)].LastTapCount(); } } diff --git a/OpenRA.Platforms.Default/Sdl2Input.cs b/OpenRA.Platforms.Default/Sdl2Input.cs index 48c26ecd17..4835adbbbf 100644 --- a/OpenRA.Platforms.Default/Sdl2Input.cs +++ b/OpenRA.Platforms.Default/Sdl2Input.cs @@ -161,8 +161,8 @@ namespace OpenRA.Platforms.Default KeyInputEvent.Down : KeyInputEvent.Up; var tapCount = e.type == SDL.SDL_EventType.SDL_KEYDOWN ? - MultiTapDetection.DetectFromKeyboard(keyCode) : - MultiTapDetection.InfoFromKeyboard(keyCode); + MultiTapDetection.DetectFromKeyboard(keyCode, mods) : + MultiTapDetection.InfoFromKeyboard(keyCode, mods); var keyEvent = new KeyInput {