Click here to Skip to main content
15,894,106 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.7K   800   3  
Raw input 64-bit .NET classes.
Public Class UdpKeyBufferFILO
    Private Const m_buffer_length_default As Integer = 4
    Private m_buffer(m_buffer_length_default) As UdpKeyInfo
    Public Sub New(Optional ByVal _length As Integer = m_buffer_length_default)
        If _length <> m_buffer_length_default Then
            If _length > 1 Then
                ReDim m_buffer(_length - 1)
            Else
                _length = m_buffer_length_default
            End If
        End If
        For i As Integer = 0 To _length - 1
            m_buffer(i) = Nothing
        Next
    End Sub
    Public Sub Push(ByVal KeyInfo As UdpKeyInfo)
        If ((KeyInfo.Message And CUInt(1)) = 0) Then 'keydown - valid for pushes
            Dim found As Boolean = False
            For i As Integer = 0 To m_buffer.Length - 1
                If ((Not m_buffer(i) Is Nothing) AndAlso (m_buffer(i).VKey = KeyInfo.VKey) AndAlso (m_buffer(i).Device = KeyInfo.Device)) Then
                    found = True
                End If
            Next
            If Not found Then
                For i As Integer = m_buffer.Length - 1 To 1 Step -1
                    m_buffer(i) = m_buffer(i - 1)
                Next
                m_buffer(0) = KeyInfo
            End If
        End If
    End Sub
    Public Function Pop(ByVal KeyInfo As UdpKeyInfo) As UdpKeyInfo
        Dim result As UdpKeyInfo = Nothing
        If ((KeyInfo.Message And CUInt(1)) = 1) Then 'keyup - valid for pops
            For i As Integer = m_buffer.Length - 1 To 0 Step -1
                If ((Not m_buffer(i) Is Nothing) AndAlso (m_buffer(i).VKey = KeyInfo.VKey) AndAlso (m_buffer(i).Device = KeyInfo.Device)) Then
                    result = m_buffer(i)
                    m_buffer(i) = Nothing
                End If
            Next
        End If
        Return result
    End Function
End Class

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