Example #1
0
 public SaitekPanelSkeleton(SaitekPanelsEnum saitekPanelsEnum, int vendorId, int productId, string serialNumber)
 {
     _saitekPanelsEnum = saitekPanelsEnum;
     _vendorId         = vendorId;
     _productId        = productId;
     _serialNumber     = serialNumber;
 }
Example #2
0
 protected SaitekPanel(SaitekPanelsEnum typeOfSaitekPanel, HIDSkeleton hidSkeleton)
 {
     _typeOfSaitekPanel = typeOfSaitekPanel;
     HIDSkeletonBase    = hidSkeleton;
     if (Common.IsOperationModeFlagSet(OperationFlag.DCSBIOSOutputEnabled))
     {
         _updateCounterDCSBIOSOutput = DCSBIOSOutput.GetUpdateCounter();
     }
     _hash = Common.GetMd5Hash(hidSkeleton.InstanceId);
 }
 public void SwitchesChanged(string uniqueId, SaitekPanelsEnum saitekPanelsEnum, HashSet <object> hashSet)
 {
     try
     {
         //todo
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(1086, ex);
     }
 }
Example #4
0
 public void SettingsCleared(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         //todo
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2001, ex);
     }
 }
 public void SettingsCleared(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         ShowGraphicConfiguration();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2009, ex);
     }
 }
Example #6
0
 public void SwitchesChanged(string uniqueId, SaitekPanelsEnum saitekPanelsEnum, HashSet <object> hashSet)
 {
     try
     {
         SetGraphicsState(hashSet);
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(1064, ex);
     }
 }
Example #7
0
 public void DeviceDetached(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         //todo
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2017, ex);
     }
 }
Example #8
0
 public void UpdatesHasBeenMissed(string uniqueId, SaitekPanelsEnum saitekPanelsEnum, int count)
 {
     try
     {
         //todo
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(471074, ex);
     }
 }
Example #9
0
 public void PanelSettingsChanged(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         //todo nada?
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2016, ex);
     }
 }
Example #10
0
 public void PanelSettingsChanged(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         Common.DebugP("Settings changed for " + saitekPanelsEnum + "   " + uniqueId);
         IsDirty = true;
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(1051, ex);
     }
 }
 public void DeviceDetached(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         if (saitekPanelsEnum == SaitekPanelsEnum.BackLitPanel && uniqueId.Equals(_backlitPanelBIP.InstanceId))
         {
             //Dispatcher.BeginInvoke((Action)(() => _parentTabItem.Header = _parentTabItemHeader + " (disconnected)"));
         }
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2062, ex);
     }
 }
 public void PanelSettingsChanged(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     try
     {
         if (!_loaded)
         {
             return;
         }
         Dispatcher.BeginInvoke((Action)(ShowGraphicConfiguration));
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2040, ex);
     }
 }
Example #13
0
 public SaitekPanelSkeleton(SaitekPanelsEnum saitekPanelsEnum, int vendorId, int productId)
 {
     _saitekPanelsEnum = saitekPanelsEnum;
     _vendorId         = vendorId;
     _productId        = productId;
 }
Example #14
0
        public bool LoadProfile(string filename)
        {
            try
            {
                Common.DebugP("LoadProfile filename : " + filename);
                if (!string.IsNullOrEmpty(filename))
                {
                    _filename        = filename;
                    _lastProfileUsed = filename;
                }

                /*
                 * 0 Open specified filename (parameter) if not null
                 * 1 If exists open last profile used (settings)
                 * 2 Try and open default profile located in My Documents
                 * 3 If none found create default file
                 */
                _isNewProfile = false;
                ClearAll();
                if (string.IsNullOrEmpty(_filename))
                {
                    if (!string.IsNullOrEmpty(_lastProfileUsed) && File.Exists(_lastProfileUsed))
                    {
                        _filename = _lastProfileUsed;
                    }
                    else if (File.Exists(DefaultFile()))
                    {
                        _filename        = DefaultFile();
                        _lastProfileUsed = filename;
                    }
                }

                Common.DebugP("LoadProfile _lastProfileUsed : " + _lastProfileUsed);
                Common.DebugP("LoadProfile _filename : " + _filename);

                if (string.IsNullOrEmpty(_filename) || !File.Exists(_filename))
                {
                    //Main window will handle this
                    Common.DebugP("LoadProfile returns false");
                    return(false);
                }

                /*
                 * Read all information and add InstanceID to all lines using BeginPanel and EndPanel
                 *
                 * PanelType=PZ55SwitchPanel
                 * PanelInstanceID=\\?\hid#vid_06a3&pid_0d06#8&3f11a32&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                 * BeginPanel
                 *      SwitchPanelKey{1KNOB_ENGINE_RIGHT}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_LEFT}\o/OSKeyPress{FiftyMilliSec,LCONTROL + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_BOTH}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_C}
                 * EndPanel
                 *
                 */
                _profileLoaded = true;
                var fileLines = File.ReadAllLines(_filename);
                SaitekPanelsEnum currentPanelType            = SaitekPanelsEnum.Unknown;
                string           currentPanelInstanceID      = null;
                string           currentPanelSettingsVersion = null;
                var          insidePanel = false;
                const string sepString   = "\\o/";

                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("Airframe="))
                    {
                        if (fileLine.StartsWith("Airframe=NONE"))
                        {
                            //Backward compability
                            _airframe = DCSAirframe.KEYEMULATOR;
                        }
                        else
                        {
                            //Backward compability
                            var airframeAsString = fileLine.Replace("Airframe=", "").Trim();
                            if (airframeAsString.StartsWith("SA342"))
                            {
                                _airframe = DCSAirframe.SA342M;
                            }
                            else if (airframeAsString.StartsWith("P51D") || airframeAsString.StartsWith("TF51D"))
                            {
                                _airframe = DCSAirframe.P51D;
                            }
                            else if (airframeAsString.StartsWith("L39"))
                            {
                                _airframe = DCSAirframe.L39ZA;
                            }
                            else
                            {
                                _airframe = (DCSAirframe)Enum.Parse(typeof(DCSAirframe), airframeAsString);
                            }
                        }
                        DCSBIOSControlLocator.Airframe      = _airframe;
                        DCSBIOSControlLocator.JSONDirectory = _jsonDirectory;
                    }
                    else if (fileLine.StartsWith("OperationLevelFlag="))
                    {
                        Common.SetOperationModeFlag(int.Parse(fileLine.Replace("OperationLevelFlag=", "").Trim()));
                    }
                    else if (fileLine.StartsWith("UseGenericRadio="))
                    {
                        Common.UseGenericRadio = (bool.Parse(fileLine.Replace("UseGenericRadio=", "").Trim()));
                    }
                    else if (!fileLine.StartsWith("#") && fileLine.Length > 2)
                    {
                        //Process all these lines.
                        if (fileLine.StartsWith("PanelType="))
                        {
                            currentPanelType = (SaitekPanelsEnum)Enum.Parse(typeof(SaitekPanelsEnum), fileLine.Replace("PanelType=", "").Trim());
                        }
                        else if (fileLine.StartsWith("PanelInstanceID="))
                        {
                            currentPanelInstanceID = fileLine.Replace("PanelInstanceID=", "").Trim();
                            _profileFileInstanceIDs.Add(new KeyValuePair <string, SaitekPanelsEnum>(currentPanelInstanceID, currentPanelType));
                        }
                        else if (fileLine.StartsWith("PanelSettingsVersion="))
                        {
                            currentPanelSettingsVersion = fileLine.Trim();
                        }
                        else if (fileLine.StartsWith("BeginPanel"))
                        {
                            insidePanel = true;
                        }
                        else if (fileLine.StartsWith("EndPanel"))
                        {
                            insidePanel = false;
                        }
                        else
                        {
                            if (insidePanel)
                            {
                                var line = fileLine;
                                if (line.StartsWith("\t"))
                                {
                                    line = line.Replace("\t", "");
                                }
                                if (currentPanelSettingsVersion != null)
                                {
                                    //0X marks that setting version isn't used (yet). Any number above 0 indicated the panel are using new versions of the settings
                                    //and that old settings won't be loaded.
                                    if (currentPanelSettingsVersion.EndsWith("0X"))
                                    {
                                        _listPanelSettingsData.Add(line + sepString + currentPanelInstanceID);
                                    }
                                    else
                                    {
                                        _listPanelSettingsData.Add(line + sepString + currentPanelInstanceID + sepString + currentPanelSettingsVersion);
                                    }
                                }
                                else
                                {
                                    _listPanelSettingsData.Add(line + sepString + currentPanelInstanceID);
                                }
                            }
                        }
                    }
                }
                //For backwards compability 10.11.2018
                if (Common.GetOperationModeFlag() == 0)
                {
                    SetOperationLevelFlag();
                }

                SendSettingsReadEvent();
                CheckAllProfileInstanceIDsAgainstAttachedHardware();
                return(true);
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(1061, ex);
                return(false);
            }
        }
Example #15
0
 public HIDSkeleton(SaitekPanelsEnum panelType, string instanceId)
 {
     _panelType  = panelType;
     _instanceId = instanceId;
 }
Example #16
0
        public bool LoadProfile(string filename)
        {
            try
            {
                Common.DebugP("LoadProfile filename : " + filename);
                if (!string.IsNullOrEmpty(filename))
                {
                    _filename        = filename;
                    _lastProfileUsed = filename;
                }

                /*
                 * 0 Open specified filename (parameter) if not null
                 * 1 If exists open last profile used (settings)
                 * 2 Try and open default profile located in My Documents
                 * 3 If none found create default file
                 */
                _isNewProfile = false;
                ClearAll();
                if (string.IsNullOrEmpty(_filename))
                {
                    if (!string.IsNullOrEmpty(_lastProfileUsed) && File.Exists(_lastProfileUsed))
                    {
                        _filename = _lastProfileUsed;
                    }
                    else if (File.Exists(DefaultFile()))
                    {
                        _filename        = DefaultFile();
                        _lastProfileUsed = filename;
                    }
                }

                Common.DebugP("LoadProfile _lastProfileUsed : " + _lastProfileUsed);
                Common.DebugP("LoadProfile _filename : " + _filename);

                if (string.IsNullOrEmpty(_filename) || !File.Exists(_filename))
                {
                    //Main window will handle this
                    Common.DebugP("LoadProfile returns false");
                    return(false);
                }

                /*
                 * Read all information and add InstanceID to all lines using BeginPanel and EndPanel
                 *
                 * PanelType=PZ55SwitchPanel
                 * PanelInstanceID=\\?\hid#vid_06a3&pid_0d06#8&3f11a32&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                 * BeginPanel
                 *      SwitchPanelKey{1KNOB_ENGINE_RIGHT}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_LEFT}\o/OSKeyPress{FiftyMilliSec,LCONTROL + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_BOTH}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_C}
                 * EndPanel
                 *
                 */
                var oldProfileStandard = true;
                var fileLines          = File.ReadAllLines(_filename);
                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("PanelType="))
                    {
                        oldProfileStandard = false;
                        break;
                    }
                }
                SaitekPanelsEnum currentPanelType       = SaitekPanelsEnum.Unknown;
                string           currentPanelInstanceID = null;
                var insidePanel = false;
                var sepString   = "\\o/";

                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("Airframe="))
                    {
                        _airframe = (DCSAirframe)Enum.Parse(typeof(DCSAirframe), fileLine.Replace("Airframe=", "").Trim());
                        DCSBIOSControlLocator.Airframe      = _airframe;
                        DCSBIOSControlLocator.JSONDirectory = _jsonDirectory;
                    }
                    else if (!fileLine.StartsWith("#") && fileLine.Length > 2)
                    {
                        if (oldProfileStandard)
                        {
                            _listPanelSettingsData.Add(fileLine);
                        }
                        else
                        {
                            //Process all these lines.
                            if (fileLine.StartsWith("PanelType="))
                            {
                                currentPanelType = (SaitekPanelsEnum)Enum.Parse(typeof(SaitekPanelsEnum), fileLine.Replace("PanelType=", "").Trim());
                            }
                            else if (fileLine.StartsWith("PanelInstanceID="))
                            {
                                currentPanelInstanceID = fileLine.Replace("PanelInstanceID=", "").Trim();
                                _profileFileInstanceIDs.Add(new KeyValuePair <string, SaitekPanelsEnum>(currentPanelInstanceID, currentPanelType));
                            }
                            else if (fileLine.StartsWith("BeginPanel"))
                            {
                                insidePanel = true;
                            }
                            else if (fileLine.StartsWith("EndPanel"))
                            {
                                insidePanel = false;
                            }
                            else
                            {
                                if (insidePanel)
                                {
                                    if (fileLine.StartsWith("\t"))
                                    {
                                        _listPanelSettingsData.Add(fileLine.Substring(1) + sepString + currentPanelInstanceID);
                                    }
                                    else
                                    {
                                        _listPanelSettingsData.Add(fileLine.Substring(1) + sepString + currentPanelInstanceID);
                                    }
                                }
                            }
                        }
                    }
                }
                SendSettingsReadEvent();
                CheckAllProfileInstanceIDsAgainstAttachedHardware();
                return(true);
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(1061, ex);
                return(false);
            }
        }
Example #17
0
 protected SaitekPanel(SaitekPanelsEnum typeOfSaitekPanel, HIDSkeleton hidSkeleton)
 {
     _typeOfSaitekPanel          = typeOfSaitekPanel;
     HIDSkeletonBase             = hidSkeleton;
     _updateCounterDCSBIOSOutput = DCSBIOSOutput.GetUpdateCounter();
 }
Example #18
0
 public void PanelSettingsChanged(string uniqueId, SaitekPanelsEnum saitekPanelsEnum)
 {
     //do nada
 }