Beispiel #1
0
        private void BtnSaveKeys(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_playerId == 1)
                {
                    // Save player 1 xml
                    var map = new XInputMapping()
                    {
                        Button1             = GetTagButtonInfo(TxtButton1),
                        Button2             = GetTagButtonInfo(TxtButton2),
                        Button3             = GetTagButtonInfo(TxtButton3),
                        Button4             = GetTagButtonInfo(TxtButton4),
                        Button5             = GetTagButtonInfo(TxtButton5),
                        Button6             = GetTagButtonInfo(TxtButton6),
                        Start               = GetTagButtonInfo(TxtStart),
                        Test                = GetTagButtonInfo(TxtTestSw),
                        Service             = GetTagButtonInfo(TxtService),
                        Up                  = GetTagButtonInfo(TxtUp),
                        Down                = GetTagButtonInfo(TxtDown),
                        Left                = GetTagButtonInfo(TxtLeft),
                        Right               = GetTagButtonInfo(TxtRight),
                        GunUp               = GetTagButtonInfo(TxtLgiUp),
                        GunDown             = GetTagButtonInfo(TxtLgiDown),
                        GunLeft             = GetTagButtonInfo(TxtLgiLeft),
                        GunRight            = GetTagButtonInfo(TxtLgiRight),
                        GunTrigger          = GetTagButtonInfo(TxtGunTrigger),
                        SonicItem           = GetTagButtonInfo(TxtSonicItemButton),
                        GasAxis             = GetTagButtonInfo(TxtGas),
                        BrakeAxis           = GetTagButtonInfo(TxtBrake),
                        WheelAxis           = GetTagButtonInfo(TxtWheel),
                        SrcGearChange1      = GetTagButtonInfo(TxtSrcGearChange1),
                        SrcGearChange2      = GetTagButtonInfo(TxtSrcGearChange2),
                        SrcGearChange3      = GetTagButtonInfo(TxtSrcGearChange3),
                        SrcGearChange4      = GetTagButtonInfo(TxtSrcGearChange4),
                        SrcViewChange1      = GetTagButtonInfo(TxtSrcViewChange1),
                        SrcViewChange2      = GetTagButtonInfo(TxtSrcViewChange2),
                        SrcViewChange3      = GetTagButtonInfo(TxtSrcViewChange3),
                        SrcViewChange4      = GetTagButtonInfo(TxtSrcViewChange4),
                        InitialD6MenuDown   = GetTagButtonInfo(TxtInitialD6MenuDown),
                        InitialD6MenuLeft   = GetTagButtonInfo(TxtInitialD6MenuLeft),
                        InitialD6MenuRight  = GetTagButtonInfo(TxtInitialD6MenuRight),
                        InitialD6MenuUp     = GetTagButtonInfo(TxtInitialD6MenuUp),
                        InitialD6ShiftDown  = GetTagButtonInfo(TxtInitialD6ShiftDown),
                        InitialD6ShiftUp    = GetTagButtonInfo(TxtInitialD6ShiftUp),
                        InitialD6ViewChange = GetTagButtonInfo(TxtInitialD6ViewChange),
                    };
                    map.GunMultiplier = IUpDownMovementMultiplier.Value ?? 1;
                    JoystickHelper.SerializeXInput(map, 1);
                }

                if (_playerId == 2)
                {
                    // Save player 2 xml
                    var map = new XInputMapping()
                    {
                        Button1    = GetTagButtonInfo(TxtButton1),
                        Button2    = GetTagButtonInfo(TxtButton2),
                        Button3    = GetTagButtonInfo(TxtButton3),
                        Button4    = GetTagButtonInfo(TxtButton4),
                        Button5    = GetTagButtonInfo(TxtButton5),
                        Button6    = GetTagButtonInfo(TxtButton6),
                        Start      = GetTagButtonInfo(TxtStart),
                        Test       = GetTagButtonInfo(TxtTestSw),
                        Service    = GetTagButtonInfo(TxtService),
                        Up         = GetTagButtonInfo(TxtUp),
                        Down       = GetTagButtonInfo(TxtDown),
                        Left       = GetTagButtonInfo(TxtLeft),
                        Right      = GetTagButtonInfo(TxtRight),
                        GunUp      = GetTagButtonInfo(TxtLgiUp),
                        GunDown    = GetTagButtonInfo(TxtLgiDown),
                        GunLeft    = GetTagButtonInfo(TxtLgiLeft),
                        GunRight   = GetTagButtonInfo(TxtLgiRight),
                        GunTrigger = GetTagButtonInfo(TxtGunTrigger)
                    };
                    map.GunMultiplier = IUpDownMovementMultiplier.Value ?? 1;
                    JoystickHelper.SerializeXInput(map, 2);
                }
                MessageBox.Show("Save Complete", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Saving failed with error: {ex.InnerException} {ex.Message}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            Close();
        }