fix problems in MultiTapDetection
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -25,11 +25,23 @@ public static class MultiTapDetection
|
|||||||
return clickHistory.GetTapCount(xy);
|
return clickHistory.GetTapCount(xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int InfoFromMouse(byte MBName)
|
||||||
|
{
|
||||||
|
var clickHistory = ClickHistoryCache[MBName];
|
||||||
|
return clickHistory.LastTapCount();
|
||||||
|
}
|
||||||
|
|
||||||
public static int DetectFromKeyboard(string KeyName)
|
public static int DetectFromKeyboard(string KeyName)
|
||||||
{
|
{
|
||||||
var keyHistory = KeyHistoryCache[KeyName];
|
var keyHistory = KeyHistoryCache[KeyName];
|
||||||
return keyHistory.GetTapCount(int2.Zero);
|
return keyHistory.GetTapCount(int2.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int InfoFromKeyboard(string KeyName)
|
||||||
|
{
|
||||||
|
var keyHistory = KeyHistoryCache[KeyName];
|
||||||
|
return keyHistory.LastTapCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TapHistory
|
class TapHistory
|
||||||
@@ -57,4 +69,11 @@ class TapHistory
|
|||||||
if (!CloseEnough(SecondRelease, FirstRelease)) return 2;
|
if (!CloseEnough(SecondRelease, FirstRelease)) return 2;
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int LastTapCount()
|
||||||
|
{
|
||||||
|
if (!CloseEnough(ThirdRelease, SecondRelease)) return 1;
|
||||||
|
if (!CloseEnough(SecondRelease, FirstRelease)) return 2;
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,12 @@ namespace OpenRA.Renderer.SdlCommon
|
|||||||
var button = MakeButton( e.button.button );
|
var button = MakeButton( e.button.button );
|
||||||
lastButtonBits |= button;
|
lastButtonBits |= button;
|
||||||
|
|
||||||
inputHandler.OnMouseInput( new MouseInput(
|
var pos = new int2( e.button.x, e.button.y );
|
||||||
MouseInputEvent.Down, button, new int2( e.button.x, e.button.y ), mods, 1 ) );
|
|
||||||
|
inputHandler.OnMouseInput(new MouseInput(
|
||||||
|
MouseInputEvent.Down, button, pos, mods,
|
||||||
|
MultiTapDetection.DetectFromMouse(e.button.button, pos)
|
||||||
|
));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Sdl.SDL_MOUSEBUTTONUP:
|
case Sdl.SDL_MOUSEBUTTONUP:
|
||||||
@@ -83,9 +87,10 @@ namespace OpenRA.Renderer.SdlCommon
|
|||||||
lastButtonBits &= ~button;
|
lastButtonBits &= ~button;
|
||||||
|
|
||||||
var pos = new int2( e.button.x, e.button.y );
|
var pos = new int2( e.button.x, e.button.y );
|
||||||
inputHandler.OnMouseInput( new MouseInput(
|
inputHandler.OnMouseInput(new MouseInput(
|
||||||
MouseInputEvent.Up, button, pos, mods,
|
MouseInputEvent.Up, button, pos, mods,
|
||||||
MultiTapDetection.DetectFromMouse( e.button.button, pos )));
|
MultiTapDetection.InfoFromMouse(e.button.button)
|
||||||
|
));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Sdl.SDL_MOUSEMOTION:
|
case Sdl.SDL_MOUSEMOTION:
|
||||||
@@ -99,13 +104,16 @@ namespace OpenRA.Renderer.SdlCommon
|
|||||||
|
|
||||||
case Sdl.SDL_KEYDOWN:
|
case Sdl.SDL_KEYDOWN:
|
||||||
{
|
{
|
||||||
|
var keyName = Sdl.SDL_GetKeyName( e.key.keysym.sym );
|
||||||
|
|
||||||
var keyEvent = new KeyInput
|
var keyEvent = new KeyInput
|
||||||
{
|
{
|
||||||
Event = KeyInputEvent.Down,
|
Event = KeyInputEvent.Down,
|
||||||
Modifiers = mods,
|
Modifiers = mods,
|
||||||
UnicodeChar = (char)e.key.keysym.unicode,
|
UnicodeChar = (char)e.key.keysym.unicode,
|
||||||
KeyName = 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)
|
||||||
};
|
};
|
||||||
|
|
||||||
if( !HandleSpecialKey( keyEvent ) )
|
if( !HandleSpecialKey( keyEvent ) )
|
||||||
@@ -123,7 +131,7 @@ namespace OpenRA.Renderer.SdlCommon
|
|||||||
UnicodeChar = (char)e.key.keysym.unicode,
|
UnicodeChar = (char)e.key.keysym.unicode,
|
||||||
KeyName = 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)
|
MultiTapCount = MultiTapDetection.InfoFromKeyboard(keyName)
|
||||||
};
|
};
|
||||||
|
|
||||||
inputHandler.OnKeyInput( keyEvent );
|
inputHandler.OnKeyInput( keyEvent );
|
||||||
|
|||||||
Reference in New Issue
Block a user