fix problems in MultiTapDetection

This commit is contained in:
Matthias Mailänder
2013-03-02 16:51:36 +01:00
parent 775b0409c4
commit 0978d21439
4 changed files with 36 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -25,11 +25,23 @@ public static class MultiTapDetection
return clickHistory.GetTapCount(xy);
}
public static int InfoFromMouse(byte MBName)
{
var clickHistory = ClickHistoryCache[MBName];
return clickHistory.LastTapCount();
}
public static int DetectFromKeyboard(string KeyName)
{
var keyHistory = KeyHistoryCache[KeyName];
return keyHistory.GetTapCount(int2.Zero);
}
public static int InfoFromKeyboard(string KeyName)
{
var keyHistory = KeyHistoryCache[KeyName];
return keyHistory.LastTapCount();
}
}
class TapHistory
@@ -57,4 +69,11 @@ class TapHistory
if (!CloseEnough(SecondRelease, FirstRelease)) return 2;
return 3;
}
public int LastTapCount()
{
if (!CloseEnough(ThirdRelease, SecondRelease)) return 1;
if (!CloseEnough(SecondRelease, FirstRelease)) return 2;
return 3;
}
}