public bool Parse(byte[] report) { if (report[0] != 0 || report[1] != 0x047 || report.Length != 9) { return(false); } VersionMajor = report[2] >> 4; VersionMinor = report[2] & 0x0f; HardwareRevision = report[3] & 0x0f; DevType = (DeviceType)(report[3] >> 4); var v = new Version(VersionMajor, VersionMinor); if (v >= Version.Parse("1.5")) { IsLegacy = false; Output = (OutputMode)report[4]; Inputs = (InputSources)report[5]; } else { IsLegacy = true; NGC = (NGCMode)report[4]; N64 = (N64Mode)report[5]; SNES = (SnesMode)report[6]; } DeviceID = (ushort)((report[7] << 8) | report[8]); PICRevision = (byte)(DeviceID & 0x0F); DeviceID &= 0xFFF0; return(true); }
public byte[] ToWriteReport() { byte[] report = new byte[9]; report[0] = 0; report[1] = (byte)(IsLegacy ? 0x46 : 0x44); report[2] = (byte)Output; report[3] = (byte)Inputs; SNES = (SnesMode)report[4]; N64 = (N64Mode)report[5]; NGC = (NGCMode)report[6]; return(report); }