/// <summary> /// Interprets the ScpControl.ini configuration file. /// </summary> private IniConfig() { var iniOpts = new IniOptions() { CommentStarter = IniCommentStarter.Semicolon, KeyDuplicate = IniDuplication.Allowed }; var ini = new IniFile(iniOpts); var fullPath = Path.Combine(WorkingDirectory, CfgFile); if (!File.Exists(fullPath)) { Log.FatalFormat("Configuration file {0} not found!", fullPath); return; } // parse data from INI try { ini.Load(fullPath); Hci = new HciCfg() { SupportedNames = ini.Sections["Host Controller Interface"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value), GenuineMacAddresses = ini.Sections["Host Controller Interface"].Keys.Where(k => k.Name == "GenuineMacAddress").Select(v => v.Value) }; Ds3Driver = new Ds3DriverCfg() { DeviceGuid = ini.Sections["DualShock 3 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 3 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; Ds4Driver = new Ds4DriverCfg() { DeviceGuid = ini.Sections["DualShock 4 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 4 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; BthDongleDriver = new BthDongleDriverCfg() { DeviceGuid = ini.Sections["Bluetooth Dongles"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["Bluetooth Dongles"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; } catch (Exception ex) { Log.FatalFormat("Error while parsing configuration file: {0}", ex); } }
/// <summary> /// Interprets the ScpControl.ini configuration file. /// </summary> private IniConfig() { var iniOpts = new IniOptions() { CommentStarter = IniCommentStarter.Semicolon, KeyDuplicate = IniDuplication.Allowed }; var ini = new IniFile(iniOpts); var fullPath = Path.Combine(GlobalConfiguration.AppDirectory, CfgFile); if (!File.Exists(fullPath)) { Log.FatalFormat("Configuration file {0} not found!", fullPath); return; } // parse data from INI try { ini.Load(fullPath); Hci = new HciCfg() { SupportedNames = ini.Sections["Host Controller Interface"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value), GenuineMacAddresses = ini.Sections["Host Controller Interface"].Keys.Where(k => k.Name == "GenuineMacAddress").Select(v => v.Value) }; Ds3Driver = new Ds3DriverCfg() { DeviceGuid = ini.Sections["DualShock 3 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 3 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; Ds4Driver = new Ds4DriverCfg() { DeviceGuid = ini.Sections["DualShock 4 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 4 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; BthDongleDriver = new BthDongleDriverCfg() { DeviceGuid = ini.Sections["Bluetooth Dongles"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["Bluetooth Dongles"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; BthChipManufacturers = new List <BthChipManufacturerCfg>(); foreach (var key in ini.Sections["Bluetooth Chip Manufacturers"].Keys) { BthChipManufacturers.Add(new BthChipManufacturerCfg() { Name = key.Name, PartialMacAddress = key.Value }); } } catch (Exception ex) { Log.FatalFormat("Error while parsing configuration file: {0}", ex); } }
/// <summary> /// Interprets the ScpControl.ini configuration file. /// </summary> private IniConfig() { var iniOpts = new IniOptions() { CommentStarter = IniCommentStarter.Semicolon, KeyDuplicate = IniDuplication.Allowed }; var ini = new IniFile(iniOpts); var fullPath = Path.Combine(WorkingDirectory, CfgFile); if (!File.Exists(fullPath)) { Log.FatalFormat("Configuration file {0} not found!", fullPath); return; } // parse data from INI try { ini.Load(fullPath); BthDongle = new BthDongleCfg() { SupportedNames = ini.Sections["BthDongle"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value), SupportedMacs = ini.Sections["BthDongle"].Keys.Where(k => k.Name == "SupportedMac").Select(v => v.Value) }; BthDs3 = new BthDs3Cfg() { SupportedNames = ini.Sections["BthDs3"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value), SupportedMacs = ini.Sections["BthDs3"].Keys.Where(k => k.Name == "SupportedMac").Select(v => v.Value) }; Hci = new HciCfg() { SupportedNames = ini.Sections["HCI"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value) }; Ds3Driver = new Ds3DriverCfg() { DeviceGuid = ini.Sections["DualShock 3 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 3 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; Ds4Driver = new Ds4DriverCfg() { DeviceGuid = ini.Sections["DualShock 4 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 4 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; BthDongleDriver = new BthDongleDriverCfg() { DeviceGuid = ini.Sections["Bluetooth Dongles"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["Bluetooth Dongles"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; } catch (Exception ex) { Log.FatalFormat("Error while parsing configuration file: {0}", ex); } }