public void get_name_index()
 {
     Assert.Equal("RY", JoystickOffsetValues.GetName(16));
     Assert.Equal("Z", JoystickOffsetValues.GetName(8));
     Assert.Equal("Button1", JoystickOffsetValues.GetName(48));
     Assert.Equal("AccelerationSliders1", JoystickOffsetValues.GetName(232));
 }
 public void get_name_enum()
 {
     Assert.Equal("RY", JoystickOffsetValues.GetName(JoystickOffset.RY));
     Assert.Equal("Z", JoystickOffsetValues.GetName(JoystickOffset.Z));
     Assert.Equal("Button1", JoystickOffsetValues.GetName(JoystickOffset.Button1));
     Assert.Equal("AccelerationSliders1", JoystickOffsetValues.GetName(JoystickOffset.AccelerationSliders1));
 }
Example #3
0
        //Don't serialize buttons that don't have any maps or custom changes
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value is ButtonAction action)
            {
                SerializeButtonAction(writer, serializer, action);
                return;
            }

            if (value is HOTASButton button)
            {
                if (button.Type == HOTASButton.ButtonType.Button && string.CompareOrdinal(button.MapName, JoystickOffsetValues.GetName(button.MapId)) != 0 ||
                    button.Type == HOTASButton.ButtonType.POV && string.CompareOrdinal(button.MapName, JoystickOffsetValues.GetPOVName(button.MapId)) != 0 ||
                    button.ActionCatalogItem?.Actions?.Count > 0 ||
                    button.IsShift)
                {
                    SerializeButton(writer, serializer, button);
                }
                return;
            }

            if (value is HOTASAxis axis)
            {
                if ((axis.ButtonMap == null || axis.ButtonMap.Count == 0) &&
                    (axis.ReverseButtonMap == null || axis.ReverseButtonMap.Count == 0))
                {
                    return;
                }

                SerializeAxis(writer, serializer, axis);
                return;
            }

            if (!(value is Dictionary <int, ObservableCollection <IHotasBaseMap> >))
            {
                return;
            }

            serializer.Serialize(writer, value);
        }