Exemplo n.º 1
0
 public void SendEvent(LibCECConfiguration config)
 {
     if (EventHandler != null)
     {
         EventHandler(this, new UpdateEvent(config));
     }
 }
Exemplo n.º 2
0
        public override void Process()
        {
            SendEvent(UpdateEventType.BaseDevicePhysicalAddress, 0);
            SendEvent(UpdateEventType.StatusText, "Setting new configuration...");
            SendEvent(UpdateEventType.ProgressBar, 25);

            if (!Lib.SetPhysicalAddress(PhysicalAddress))
            {
                SendEvent(UpdateEventType.StatusText, "Could not activate the new source");
            }
            else
            {
                LibCECConfiguration config = new LibCECConfiguration();
                Lib.GetCurrentConfiguration(config);

                SendEvent(UpdateEventType.StatusText, "Activating source...");
                SendEvent(UpdateEventType.ProgressBar, 50);
                Lib.SetActiveSource(config.DeviceTypes.Types[0]);

                SendEvent(UpdateEventType.StatusText, "Reading configuration...");
                SendEvent(UpdateEventType.ProgressBar, 75);
                Lib.GetCurrentConfiguration(config);

                SendEvent(config);
                SendEvent(UpdateEventType.StatusText, "Ready.");
            }
            SendEvent(UpdateEventType.ProgressBar, 100);
        }
Exemplo n.º 3
0
        public override void Process()
        {
            SendEvent(UpdateEventType.StatusText, "Requesting physical address...");
              SendEvent(UpdateEventType.ProgressBar, 0);

              ushort iPhysicalAddress = Lib.GetDevicePhysicalAddress(Address);
              SendEvent(UpdateEventType.BaseDevicePhysicalAddress, iPhysicalAddress);

              SendEvent(UpdateEventType.StatusText, "Setting new configuration...");
              SendEvent(UpdateEventType.ProgressBar, 25);

              if (!Lib.SetHDMIPort(Address, (byte)PortNumber))
              {
            SendEvent(UpdateEventType.StatusText, "Could not activate the new source");
              }
              else
              {
            LibCECConfiguration config = new LibCECConfiguration();
            Lib.GetCurrentConfiguration(config);

            SendEvent(UpdateEventType.StatusText, "Activating source...");
            SendEvent(UpdateEventType.ProgressBar, 50);
            Lib.SetActiveSource(config.DeviceTypes.Types[0]);

            SendEvent(UpdateEventType.StatusText, "Reading configuration...");
            SendEvent(UpdateEventType.ProgressBar, 75);
            Lib.GetCurrentConfiguration(config);

            SendEvent(config);
            SendEvent(UpdateEventType.StatusText, "Ready.");
              }
              SendEvent(UpdateEventType.ProgressBar, 100);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aDeviceName"></param>
        /// <param name="aHdmiPort"></param>
        public Client(string aDeviceName, byte aHdmiPort, CecDeviceType aDeviceType = CecDeviceType.PlaybackDevice)
        {
            Config = new LibCECConfiguration();
            Config.DeviceTypes.Types[0] = aDeviceType;
            Config.DeviceName           = aDeviceName;
            Config.HDMIPort             = aHdmiPort;
            //Config.ClientVersion = LibCECConfiguration.CurrentVersion;
            Config.SetCallbacks(this);

            iLib = new LibCecSharp(Config);
            iLib.InitVideoStandalone();

            if (Static != null)
            {
                Trace.WriteLine("WARNING: CEC client static already exists");
            }
            else
            {
                Static = this;
            }


            //Trace.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
            Trace.WriteLine("INFO: CEC Parser created - libCEC version " + Config.ServerVersion);
        }
Exemplo n.º 5
0
    public override void Process()
    {
      SendEvent(UpdateEventType.StatusText, Resources.action_requesting_physical_address);
      SendEvent(UpdateEventType.ProgressBar, 0);

      var iPhysicalAddress = _lib.GetDevicePhysicalAddress(_address);
      SendEvent(UpdateEventType.BaseDevicePhysicalAddress, iPhysicalAddress);

      SendEvent(UpdateEventType.StatusText, Resources.action_setting_new_libcec_configuration);
      SendEvent(UpdateEventType.ProgressBar, 25);

      if (!_lib.SetHDMIPort(_address, (byte)_portNumber))
      {
        SendEvent(UpdateEventType.StatusText, string.Format(Resources.command_not_acked, "SetHDMIPort"));
      }
      else
      {
        LibCECConfiguration config = new LibCECConfiguration();
        _lib.GetCurrentConfiguration(config);

        SendEvent(UpdateEventType.StatusText, Resources.action_activating_source);
        SendEvent(UpdateEventType.ProgressBar, 50);
        _lib.SetActiveSource(config.DeviceTypes.Types[0]);

        SendEvent(UpdateEventType.StatusText, Resources.action_reading_device_configuration);
        SendEvent(UpdateEventType.ProgressBar, 75);
        _lib.GetCurrentConfiguration(config);

        SendEvent(config);
        SendEvent(UpdateEventType.StatusText, Resources.ready);
      }
      SendEvent(UpdateEventType.ProgressBar, 100);
    }
Exemplo n.º 6
0
        public override int ConfigurationChanged(LibCECConfiguration config)
        {
            Config.Update(config);
            Settings.PhysicalAddress.Value = config.PhysicalAddress;
            if (config.AutodetectAddress)
            {
                Settings.DetectPhysicalAddress.Value = true;
                Settings.ConnectedDevice.Value       = CecLogicalAddress.Unknown;
                Settings.HDMIPort.Value = 0;
                _gui.SetControlEnabled(Settings.ConnectedDevice.ValueControl, false);
                _gui.SetControlEnabled(Settings.HDMIPort.ValueControl, false);
            }
            else
            {
                Settings.ConnectedDevice.Value       = config.BaseDevice == CecLogicalAddress.AudioSystem ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
                Settings.HDMIPort.Value              = config.HDMIPort;
                Settings.DetectPhysicalAddress.Value = false;
                _gui.SetControlEnabled(Settings.ConnectedDevice.ValueControl, true);
                _gui.SetControlEnabled(Settings.HDMIPort.ValueControl, true);
            }
            Settings.WakeDevices.Value     = Config.WakeDevices;
            Settings.PowerOffDevices.Value = Config.PowerOffDevices;
            Settings.ActivateSource.Value  = Config.ActivateSource;
            Settings.DeviceType.Value      = config.DeviceTypes.Types[0];
            Settings.TVAutoPowerOn.Value   = (config.AutoPowerOn == BoolSetting.Enabled);

            if (config.TvVendor != CecVendorId.Unknown)
            {
                Settings.OverrideTVVendor.Value = true;
                Settings.TVVendor.Value         = config.TvVendor;
            }
            else
            {
                Settings.OverrideTVVendor.Value = false;
            }

            _gui.SetControlText(_gui, Resources.app_name + " - libCEC " + Lib.VersionToString(Config.ServerVersion));

            if (Config.AdapterType == CecAdapterType.PulseEightExternal || Config.AdapterType == CecAdapterType.PulseEightDaughterboard)
            {
                var versionAvailable = int.Parse(Resources.cec_firmware_version);
                _gui.SetControlVisible(_gui.pbFirmwareUpgrade, true);
                _gui.SetControlVisible(_gui.lFirmware, true);
                _gui.SetControlVisible(_gui.lFirmwareVersion, true);
                _gui.SetControlVisible(_gui.bFirmwareUpgrade, (File.Exists(FirmwareUpgradeExe)));
                _gui.SetControlText(_gui.lFirmwareVersion, "v" + Config.FirmwareVersion + " " + Config.FirmwareBuildDate);
                _gui.SetControlEnabled(_gui.bFirmwareUpgrade, ((Config.FirmwareVersion < versionAvailable) || (Config.FirmwareVersion > 100)));
            }
            else
            {
                _gui.SetControlVisible(_gui.pbFirmwareUpgrade, false);
                _gui.SetControlVisible(_gui.lFirmware, false);
                _gui.SetControlVisible(_gui.lFirmwareVersion, false);
                _gui.SetControlVisible(_gui.bFirmwareUpgrade, false);
            }
            _gui.SetControlVisible(Settings.TVAutoPowerOn.ValueControl, (Config.FirmwareVersion >= 9));

            CECActions.UpdatePhysicalAddress();
            return(1);
        }
Exemplo n.º 7
0
        public override void Process()
        {
            SendEvent(UpdateEventType.BaseDevicePhysicalAddress, 0);
            SendEvent(UpdateEventType.StatusText, Resources.action_setting_new_libcec_configuration);
            SendEvent(UpdateEventType.ProgressBar, 25);

            if (!_lib.SetPhysicalAddress(_physicalAddress))
            {
                SendEvent(UpdateEventType.StatusText, string.Format(Resources.command_not_acked, "SetPhysicalAddress"));
            }
            else
            {
                LibCECConfiguration config = new LibCECConfiguration();
                _lib.GetCurrentConfiguration(config);

                SendEvent(UpdateEventType.StatusText, Resources.action_activating_source);
                SendEvent(UpdateEventType.ProgressBar, 50);
                _lib.SetActiveSource(config.DeviceTypes.Types[0]);

                SendEvent(UpdateEventType.StatusText, Resources.action_reading_device_configuration);
                SendEvent(UpdateEventType.ProgressBar, 75);
                _lib.GetCurrentConfiguration(config);

                SendEvent(config);
                SendEvent(UpdateEventType.StatusText, Resources.ready);
            }
            SendEvent(UpdateEventType.ProgressBar, 100);
        }
Exemplo n.º 8
0
        public override int ConfigurationChanged(LibCECConfiguration config)
        {
            Settings.PhysicalAddress.Value = Config.PhysicalAddress;
            Settings.ConnectedDevice.Value = Config.BaseDevice == CecLogicalAddress.AudioSystem ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
            Settings.HDMIPort.Value        = Config.HDMIPort;
            Settings.WakeDevices.Value     = Config.WakeDevices;
            Settings.PowerOffDevices.Value = Config.PowerOffDevices;
            Settings.ActivateSource.Value  = Config.ActivateSource;
            Settings.DeviceType.Value      = config.DeviceTypes.Types[0];

            if (config.TvVendor != CecVendorId.Unknown)
            {
                Settings.OverrideTVVendor.Value = true;
                Settings.TVVendor.Value         = config.TvVendor;
            }
            else
            {
                Settings.OverrideTVVendor.Value = false;
            }

            _gui.SetControlText(_gui, Resources.app_name + " - libCEC " + Lib.VersionToString(Config.ServerVersion));

            CECActions.UpdatePhysicalAddress();
            return(1);
        }
Exemplo n.º 9
0
        public void SendEvent(LibCECConfiguration config)
        {
            EventHandler <UpdateEvent> temp = EventHandler;

            if (temp != null)
            {
                temp(this, new UpdateEvent(config));
            }
        }
Exemplo n.º 10
0
        public CecClient()
        {
            config = new LibCECConfiguration();
            config.DeviceTypes.Types[0] = CecDeviceType.PlaybackDevice;
            config.DeviceName           = "kek";
            config.ClientVersion        = LibCECConfiguration.CurrentVersion;
            config.HDMIPort             = 2; // TODO: make this configurable
            logLevel = (int)CecLogLevel.All;

            lib = new LibCecSharp(this, config);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Connect to the adapter with the given configuration
        /// </summary>
        /// <param name="config">The client configuration</param>
        public void ConnectToDevice(LibCECConfiguration config)
        {
            if (_activeProcess != null)
            {
                return;
            }

            _activeProcess = new ConnectToDevice(_controller.Lib, config);
            _activeProcess.EventHandler += ProcessEventHandler;
            (new Thread(_activeProcess.Run)).Start();
        }
Exemplo n.º 12
0
 public CecSharpClient()
 {
     Config = new LibCECConfiguration();
     Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
     Config.DeviceName           = "Pulse Eight USB CEC Adapter";
     Config.ClientVersion        = LibCECConfiguration.CurrentVersion;
     Config.SetCallbacks(this);
     LogLevel = (int)CecLogLevel.All;
     Lib      = new LibCecSharp(Config);
     Lib.InitVideoStandalone();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Send an updated configuration to libCEC
        /// </summary>
        /// <param name="config">The new configuration</param>
        public void UpdateConfigurationAsync(LibCECConfiguration config)
        {
            if (SuppressUpdates || _activeProcess != null)
            {
                return;
            }

            _controller.SetControlsEnabled(false);
            _activeProcess = new UpdateConfiguration(_controller.Lib, config);
            _activeProcess.EventHandler += ProcessEventHandler;
            (new Thread(_activeProcess.Run)).Start();
        }
Exemplo n.º 14
0
        public CECClient()
        {
            Config = new LibCECConfiguration();
            Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
            Config.DeviceName           = "Cenero Conferencing System";
            Config.ClientVersion        = LibCECConfiguration.CurrentVersion;
            Config.SetCallbacks(this);
            LogLevel = (int)CecLogLevel.All;

            Lib = new LibCecSharp(Config);
            Lib.InitVideoStandalone();
        }
Exemplo n.º 15
0
        public override int ConfigurationChanged(LibCECConfiguration config)
        {
            _libConfig = config;
            WriteLog("Configuration updated from libcec.");

            if (_extensiveLogging)
            {
                WriteLog("Autodetected hdmi port: " + _libConfig.AutodetectAddress.ToString());
            }

            return(1);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Constructor
        /// </summary>
        public CecClient()
        {
            CecConfig = new LibCECConfiguration();
            CecConfig.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
            CecConfig.DeviceName           = "Avid TV Switch";
            CecConfig.ClientVersion        = LibCECConfiguration.CurrentVersion;
            CecConfig.ActivateSource       = false;
            CecConfig.SetCallbacks(this);

            CecLib = new LibCecSharp(CecConfig);
            CecLib.InitVideoStandalone();
        }
Exemplo n.º 17
0
        public CecSharpClient()
        {
            Config = new LibCECConfiguration();
            Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
            Config.DeviceName           = "CEC Tester";
            Config.ClientVersion        = LibCECConfiguration.CurrentVersion;
            LogLevel = (int)CecLogLevel.All;

            Lib = new LibCecSharp(this, Config);
            Lib.InitVideoStandalone();

            Console.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
        }
Exemplo n.º 18
0
        public CecSharpClient()
        {
            Config = new LibCECConfiguration();
            Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
            Config.DeviceName           = "CEC Tester";
            Config.ClientVersion        = CecClientVersion.Version1_5_0;
            Config.SetCallbacks(this);
            LogLevel = (int)CecLogLevel.All;

            Lib = new LibCecSharp(Config);

            Console.WriteLine("CEC Parser created - libcec version " + Lib.ToString(Config.ServerVersion));
        }
Exemplo n.º 19
0
        public CecSharpClient()
        {
            Config = new LibCECConfiguration();
              Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
              Config.DeviceName = "CEC Tester";
              Config.ClientVersion = CecClientVersion.Version1_5_0;
              Config.SetCallbacks(this);
              LogLevel = (int)CecLogLevel.All;

              Lib = new LibCecSharp(Config);

              Console.WriteLine("CEC Parser created - libcec version " + Lib.ToString(Config.ServerVersion));
        }
Exemplo n.º 20
0
        public virtual void DeInit()
        {
            if (_lib != null)
            {
                _lib.DisableCallbacks();
                _lib.Close();
                _lib.Dispose();
            }

            _connected = false;

            _lib         = null;
            _libConfig   = null;
            _cecConfig   = null;
            _repeatTimer = null;
        }
    public override void Process()
    {
      SendEvent(UpdateEventType.ProgressBar, 10);
      SendEvent(UpdateEventType.StatusText, Resources.action_requesting_physical_address);

      LibCECConfiguration config = new LibCECConfiguration();
      _lib.GetCurrentConfiguration(config);
      var physicalAddress = _lib.GetDevicePhysicalAddress(config.LogicalAddresses.Primary);

      if (physicalAddress != 0xFFFF &&
          physicalAddress != 0)
        SendEvent(UpdateEventType.PhysicalAddress, physicalAddress);

      SendEvent(UpdateEventType.ProgressBar, 100);
      SendEvent(UpdateEventType.StatusText, Resources.ready);
    }
Exemplo n.º 22
0
        public CecConfigGUI()
        {
            Config = new LibCECConfiguration();
              Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
              Config.DeviceName = "CEC Config";
              Config.GetSettingsFromROM = true;
              Config.ClientVersion = CecClientVersion.Version1_5_1;
              Callbacks = new CecCallbackWrapper(this);
              Config.SetCallbacks(Callbacks);
              LoadXMLConfiguration(ref Config);
              Lib = new LibCecSharp(Config);

              InitializeComponent();
              LoadButtonConfiguration();

              ActiveProcess = new ConnectToDevice(ref Lib, Config);
              ActiveProcess.EventHandler += ProcessEventHandler;
              (new Thread(ActiveProcess.Run)).Start();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Initialize the Cec bus without callback methods (no need)
        /// </summary>
        /// <param name="timeout">Timeout for the connections to the bus. Must be positive</param>
        /// <exception cref="CecException">Unable to initialize Cec Bus or can't find controller</exception>
        /// <exception cref="ArgumentOutOfRangeException">timeout not strictly positive</exception>
        public CecBus(int timeout)
        {
            if (timeout <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout));
            }

            this.timeout = timeout;

            configuration = new LibCECConfiguration();
            configuration.DeviceTypes.Types[0] = CecDeviceType.PlaybackDevice;
            configuration.DeviceName           = Resources.StrCecDeviceName;
            configuration.ClientVersion        = LibCECConfiguration.CurrentVersion;
            configuration.SetCallbacks(this);

            connection = new LibCecSharp(configuration) ?? throw new CecException(Resources.ErrorNoCecBus);
            connection.InitVideoStandalone();

            // Get the controller on the bus
            controller = null;
            CecAdapter[] adapters = connection.FindAdapters(string.Empty);
            if (adapters.Length > 0)
            {
                controller = adapters[controllerId];
            }
            else
            {
                throw new CecException(Resources.ErrorNoCecController);
            }

            // Connection must be openned before going to suspend mode as the SCM stop the thread if we try to open
            // the connection during power event because it's an async operation
            if (!connection.Open(controller.ComPort, timeout))
            {
                throw new CecException(Resources.ErrorNoCecControllerConnection);
            }

            // Register active source of the connection
            connection.SetActiveSource(CecDeviceType.PlaybackDevice);
        }
Exemplo n.º 24
0
        public LibCECClient()
        {
            var config = new LibCECConfiguration();

            config.DeviceTypes.Types[0] = CecDeviceType.PlaybackDevice;
            config.DeviceName           = "MP-S";
            config.ClientVersion        = LibCECConfiguration.CurrentVersion;
            config.SetCallbacks(this);
            //config.PhysicalAddress = 1000;
            config.HDMIPort    = 1;
            config.AdapterType = CecAdapterType.PulseEightExternal;
            config.TvVendor    = CecVendorId.Philips;

            config.ActivateSource = false;

            _logLevel = (int)CecLogLevel.All;

            Lib = new LibCecSharp(config);
            Lib.InitVideoStandalone();

            Log("LibCECClient: Successfully created LibCEC Parser with version: " +
                Lib.VersionToString(config.ServerVersion));
        }
Exemplo n.º 25
0
        public CecSharpClient()
        {
            Config                      = new LibCECConfiguration();
            Config.BaseDevice           = CecLogicalAddress.AudioSystem;
            Config.HDMIPort             = 5;
            Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
            Config.DeviceName           = "CEC PX";
            Config.ClientVersion        = LibCECConfiguration.CurrentVersion;
            //Config.AutodetectAddress = false;

            //LogLevel = (int)CecLogLevel.All & ~(int)CecLogLevel.Debug & ~(int)CecLogLevel.Traffic;

            Lib = new LibCecSharp(this, Config);
            Lib.InitVideoStandalone();


            //if (Lib.IsActiveDevice(CecLogicalAddress.Tv) && !Lib.GetDevicePowerStatus(CecLogicalAddress.Tv).Equals(CecPowerStatus.On))
            //{
            //  Lib.SetActiveSource(CecDeviceType.Reserved);
            //}

            Console.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
        }
Exemplo n.º 26
0
 public ConnectToDevice(LibCecSharp lib, LibCECConfiguration config)
 {
     _lib    = lib;
     _config = config;
 }
Exemplo n.º 27
0
        public override int ConfigurationChanged(LibCECConfiguration config)
        {
            Settings.PhysicalAddress.Value = Config.PhysicalAddress;
              Settings.ConnectedDevice.Value = Config.BaseDevice == CecLogicalAddress.AudioSystem ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
              Settings.HDMIPort.Value = Config.HDMIPort;
              Settings.WakeDevices.Value = Config.WakeDevices;
              Settings.PowerOffDevices.Value = Config.PowerOffDevices;
              Settings.ActivateSource.Value = Config.ActivateSource;
              Settings.DeviceType.Value = config.DeviceTypes.Types[0];

              if (config.TvVendor != CecVendorId.Unknown)
              {
            Settings.OverrideTVVendor.Value = true;
            Settings.TVVendor.Value = config.TvVendor;
              }
              else
              {
            Settings.OverrideTVVendor.Value = false;
              }

              _gui.SetControlText(_gui, Resources.app_name + " - libCEC " + Lib.ToString(Config.ServerVersion));

              CECActions.UpdatePhysicalAddress();
              return 1;
        }
Exemplo n.º 28
0
 public UpdateConfiguration(ref LibCecSharp lib, LibCECConfiguration config)
 {
     Lib    = lib;
     Config = config;
 }
Exemplo n.º 29
0
        private bool LoadXMLConfiguration(ref LibCECConfiguration config)
        {
            bool gotConfig = false;
              string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
              string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
              string file = defaultDir + @"\usb_2548_1001.xml";
              if (File.Exists(xbmcDir + @"\usb_2548_1001.xml"))
            file = xbmcDir + @"\usb_2548_1001.xml";

              if (File.Exists(file))
              {
            XmlTextReader reader = new XmlTextReader(file);
            while (reader.Read())
            {
              gotConfig = true;
              switch (reader.NodeType)
              {
            case XmlNodeType.Element:
              if (reader.Name.ToLower() == "setting")
              {
                string name = string.Empty;
                string value = string.Empty;

                while (reader.MoveToNextAttribute())
                {
                  if (reader.Name.ToLower().Equals("id"))
                    name = reader.Value.ToLower();
                  if (reader.Name.ToLower().Equals("value"))
                    value = reader.Value;
                }

                switch (name)
                {
                  case "cec_hdmi_port":
                    {
                      byte iPort;
                      if (byte.TryParse(value, out iPort))
                        config.HDMIPort = iPort;
                    }
                    break;
                  case "connected_device":
                    {
                      ushort iDevice;
                      if (ushort.TryParse(value, out iDevice))
                        config.BaseDevice = (CecLogicalAddress)iDevice;
                    }
                    break;
                  case "cec_power_on_startup":
                    if (value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"))
                    {
                      config.ActivateSource = true;
                      config.WakeDevices.Set(CecLogicalAddress.Tv);
                    }
                    break;
                  case "cec_power_off_shutdown":
                    if (value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"))
                      config.PowerOffDevices.Set(CecLogicalAddress.Broadcast);
                    break;
                  case "cec_standby_screensaver":
                    config.PowerOffScreensaver = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
                    break;
                  case "standby_pc_on_tv_standby":
                    config.PowerOffOnStandby = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
                    break;
                  case "use_tv_menu_language":
                    config.UseTVMenuLanguage = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
                    break;
                  // 1.5.0+ settings
                  case "physical_address":
                    {
                      ushort physicalAddress = 0;
                      if (ushort.TryParse(value, NumberStyles.AllowHexSpecifier, null, out physicalAddress))
                        config.PhysicalAddress = physicalAddress;
                    }
                    break;
                  case "device_type":
                    {
                      ushort iType;
                      if (ushort.TryParse(value, out iType))
                        config.DeviceTypes.Types[0] = (CecDeviceType)iType;
                    }
                    break;
                  case "tv_vendor":
                    {
                      UInt64 iVendor;
                      if (UInt64.TryParse(value, out iVendor))
                        config.TvVendor = (CecVendorId)iVendor;
                    }
                    break;
                  case "wake_devices":
                    {
                      config.WakeDevices.Clear();
                      string[] split = value.Split(new[] { ' ' });
                      foreach (string dev in split)
                      {
                        byte iLogicalAddress;
                        if (byte.TryParse(dev, out iLogicalAddress))
                          config.WakeDevices.Set((CecLogicalAddress)iLogicalAddress);
                      }
                    }
                    break;
                  case "standby_devices":
                    {
                      config.PowerOffDevices.Clear();
                      string[] split = value.Split(new char[] { ' ' });
                      foreach (string dev in split)
                      {
                        byte iLogicalAddress;
                        if (byte.TryParse(dev, out iLogicalAddress))
                          config.PowerOffDevices.Set((CecLogicalAddress)iLogicalAddress);
                      }
                    }
                    break;
                  case "enabled":
                    break;
                  case "port":
                    //TODO
                    break;
                  // 1.5.1 settings
                  case "send_inactive_source":
                    config.SendInactiveSource = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
                    break;
                  default:
                    break;
                }
              }
              break;
            default:
              break;
              }
            }
              }
              return gotConfig;
        }
Exemplo n.º 30
0
 public override int ConfigurationChanged(LibCECConfiguration config)
 {
     return Gui.ConfigurationChanged(config);
 }
Exemplo n.º 31
0
 public UpdateEvent(LibCECConfiguration config)
 {
     Type = UpdateEventType.Configuration;
       ConfigValue = config;
 }
Exemplo n.º 32
0
 public UpdateConfiguration(ref LibCecSharp lib, LibCECConfiguration config)
 {
     Lib = lib;
       Config = config;
 }
Exemplo n.º 33
0
        public virtual void LoadConfig()
        {
            WriteLog("Loading configuration...");

            if (_cecConfig == null)
            {
                WriteLog("Configuration not set, abort");
                return;
            }

            _fastScrolling         = _cecConfig.FastScrolling;
            _fastScrollingKeyCount = _cecConfig.FastScrollingRepeatDelay;
            _repeatTimer           = new System.Timers.Timer(_cecConfig.FastScrollingRepeatRate);

            _extensiveLogging        = _cecConfig.ExtensiveLogging;
            _disableScreensaver      = _cecConfig.DisableScreensaver;
            _requireDelayBetweenKeys = _cecConfig.RequireDelayBetweenKeys;

            if (_fastScrolling)
            {
                _repeatTimer.Elapsed  += new ElapsedEventHandler(OnRepeatKeyPressEvent);
                _repeatTimer.AutoReset = true;
            }


            // Build configuration for new Lib

            try
            {
                if (_libConfig == null)
                {
                    _libConfig = new LibCECConfiguration();
                    _libConfig.SetCallbacks(this);
                }

                _libConfig.DeviceTypes.Types[0] = _cecConfig.DeviceType;
                _libConfig.DeviceName           = _cecConfig.OsdName;
                _libConfig.ClientVersion        = LibCECConfiguration.CurrentVersion;
                _libConfig.WakeDevices.Clear();
                _libConfig.PowerOffDevices.Clear();
                _libConfig.PhysicalAddress = 0;
                _libConfig.ActivateSource  = false; // Control this manually based on settings.
                _libConfig.HDMIPort        = (byte)_cecConfig.HdmiPort;
                _libConfig.BaseDevice      = _cecConfig.ConnectedTo;

                if (_cecConfig.ForcePhysicalAddress)
                {
                    WriteLog("Physical address overriding enabled, ignoring HDMI port an using address: " + _cecConfig.PhysicalAddress);

                    _libConfig.PhysicalAddress = ushort.Parse(_cecConfig.PhysicalAddress, System.Globalization.NumberStyles.AllowHexSpecifier);
                }

                WriteLog("Configuration loaded succesfully.");

                if (_lib == null)
                {
                    _lib = new LibCecSharp(_libConfig);
                    WriteLog("Lib created succesfully.");
                }
                else
                {
                    _lib.SetConfiguration(_libConfig);
                    _lib.EnableCallbacks(this);
                    WriteLog("Lib configuration updated");
                }
            }
            catch (Exception ex)
            {
                WriteLog("Could not configure libCec." + ex.ToString());
                throw;
            }
        }
Exemplo n.º 34
0
 public ConnectToDevice(ref LibCecSharp lib, LibCECConfiguration config)
 {
     Lib = lib;
       Config = config;
 }
Exemplo n.º 35
0
 public void SendEvent(LibCECConfiguration config)
 {
     EventHandler?.Invoke(this, new UpdateEvent(config));
 }
Exemplo n.º 36
0
    /// <summary>
    /// Send an updated configuration to libCEC
    /// </summary>
    /// <param name="config">The new configuration</param>
    public void UpdateConfigurationAsync(LibCECConfiguration config)
    {
      if (SuppressUpdates || _activeProcess != null) return;

      _controller.SetControlsEnabled(false);
      _activeProcess = new UpdateConfiguration(_controller.Lib, config);
      _activeProcess.EventHandler += ProcessEventHandler;
      (new Thread(_activeProcess.Run)).Start();
    }
Exemplo n.º 37
0
    /// <summary>
    /// Connect to the adapter with the given configuration
    /// </summary>
    /// <param name="config">The client configuration</param>
    public void ConnectToDevice(LibCECConfiguration config)
    {
      if (_activeProcess != null) return;

      _activeProcess = new ConnectToDevice(_controller.Lib, config);
      _activeProcess.EventHandler += ProcessEventHandler;
      (new Thread(_activeProcess.Run)).Start();
    }
Exemplo n.º 38
0
 public void SendEvent(LibCECConfiguration config)
 {
     EventHandler<UpdateEvent> temp = EventHandler;
       if (temp != null)
     temp(this, new UpdateEvent(config));
 }
Exemplo n.º 39
0
        public int ConfigurationChanged(LibCECConfiguration config)
        {
            Config = config;
              SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", Config.PhysicalAddress));
              SetControlText(cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString);
              SetControlText(cbPortNumber, Config.HDMIPort.ToString());
              switch (config.DeviceTypes.Types[0])
              {
            case CecDeviceType.RecordingDevice:
              SetControlText(cbDeviceType, "Recorder");
              break;
            case CecDeviceType.PlaybackDevice:
              SetControlText(cbDeviceType, "Player");
              break;
            case CecDeviceType.Tuner:
              SetControlText(cbDeviceType, "Tuner");
              break;
            default:
              SetControlText(cbDeviceType, "Recorder");
              break;
              }
              if (config.TvVendor != CecVendorId.Unknown)
              {
            SetCheckboxChecked(cbVendorOverride, true);
            SetControlText(cbVendorId, Lib.ToString(config.TvVendor));
              }
              else
              {
            SetCheckboxChecked(cbVendorOverride, false);
            SetControlText(cbVendorId, Lib.ToString(TVVendor));
              }

              SetCheckboxChecked(cbUseTVMenuLanguage, Config.UseTVMenuLanguage);
              SetCheckboxChecked(cbActivateSource, Config.ActivateSource);
              SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
              SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby);
              SetCheckboxChecked(cbSendInactiveSource, Config.SendInactiveSource);
              UpdateSelectedDevice();

              for (int iPtr = 0; iPtr < 15; iPtr++)
            SetCheckboxItemChecked(cbWakeDevices, iPtr, Config.WakeDevices.IsSet((CecLogicalAddress)iPtr));
              for (int iPtr = 0; iPtr < 15; iPtr++)
            SetCheckboxItemChecked(cbPowerOffDevices, iPtr, Config.PowerOffDevices.IsSet((CecLogicalAddress)iPtr));

              SetControlText(this, "Pulse-Eight USB-CEC Adapter - libCEC " + Lib.ToString(Config.ServerVersion));
              return 1;
        }
Exemplo n.º 40
0
 public ConnectToDevice(LibCecSharp lib, LibCECConfiguration config)
 {
     _lib = lib;
       _config = config;
 }
Exemplo n.º 41
0
 public UpdateConfiguration(LibCecSharp lib, LibCECConfiguration config)
 {
     _lib    = lib;
     _config = config;
 }
Exemplo n.º 42
0
    public virtual void DeInit()
    {
      if (_lib != null)
      {
        _lib.DisableCallbacks();
        _lib.Close();
        _lib.Dispose();
      }

      _connected = false;

      _lib = null;
      _libConfig = null;
      _cecConfig = null;
      _repeatTimer = null;
    }
Exemplo n.º 43
0
 public UpdateConfiguration(LibCecSharp lib, LibCECConfiguration config)
 {
   _lib = lib;
   _config = config;
 }
Exemplo n.º 44
0
 public ConnectToDevice(ref LibCecSharp lib, LibCECConfiguration config)
 {
     Lib    = lib;
     Config = config;
 }
Exemplo n.º 45
0
        /// <summary>
        /// Reset all settings to their default values
        /// </summary>
        public void ResetDefaultSettings()
        {
            SetControlsEnabled(false);
              _gui.ShowHideAdvanced(false);

              CECActions.SuppressUpdates = true;
              Settings.SetDefaultValues();
              _config = null;
              Lib.SetConfiguration(Config);
              CECActions.SuppressUpdates = false;

              _gui.ShowHideAdvanced(Settings.AdvancedMode.Value);
              SetControlsEnabled(true);
        }
Exemplo n.º 46
0
    public override int ConfigurationChanged(LibCECConfiguration config)
    {
      _libConfig = config;
      WriteLog("Configuration updated from libcec.");

      if (_extensiveLogging)
      {
        WriteLog("Autodetected hdmi port: " + _libConfig.AutodetectAddress.ToString());
      }

      return 1;
    }
Exemplo n.º 47
0
 public void SendEvent(LibCECConfiguration config)
 {
     if (EventHandler != null)
     EventHandler(this, new UpdateEvent(config));
 }
Exemplo n.º 48
0
    public virtual void LoadConfig()
    {
      WriteLog("Loading configuration...");

      if (_cecConfig == null)
      {
        WriteLog("Configuration not set, abort");
        return;
      }

      _fastScrolling = _cecConfig.FastScrolling;
      _fastScrollingKeyCount = _cecConfig.FastScrollingRepeatDelay;
      _repeatTimer = new System.Timers.Timer(_cecConfig.FastScrollingRepeatRate);

      _extensiveLogging = _cecConfig.ExtensiveLogging;
      _disableScreensaver = _cecConfig.DisableScreensaver;
      _requireDelayBetweenKeys = _cecConfig.RequireDelayBetweenKeys;

      if (_fastScrolling)
      {
        _repeatTimer.Elapsed += new ElapsedEventHandler(OnRepeatKeyPressEvent);
        _repeatTimer.AutoReset = true;
      }


      // Build configuration for new Lib

      try
      {
        if (_libConfig == null)
        {
          _libConfig = new LibCECConfiguration();
          _libConfig.SetCallbacks(this);
        }
        
        _libConfig.DeviceTypes.Types[0] = _cecConfig.DeviceType;
        _libConfig.DeviceName = _cecConfig.OsdName;
        _libConfig.ClientVersion = LibCECConfiguration.CurrentVersion;
        _libConfig.WakeDevices.Clear();
        _libConfig.PowerOffDevices.Clear();
        _libConfig.PhysicalAddress = 0;
        _libConfig.ActivateSource = false;  // Control this manually based on settings.
        _libConfig.HDMIPort = (byte)_cecConfig.HdmiPort;
        _libConfig.BaseDevice = _cecConfig.ConnectedTo;

        if (_cecConfig.ForcePhysicalAddress)
        {
            WriteLog("Physical address overriding enabled, ignoring HDMI port an using address: " + _cecConfig.PhysicalAddress);

            _libConfig.PhysicalAddress = ushort.Parse(_cecConfig.PhysicalAddress, System.Globalization.NumberStyles.AllowHexSpecifier);
        }

        WriteLog("Configuration loaded succesfully.");

        if (_lib == null)
        {
          _lib = new LibCecSharp(_libConfig);
          WriteLog("Lib created succesfully.");
        }
        else
        {
          _lib.SetConfiguration(_libConfig);
          _lib.EnableCallbacks(this);
          WriteLog("Lib configuration updated");
        }
      }
      catch (Exception ex)
      {
        WriteLog("Could not configure libCec." + ex.ToString());
        throw;
      }

    }
Exemplo n.º 49
0
        public void Start()
        {
            Config = new LibCECConfiguration();
              Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
              Config.DeviceName = "CEC Tester";
              Config.ClientVersion = CecClientVersion.CurrentVersion;
              Config.SetCallbacks(this);
              LogLevel = (int)CecLogLevel.All;

              Lib = new LibCecSharp(Config);
              Lib.InitVideoStandalone();

              CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
              if (adapters.Length > 0)
              {
            Console.WriteLine("Found CEC adapters");
            Lib.Open(adapters[0].ComPort, 1000);
            this.EnsureActive();
              }
              else
              {
            Console.WriteLine("Did not find any CEC adapters");
              }
        }
Exemplo n.º 50
0
 public UpdateEvent(LibCECConfiguration config)
 {
     Type        = UpdateEventType.Configuration;
     ConfigValue = config;
 }