/// <summary> /// Compare to another state. /// </summary> /// <param name="state"></param> /// <returns></returns> public string[] CompareTo(CustomDiState state) { var list = new List <string>(); list.AddRange(CompareAxisAndSliders(Axis, state.Axis, "Axis")); list.AddRange(CompareAxisAndSliders(Sliders, state.Sliders, "Slider")); // Compare Buttons if (Buttons.Length == state.Buttons.Length) { for (int i = 0; i < Buttons.Length; i++) { if (Buttons[i] != state.Buttons[i]) { list.Add(string.Format("Button {0}", i + 1)); } } } ; // Compare POVs. if (Povs.Length == state.Povs.Length) { for (int i = 0; i < Povs.Length; i++) { if (Povs[i] != state.Povs[i]) { //list.Add(string.Format("DPad {0}", i + 1)); var v = state.Povs[0]; if ((DPadEnum)v == DPadEnum.Up) { list.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Up.ToString())); } if ((DPadEnum)v == DPadEnum.Right) { list.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Right.ToString())); } if ((DPadEnum)v == DPadEnum.Down) { list.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Down.ToString())); } if ((DPadEnum)v == DPadEnum.Left) { list.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Left.ToString())); } } } } ; return(list.ToArray()); }
/// <summary> /// Compare states and return differences /// </summary> public static CustomDiUpdate[] CompareTo(CustomDiState oldState, CustomDiState newState) { if (oldState == null) { throw new ArgumentNullException(nameof(oldState)); } if (newState == null) { throw new ArgumentNullException(nameof(newState)); } var list = new List <CustomDiUpdate>(); list.AddRange(CompareRange(oldState.Axis, newState.Axis, MapType.Axis)); list.AddRange(CompareRange(oldState.Sliders, newState.Sliders, MapType.Slider)); list.AddRange(CompareValue(oldState.POVs, newState.POVs, MapType.POV)); list.AddRange(CompareValue(oldState.Buttons, newState.Buttons, MapType.Button)); // Return results. return(list.ToArray()); }