Beispiel #1
0
 public static void Init()
 {
     if (_initialized)
     {
         Log.Info("Remotes: Init was called before Stop - stopping devices now");
         Stop();
     }
     _initialized = true;
     //diRemote.Init(); // Disable DirectX Input (not compatible with NET4 and later)
     X10Remote.Init();
     CentareaRemote.Init();
     HidListener.Init(GUIGraphicsContext.ActiveForm);
     MCE2005Remote.Init(GUIGraphicsContext.ActiveForm);
     FireDTVRemote.Init(GUIGraphicsContext.ActiveForm);
     HCWRemote.Init(GUIGraphicsContext.ActiveForm);
     IrTrans.Init(GUIGraphicsContext.ActiveForm);
 }
Beispiel #2
0
 public static void Init()
 {
     if (_initialized)
     {
         Log.Info("Remotes: Init was called before Stop - stopping devices now");
         Stop();
     }
     _initialized = true;
     diRemote.Init();
     X10Remote.Init();
     CentareaRemote.Init();
     HidListener.Init(GUIGraphicsContext.ActiveForm);
     MCE2005Remote.Init(GUIGraphicsContext.ActiveForm);
     FireDTVRemote.Init(GUIGraphicsContext.ActiveForm);
     HCWRemote.Init(GUIGraphicsContext.ActiveForm);
     IrTrans.Init(GUIGraphicsContext.ActiveForm);
 }
Beispiel #3
0
    /// <summary>
    /// 
    /// </summary>
    public override void LoadSettings()
    {
      using (Settings xmlreader = new MPSettings())
      {

        #region HCW

        checkBoxHcwEnabled.Checked = xmlreader.GetValueAsBool("remote", "HCW", false);
        checkBoxHcwAllowExternal.Checked = xmlreader.GetValueAsBool("remote", "HCWAllowExternal", false);
        checkBoxHcwKeepControl.Checked = xmlreader.GetValueAsBool("remote", "HCWKeepControl", false);
        checkBoxHcwExtendedLogging.Checked = xmlreader.GetValueAsBool("remote", "HCWVerboseLog", false);
        hScrollBarHcwButtonRelease.Value = xmlreader.GetValueAsInt("remote", "HCWButtonRelease", 200);
        hScrollBarHcwRepeatFilter.Value = xmlreader.GetValueAsInt("remote", "HCWRepeatFilter", 2);
        hScrollBarHcwRepeatSpeed.Value = xmlreader.GetValueAsInt("remote", "HCWRepeatSpeed", 0);
        checkBoxHcwFilterDoubleKlicks.Checked = xmlreader.GetValueAsBool("remote", "HCWFilterDoubleKlicks", false);

        if (checkBoxHcwAllowExternal.Checked)
        {
          checkBoxHcwKeepControl.Enabled = true;
        }
        else
        {
          checkBoxHcwKeepControl.Enabled = false;
        }

        if (!checkBoxHcwEnabled.Checked)
        {
          groupBoxHcwSettings.Enabled = false;
          groupBoxHcwRepeatDelay.Enabled = false;
        }

        string exePath = irremote.GetHCWPath();
        string dllPath = irremote.GetDllPath();

        if (File.Exists(exePath + "Ir.exe"))
        {
          FileVersionInfo exeVersionInfo = FileVersionInfo.GetVersionInfo(exePath + "Ir.exe");
          if (exeVersionInfo.FileVersion.CompareTo(irremote.CurrentVersion) < 0)
          {
            labelHcwDriverStatus.ForeColor = Color.Red;
            labelHcwDriverStatus.Text = errHcwOutOfDate;
            linkLabelHcwDownload.Visible = true;
          }
        }
        else
        {
          labelHcwDriverStatus.ForeColor = Color.Red;
          labelHcwDriverStatus.Text = errHcwMissingExe;
          linkLabelHcwDownload.Visible = true;
          checkBoxHcwAllowExternal.Enabled = false;
          checkBoxHcwKeepControl.Enabled = false;
        }

        if (File.Exists(dllPath + "irremote.DLL"))
        {
          FileVersionInfo dllVersionInfo = FileVersionInfo.GetVersionInfo(dllPath + "irremote.DLL");

          //Initialize the remote for learning purposes
          if (HCWRemote == null)
          {
            HCWRemote = new HcwRemote();
          }
          HCWRemote.Init();
          //HCWRemote.StartHcw();

          if (dllVersionInfo.FileVersion.CompareTo(irremote.CurrentVersion) < 0)
          {
            labelHcwDriverStatus.ForeColor = Color.Red;
            labelHcwDriverStatus.Text = errHcwOutOfDate;
            linkLabelHcwDownload.Visible = true;
          }
        }
        else
        {
          labelHcwDriverStatus.ForeColor = Color.Red;
          labelHcwDriverStatus.Text = errHcwNotInstalled;
          linkLabelHcwDownload.Visible = true;
          checkBoxHcwEnabled.Enabled = false;
          groupBoxHcwSettings.Enabled = false;
          groupBoxHcwRepeatDelay.Enabled = false;
          using (Settings xmlwriter = new MPSettings())
          {
            xmlwriter.SetValueAsBool("remote", "HCW", false);
          }
        }
        HCWLearn.Enabled = buttonHcwDefaults.Enabled = checkBoxHcwEnabled.Checked;

        toolTip.SetToolTip(hScrollBarHcwButtonRelease, string.Format("{0} msec.", hScrollBarHcwButtonRelease.Value));
        toolTip.SetToolTip(hScrollBarHcwRepeatFilter, hScrollBarHcwRepeatFilter.Value.ToString());
        Type repeatSpeed = typeof (hcwRepeatSpeed);
        toolTip.SetToolTip(hScrollBarHcwRepeatSpeed, Enum.GetName(repeatSpeed, 2 - hScrollBarHcwRepeatSpeed.Value));
        toolTip.SetToolTip(checkBoxHcwKeepControl,
                           "If checked, MediaPortal keeps control of the remote. Only applications launched by\nMediaPortal can steal focus (external Players, MyPrograms, ...).");
        toolTip.SetToolTip(checkBoxHcwAllowExternal,
                           "If checked, MediaPortal does not keep control of the remote\nwhen it looses focus.");

        #endregion

        #region X10

        checkBoxX10Enabled.Checked = xmlreader.GetValueAsBool("remote", "X10", false);
        radioButtonX10Medion.Checked = xmlreader.GetValueAsBool("remote", "X10Medion", false);
        radioButtonX10Ati.Checked = xmlreader.GetValueAsBool("remote", "X10ATI", false);
        radioButtonX10Firefly.Checked = xmlreader.GetValueAsBool("remote", "X10Firefly", false);
        radioButtonX10Other.Checked = (!radioButtonX10Medion.Checked && !radioButtonX10Ati.Checked &&
                                       !radioButtonX10Firefly.Checked);
        checkBoxX10ExtendedLogging.Checked = xmlreader.GetValueAsBool("remote", "X10VerboseLog", false);
        checkBoxX10ChannelControl.Checked = xmlreader.GetValueAsBool("remote", "X10UseChannelControl", false);
        x10Channel = xmlreader.GetValueAsInt("remote", "X10Channel", 0);
        TextBoxChannelNumber.Text = x10Channel.ToString();

        radioButtonX10Medion.Enabled =
          radioButtonX10Ati.Enabled =
          radioButtonX10Other.Enabled =
          radioButtonX10Firefly.Enabled =
          buttonX10LearnMapping.Enabled =
          groupBoxX10Settings.Enabled = checkBoxX10Enabled.Checked;

        TextBoxChannelNumber.Enabled = checkBoxX10ChannelControl.Enabled && checkBoxX10ChannelControl.Checked;

        //See if the X10 driver is installed
        try
        {
          if (X10Remote == null)
          {
            X10Remote = new X10Remote();
            X10Remote.Init();
          }

          if (X10Remote._remotefound == false)
          {
            Log.Warn("x10Remote: Can't initialize");
            labelX10DriverInfo.Visible = true;
            labelX10DriverInfo.ForeColor = Color.Red;
            labelX10DriverInfo.Text =
              "The X10 Driver is not installed.\nYou have to use the driver below, or your remote might not work with MediaPortal.";
            linkLabelDownloadX10.Visible = true;
            labelX10Status.Visible = false;
            buttonX10LearnMapping.Enabled = false;
            checkBoxX10Enabled.Checked = false;
            checkBoxX10Enabled.Enabled = false;
          }
          else
          {
            Log.Info("x10Remote:Initialized");
            labelX10DriverInfo.Visible = false;
            linkLabelDownloadX10.Visible = true;
            labelX10Status.Visible = true;
            labelX10Status.Text =
              "The X10 Driver is installed. If you experience problems with this driver,\nuninstall your current driver and download the version below";
          }
        }
        catch (COMException)
        {
          Log.Warn("x10Remote: Can't initialize");
          labelX10DriverInfo.Visible = true;
          labelX10DriverInfo.ForeColor = Color.Red;
          labelX10DriverInfo.Text =
            "The X10 Driver is not installed.\nYou have to use the driver below, or your remote might not work with MediaPortal.";
          linkLabelDownloadX10.Visible = true;
          labelX10Status.Visible = false;
          buttonX10LearnMapping.Enabled = false;
          checkBoxX10Enabled.Checked = false;
          checkBoxX10Enabled.Enabled = false;
        }

        #endregion

        #region Generic HID

        //We want HID to be enabled by default
        //HID is also using MCE legacy setting for a smooth transition from MCE to HID
        checkBoxHidEnabled.Checked = xmlreader.GetValueAsBool("remote", "HidEnabled", true) || xmlreader.GetValueAsBool("remote", "MCE", false);
        checkBoxHidExtendedLogging.Checked = xmlreader.GetValueAsBool("remote", "HidVerbose", false) || xmlreader.GetValueAsBool("remote", "MCEVerboseLog", false);
        numericRepeatDelay.Value = xmlreader.GetValueAsInt("remote", "HidRepeatDelayInMs", -1);
        numericRepeatSpeed.Value = xmlreader.GetValueAsInt("remote", "HidRepeatSpeedInMs", -1);        
        buttonHidMapping.Enabled = checkBoxHidEnabled.Checked;

        #endregion

        #region AppCommand

        mpCheckBoxAppCommandEnabled.Checked = xmlreader.GetValueAsBool("remote", "AppCommand", false);
        mpCheckBoxAppCommandVerbose.Checked = xmlreader.GetValueAsBool("remote", "AppCommandVerbose", false);
        checkBoxAppCommandBackground.Checked = xmlreader.GetValueAsBool("remote", "AppCommandBackground", false);
        mpButtonAppCommandMapping.Enabled = mpCheckBoxAppCommandEnabled.Checked;

        #endregion

        #region IRTrans

        checkBoxIrTransEnabled.Checked = xmlreader.GetValueAsBool("remote", "IRTrans", false);
        textBoxRemoteModel.Text = xmlreader.GetValueAsString("remote", "IRTransRemoteModel", "mediacenter");
        textBoxIrTransServerPort.Value = xmlreader.GetValueAsInt("remote", "IRTransServerPort", 21000);
        textBoxIrTransServerPort.Text = textBoxIrTransServerPort.Value.ToString();
        checkBoxIrTransExtendedLogging.Checked = xmlreader.GetValueAsBool("remote", "IRTransVerboseLog", false);
        buttonIrTransMapping.Enabled = checkBoxIrTransEnabled.Checked;
        groupBoxIrTransStatus.Enabled = groupBoxIrTransServerSettings.Enabled = checkBoxIrTransEnabled.Checked;

        #endregion

        #region FireDTV

        // Enable wiki link if x64 is detected
        bool _isx64 = Util.Win32API.Check64Bit();
        groupBox_x64.Visible = _isx64;
        linkLabel_x64.Enabled = _isx64;

        try
        {
          string prgPath = Environment.GetEnvironmentVariable("ProgramW6432");
          if (string.IsNullOrEmpty(prgPath))
          {
            prgPath = Environment.GetEnvironmentVariable("ProgramFiles");
          }

          // Look for Digital Everywhere's software which uses a hardcoded path
          string fullDllPath = Path.Combine(prgPath, @"FireDTV\Tools\FiresatApi.dll");
          if (File.Exists(fullDllPath))
          {
            // Is the FireDTV remote enabled
            checkBoxFireDTVEnabled.Checked = xmlreader.GetValueAsBool("remote", "FireDTV", false);

            // Fill combobox with list of availabe FireDTV recievers
            try
            {
              Log.Info("FireDTV: Using FiresatApi.dll located in FireDTV's install path {0}", fullDllPath);
              fireDTV = new FireDTVControl((IntPtr) 0);
              if (fireDTV.OpenDrivers())
              {
                comboBoxFireDTVReceiver.DataSource = fireDTV.SourceFilters;
                comboBoxFireDTVReceiver.DisplayMember = "FriendlyName";
                comboBoxFireDTVReceiver.ValueMember = "Name";
              }
            }
            catch (Exception e)
            {
              Log.Error("FireDTVRemote: Exception during setting combo {0}", e.Message);
            }

            // Set the rest of the controls
            checkBoxFireDTVExtendedLogging.Checked = xmlreader.GetValueAsBool("remote", "FireDTVVerboseLog", false);
            string deviceName = xmlreader.GetValueAsString("remote", "FireDTVDeviceName", string.Empty);
            try
            {
              if ((deviceName != null) && (!deviceName.Equals(string.Empty)))
              {
                comboBoxFireDTVReceiver.SelectedValue = deviceName;
              }
            }
            catch (InvalidOperationException ex)
            {
              Log.Error("FireDTV: Error setting device name - device unplugged?! - {0}", ex.Message);
            }

            // Enable/Disable the controls
            buttonFireDTVMapping.Enabled = checkBoxFireDTVEnabled.Checked;
            checkBoxFireDTVExtendedLogging.Enabled = checkBoxFireDTVEnabled.Checked;
            comboBoxFireDTVReceiver.Enabled = checkBoxFireDTVEnabled.Checked;
            groupBoxFireDTVRecieiverSettings.Enabled = checkBoxFireDTVEnabled.Checked;
          }
          else
          {
            checkBoxFireDTVEnabled.Enabled = false;
            checkBoxFireDTVExtendedLogging.Enabled = false;
            buttonFireDTVMapping.Enabled = false;
            groupBoxFireDTVRecieiverSettings.Enabled = false;
            Log.Info("FireDTV: FiresatApi.dll could not be found on your system!");
          }
        }
        catch (Exception)
        {
          Log.Error("FireDTVRemote: Exception during checking path and dll");
        }

        #endregion

        #region Sceneo

        checkBoxCentareaEnabled.Checked = xmlreader.GetValueAsBool("remote", "Centarea", false);
        checkBoxCentareaVerbose.Checked = xmlreader.GetValueAsBool("remote", "CentareaVerbose", false);
        checkBoxCentareaReMapMouseButton.Checked = xmlreader.GetValueAsBool("remote", "CentareaMouseOkMap", true);
        checkBoxMapJoystick.Checked = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false);

        #endregion
      }
    }