From dc8726a6a032a8cbd7877890811bb368a21da718 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 10 Oct 2011 13:07:31 +1300 Subject: [PATCH] fix multitap for keyboard events, in a way that doesnt break scrolling etc --- OpenRA.FileFormats/Graphics/IInputHandler.cs | 1 + OpenRA.Renderer.SdlCommon/MultiTapDetection.cs | 7 ++----- OpenRA.Renderer.SdlCommon/SdlInput.cs | 6 ++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenRA.FileFormats/Graphics/IInputHandler.cs b/OpenRA.FileFormats/Graphics/IInputHandler.cs index 29d7c56291..397ebb1c35 100755 --- a/OpenRA.FileFormats/Graphics/IInputHandler.cs +++ b/OpenRA.FileFormats/Graphics/IInputHandler.cs @@ -70,5 +70,6 @@ namespace OpenRA public string KeyName; public Modifiers Modifiers; public int VirtKey; + public int MultiTapCount; } } diff --git a/OpenRA.Renderer.SdlCommon/MultiTapDetection.cs b/OpenRA.Renderer.SdlCommon/MultiTapDetection.cs index 5a483a96cf..9e1c013393 100644 --- a/OpenRA.Renderer.SdlCommon/MultiTapDetection.cs +++ b/OpenRA.Renderer.SdlCommon/MultiTapDetection.cs @@ -26,13 +26,10 @@ public static class MultiTapDetection return clickHistory.GetTapCount(xy); } - static readonly string[] KeyNameModifiers = new [] { "", "", "DoubleTapOf_", "TripleTapOf_" }; - - public static string DetectFromKeyboard(string KeyName) + public static int DetectFromKeyboard(string KeyName) { var keyHistory = KeyHistoryCache[KeyName]; - var count = keyHistory.GetTapCount(int2.Zero); - return KeyNameModifiers[count]; + return keyHistory.GetTapCount(int2.Zero); } } diff --git a/OpenRA.Renderer.SdlCommon/SdlInput.cs b/OpenRA.Renderer.SdlCommon/SdlInput.cs index 797f2d7cf9..8652c93e77 100644 --- a/OpenRA.Renderer.SdlCommon/SdlInput.cs +++ b/OpenRA.Renderer.SdlCommon/SdlInput.cs @@ -116,14 +116,16 @@ namespace OpenRA.Renderer.SdlCommon case Sdl.SDL_KEYUP: { + var keyName = Sdl.SDL_GetKeyName( e.key.keysym.sym ); + var keyEvent = new KeyInput { Event = KeyInputEvent.Up, Modifiers = mods, UnicodeChar = (char)e.key.keysym.unicode, -// KeyName = MultiTapDetection.DetectFromKeyboard(Sdl.SDL_GetKeyName( e.key.keysym.sym )), KeyName = Sdl.SDL_GetKeyName( e.key.keysym.sym ), - VirtKey = e.key.keysym.sym + VirtKey = e.key.keysym.sym, + MultiTapCount = MultiTapDetection.DetectFromKeyboard(keyName) }; inputHandler.OnKeyInput( keyEvent );