From: <an...@us...> - 2007-09-02 17:09:50
|
Revision: 882 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=882&view=rev Author: and-81 Date: 2007-09-02 10:09:43 -0700 (Sun, 02 Sep 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/IgorPlug USB Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.resx trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Microsoft MCE Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Pronto.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite.sln Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrCode.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DeviceAccess.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IRCodeConversion.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MceIrCode.cs Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -30,7 +30,7 @@ #region Variables - RemoteButtonHandler _remoteButtonHandler = null; + RemoteHandler _remoteHandler = null; FileStream _deviceStream; byte[] _deviceBuffer; @@ -79,21 +79,17 @@ #endregion - #region IIRServerPlugin Members + #region Implementation - public string Name { get { return "Custom HID Receiver"; } } - public string Version { get { return "1.0.3.4"; } } - public string Author { get { return "and-81"; } } - public string Description { get { return "Supports HID USB devices."; } } - public bool CanReceive { get { return true; } } - public bool CanTransmit { get { return false; } } - public bool CanLearn { get { return false; } } - public bool CanConfigure { get { return true; } } + public override string Name { get { return "Custom HID Receiver"; } } + public override string Version { get { return "1.0.3.4"; } } + public override string Author { get { return "and-81"; } } + public override string Description { get { return "Supports HID USB devices."; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { - get { return _remoteButtonHandler; } - set { _remoteButtonHandler = value; } + get { return _remoteHandler; } + set { _remoteHandler = value; } } public string[] AvailablePorts { get { return Ports; } } @@ -108,7 +104,7 @@ } } - public bool Start() + public override bool Start() { if (String.IsNullOrEmpty(_deviceID)) throw new Exception("No HID Device selected for use"); @@ -134,9 +130,9 @@ return true; } - public void Suspend() { } - public void Resume() { } - public void Stop() + public override void Suspend() { } + public override void Resume() { } + public override void Stop() { if (_deviceStream == null) return; @@ -156,12 +152,6 @@ public bool Transmit(string file) { return false; } public LearnStatus Learn(string file) { return LearnStatus.Failure; } - public bool SetPort(string port) { return true; } - - #endregion IIRServerPlugin Members - - #region Implementation - protected virtual void Dispose(bool disposeManagedResources) { // process only if mananged and unmanaged resources have @@ -312,7 +302,7 @@ if (bytesRead == 0) throw new Exception("Error reading from HID Device, zero bytes read"); - if (_remoteButtonHandler != null) + if (_remoteHandler != null) { string keyCode = String.Empty; @@ -333,13 +323,13 @@ if (timeSpan.Milliseconds >= _repeatDelay) { - _remoteButtonHandler(keyCode); + _remoteHandler(keyCode); _lastCodeTime = DateTime.Now; } } else { - _remoteButtonHandler(keyCode); + _remoteHandler(keyCode); _lastCodeTime = DateTime.Now; _lastKeyCode = keyCode; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.csproj 2007-09-02 17:09:43 UTC (rev 882) @@ -33,6 +33,25 @@ <TreatWarningsAsErrors>true</TreatWarningsAsErrors> <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>bin\x86\Release\</OutputPath> + <Optimize>true</Optimize> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <DebugType> + </DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> Modified: trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -187,7 +187,7 @@ #region Variables - static RemoteHandler _remoteButtonHandler = null; + static RemoteHandler _remoteHandler = null; static FileStream _deviceStream; static byte[] _deviceBuffer; @@ -243,8 +243,8 @@ public RemoteHandler RemoteCallback { - get { return _remoteButtonHandler; } - set { _remoteButtonHandler = value; } + get { return _remoteHandler; } + set { _remoteHandler = value; } } static void OpenDevice() @@ -354,8 +354,8 @@ { _lastCodeTime = DateTime.Now; - if (_remoteButtonHandler != null) - _remoteButtonHandler(keyCode.ToString()); + if (_remoteHandler != null) + _remoteHandler(keyCode.ToString()); } else { @@ -366,8 +366,8 @@ { _lastCodeTime = DateTime.Now; - if (_remoteButtonHandler != null) - _remoteButtonHandler(keyCode.ToString()); + if (_remoteHandler != null) + _remoteHandler(keyCode.ToString()); } } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -38,7 +38,7 @@ //Sets up callback so that other forms can catch a key press public delegate void HCWEvent(int keypress); - public event HCWEvent HCWKeyPressed; + //public event HCWEvent HCWKeyPressed; #endregion Delegates @@ -77,11 +77,6 @@ string _lastCode = String.Empty; DateTime _lastCodeTime = DateTime.Now; - // ------- - - int _abortLearn = AllowLearn; - bool _learnTimedOut; - #endregion Variables #region Implementation Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/IgorPlug USB Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/IgorPlug USB Receiver.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/IgorPlug USB Receiver.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -13,7 +13,7 @@ namespace IgorPlugUSBReceiver { - public class IgorPlugUSBReceiver : IRServerPlugin + public class IgorPlugUSBReceiver : IRServerPlugin, IRemoteReceiver { #region Constants @@ -59,17 +59,28 @@ #endregion Interop - #region IIRServerPlugin Members + #region Implementation - public string Name { get { return "IgorPlug USB"; } } - public string Version { get { return "1.0.3.4"; } } - public string Author { get { return "and-81"; } } - public string Description { get { return "IgorPlug USB Receiver"; } } - public bool CanReceive { get { return true; } } - public bool CanTransmit { get { return false; } } - public bool CanLearn { get { return false; } } - public bool CanConfigure { get { return false; } } + public override string Name { get { return "IgorPlug USB"; } } + public override string Version { get { return "1.0.3.4"; } } + public override string Author { get { return "and-81"; } } + public override string Description { get { return "IgorPlug USB Receiver"; } } + public override bool Start() + { + ThreadStart readThreadStart = new ThreadStart(ReadThread); + _readThread = new Thread(readThreadStart); + _readThread.Start(); + + return true; + } + public override void Suspend() { } + public override void Resume() { } + public override void Stop() + { + _readThread.Abort(); + } + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } @@ -83,21 +94,7 @@ public string[] AvailablePorts { get { return Ports; } } public void Configure() { } - public bool Start() - { - ThreadStart readThreadStart = new ThreadStart(ReadThread); - _readThread = new Thread(readThreadStart); - _readThread.Start(); - return true; - } - public void Suspend() { } - public void Resume() { } - public void Stop() - { - _readThread.Abort(); - } - public bool Transmit(string file) { return false; } public LearnStatus Learn(out byte[] data) { @@ -105,12 +102,6 @@ return LearnStatus.Failure; } - public bool SetPort(string port) { return true; } - - #endregion IIRServerPlugin Members - - #region Implementation - void ReadThread() { try Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.Designer.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.Designer.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -37,14 +37,14 @@ this.buttonCancel = new System.Windows.Forms.Button(); this.groupBoxTimes = new System.Windows.Forms.GroupBox(); this.toolTips = new System.Windows.Forms.ToolTip(this.components); - this.comboBoxBlasterType = new System.Windows.Forms.ComboBox(); this.numericUpDownLearnTimeout = new System.Windows.Forms.NumericUpDown(); this.numericUpDownKeyHeldDelay = new System.Windows.Forms.NumericUpDown(); this.numericUpDownKeyRepeatDelay = new System.Windows.Forms.NumericUpDown(); this.checkBoxHandleKeyboardLocal = new System.Windows.Forms.CheckBox(); this.checkBoxHandleMouseLocal = new System.Windows.Forms.CheckBox(); this.numericUpDownMouseSensitivity = new System.Windows.Forms.NumericUpDown(); - this.labelBlasterType = new System.Windows.Forms.Label(); + this.checkBoxDisableMCEServices = new System.Windows.Forms.CheckBox(); + this.buttonAdvanced = new System.Windows.Forms.Button(); this.labelLearnIRTimeout = new System.Windows.Forms.Label(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabPageBasic = new System.Windows.Forms.TabPage(); @@ -58,7 +58,6 @@ this.tabPageMouse = new System.Windows.Forms.TabPage(); this.labelMouseSensitivity = new System.Windows.Forms.Label(); this.checkBoxEnableMouse = new System.Windows.Forms.CheckBox(); - this.checkBoxLearnAsPronto = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownButtonRepeatDelay)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownButtonHeldDelay)).BeginInit(); this.groupBoxTimes.SuspendLayout(); @@ -148,7 +147,7 @@ this.buttonOK.Location = new System.Drawing.Point(120, 208); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(64, 24); - this.buttonOK.TabIndex = 1; + this.buttonOK.TabIndex = 2; this.buttonOK.Text = "OK"; this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); @@ -159,7 +158,7 @@ this.buttonCancel.Location = new System.Drawing.Point(192, 208); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(64, 24); - this.buttonCancel.TabIndex = 2; + this.buttonCancel.TabIndex = 3; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); @@ -177,16 +176,6 @@ this.groupBoxTimes.TabStop = false; this.groupBoxTimes.Text = "Remote button timing (in milliseconds)"; // - // comboBoxBlasterType - // - this.comboBoxBlasterType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxBlasterType.FormattingEnabled = true; - this.comboBoxBlasterType.Location = new System.Drawing.Point(144, 40); - this.comboBoxBlasterType.Name = "comboBoxBlasterType"; - this.comboBoxBlasterType.Size = new System.Drawing.Size(88, 21); - this.comboBoxBlasterType.TabIndex = 1; - this.toolTips.SetToolTip(this.comboBoxBlasterType, "Choose between Microsoft or SMK manufactured MCE IR transceivers"); - // // numericUpDownLearnTimeout // this.numericUpDownLearnTimeout.Increment = new decimal(new int[] { @@ -194,7 +183,7 @@ 0, 0, 0}); - this.numericUpDownLearnTimeout.Location = new System.Drawing.Point(144, 72); + this.numericUpDownLearnTimeout.Location = new System.Drawing.Point(144, 40); this.numericUpDownLearnTimeout.Maximum = new decimal(new int[] { 60000, 0, @@ -207,7 +196,7 @@ 0}); this.numericUpDownLearnTimeout.Name = "numericUpDownLearnTimeout"; this.numericUpDownLearnTimeout.Size = new System.Drawing.Size(88, 20); - this.numericUpDownLearnTimeout.TabIndex = 3; + this.numericUpDownLearnTimeout.TabIndex = 1; this.numericUpDownLearnTimeout.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.numericUpDownLearnTimeout.ThousandsSeparator = true; this.toolTips.SetToolTip(this.numericUpDownLearnTimeout, "When teaching IR commands this is how long before the process times out"); @@ -321,21 +310,36 @@ 0, 65536}); // - // labelBlasterType + // checkBoxDisableMCEServices // - this.labelBlasterType.Location = new System.Drawing.Point(8, 40); - this.labelBlasterType.Name = "labelBlasterType"; - this.labelBlasterType.Size = new System.Drawing.Size(136, 21); - this.labelBlasterType.TabIndex = 0; - this.labelBlasterType.Text = "Blaster manufacturer:"; - this.labelBlasterType.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.checkBoxDisableMCEServices.Checked = true; + this.checkBoxDisableMCEServices.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxDisableMCEServices.Location = new System.Drawing.Point(8, 80); + this.checkBoxDisableMCEServices.Name = "checkBoxDisableMCEServices"; + this.checkBoxDisableMCEServices.Size = new System.Drawing.Size(224, 24); + this.checkBoxDisableMCEServices.TabIndex = 2; + this.checkBoxDisableMCEServices.Text = "Disable Windows Media Center services"; + this.toolTips.SetToolTip(this.checkBoxDisableMCEServices, "Disable Microsoft Windows Media Center services to prevent interference with IR S" + + "erver"); + this.checkBoxDisableMCEServices.UseVisualStyleBackColor = true; // + // buttonAdvanced + // + this.buttonAdvanced.Location = new System.Drawing.Point(8, 208); + this.buttonAdvanced.Name = "buttonAdvanced"; + this.buttonAdvanced.Size = new System.Drawing.Size(72, 24); + this.buttonAdvanced.TabIndex = 1; + this.buttonAdvanced.Text = "Advanced"; + this.toolTips.SetToolTip(this.buttonAdvanced, "Click here for advanced driver settings"); + this.buttonAdvanced.UseVisualStyleBackColor = true; + this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click); + // // labelLearnIRTimeout // - this.labelLearnIRTimeout.Location = new System.Drawing.Point(8, 72); + this.labelLearnIRTimeout.Location = new System.Drawing.Point(8, 40); this.labelLearnIRTimeout.Name = "labelLearnIRTimeout"; this.labelLearnIRTimeout.Size = new System.Drawing.Size(136, 20); - this.labelLearnIRTimeout.TabIndex = 2; + this.labelLearnIRTimeout.TabIndex = 0; this.labelLearnIRTimeout.Text = "Learn IR timeout:"; this.labelLearnIRTimeout.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -353,11 +357,9 @@ // // tabPageBasic // - this.tabPageBasic.Controls.Add(this.checkBoxLearnAsPronto); + this.tabPageBasic.Controls.Add(this.checkBoxDisableMCEServices); this.tabPageBasic.Controls.Add(this.labelLearnIRTimeout); - this.tabPageBasic.Controls.Add(this.labelBlasterType); this.tabPageBasic.Controls.Add(this.numericUpDownLearnTimeout); - this.tabPageBasic.Controls.Add(this.comboBoxBlasterType); this.tabPageBasic.Location = new System.Drawing.Point(4, 22); this.tabPageBasic.Name = "tabPageBasic"; this.tabPageBasic.Padding = new System.Windows.Forms.Padding(3); @@ -478,17 +480,6 @@ this.checkBoxEnableMouse.Text = "Enable mouse input"; this.checkBoxEnableMouse.UseVisualStyleBackColor = true; // - // checkBoxLearnAsPronto - // - this.checkBoxLearnAsPronto.Enabled = false; - this.checkBoxLearnAsPronto.Location = new System.Drawing.Point(8, 104); - this.checkBoxLearnAsPronto.Name = "checkBoxLearnAsPronto"; - this.checkBoxLearnAsPronto.Size = new System.Drawing.Size(224, 24); - this.checkBoxLearnAsPronto.TabIndex = 4; - this.checkBoxLearnAsPronto.Text = "Store learned codes in Pronto format"; - this.toolTips.SetToolTip(this.checkBoxLearnAsPronto, "Store learned IR commands in Philips Pronto format"); - this.checkBoxLearnAsPronto.UseVisualStyleBackColor = true; - // // Configure // this.AcceptButton = this.buttonOK; @@ -497,6 +488,7 @@ this.CancelButton = this.buttonCancel; this.ClientSize = new System.Drawing.Size(264, 239); this.ControlBox = false; + this.Controls.Add(this.buttonAdvanced); this.Controls.Add(this.tabControl); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); @@ -531,8 +523,6 @@ private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.GroupBox groupBoxTimes; private System.Windows.Forms.ToolTip toolTips; - private System.Windows.Forms.ComboBox comboBoxBlasterType; - private System.Windows.Forms.Label labelBlasterType; private System.Windows.Forms.Label labelLearnIRTimeout; private System.Windows.Forms.NumericUpDown numericUpDownLearnTimeout; private System.Windows.Forms.TabControl tabControl; @@ -552,6 +542,7 @@ private System.Windows.Forms.NumericUpDown numericUpDownMouseSensitivity; private System.Windows.Forms.CheckBox checkBoxHandleMouseLocal; private System.Windows.Forms.CheckBox checkBoxEnableMouse; - private System.Windows.Forms.CheckBox checkBoxLearnAsPronto; + private System.Windows.Forms.CheckBox checkBoxDisableMCEServices; + private System.Windows.Forms.Button buttonAdvanced; } } \ No newline at end of file Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -13,22 +13,15 @@ #region Properties - public BlasterType BlastType - { - get { return (BlasterType)Enum.Parse(typeof(BlasterType), comboBoxBlasterType.SelectedItem as string, true); } - set { comboBoxBlasterType.SelectedItem = Enum.GetName(typeof(BlasterType), value); } - } - public int LearnTimeout { get { return Decimal.ToInt32(numericUpDownLearnTimeout.Value); } set { numericUpDownLearnTimeout.Value = new Decimal(value); } } - - public bool LearnAsPronto + public bool DisableMceServices { - get { return checkBoxLearnAsPronto.Checked; } - set { checkBoxLearnAsPronto.Checked = value; } + get { return checkBoxDisableMCEServices.Checked; } + set { checkBoxDisableMCEServices.Checked = value; } } public bool EnableRemote @@ -91,15 +84,18 @@ public Configure() { InitializeComponent(); - - comboBoxBlasterType.Items.Clear(); - comboBoxBlasterType.Items.AddRange(Enum.GetNames(typeof(BlasterType))); } #endregion Constructor #region Buttons + private void buttonAdvanced_Click(object sender, EventArgs e) + { + Advanced advanced = new Advanced(); + advanced.ShowDialog(this); + } + private void buttonOK_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.resx =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.resx 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.resx 2007-09-02 17:09:43 UTC (rev 882) @@ -120,7 +120,4 @@ <metadata name="toolTips.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> - <metadata name="toolTips.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>17, 17</value> - </metadata> </root> \ No newline at end of file Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DeviceAccess.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DeviceAccess.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DeviceAccess.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -1,303 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Runtime.InteropServices; -using System.Text; - -using Microsoft.Win32.SafeHandles; - -namespace MicrosoftMceTransceiver -{ - - /// <summary> - /// Provides access to the MCE driver. - /// </summary> - public static class DeviceAccess - { - - #region Enumerations - - [Flags] - enum Digcfs - { - None = 0x00, - Default = 0x01, - Present = 0x02, - AllClasses = 0x04, - Profile = 0x08, - DeviceInterface = 0x10, - } - - [Flags] - public enum FileShares - { - None = 0x00, - Read = 0x01, - Write = 0x02, - Delete = 0x04, - } - - public enum CreationDisposition - { - None = 0, - New = 1, - CreateAlways = 2, - OpenExisting = 3, - OpenAlways = 4, - TruncateExisting = 5, - } - - [Flags] - public enum FileAttributes : uint - { - Readonly = 0x00000001, - Hidden = 0x00000002, - System = 0x00000004, - Directory = 0x00000010, - Archive = 0x00000020, - Device = 0x00000040, - Normal = 0x00000080, - Temporary = 0x00000100, - SparseFile = 0x00000200, - ReparsePoint = 0x00000400, - Compressed = 0x00000800, - Offline = 0x00001000, - NotContentIndexed = 0x00002000, - Encrypted = 0x00004000, - Write_Through = 0x80000000, - Overlapped = 0x40000000, - NoBuffering = 0x20000000, - RandomAccess = 0x10000000, - SequentialScan = 0x08000000, - DeleteOnClose = 0x04000000, - BackupSemantics = 0x02000000, - PosixSemantics = 0x01000000, - OpenReparsePoint = 0x00200000, - OpenNoRecall = 0x00100000, - FirstPipeInstance = 0x00080000, - } - - [Flags] - public enum FileAccessTypes : uint - { - GenericRead = 0x80000000, - GenericWrite = 0x40000000, - GenericExecute = 0x20000000, - GenericAll = 0x10000000, - } - - #endregion Enumerations - - #region Structures - - [StructLayout(LayoutKind.Sequential)] - struct DeviceInfoData - { - public int Size; - public Guid Class; - public uint DevInst; - public IntPtr Reserved; - } - - [StructLayout(LayoutKind.Sequential)] - struct DeviceInterfaceData - { - public int Size; - public Guid Class; - public uint Flags; - public uint Reserved; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - struct DeviceInterfaceDetailData - { - public int Size; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] - public string DevicePath; - } - - #endregion Structures - - #region Interop - - [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto)] - static extern SafeFileHandle CreateFile( - [MarshalAs(UnmanagedType.LPTStr)] string fileName, - [MarshalAs(UnmanagedType.U4)] FileAccessTypes fileAccess, - [MarshalAs(UnmanagedType.U4)] FileShares fileShare, - IntPtr securityAttributes, - [MarshalAs(UnmanagedType.U4)] CreationDisposition creationDisposition, - [MarshalAs(UnmanagedType.U4)] FileAttributes flags, - IntPtr templateFile); - - [DllImport("kernel32")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool CancelIo( - SafeFileHandle handle); - - [DllImport("setupapi", CharSet = CharSet.Auto)] - static extern IntPtr SetupDiGetClassDevs( - ref Guid classGuid, - [MarshalAs(UnmanagedType.LPTStr)] string enumerator, - IntPtr hwndParent, - [MarshalAs(UnmanagedType.U4)] Digcfs flags); - - [DllImport("setupapi", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool SetupDiEnumDeviceInfo( - IntPtr handle, - int index, - ref DeviceInfoData deviceInfoData); - - [DllImport("setupapi", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool SetupDiEnumDeviceInterfaces( - IntPtr handle, - ref DeviceInfoData deviceInfoData, - ref Guid guidClass, - int memberIndex, - ref DeviceInterfaceData deviceInterfaceData); - - [DllImport("setupapi", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool SetupDiGetDeviceInterfaceDetail( - IntPtr handle, - ref DeviceInterfaceData deviceInterfaceData, - IntPtr unused1, - int unused2, - ref uint requiredSize, - IntPtr unused3); - - [DllImport("setupapi", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool SetupDiGetDeviceInterfaceDetail( - IntPtr handle, - ref DeviceInterfaceData deviceInterfaceData, - ref DeviceInterfaceDetailData deviceInterfaceDetailData, - uint detailSize, - IntPtr unused1, - IntPtr unused2); - - [DllImport("setupapi")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool SetupDiDestroyDeviceInfoList( - IntPtr handle); - - #endregion Interop - - #region Methods - - /// <summary> - /// Find the device path for the supplied Device Class Guid. - /// </summary> - /// <param name="classGuid">GUID to locate device with.</param> - /// <returns>Device path.</returns> - public static string FindDevice(Guid classGuid) - { - string devicePath = null; - - IntPtr handle = SetupDiGetClassDevs(ref classGuid, null, IntPtr.Zero, Digcfs.DeviceInterface | Digcfs.Present); - - if (handle.ToInt32() == -1) - return null; - - for (int deviceIndex = 0; ; deviceIndex++) - { - DeviceInfoData deviceInfoData = new DeviceInfoData(); - deviceInfoData.Size = Marshal.SizeOf(deviceInfoData); - - if (!SetupDiEnumDeviceInfo(handle, deviceIndex, ref deviceInfoData)) - { - int lastError = Marshal.GetLastWin32Error(); - - // out of devices or do we have an error? - if (lastError != 0x0103 && lastError != 0x007E) - { - SetupDiDestroyDeviceInfoList(handle); - throw new Win32Exception(lastError); - } - - SetupDiDestroyDeviceInfoList(handle); - break; - } - - DeviceInterfaceData deviceInterfaceData = new DeviceInterfaceData(); - deviceInterfaceData.Size = Marshal.SizeOf(deviceInterfaceData); - - if (!SetupDiEnumDeviceInterfaces(handle, ref deviceInfoData, ref classGuid, 0, ref deviceInterfaceData)) - { - SetupDiDestroyDeviceInfoList(handle); - throw new Win32Exception(Marshal.GetLastWin32Error()); - } - - uint cbData = 0; - - if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, IntPtr.Zero, 0, ref cbData, IntPtr.Zero) && cbData == 0) - { - SetupDiDestroyDeviceInfoList(handle); - throw new Win32Exception(Marshal.GetLastWin32Error()); - } - - DeviceInterfaceDetailData deviceInterfaceDetailData = new DeviceInterfaceDetailData(); - deviceInterfaceDetailData.Size = 5; - - if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, ref deviceInterfaceDetailData, cbData, IntPtr.Zero, IntPtr.Zero)) - { - SetupDiDestroyDeviceInfoList(handle); - throw new Win32Exception(Marshal.GetLastWin32Error()); - } - - if ((deviceInterfaceDetailData.DevicePath.IndexOf("#vid_03ee&pid_2501") != -1) || // Mitsumi MCE remote - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_043e&pid_9803") != -1) || // LG - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_045e&pid_00a0") != -1) || // Microsoft - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_0471&pid_0815") != -1) || // Microsoft/Philips 2005 - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_0471&pid_060c") != -1) || // Philips (HP branded) - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_045e&pid_006d") != -1) || // Microsoft/Philips 2004 - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_0609&pid_031d") != -1) || // SMK/Toshiba G83C0004D410 (Hauppauge) - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_0609&pid_0322") != -1) || // SMK (Sony VAIO) - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_107b&pid_3009") != -1) || // FIC Spectra/Mycom Mediacenter - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_1308&pid_c001") != -1) || // Shuttle - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_1460&pid_9150") != -1) || // HP - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_1509&pid_9242") != -1) || // Fujitsu Scaleo-E - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_1784&pid_0001") != -1) || // Topseed - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_179d&pid_0010") != -1) || // Ricavision internal - (deviceInterfaceDetailData.DevicePath.IndexOf("#vid_195d&pid_7002") != -1) || // Itron ione Libra Q-11 - (deviceInterfaceDetailData.DevicePath.StartsWith(@"\\?\hid#irdevice&col01#2"))) // Microsoft/Philips 2005 (Vista) - { - SetupDiDestroyDeviceInfoList(handle); - devicePath = deviceInterfaceDetailData.DevicePath; - break; - } - } - - return devicePath; - } - - /// <summary> - /// Open a handle to the device driver. - /// </summary> - /// <param name="devicePath">Device path.</param> - /// <param name="access">Access type.</param> - /// <param name="share">Share type.</param> - /// <returns>Handle to device driver.</returns> - public static SafeFileHandle OpenHandle(string devicePath, FileAccessTypes access, FileShares share) - { - return CreateFile(devicePath, access, share, - IntPtr.Zero, CreationDisposition.OpenExisting, FileAttributes.Overlapped, IntPtr.Zero); - } - - /// <summary> - /// Cancel IO for device. - /// </summary> - /// <param name="deviceHandle">Handle to device.</param> - /// <returns>Success.</returns> - public static bool CancelDeviceIo(SafeFileHandle deviceHandle) - { - return CancelIo(deviceHandle); - } - - #endregion Methods - - } - -} Added: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -0,0 +1,283 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; + +using Microsoft.Win32.SafeHandles; + +namespace MicrosoftMceTransceiver +{ + + public abstract class Driver + { + + #region Enumerations + + [Flags] + enum Digcfs + { + None = 0x00, + Default = 0x01, + Present = 0x02, + AllClasses = 0x04, + Profile = 0x08, + DeviceInterface = 0x10, + } + + [Flags] + public enum FileShares + { + None = 0x00, + Read = 0x01, + Write = 0x02, + Delete = 0x04, + } + + public enum CreationDisposition + { + None = 0, + New = 1, + CreateAlways = 2, + OpenExisting = 3, + OpenAlways = 4, + TruncateExisting = 5, + } + + [Flags] + public enum FileAttributes : uint + { + Readonly = 0x00000001, + Hidden = 0x00000002, + System = 0x00000004, + Directory = 0x00000010, + Archive = 0x00000020, + Device = 0x00000040, + Normal = 0x00000080, + Temporary = 0x00000100, + SparseFile = 0x00000200, + ReparsePoint = 0x00000400, + Compressed = 0x00000800, + Offline = 0x00001000, + NotContentIndexed = 0x00002000, + Encrypted = 0x00004000, + Write_Through = 0x80000000, + Overlapped = 0x40000000, + NoBuffering = 0x20000000, + RandomAccess = 0x10000000, + SequentialScan = 0x08000000, + DeleteOnClose = 0x04000000, + BackupSemantics = 0x02000000, + PosixSemantics = 0x01000000, + OpenReparsePoint = 0x00200000, + OpenNoRecall = 0x00100000, + FirstPipeInstance = 0x00080000, + } + + [Flags] + public enum FileAccessTypes : uint + { + GenericRead = 0x80000000, + GenericWrite = 0x40000000, + GenericExecute = 0x20000000, + GenericAll = 0x10000000, + } + + #endregion Enumerations + + #region Structures + + [StructLayout(LayoutKind.Sequential)] + struct DeviceInfoData + { + public int Size; + public Guid Class; + public uint DevInst; + public IntPtr Reserved; + } + + [StructLayout(LayoutKind.Sequential)] + struct DeviceInterfaceData + { + public int Size; + public Guid Class; + public uint Flags; + public uint Reserved; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + struct DeviceInterfaceDetailData + { + public int Size; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string DevicePath; + } + + #endregion Structures + + #region Interop + + [DllImport("setupapi.dll", CharSet = CharSet.Auto)] + static extern IntPtr SetupDiGetClassDevs( + ref Guid classGuid, + [MarshalAs(UnmanagedType.LPTStr)] string enumerator, + IntPtr hwndParent, + [MarshalAs(UnmanagedType.U4)] Digcfs flags); + + [DllImport("setupapi.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetupDiEnumDeviceInfo( + IntPtr handle, + int index, + ref DeviceInfoData deviceInfoData); + + [DllImport("setupapi.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetupDiEnumDeviceInterfaces( + IntPtr handle, + ref DeviceInfoData deviceInfoData, + ref Guid guidClass, + int memberIndex, + ref DeviceInterfaceData deviceInterfaceData); + + [DllImport("setupapi.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetupDiGetDeviceInterfaceDetail( + IntPtr handle, + ref DeviceInterfaceData deviceInterfaceData, + IntPtr unused1, + int unused2, + ref uint requiredSize, + IntPtr unused3); + + [DllImport("setupapi.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetupDiGetDeviceInterfaceDetail( + IntPtr handle, + ref DeviceInterfaceData deviceInterfaceData, + ref DeviceInterfaceDetailData deviceInterfaceDetailData, + uint detailSize, + IntPtr unused1, + IntPtr unused2); + + [DllImport("setupapi.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetupDiDestroyDeviceInfoList( + IntPtr handle); + + #endregion Interop + + #region Variables + + protected Guid _deviceGuid; + protected string _devicePath; + + protected RemoteCallback _remoteCallback = null; + protected KeyboardCallback _keyboardCallback = null; + protected MouseCallback _mouseCallback = null; + + #endregion Variables + + #region Constructors + + public Driver() { } + public Driver(Guid deviceGuid, string devicePath, RemoteCallback remoteCallback, KeyboardCallback keyboardCallback, MouseCallback mouseCallback) + { + _deviceGuid = deviceGuid; + _devicePath = devicePath; + + _remoteCallback = remoteCallback; + _keyboardCallback = keyboardCallback; + _mouseCallback = mouseCallback; + } + + #endregion Constructors + + #region Abstract Methods + + public abstract void Start(); + + public abstract void Stop(); + + public abstract IrCode Learn(int learnTimeout); + + public abstract void Send(IrCode code, uint port); + + #endregion Abstract Methods + + #region Static Methods + + /// <summary> + /// Find the device path for the supplied Device Class Guid. + /// </summary> + /// <param name="classGuid">GUID to locate device with.</param> + /// <returns>Device path.</returns> + public static string Find(Guid classGuid) + { + IntPtr handle = SetupDiGetClassDevs(ref classGuid, null, IntPtr.Zero, Digcfs.DeviceInterface | Digcfs.Present); + + if (handle.ToInt32() == -1) + return null; + + for (int deviceIndex = 0; ; deviceIndex++) + { + DeviceInfoData deviceInfoData = new DeviceInfoData(); + deviceInfoData.Size = Marshal.SizeOf(deviceInfoData); + + if (!SetupDiEnumDeviceInfo(handle, deviceIndex, ref deviceInfoData)) + { + int lastError = Marshal.GetLastWin32Error(); + + // out of devices or do we have an error? + if (lastError != Win32ErrorCodes.ERROR_NO_MORE_ITEMS && lastError != Win32ErrorCodes.ERROR_MOD_NOT_FOUND) + { + SetupDiDestroyDeviceInfoList(handle); + throw new Win32Exception(lastError); + } + + SetupDiDestroyDeviceInfoList(handle); + break; + } + + DeviceInterfaceData deviceInterfaceData = new DeviceInterfaceData(); + deviceInterfaceData.Size = Marshal.SizeOf(deviceInterfaceData); + + if (!SetupDiEnumDeviceInterfaces(handle, ref deviceInfoData, ref classGuid, 0, ref deviceInterfaceData)) + { + SetupDiDestroyDeviceInfoList(handle); + throw new Win32Exception(Marshal.GetLastWin32Error()); + } + + uint cbData = 0; + + if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, IntPtr.Zero, 0, ref cbData, IntPtr.Zero) && cbData == 0) + { + SetupDiDestroyDeviceInfoList(handle); + throw new Win32Exception(Marshal.GetLastWin32Error()); + } + + DeviceInterfaceDetailData deviceInterfaceDetailData = new DeviceInterfaceDetailData(); + deviceInterfaceDetailData.Size = 5; + + if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, ref deviceInterfaceDetailData, cbData, IntPtr.Zero, IntPtr.Zero)) + { + SetupDiDestroyDeviceInfoList(handle); + throw new Win32Exception(Marshal.GetLastWin32Error()); + } + + if (!String.IsNullOrEmpty(deviceInterfaceDetailData.DevicePath)) + { + SetupDiDestroyDeviceInfoList(handle); + return deviceInterfaceDetailData.DevicePath; + } + } + + return null; + } + + #endregion Static Methods + + } + +} Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IRCodeConversion.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IRCodeConversion.cs 2007-08-31 15:38:37 UTC (rev 881) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IRCodeConversion.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace MicrosoftMceTransceiver -{ - - public static class IRCodeConversion - { - - #region Member Variables - - static uint[] timingData = null; - static int timingDataCount = 0; - static uint lastSpace = IRDecoder.PulseMask; - - #endregion Member Variables - - public static byte[] ConvertRawPacketToNativeData(byte[] rawPacket) - { - List<byte> nativeData = new List<byte>(); - byte packetByte; - int jump = 0; - - for (int index = 0; index < rawPacket.Length; index += jump + 1) - { - packetByte = rawPacket[index]; - - if (packetByte == 0x9F) - { - // Packet is finished - break; - } - - if (packetByte >= 0x81 && packetByte <= 0x84) - { - jump = packetByte & 0x7F; - - if (index + jump + 1 > rawPacket.Length) - { - // bad packet - return null; - } - - for (int get = index + 1; get < index + jump + 1; get++) - nativeData.Add(rawPacket[get]); - } - else - { - // Bad packet - return null; - } - } - - return nativeData.ToArray(); - } - - // TODO: Rewrite - public static uint[] ConvertNativeDataToTimingData(byte[] nativeData) - { - int index = 0; - uint code; - - if (timingData == null || nativeData == null) - { - timingData = new uint[100]; - timingData[1] = lastSpace; - timingData[2] = 0; - timingDataCount = 2; - } - - if (nativeData == null) - return null; - - bool pulse; - - while (index < nativeData.Length) - { - pulse = false; - code = nativeData[index++]; - - if ((code & 0x80) != 0) - { - pulse = true; - code &= 0x7F; - } - code *= 50; - - if (pulse) - { - if (lastSpace != 0) - { - timingData[timingDataCount++] = lastSpace; - lastSpace = 0; - timingData[timingDataCount] = 0; - } - - timingData[timingDataCount] += code; - timingData[timingDataCount] |= IRDecoder.PulseBit; - } - else - { - if (timingData[timingDataCount] != 0 && lastSpace == 0) - timingDataCount++; - - lastSpace += code; - } - } - - uint[] outData = new uint[timingDataCount]; - Array.Copy(timingData, outData, outData.Length); - - timingData[0] = timingData[timingDataCount]; - timingDataCount = 0; - - return outData; - } - - } - -} Added: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrCode.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrCode.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrCode.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +// Remember: Pulse is Positive, Space is Negative. + +namespace MicrosoftMceTransceiver +{ + + /// <summary> + /// Encapsulates an MCE compatible IR code. + /// </summary> + public class IrCode + { + + #region Constants + + public const int CarrierFrequencyUnknown = -1; + public const int CarrierFrequencyPulseMode = 0; + public const int CarrierFrequencyDefault = 36000; + + const int LongestSpace = -10000; + + #endregion Constants + + #region Member Variables + + int _carrier; + int[] _timingData; + + #endregion Member Variables + + #region Properties + + /// <summary> + /// The IR carrier frequency. + /// </summary> + public int Carrier + { + get { return _carrier; } + set { _carrier = value; } + } + + /// <summary> + /// The IR timing data. + /// </summary> + public int[] TimingData + { + get { return _timingData; } + set { _timingData = value; } + } + + #endregion Properties + + #region Constructors + + public IrCode() : this(CarrierFrequencyUnknown, new int[] { }) { } + public IrCode(int carrier) : this(carrier, new int[] { }) { } + public IrCode(int[] timingData) : this(CarrierFrequencyUnknown, timingData) { } + public IrCode(int carrier, int[] timingData) + { + _carrier = carrier; + _timingData = timingData; + } + + #endregion Constructors + + #region Methods + + public bool Finalize() + { + if (_timingData.Length == 0) + return false; + + List<int> newData = new List<int>(); + + for (int index = 0; index < _timingData.Length; index++) + { + int time = _timingData[index]; + + if (time < LongestSpace) + { + newData.Add(LongestSpace); + break; + } + else + { + newData.Add(time); + } + } + + _timingData = newData.ToArray(); + return true; + } + + /// <summary> + /// Add timing data to this IR code. + /// </summary> + /// <param name="addTimingData">Addition timing data.</param> + public void AddTimingData(int[] addTimingData) + { + List<int> newTimingData = new List<int>(); + + int index = 0; + + if (_timingData.Length > 1) + { + for (index = 0; index < _timingData.Length - 1; index++) + newTimingData.Add(_timingData[index]); + } + else if (_timingData.Length == 0) + { + _timingData = new int[addTimingData.Length]; + addTimingData.CopyTo(_timingData, 0); + return; + } + + if (addTimingData.Length == 0 || index >= _timingData.Length) + { + return; + } + + + if (Math.Sign(addTimingData[0]) == Math.Sign(_timingData[index])) + { + newTimingData.Add(_timingData[index] + addTimingData[0]); + + for (index = 1; index < addTimingData.Length; index++) + newTimingData.Add(addTimingData[index]); + } + else + { + newTimingData.Add(_timingData[index]); + newTimingData.AddRange(addTimingData); + } + + _timingData = newTimingData.ToArray(); + } + + public override string ToString() + { + ushort[] prontoData = Pronto.ConvertIrCodeToProntoRaw(this); + + StringBuilder output = new StringBuilder(); + + for (int index = 0; index < prontoData.Length; index++) + { + output.Append(prontoData[index].ToString("X4")); + if (index != prontoData.Length - 1) + output.Append(' '); + } + + return output.ToString(); + } + + #endregion Methods + + #region Static Methods + + /// <summary> + /// Takes old IR file bytes. + /// </summary> + /// <param name="data">IR file bytes.</param> + /// <returns>New IrCode object.</returns> + public static IrCode FromBytes(byte[] data) + { + List<int> timingData = new List<int>(); + + int len = 0; + + for (int index = 0; index < data.Length; index++) + { + byte curByte = data[index]; + + if ((curByte & 0x80) != 0) + len += (int)(curByte & 0x7F); + else + len -= (int)(curByte & 0x7F); + + if ((curByte & 0x7F) != 0x7F) + { + timingData.Add(len * 50); + len = 0; + } + } + + return new IrCode(timingData.ToArray()); + } + + public static IrCode FromString(string code) + { + string[] stringData = code.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + + ushort[] prontoData = new ushort[stringData.Length]; + for (int i = 0; i < stringData.Length; i++) + prontoData[i] = ushort.Parse(stringData[i], System.Globalization.NumberStyles.HexNumber); + + return Pronto.ConvertProntoDataToIrCode(prontoData); + } + + #endregion Static Methods + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs 2007-09-02 17:09:43 UTC (rev 882) @@ -0,0 +1,1353 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MicrosoftMceTransceiver +{ + + #region Enumerations + + /// <summary> + /// Protocol of IR Code. + /// </summary> + public enum IRProtocol + { + None, + //ITT, + JVC, + NEC, + //NRC17, + RC5, + RC6, + RCA, + //RCMM, + RECS80, + //Sharp, + SIRC, + //XSAT, + } + + #endregion Enumerations + + #region Delegates + + public delegate void RemoteCallback(IRProtocol codeType, uint keyCode); + public delegate void KeyboardCallback(uint keyCode, uint modifiers); + public delegate void MouseCallback(int deltaX, int deltaY, bool rightButton, bool leftButton); + + #endregion Delegates + + /// <summary> + /// Used for decoding received IR codes. + /// </summary> + public static class IrDecoder + { + + #region Constants + + //public const uint PulseBit = 0x01000000; + //public const uint PulseMask = 0x00FFFFFF; + + //const UInt16 ToggleBitMce = 0x8000; + const UInt16 ToggleMaskMce = 0x7FFF; + const UInt16 CustomerMce = 0x800F; + + const UInt16 ToggleMaskRC5 = 0xF7FF; + const UInt16 ToggleMaskRC5X = 0xFFFF; + + const uint PrefixRC6 = 0x000FC950; + const uint PrefixRC6A = 0x000FCA90; + + const uint MceMouse = 1; + const uint MceKeyboard = 4; + + #endregion Constants + + #region Detection Data + + static RemoteDetectionData JVC_Data = null; + static RemoteDetectionData NEC_Data = null; + static RemoteDetectionData RC5_Data = null; + static RemoteDetectionData RC6_Data = null; + static RemoteDetectionData RCA_Data = null; + static RemoteDetectionData RECS80_Data = null; + static RemoteDetectionData SIRC_Data = null; + + static MceDetectionData MCE_Data = null; + + #endregion Detection Data + + #region Methods + + /// <summary> + /// Decode timing data to discover IR Protocol and button code. + /// </summary> + /// <param name="timingData">Input timing data.</param> + /// <param name="remoteCallback">Method to call when Remote button decoded.</param> + /// <param name="keyboardCallback">Method to call when Keyboard event decoded.</param> + /// <param name="mouseCallback">Method to call when Mouse event decoded.</param> + public static void DecodeIR(int[] timingData, RemoteCallback remoteCallback, KeyboardCallback keyboardCallback, MouseCallback mouseCallback) + { +// DetectITT(timingData, remoteCallback); + DetectJVC(timingData, remoteCallback); + DetectNEC(timingData, remoteCallback); +// DetectNRC17(timingData, remoteCallback); + DetectRC5(timingData, remoteCallback); + DetectRC6(timingData, remoteCallback); + DetectRCA(timingData, remoteCallback); +// DetectRCMM(timingData, remoteCallback); + DetectRECS80(timingData, remoteCallback); +// DetectSharp(timingData, remoteCallback); + DetectSIRC(timingData, remoteCallback); // 15 Bit +// DetectXSAT(timingData, remoteCallback); + + DetectMCE(timingData, keyboardCallback, mouseCallback); + } + + static void DetectJVC(int[] timingData, RemoteCallback remoteCallback) + { + if (JVC_Data == null || timingData == null) + JVC_Data = new RemoteDetectionData(); + + if (timingData == null) + return; + + for (int i = 0; i < timingData.Length; i++) + { + int duration = Math.Abs(timingData[i]); + bool pulse = (timingData[i] > 0); + bool ignored = true; + + switch (JVC_Data.State) + { + + #region HeaderPulse + case RemoteDetectionState.HeaderPulse: + //Console.WriteLine("JVC HeaderPulse"); + + if (pulse && duration >= 8200 && duration <= 8600) + { + JVC_Data.State = RemoteDetectionState.HeaderSpace; + ignored = false; + } + break; + #endregion HeaderPulse + + #region HeaderSpace + case RemoteDetectionState.HeaderSpace: + //Console.WriteLine("JVC HeaderSpace"); + + if (!pulse && duration >= 4000 && duration <= 4400) + { + JVC_Data.State = RemoteDetectionState.Data; + JVC_Data.HalfBit = 0; + JVC_Data.Bit = 0; + JVC_Data.Code = 0; + ignored = false; + } + break; + #endregion HeaderSpace + + #region Data + case RemoteDetectionState.Data: + //Console.WriteLine("JVC Data"); + + if (pulse && duration >= 350 && duration <= 750) + { + JVC_Data.HalfBit = 1; + ignored = false; + } + else if (!pulse && duration >= 250 && duration <= 650 && JVC_Data.HalfBit == 1) + { + JVC_Data.Code <<= 1; + JVC_Data.Bit++; + JVC_Data.HalfBit = 0; + ignored = false; + } + else if (!pulse && duration >= 1450 && duration <= 1850 && JVC_Data.HalfBit == 1) + { + JVC_Data.Code <<= 1; + JVC_Data.Code |= 1; + JVC_Data.Bit++; + JVC_Data.HalfBit = 0; + ignored = false; + } + else + { + //Console.WriteLine("JVC Error"); + } + + if (JVC_Data.Bit == 16) + { + remoteCallback(IRProtocol.JVC, JVC_Data.Code); + JVC_Data.State = RemoteDetectionState.Leading; + } + break; + #endregion Data + + #region Leading + case RemoteDetectionState.Leading: + //Console.WriteLine("JVC Leading"); + + if (pulse && duration >= 350 && duration <= 750) + { + JVC_Data = new RemoteDetectionData(); + JVC_Data.State = RemoteDetectionState.Data; + ignored = false; + } + break; + #endregion Leading + + } + + if (ignored && (JVC_Data.State != RemoteDetectionState.HeaderPulse)) + JVC_Data = new RemoteDetectionData(); + } + } + static void DetectNEC(int[] timingData, RemoteCallback remoteCallback) + { + if (NEC_Data == null || timingData == null) + NEC_Data = new RemoteDetectionData(); + + if (timingData == null) + return; + + for (int i = 0; i < timingData.Length; i++) + { + int duration = Math.Abs(timingData[i]); + bool pulse = (timingData[i] > 0); + bool ignored = true; + + switch (NEC_Data.State) + { + + #region HeaderPulse + case RemoteDetectionState.HeaderPulse: + //Console.WriteLine("NEC HeaderPulse"); + + if (pulse && duration >= 8800 && durati... [truncated message content] |