internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (WindowsBinding)");
            }
            if (settings.StartsWith("MultiPanelOSPZ70{"))
            {
                //MultiPanelOSPZ70{ALT}\o/{1KNOB_ENGINE_LEFT}\o/OSCommand{FILE\o/ARGUMENTS\o/NAME}\o/\\?\hid#vid_06a3&pid_0d67#9&231fd360&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                var parameters = settings.Split(new[] { Constants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //MultiPanelOSPZ70{ALT}
                var param0 = parameters[0].Replace("MultiPanelOSPZ70{", "").Replace("}", "");
                _pz70DialPosition = (PZ70DialPosition)Enum.Parse(typeof(PZ70DialPosition), param0);

                //{1KNOB_ENGINE_LEFT}
                var param1 = parameters[1].Replace("{", "").Replace("}", "");
                //1KNOB_ENGINE_LEFT
                WhenTurnedOn        = param1.Substring(0, 1) == "1";
                param1              = param1.Substring(1);
                _multiPanelPZ70Knob = (MultiPanelPZ70Knobs)Enum.Parse(typeof(MultiPanelPZ70Knobs), param1);

                //OSCommand{FILE\o/ARGUMENTS\o/NAME}
                OSCommandObject = new OSCommand();
                OSCommandObject.ImportString(parameters[2]);
            }
        }
Пример #2
0
        internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (KeyBinding)");
            }
            if (settings.StartsWith("MultiPanelKnob{"))
            {
                //MultiPanelKey{ALT}\o/{1KNOB_ENGINE_LEFT}\o/OSKeyPress{[FiftyMilliSec,RCONTROL + RSHIFT + VK_R][FiftyMilliSec,RCONTROL + RSHIFT + VK_W]}\o/\\?\hid#vid_06a3&pid_0d67#9&231fd360&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                var parameters = settings.Split(new[] { SeparatorChars }, StringSplitOptions.RemoveEmptyEntries);

                //MultiPanelKey{ALT}
                var param0 = parameters[0].Replace("MultiPanelKnob{", "").Replace("}", "");
                _pz70DialPosition = (PZ70DialPosition)Enum.Parse(typeof(PZ70DialPosition), param0);

                //{1KNOB_ENGINE_LEFT}
                var param1 = parameters[1].Replace("{", "").Replace("}", "");
                //1KNOB_ENGINE_LEFT
                WhenTurnedOn        = param1.Substring(0, 1) == "1";
                param1              = param1.Substring(1);
                _multiPanelPZ70Knob = (MultiPanelPZ70Knobs)Enum.Parse(typeof(MultiPanelPZ70Knobs), param1);

                //OSKeyPress{[FiftyMilliSec,RCONTROL + RSHIFT + VK_R][FiftyMilliSec,RCONTROL + RSHIFT + VK_W]}
                OSKeyPress = new OSKeyPress();
                OSKeyPress.ImportString(parameters[2]);
            }
        }
        internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (DCSBIOSBindingPZ70)");
            }

            if (settings.StartsWith("MultiPanelDCSBIOSControl{"))
            {
                // MultiPanelDCSBIOSControl{HDG}\\o/{1LCD_WHEEL_DEC|DCS-BIOS}\\o/\\o/DCSBIOSInput{AAP_CDUPWR|SET_STATE|1|0}\\o/\\\\?\\hid#vid_06a3&pid_0d06#9&244b4bcc&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\\o/PanelSettingsVersion=2X"
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                // MultiPanelDCSBIOSControl{ALT}
                var param0 = parameters[0].Replace("MultiPanelDCSBIOSControl{", string.Empty).Replace("}", string.Empty);
                _pz70DialPosition = (PZ70DialPosition)Enum.Parse(typeof(PZ70DialPosition), param0);

                // {1KNOB_ALT}
                // or
                // {1KNOB_ALT|Landing gear up and blablabla description}
                var param1 = parameters[1].Replace("{", string.Empty).Replace("}", string.Empty);

                // 1KNOB_ALT
                // or
                // 1KNOB_ALT|Landing gear up and blablabla description
                WhenTurnedOn = (param1.Substring(0, 1) == "1");
                if (param1.Contains("|"))
                {
                    // 1KNOB_ALT|Landing gear up and blablabla description
                    param1 = param1.Substring(1);

                    // KNOB_ALT|Landing gear up and blablabla description
                    var stringArray = param1.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    _multiPanelPZ70Knob = (MultiPanelPZ70Knobs)Enum.Parse(typeof(MultiPanelPZ70Knobs), stringArray[0]);
                    Description         = stringArray[1];
                }
                else
                {
                    param1 = param1.Substring(1);
                    _multiPanelPZ70Knob = (MultiPanelPZ70Knobs)Enum.Parse(typeof(MultiPanelPZ70Knobs), param1);
                }

                // The rest of the array besides last entry are DCSBIOSInput
                // DCSBIOSInput{AAP_EGIPWR|FIXED_STEP|INC}
                DCSBIOSInputs = new List <DCSBIOSInput>();
                for (var i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i].StartsWith("DCSBIOSInput{"))
                    {
                        var dcsbiosInput = new DCSBIOSInput();
                        dcsbiosInput.ImportString(parameters[i]);
                        DCSBIOSInputs.Add(dcsbiosInput);
                    }
                }
            }
        }
Пример #4
0
 public bool FlipButton(PZ70DialPosition pz70DialPosition, MultiPanelPZ70Knobs multiPanelPZ70Knob)
 {
     try
     {
         return(FlipButton(GetMaskForDialPosition(pz70DialPosition), GetMaskForButton(multiPanelPZ70Knob)));
     }
     catch (Exception e)
     {
         Common.LogError(e, "Flipbutton()");
         throw;
     }
 }
        internal void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (DCSBIOSBindingPZ70)");
            }
            if (settings.StartsWith("MultiPanelDCSBIOSControlLCD{") && settings.Contains("DCSBiosOutput{"))
            {
                //MultiPanelDCSBIOSControlLCD{ALT}\o/{LowerLCD}\o/DCSBiosOutput{ANT_EGIHQTOD|Equals|0}
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //[0]
                //MultiPanelDCSBIOSControlLCD{ALT}
                var param0 = parameters[0].Replace("MultiPanelDCSBIOSControlLCD{", "").Replace("}", "");
                _pz70DialPosition = (PZ70DialPosition)Enum.Parse(typeof(PZ70DialPosition), param0);

                //[1]
                //{LowerLCD}
                var param1 = parameters[1].Replace("{", "").Replace("}", "").Trim();
                _pz70LCDPosition = (PZ70LCDPosition)Enum.Parse(typeof(PZ70LCDPosition), param1);

                //[2]
                //DCSBiosOutput{ANT_EGIHQTOD|Equals|0}
                _dcsbiosOutput = new DCSBIOSOutput();
                _dcsbiosOutput.ImportString(parameters[2]);
            }
            if (settings.StartsWith("MultiPanelDCSBIOSControlLCD{") && settings.Contains("DCSBiosOutputFormula{"))
            {
                //MultiPanelDCSBIOSControlLCD{ALT}\o/{UpperLCD}\o/DCSBiosOutputFormula{ANT_EGIHQTOD+10}
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //[0]
                //MultiPanelDCSBIOSFormulaLCD{ALT}
                var param0 = parameters[0].Replace("MultiPanelDCSBIOSControlLCD{", "").Replace("}", "").Trim();
                _pz70DialPosition = (PZ70DialPosition)Enum.Parse(typeof(PZ70DialPosition), param0);

                //[1]
                //{UpperLCD}
                var param1 = parameters[1].Replace("{", "").Replace("}", "").Trim();
                _pz70LCDPosition = (PZ70LCDPosition)Enum.Parse(typeof(PZ70LCDPosition), param1);

                //[2]
                //DCSBiosOutputFormula{ANT_EGIHQTOD+10}
                _dcsbiosOutputFormula = new DCSBIOSOutputFormula();
                _dcsbiosOutputFormula.ImportString(parameters[2]);
            }
        }
Пример #6
0
 public bool IsOn(PZ70DialPosition pz70DialPosition, MultiPanelPZ70Knobs multiPanelPZ70Knobs)
 {
     try
     {
         var dialMask   = GetMaskForDialPosition(pz70DialPosition);
         var buttonMask = GetMaskForButton(multiPanelPZ70Knobs);
         for (int i = 0; i < _buttonDialPosition.Length; i++)
         {
             if ((_buttonDialPosition[i] & dialMask) != 0)
             {
                 return((_buttonBytes[i] & buttonMask) != 0);
             }
         }
         throw new Exception("Multipanel IsOn : Failed to find Mask for dial position " + pz70DialPosition + " knob " + multiPanelPZ70Knobs);
     }
     catch (Exception e)
     {
         Common.LogError(e, "IsOn()");
         throw;
     }
 }
Пример #7
0
 public byte GetButtonByte(PZ70DialPosition pz70DialPosition)
 {
     try
     {
         var mask = GetMaskForDialPosition(pz70DialPosition);
         for (int i = 0; i < _buttonDialPosition.Length; i++)
         {
             //(b & mask) != 0
             if ((_buttonDialPosition[i] & mask) != 0)
             {
                 return(_buttonBytes[i]);
             }
         }
         throw new Exception("Multipanel : Failed to find button byte for " + pz70DialPosition);
     }
     catch (Exception e)
     {
         Common.LogError(e);
         throw;
     }
 }
Пример #8
0
        public int GetMaskForDialPosition(PZ70DialPosition pz70DialPosition)
        {
            try
            {
                switch (pz70DialPosition)
                {
                case PZ70DialPosition.ALT:
                {
                    return(DIAL_ALT_MASK);
                }

                case PZ70DialPosition.VS:
                {
                    return(DIAL_VS_MASK);
                }

                case PZ70DialPosition.IAS:
                {
                    return(DIAL_IAS_MASK);
                }

                case PZ70DialPosition.HDG:
                {
                    return(DIAL_HDG_MASK);
                }

                case PZ70DialPosition.CRS:
                {
                    return(DIAL_CRS_MASK);
                }
                }
                throw new Exception("Multipanel : Failed to find Mask for dial position " + pz70DialPosition);
            }
            catch (Exception e)
            {
                Common.LogError(e);
                throw;
            }
        }
Пример #9
0
        private void PZ70SwitchChanged(bool isFirstReport, IEnumerable <object> hashSet)
        {
            foreach (var o in hashSet)
            {
                var multiPanelKnob = (MultiPanelKnob)o;
                if (multiPanelKnob.IsOn)
                {
                    switch (multiPanelKnob.MultiPanelPZ70Knob)
                    {
                    case MultiPanelPZ70Knobs.KNOB_ALT:
                    {
                        _pz70DialPosition = PZ70DialPosition.ALT;
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        UpdateLCD();
                        break;
                    }

                    case MultiPanelPZ70Knobs.KNOB_VS:
                    {
                        _pz70DialPosition = PZ70DialPosition.VS;
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        UpdateLCD();
                        break;
                    }

                    case MultiPanelPZ70Knobs.KNOB_IAS:
                    {
                        _pz70DialPosition = PZ70DialPosition.IAS;
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        UpdateLCD();
                        break;
                    }

                    case MultiPanelPZ70Knobs.KNOB_HDG:
                    {
                        _pz70DialPosition = PZ70DialPosition.HDG;
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        UpdateLCD();
                        break;
                    }

                    case MultiPanelPZ70Knobs.KNOB_CRS:
                    {
                        _pz70DialPosition = PZ70DialPosition.CRS;
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        UpdateLCD();
                        break;
                    }

                    case MultiPanelPZ70Knobs.AP_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.AP_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.HDG_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.HDG_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.NAV_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.NAV_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.IAS_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.IAS_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.ALT_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.ALT_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.VS_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.VS_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.APR_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.APR_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }

                    case MultiPanelPZ70Knobs.REV_BUTTON:
                    {
                        multiPanelKnob.IsOn = _lcdButtonByteListHandler.FlipButton(PZ70DialPosition, MultiPanelPZ70Knobs.REV_BUTTON);
                        Interlocked.Add(ref _doUpdatePanelLCD, 1);
                        break;
                    }
                    }
                }
            }
            UpdateLCD();
            if (!ForwardPanelEvent)
            {
                return;
            }

            foreach (var o in hashSet)
            {
                var multiPanelKnob = (MultiPanelKnob)o;

                /*
                 * IMPORTANT
                 * ---------
                 * The LCD buttons toggle between on and off. It is the toggle value that defines if the button is OFF, not the fact that the user releases the button.
                 * Therefore the fore-mentioned buttons cannot be used as usual in a loop with knobBinding.WhenTurnedOn
                 * Instead the buttons global bool value must be used!
                 *
                 */
                if (Common.IsOperationModeFlagSet(EmulationMode.KeyboardEmulationOnly) && multiPanelKnob.MultiPanelPZ70Knob == MultiPanelPZ70Knobs.LCD_WHEEL_INC || multiPanelKnob.MultiPanelPZ70Knob == MultiPanelPZ70Knobs.LCD_WHEEL_DEC)
                {
                    Interlocked.Add(ref _doUpdatePanelLCD, 1);
                    LCDDialChangesHandle(multiPanelKnob);
                    UpdateLCD();
                }

                var found = false;
                foreach (var knobBinding in _knobBindings)
                {
                    if (!isFirstReport && knobBinding.DialPosition == _pz70DialPosition && knobBinding.OSKeyPress != null && knobBinding.MultiPanelPZ70Knob == multiPanelKnob.MultiPanelPZ70Knob && knobBinding.WhenTurnedOn == multiPanelKnob.IsOn)
                    {
                        if (knobBinding.MultiPanelPZ70Knob == MultiPanelPZ70Knobs.LCD_WHEEL_INC || knobBinding.MultiPanelPZ70Knob == MultiPanelPZ70Knobs.LCD_WHEEL_DEC)
                        {
                            if (!SkipCurrentLcdKnobChange())
                            {
                                knobBinding.OSKeyPress.Execute(new CancellationToken());
                            }
                            found = true;
                        }
                        else
                        {
                            knobBinding.OSKeyPress.Execute(new CancellationToken());
                            found = true;
                        }
                        break;
                    }
                }
                if (!isFirstReport && !found)
                {
                    foreach (var dcsBiosBinding in _dcsBiosBindings)
                    {
                        if (dcsBiosBinding.DialPosition == _pz70DialPosition && dcsBiosBinding.DCSBIOSInputs.Count > 0 && dcsBiosBinding.MultiPanelPZ70Knob == multiPanelKnob.MultiPanelPZ70Knob && dcsBiosBinding.WhenTurnedOn == multiPanelKnob.IsOn)
                        {
                            dcsBiosBinding.SendDCSBIOSCommands(new CancellationToken());
                            break;
                        }
                    }
                }
                foreach (var osCommand in _osCommandBindings)
                {
                    if (!isFirstReport && osCommand.DialPosition == _pz70DialPosition && osCommand.OSCommandObject != null && osCommand.MultiPanelPZ70Knob == multiPanelKnob.MultiPanelPZ70Knob && osCommand.WhenTurnedOn == multiPanelKnob.IsOn)
                    {
                        osCommand.OSCommandObject.Execute(new CancellationToken());
                        found = true;
                        break;
                    }
                }
                foreach (var bipLinkPZ70 in _bipLinks)
                {
                    if (!isFirstReport && bipLinkPZ70.BIPLights.Count > 0 && bipLinkPZ70.MultiPanelPZ70Knob == multiPanelKnob.MultiPanelPZ70Knob && bipLinkPZ70.WhenTurnedOn == multiPanelKnob.IsOn)
                    {
                        bipLinkPZ70.Execute();
                        break;
                    }
                }
            }
        }
Пример #10
0
 public void SetButtonOn(PZ70DialPosition pz70DialPosition, MultiPanelPZ70Knobs multiPanelPZ70Knob)
 {
     SetButtonOn(GetMaskForDialPosition(pz70DialPosition), GetMaskForButton(multiPanelPZ70Knob));
 }
Пример #11
0
 public void SetButtonOnOrOff(PZ70DialPosition pz70DialPosition, MultiPanelPZ70Knobs multiPanelPZ70Knob, bool on)
 {
     SetButtonOnOrOff(GetMaskForDialPosition(pz70DialPosition), GetMaskForButton(multiPanelPZ70Knob), on);
 }