Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / Win32

Mirror keys for multiboxing MMORPG games like WOW/LOTRO

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
7 Mar 2013CPOL5 min read 20.6K   800   3  
Raw input 64-bit .NET classes.

public class UdpKeyBufferFILO
{
	private const int m_buffer_length_default = 4;
    private UdpKeyInfo[] m_buffer = new UdpKeyInfo[m_buffer_length_default + 1];
	public UdpKeyBufferFILO(int _length)
	{
		if (_length != m_buffer_length_default) {
			if (_length > 1) {
                m_buffer = new UdpKeyInfo[_length + 1];
			} else {
				_length = m_buffer_length_default;
			}
		}
		for (int i = 0; i <= _length - 1; i++) {
			m_buffer[i] = null;
		}
	}
	public void Push(UdpKeyInfo KeyInfo)
	{
		//keydown - valid for pushes
		if (((KeyInfo.Message &System.Convert.ToUInt32(1)) == 0)) {
			bool found = false;
			for (int i = 0; i <= m_buffer.Length - 1; i++) {
				if ((((m_buffer[i] != null)) && (m_buffer[i].VKey == KeyInfo.VKey) && (m_buffer[i].Device == KeyInfo.Device))) {
					found = true;
				}
			}
			if (!found) {
				for (int i = m_buffer.Length - 1; i >= 1; i += -1) {
					m_buffer[i] = m_buffer[i - 1];
				}
				m_buffer[0] = KeyInfo;
			}
		}
	}
	public UdpKeyInfo Pop(UdpKeyInfo KeyInfo)
	{
		UdpKeyInfo result = null;
		//keyup - valid for pops
		if (((KeyInfo.Message &System.Convert.ToUInt32(1)) == 1)) {
			for (int i = m_buffer.Length - 1; i >= 0; i += -1) {
				if ((((m_buffer[i] != null)) && (m_buffer[i].VKey == KeyInfo.VKey) && (m_buffer[i].Device == KeyInfo.Device))) {
					result = m_buffer[i];
					m_buffer[i] = null;
				}
			}
		}
		return result;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions