public static bool samePad(GCPadStatus a, GCPadStatus b) { string[] asplit = a.ToString().Split(new char[1] { ';' }); string[] bsplit = b.ToString().Split(new char[1] { ';' }); for (int i = 1; i < asplit.Length; i++) { if (asplit[i] != bsplit[i]) { return(false); } } return(true); }
public void run() { TcpClient tcpclnt = new TcpClient(); tcpclnt.Connect("127.0.0.1", 27015); StreamReader read = new StreamReader(tcpclnt.GetStream()); StreamWriter write = new StreamWriter(tcpclnt.GetStream()); GCPadStatus[] PreviousPads = new GCPadStatus[4]; bool[] firsts = new bool[4] { true, true, true, true }; GCPadStatus CurrentPad; string packet; while (true) { packet = read.ReadLine(); CurrentPad = new GCPadStatus(packet); for (int i = 0; i < 4; i++) { if (!firsts[i] && CurrentPad.ID == i && CurrentPad.Frame != PreviousPads[i].Frame) { GCPadCallbacks[i](CurrentPad, PreviousPads[i], write); PreviousPads[i] = CurrentPad; } else if (firsts[i] && CurrentPad.ID == i) { firsts[i] = false; PreviousPads[i] = CurrentPad; } } } tcpclnt.Close(); }
public static void DefaultGCPadCallback(GCPadStatus cs, GCPadStatus ps, StreamWriter w) { }