public static Report GetStickParameters(JoyConType type, IntPtr handle) { int paraAddr = StickParameterAddr[(int)type]; var report = ReadSPI(paraAddr, 16, handle); return(report); }
public JoyCon(JoyConType type, IntPtr handle, bool imu) { this.Type = type; this.handle = handle; this.IMU = imu; this.State = State.NOT_ATTACHED; reports = new Queue <Report>(); }
public static StickParameter ReadStickParameter(Report report, JoyConType type) { report.Seek(20); var para = new StickParameter(); report.Read2UInt12(); var temp = report.Read2UInt12(); para.deadzone = temp[0]; para.rangeRatio = temp[1]; return(para); }
public void Rumble(JoyConType type, JoyConRumbleInfo rumbleInfo) { switch (type) { case JoyConType.Left: LeftJoyCon.Rumble(rumbleInfo); break; case JoyConType.Right: RightJoyCon.Rumble(rumbleInfo); break; default: throw new NotImplementedException(); } }
public static StickCalibration ReadStickCalibration(Report report, JoyConType type) { report.Seek(20); var cal = new StickCalibration(); var temp = new ushort[2]; if (type == JoyConType.LEFT) { temp = report.Read2UInt12(); cal.xMax = temp[0]; cal.yMax = temp[1]; temp = report.Read2UInt12(); cal.xCenter = temp[0]; cal.yCenter = temp[1]; temp = report.Read2UInt12(); cal.xMin = temp[0]; cal.xMin = temp[1]; } else { temp = report.Read2UInt12(); cal.xCenter = temp[0]; cal.yCenter = temp[1]; temp = report.Read2UInt12(); cal.xMin = temp[0]; cal.xMin = temp[1]; temp = report.Read2UInt12(); cal.xMax = temp[0]; cal.yMax = temp[1]; } //cal.xMin = 0x0; //cal.xCenter = 0x7ff; //cal.xMax = 0xfff; //cal.yMin = 0x0; //cal.yCenter = 0x7ff; //cal.yMax = 0xfff; return(cal); }
public static JoyConState ReadInput(byte[] data, JoyConType type) { if (data[0] == 0x3F) { } else if (data[0] == 0x21 || data[0] == 0x31) { switch (type) { case JoyConType.Left: return(ReadLeftInput(data)); case JoyConType.Right: return(ReadRightInput(data)); default: throw new NotImplementedException(); } } return(null); }
public static Report GetStickCalibration(JoyConType type, IntPtr handle) { int calAddr = StickUserCalibrationAddr[(int)type]; var report = ReadSPI(calAddr, 9, handle); if (!report.CheckEmpty(9)) { Debug.Log("Use user stick calibration."); return(report); } calAddr = StickFactoryCalibrationAddr[(int)type]; report = ReadSPI(calAddr, 9, handle); if (!report.CheckEmpty(9)) { Debug.Log("Use factory stick calibration."); return(report); } Debug.LogError("No stick calibration."); return(null); }
public void Rumble(JoyConType type, JoyConRumble rumble) { Rumble(type, new JoyConRumbleInfo(rumble)); }