From: <an...@us...> - 2007-02-25 14:14:33
|
Revision: 138 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=138&view=rev Author: and-81 Date: 2007-02-25 06:14:27 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/XBCDRC/XBCDRCPlugin.cs Modified: trunk/plugins/XBCDRC/XBCDRCPlugin.cs =================================================================== --- trunk/plugins/XBCDRC/XBCDRCPlugin.cs 2007-02-25 05:56:26 UTC (rev 137) +++ trunk/plugins/XBCDRC/XBCDRCPlugin.cs 2007-02-25 14:14:27 UTC (rev 138) @@ -19,9 +19,9 @@ FileStream _deviceStream; byte[] _deviceBuffer; - int _lastPacketID = 0; - int _lastKeyCode = -1; - int _lastKeyTick = 0; + int _lastPacketID = 0; + int _lastCode = -1; + DateTime _lastCodeTime = DateTime.Now; bool _disposed = false; @@ -357,24 +357,15 @@ { _lastPacketID = packetID; + TimeSpan timeSpan = DateTime.Now - _lastCodeTime; + _lastCodeTime = DateTime.Now; + int keyCode = (int)_deviceBuffer[3]; - if (keyCode == _lastKeyCode) - { - int tick = Environment.TickCount; - - if (tick >= (_lastKeyTick + 250)) - { - _lastKeyTick = tick; - _inputHandler.MapAction(keyCode); - } - } - else - { - _lastKeyCode = keyCode; - _lastKeyTick = Environment.TickCount; + if (keyCode != _lastCode || timeSpan.Milliseconds > 250) _inputHandler.MapAction(keyCode); - } + + _lastCode = keyCode; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |