From: <an...@us...> - 2007-08-02 15:43:46
|
Revision: 785 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=785&view=rev Author: and-81 Date: 2007-08-02 08:43:42 -0700 (Thu, 02 Aug 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/Properties/AssemblyInfo.cs 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/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Windows Message Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/X10Transceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs 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-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -198,7 +198,7 @@ #region Variables - static RemoteButtonHandler _remoteButtonHandler = null; + static RemoteHandler _remoteButtonHandler = null; static FileStream _deviceStream; static byte[] _deviceBuffer; @@ -209,7 +209,7 @@ #region IIRServerPlugin Members public string Name { get { return "FusionREMOTE"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "DViCO FusionREMOTE Receiver"; } } public bool CanReceive { get { return true; } } @@ -217,12 +217,16 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return false; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + public string[] AvailablePorts { get { return Ports; } @@ -270,8 +274,9 @@ { return false; } - public LearnStatus Learn(string file) + public LearnStatus Learn(out byte[] data) { + data = null; return LearnStatus.Failure; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/IRServerPluginInterface.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -11,8 +11,24 @@ /// IR Server callback for remote button press handling. /// </summary> /// <param name="keyCode">Remote button code.</param> - public delegate void RemoteButtonHandler(string keyCode); + public delegate void RemoteHandler(string keyCode); + /// <summary> + /// IR Server callback for keyboard key press handling. + /// </summary> + /// <param name="vKey">Virtual key code.</param> + /// <param name="keyUp">.</param> + public delegate void KeyboardHandler(int vKey, bool keyUp); + + /// <summary> + /// IR Server callback for mouse event handling. + /// </summary> + /// <param name="deltaX">Mouse movement on the X-axis.</param> + /// <param name="deltaY">Mouse movement on the Y-axis.</param> + /// <param name="rightButton">Is the right button pressed?</param> + /// <param name="leftButton">Is the left button pressed?</param> + public delegate void MouseHandler(int deltaX, int deltaY, int buttons); + #endregion Delegates #region Enumerations @@ -89,9 +105,19 @@ /// <summary> /// Callback for remote button presses. /// </summary> - RemoteButtonHandler RemoteButtonCallback { get; set; } + RemoteHandler RemoteCallback { get; set; } /// <summary> + /// Callback for keyboard presses. + /// </summary> + KeyboardHandler KeyboardCallback { get; set; } + + /// <summary> + /// Callback for mouse events. + /// </summary> + MouseHandler MouseCallback { get; set; } + + /// <summary> /// Lists the available blaster ports. /// </summary> string[] AvailablePorts { get; } @@ -141,9 +167,9 @@ /// <summary> /// Learn an infrared command. /// </summary> - /// <param name="file">New infrared command file to create.</param> + /// <param name="data">New infrared command.</param> /// <returns>Tells the calling code if the learn was Successful, Failed or Timed Out.</returns> - LearnStatus Learn(string file); + LearnStatus Learn(out byte[] data); /// <summary> /// Set the transmit port to use for infrared command output. @@ -163,4 +189,37 @@ } + /* + + public interface IConfigurable + { + + } + + public interface ITransmitIR + { + + } + + public interface ILearnIR + { + + } + + public interface IRemoteReceiver + { + + } + + public interface IKeyboardReceiver + { + + } + + public interface IMouseReceiver + { + + } + + */ } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -34,7 +34,7 @@ SerialPort _serialPort; byte[] _deviceBuffer; - RemoteButtonHandler _remoteButtonHandler = null; + RemoteHandler _remoteButtonHandler = null; int _repeatDelay; string _serialPortName; @@ -49,7 +49,7 @@ #region IIRServerPlugin Members public string Name { get { return "IRMan"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "Receiver support for the Serial IRMan device"; } } public bool CanReceive { get { return true; } } @@ -57,13 +57,17 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return true; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } - public string[] AvailablePorts { get { return Ports; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + + public string[] AvailablePorts { get { return Ports; } } public string[] AvailableSpeeds { get { return Speeds; } } public void Configure() @@ -134,7 +138,11 @@ } public bool Transmit(string file) { return false; } - public LearnStatus Learn(string file) { return LearnStatus.Failure; } + public LearnStatus Learn(out byte[] data) + { + data = null; + return LearnStatus.Failure; + } public bool SetPort(string port) { return true; } public bool SetSpeed(string speed) { return true; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -204,7 +204,7 @@ #region Variables - static RemoteButtonHandler _remoteButtonHandler = null; + static RemoteHandler _remoteButtonHandler = null; static string _blasterSpeed = Speeds[0]; static string _blasterPort = Ports[0]; @@ -221,7 +221,7 @@ #region IIRServerPlugin Members public string Name { get { return "IRTrans (Experimental)"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "IRTrans Transceiver (Experimental)"; } } public bool CanReceive { get { return true; } } @@ -229,12 +229,16 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return true; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + public string[] AvailablePorts { get { return Ports; } @@ -322,8 +326,10 @@ } */ } - public LearnStatus Learn(string file) + public LearnStatus Learn(out byte[] data) { + data = null; + /* try { Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] 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-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/IgorPlug USB Receiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -27,7 +27,7 @@ #region Variables - RemoteButtonHandler _remoteButtonHandler = null; + RemoteHandler _remoteButtonHandler = null; Thread _readThread; @@ -63,7 +63,7 @@ #region IIRServerPlugin Members public string Name { get { return "IgorPlug USB"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "IgorPlug USB Receiver"; } } public bool CanReceive { get { return true; } } @@ -71,13 +71,17 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return false; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } - public string[] AvailablePorts { get { return Ports; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + + public string[] AvailablePorts { get { return Ports; } } public string[] AvailableSpeeds { get { return Speeds; } } public void Configure() { } @@ -97,7 +101,11 @@ } public bool Transmit(string file) { return false; } - public LearnStatus Learn(string file) { return LearnStatus.Failure; } + public LearnStatus Learn(out byte[] data) + { + data = null; + return LearnStatus.Failure; + } public bool SetPort(string port) { return true; } public bool SetSpeed(string speed) { return true; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug USB Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ #region Variables - RemoteButtonHandler _remoteButtonHandler = null; + RemoteHandler _remoteButtonHandler = null; WinLircServer _server; IPAddress _serverIP; @@ -43,7 +43,7 @@ #region IIRServerPlugin Members public string Name { get { return "WinLirc"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81, original code for MediaPortal by Sven"; } } public string Description { get { return "Supports WinLirc as a reciever"; } } public bool CanReceive { get { return true; } } @@ -51,12 +51,16 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return true; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + public string[] AvailablePorts { get { return Ports; } } public string[] AvailableSpeeds { get { return Speeds; } } @@ -129,8 +133,9 @@ return false; } } - public LearnStatus Learn(string file) + public LearnStatus Learn(out byte[] data) { + data = null; return LearnStatus.Failure; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Windows Message Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Windows Message Receiver.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Windows Message Receiver/Windows Message Receiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -47,14 +47,14 @@ int _messageType = WM_APP; int _wParam = DefaultMessageID; - RemoteButtonHandler _remoteButtonHandler = null; + RemoteHandler _remoteButtonHandler = null; #endregion Variables #region IIRServerPlugin Members public string Name { get { return "Windows Messages"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "Supports receiving simulated button presses through Windows Messages"; } } public bool CanReceive { get { return true; } } @@ -62,12 +62,16 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return true; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + public string[] AvailablePorts { get { return Ports; } } public string[] AvailableSpeeds { get { return Speeds; } } @@ -120,8 +124,9 @@ */ return false; } - public LearnStatus Learn(string file) + public LearnStatus Learn(out byte[] data) { + data = null; return LearnStatus.Failure; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/X10Transceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/X10Transceiver.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/X10 Transceiver/X10Transceiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -28,7 +28,7 @@ #region Variables - static RemoteButtonHandler _remoteButtonHandler = null; + static RemoteHandler _remoteButtonHandler = null; static string _blasterSpeed = Speeds[0]; static string _blasterPort = Ports[0]; @@ -43,7 +43,7 @@ #region IIRServerPlugin Members public string Name { get { return "X10 (Experimental)"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "X10 Transceiver (Experimental)"; } } public bool CanReceive { get { return true; } } @@ -51,12 +51,16 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return false; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + public string[] AvailablePorts { get { return Ports; } @@ -105,8 +109,9 @@ { return false; } - public LearnStatus Learn(string file) + public LearnStatus Learn(out byte[] data) { + data = null; return LearnStatus.Failure; } @@ -132,8 +137,8 @@ { string keyCode = Enum.GetName(typeof(X10.EX10Command), eCommand); - if (RemoteButtonCallback != null) - RemoteButtonCallback(keyCode); + if (RemoteCallback != null) + RemoteCallback(keyCode); } catch (Exception ex) { Modified: trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/Properties/AssemblyInfo.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -29,7 +29,7 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.3.2")] -[assembly: AssemblyFileVersion("1.0.3.2")] +[assembly: AssemblyVersion("1.0.3.3")] +[assembly: AssemblyFileVersion("1.0.3.3")] [assembly: CLSCompliant(true)] Modified: trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs 2007-08-02 15:40:55 UTC (rev 784) +++ trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs 2007-08-02 15:43:42 UTC (rev 785) @@ -25,7 +25,7 @@ #region Variables - RemoteButtonHandler _remoteButtonHandler = null; + RemoteHandler _remoteButtonHandler = null; FileStream _deviceStream; byte[] _deviceBuffer; @@ -187,7 +187,7 @@ #region IIRServerPlugin Members public string Name { get { return "XBCDRC"; } } - public string Version { get { return "1.0.3.2"; } } + public string Version { get { return "1.0.3.3"; } } public string Author { get { return "and-81"; } } public string Description { get { return "Supports the XBox 1 IR receiver with XBCDRC"; } } public bool CanReceive { get { return true; } } @@ -195,13 +195,17 @@ public bool CanLearn { get { return false; } } public bool CanConfigure { get { return false; } } - public RemoteButtonHandler RemoteButtonCallback + public RemoteHandler RemoteCallback { get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } - public string[] AvailablePorts { get { return Ports; } } + public KeyboardHandler KeyboardCallback { get { return null; } set { } } + + public MouseHandler MouseCallback { get { return null; } set { } } + + public string[] AvailablePorts { get { return Ports; } } public string[] AvailableSpeeds { get { return Speeds; } } public void Configure() { } @@ -248,7 +252,11 @@ } public bool Transmit(string file) { return false; } - public LearnStatus Learn(string file) { return LearnStatus.Failure; } + public LearnStatus Learn(out byte[] data) + { + data = null; + return LearnStatus.Failure; + } public bool SetPort(string port) { return true; } public bool SetSpeed(string speed) { return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-08-22 15:01:36
|
Revision: 856 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=856&view=rev Author: and-81 Date: 2007-08-22 08:01:30 -0700 (Wed, 22 Aug 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/Properties/AssemblyInfo.cs Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/USB-UIRT Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/UirtTransceiver.cs Copied: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver (from rev 853, trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver) Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj 2007-08-22 15:01:30 UTC (rev 856) @@ -0,0 +1,95 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{EE8F2C22-8BD3-4832-85F0-E6F67ED3AADB}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>HcwTransceiver</RootNamespace> + <AssemblyName>HCW Transceiver</AssemblyName> + <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>false</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>true</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants> + </DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <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" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Configure.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Configure.Designer.cs"> + <DependentUpon>Configure.cs</DependentUpon> + </Compile> + <Compile Include="HcwTransceiver.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Configure.resx"> + <DependentUpon>Configure.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> + <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> + <Name>IR Server Plugin Interface</Name> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <PostBuildEvent>copy "$(TargetFileName)" "\MediaPortal Development\Plugin Releases\IR Server Suite\IR Server Plugins\"</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs 2007-08-22 15:01:30 UTC (rev 856) @@ -0,0 +1,438 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using System.Xml; + +using Microsoft.Win32.SafeHandles; + +using IRServerPluginInterface; + +namespace HcwTransceiver +{ + + [CLSCompliant(false)] + public class HcwTransceiver : + IRServerPlugin, IConfigure, ITransmitIR, ILearnIR, IRemoteReceiver, IDisposable + { + + #region Interop + + [StructLayout(LayoutKind.Sequential)] + struct UUINFO + { + public int fwVersion; + public int protVersion; + public char fwDateDay; + public char fwDateMonth; + public char fwDateYear; + } + + //Not used + //[StructLayout(LayoutKind.Sequential)] + //internal struct UUGPIO + //{ + // public byte[] irCode; + // public byte action; + // public byte duration; + //} + + [DllImport("uuirtdrv.dll")] + static extern IntPtr UUIRTOpen(); + + [DllImport("uuirtdrv.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool UUIRTClose( + IntPtr hHandle); + + //[DllImport("uuirtdrv.dll")] + //[return: MarshalAs(UnmanagedType.Bool)] + //internal static extern bool UUIRTGetDrvInfo(ref int puDrvVersion); + + //[DllImport("uuirtdrv.dll")] + //[return: MarshalAs(UnmanagedType.Bool)] + //internal static extern bool UUIRTGetUUIRTInfo( + // IntPtr hHandle, + // ref UUINFO puuInfo); + + //[DllImport("uuirtdrv.dll")] + //[return: MarshalAs(UnmanagedType.Bool)] + //internal static extern bool UUIRTGetUUIRTConfig( + // IntPtr hHandle, + // ref uint puConfig); + + //[DllImport("uuirtdrv.dll")] + //[return: MarshalAs(UnmanagedType.Bool)] + //internal static extern bool UUIRTSetUUIRTConfig( + // IntPtr hHandle, + // uint uConfig); + + [DllImport("uuirtdrv.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool UUIRTTransmitIR( + IntPtr hHandle, + string IRCode, + int codeFormat, + int repeatCount, + int inactivityWaitTime, + IntPtr hEvent, + int res1, + int res2); + + [DllImport("uuirtdrv.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool UUIRTLearnIR( + IntPtr hHandle, + int codeFormat, + [MarshalAs(UnmanagedType.LPStr)] StringBuilder ircode, + IRLearnCallbackDelegate progressProc, + int userData, + ref int pAbort, + int param1, + [MarshalAs(UnmanagedType.AsAny)] Object o, + [MarshalAs(UnmanagedType.AsAny)] Object oo); + + [DllImport("uuirtdrv.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool UUIRTSetReceiveCallback( + IntPtr hHandle, + UUIRTReceiveCallbackDelegate receiveProc, + int none); + + //[DllImport("uuirtdrv.dll")] + //static extern bool UUIRTSetUUIRTGPIOCfg(IntPtr hHandle, int index, ref UUGPIO GpioSt); + + //[DllImport("uuirtdrv.dll")] + //static extern bool UUIRTGetUUIRTGPIOCfg(IntPtr hHandle, ref int numSlots, ref uint dwPortPins, + // ref UUGPIO GpioSt); + + #endregion + + #region Delegates + + delegate void UUIRTReceiveCallbackDelegate(string irCode, IntPtr userData); + delegate void IRLearnCallbackDelegate(uint progress, uint sigQuality, ulong carrierFreq, IntPtr userData); + + #endregion Delegates + + #region Constants + + static readonly string ConfigurationFile = + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + + "\\IR Server Suite\\IR Server\\USB-UIRT Transceiver.xml"; + + const int UUIRTDRV_IRFMT_UUIRT = 0x0000; + const int UUIRTDRV_IRFMT_PRONTO = 0x0010; + const int UUIRTDRV_IRFMT_LEARN_FORCERAW = 0x0100; + const int UUIRTDRV_IRFMT_LEARN_FORCESTRUC = 0x0200; + const int UUIRTDRV_IRFMT_LEARN_FORCEFREQ = 0x0400; + const int UUIRTDRV_IRFMT_LEARN_FREQDETECT = 0x0800; + + static readonly string[] Ports = new string[] { "Default", "Port 1", "Port 2", "Port 3" }; + + const int AbortLearn = -1; + const int AllowLearn = 0; + + #endregion Constants + + #region Variables + + RemoteHandler _remoteButtonHandler = null; + + string _blastPort = Ports[0]; + + int _repeatDelay; + int _blastRepeats; + int _learnTimeout; + + //ulong _learnCarrierFreq; + + string _lastCode = String.Empty; + DateTime _lastCodeTime = DateTime.Now; + + // ------- + + int _abortLearn = AllowLearn; + bool _learnTimedOut; + UUIRTReceiveCallbackDelegate _receiveCallback = null; + bool _isUsbUirtLoaded = false; + IntPtr _usbUirtHandle = IntPtr.Zero; + bool _disposed = false; + + #endregion Variables + + #region Deconstructor + + ~HcwTransceiver() + { + Dispose(false); + } + + #endregion Deconstructor + + #region IDisposable Members + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposeManagedResources) + { + if (!_disposed) + { + _disposed = true; + + if (disposeManagedResources) + { + // Dispose any managed resources. + } + + if (_isUsbUirtLoaded && _usbUirtHandle != new IntPtr(-1) && _usbUirtHandle != IntPtr.Zero) + { + UUIRTClose(_usbUirtHandle); + _usbUirtHandle = IntPtr.Zero; + _isUsbUirtLoaded = false; + } + } + } + + #endregion IDisposable Members + + #region Implementation + + public override string Name { get { return "USB-UIRT"; } } + public override string Version { get { return "1.0.3.3"; } } + public override string Author { get { return "and-81"; } } + public override string Description { get { return "Support for the USB-UIRT transceiver"; } } + + public override bool Start() + { + LoadSettings(); + + _usbUirtHandle = UUIRTOpen(); + + if (_usbUirtHandle != new IntPtr(-1)) + { + _isUsbUirtLoaded = true; + + // Setup callack to receive IR messages + _receiveCallback = new UUIRTReceiveCallbackDelegate(UUIRTReceiveCallback); + UUIRTSetReceiveCallback(_usbUirtHandle, _receiveCallback, 0); + } + + return _isUsbUirtLoaded; + } + public override void Suspend() + { + Stop(); + } + public override void Resume() + { + Start(); + } + public override void Stop() + { + UUIRTClose(_usbUirtHandle); + + _usbUirtHandle = IntPtr.Zero; + _isUsbUirtLoaded = false; + } + + public void Configure() + { + LoadSettings(); + + Configure config = new Configure(); + + config.RepeatDelay = _repeatDelay; + config.BlastRepeats = _blastRepeats; + config.LearnTimeout = _learnTimeout; + + if (config.ShowDialog() == DialogResult.OK) + { + _repeatDelay = config.RepeatDelay; + _blastRepeats = config.BlastRepeats; + _learnTimeout = config.LearnTimeout; + + SaveSettings(); + } + } + + public RemoteHandler RemoteCallback + { + get { return _remoteButtonHandler; } + set { _remoteButtonHandler = value; } + } + + public string[] AvailablePorts { get { return Ports; } } + + public bool Transmit(string port, byte[] data) + { + bool result = false; + + string irCode = Encoding.ASCII.GetString(data); + + // Set blaster port ... + if (port.Equals(Ports[1], StringComparison.InvariantCultureIgnoreCase)) + irCode = "Z1" + irCode; + else if (port.Equals(Ports[2], StringComparison.InvariantCultureIgnoreCase)) + irCode = "Z2" + irCode; + else if (port.Equals(Ports[3], StringComparison.InvariantCultureIgnoreCase)) + irCode = "Z3" + irCode; + + result = UUIRTTransmitIR( + _usbUirtHandle, // Handle to USB-UIRT + irCode, // IR Code + UUIRTDRV_IRFMT_PRONTO, // Code Format + _blastRepeats, // Repeat Count + 0, // Inactivity Wait Time + IntPtr.Zero, // hEvent + 0, // reserved1 + 0 // reserved2 + ); + + return result; + } + public LearnStatus Learn(out byte[] data) + { + bool result = false; + + data = null; + + StringBuilder irCode = new StringBuilder("1", 2048); + _abortLearn = AllowLearn; + _learnTimedOut = false; + + //_learnCarrierFreq = 0; + + Timer timer = new Timer(); + timer.Interval = _learnTimeout; + timer.Tick += new EventHandler(timer_Tick); + timer.Enabled = true; + timer.Start(); + + //IRLearnCallbackDelegate learnCallback = new IRLearnCallbackDelegate(UUIRTLearnCallback); + + result = UirtTransceiver.UUIRTLearnIR( + _usbUirtHandle, // Handle to USB-UIRT + UirtTransceiver.UUIRTDRV_IRFMT_PRONTO | UirtTransceiver.UUIRTDRV_IRFMT_LEARN_FREQDETECT, // | UirtTransceiver.UUIRTDRV_IRFMT_LEARN_FORCERAW + irCode, // Where to put the IR Code + null, // Learn status callback + 0, // User data + ref _abortLearn, // Abort flag? + 0, + null, + null); + + timer.Stop(); + + //MessageBox.Show(_learnCarrierFreq.ToString()); + + if (_learnTimedOut) + { + return LearnStatus.Timeout; + } + else if (result) + { + data = Encoding.ASCII.GetBytes(irCode.ToString()); + + return LearnStatus.Success; + } + else + { + return LearnStatus.Failure; + } + } + + void LoadSettings() + { + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(ConfigurationFile); + + _repeatDelay = int.Parse(doc.DocumentElement.Attributes["RepeatDelay"].Value); + _blastRepeats = int.Parse(doc.DocumentElement.Attributes["BlastRepeats"].Value); + _learnTimeout = int.Parse(doc.DocumentElement.Attributes["LearnTimeout"].Value); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + + _repeatDelay = 500; + _blastRepeats = 4; + _learnTimeout = 10000; + } + } + void SaveSettings() + { + try + { + XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8); + writer.Formatting = Formatting.Indented; + writer.Indentation = 1; + writer.IndentChar = (char)9; + writer.WriteStartDocument(true); + writer.WriteStartElement("settings"); // <settings> + + writer.WriteAttributeString("RepeatDelay", _repeatDelay.ToString()); + writer.WriteAttributeString("BlastRepeats", _blastRepeats.ToString()); + writer.WriteAttributeString("LearnTimeout", _learnTimeout.ToString()); + + writer.WriteEndElement(); // </settings> + writer.WriteEndDocument(); + writer.Close(); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + void UUIRTReceiveCallback(string keyCode, IntPtr userData) + { + if (_remoteButtonHandler == null) + return; + + TimeSpan timeSpan = DateTime.Now - _lastCodeTime; + + if (keyCode == _lastCode) // Repeated button + { + if (timeSpan.Milliseconds > _repeatDelay) + { + _remoteButtonHandler(keyCode); + _lastCodeTime = DateTime.Now; + } + } + else + { + _remoteButtonHandler(keyCode); + _lastCodeTime = DateTime.Now; + } + + _lastCode = keyCode; + } + /* + void UUIRTLearnCallback(uint progress, uint sigQuality, ulong carrierFreq, IntPtr userData) + { + _learnCarrierFreq = carrierFreq; + //MessageBox.Show(_learnCarrierFreq.ToString()); + } + */ + void timer_Tick(object sender, EventArgs e) + { + _abortLearn = AbortLearn; + _learnTimedOut = true; + + ((Timer)sender).Stop(); + } + + #endregion Implementation + + } + +} Modified: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/Properties/AssemblyInfo.cs 2007-08-22 05:26:54 UTC (rev 853) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/Properties/AssemblyInfo.cs 2007-08-22 15:01:30 UTC (rev 856) @@ -6,11 +6,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("USB-UIRT Transceiver")] -[assembly: AssemblyDescription("IR Server plugin to support the USB-UIRT transceiver")] +[assembly: AssemblyTitle("HCW Transceiver")] +[assembly: AssemblyDescription("IR Server plugin to support the HCW transceiver")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("UirtTransceiver")] +[assembly: AssemblyProduct("HcwTransceiver")] [assembly: AssemblyCopyright("Aaron Dinnage")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/USB-UIRT Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/USB-UIRT Transceiver.csproj 2007-08-22 05:26:54 UTC (rev 853) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/USB-UIRT Transceiver.csproj 2007-08-22 15:01:30 UTC (rev 856) @@ -1,95 +0,0 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{99B5CA78-3E0B-477F-A7D3-EE1B65E85DE4}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>UirtTransceiver</RootNamespace> - <AssemblyName>USB-UIRT Transceiver</AssemblyName> - <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>false</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <UseVSHostingProcess>true</UseVSHostingProcess> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>none</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants> - </DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <UseVSHostingProcess>false</UseVSHostingProcess> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <OutputPath>bin\x86\Debug\</OutputPath> - <DefineConstants>DEBUG</DefineConstants> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <DebugType>full</DebugType> - <PlatformTarget>x86</PlatformTarget> - <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" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Configure.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Configure.Designer.cs"> - <DependentUpon>Configure.cs</DependentUpon> - </Compile> - <Compile Include="UirtTransceiver.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="Configure.resx"> - <DependentUpon>Configure.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> - <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> - <Name>IR Server Plugin Interface</Name> - <Private>False</Private> - </ProjectReference> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> - <PropertyGroup> - <PostBuildEvent>copy "$(TargetFileName)" "\MediaPortal Development\Plugin Releases\IR Server Suite\IR Server Plugins\"</PostBuildEvent> - </PropertyGroup> -</Project> \ No newline at end of file Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/UirtTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2007-08-22 05:26:54 UTC (rev 853) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/UirtTransceiver.cs 2007-08-22 15:01:30 UTC (rev 856) @@ -1,465 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using System.Xml; - -using Microsoft.Win32.SafeHandles; - -using IRServerPluginInterface; - -namespace UirtTransceiver -{ - - [CLSCompliant(false)] - public class UirtTransceiver : IIRServerPlugin, IDisposable - { - - #region Interop - - [StructLayout(LayoutKind.Sequential)] - struct UUINFO - { - public int fwVersion; - public int protVersion; - public char fwDateDay; - public char fwDateMonth; - public char fwDateYear; - } - - //Not used - //[StructLayout(LayoutKind.Sequential)] - //internal struct UUGPIO - //{ - // public byte[] irCode; - // public byte action; - // public byte duration; - //} - - [DllImport("uuirtdrv.dll")] - static extern IntPtr UUIRTOpen(); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTClose( - IntPtr hHandle); - - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTGetDrvInfo(ref int puDrvVersion); - - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTGetUUIRTInfo( - // IntPtr hHandle, - // ref UUINFO puuInfo); - - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTGetUUIRTConfig( - // IntPtr hHandle, - // ref uint puConfig); - - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTSetUUIRTConfig( - // IntPtr hHandle, - // uint uConfig); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTTransmitIR( - IntPtr hHandle, - string IRCode, - int codeFormat, - int repeatCount, - int inactivityWaitTime, - IntPtr hEvent, - int res1, - int res2); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTLearnIR( - IntPtr hHandle, - int codeFormat, - [MarshalAs(UnmanagedType.LPStr)] StringBuilder ircode, - IRLearnCallbackDelegate progressProc, - int userData, - ref int pAbort, - int param1, - [MarshalAs(UnmanagedType.AsAny)] Object o, - [MarshalAs(UnmanagedType.AsAny)] Object oo); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTSetReceiveCallback( - IntPtr hHandle, - UUIRTReceiveCallbackDelegate receiveProc, - int none); - - //[DllImport("uuirtdrv.dll")] - //static extern bool UUIRTSetUUIRTGPIOCfg(IntPtr hHandle, int index, ref UUGPIO GpioSt); - - //[DllImport("uuirtdrv.dll")] - //static extern bool UUIRTGetUUIRTGPIOCfg(IntPtr hHandle, ref int numSlots, ref uint dwPortPins, - // ref UUGPIO GpioSt); - - #endregion - - #region Delegates - - delegate void UUIRTReceiveCallbackDelegate(string irCode, IntPtr userData); - delegate void IRLearnCallbackDelegate(uint progress, uint sigQuality, ulong carrierFreq, IntPtr userData); - - #endregion Delegates - - #region Constants - - static readonly string ConfigurationFile = - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + - "\\IR Server Suite\\IR Server\\USB-UIRT Transceiver.xml"; - - const int UUIRTDRV_IRFMT_UUIRT = 0x0000; - const int UUIRTDRV_IRFMT_PRONTO = 0x0010; - const int UUIRTDRV_IRFMT_LEARN_FORCERAW = 0x0100; - const int UUIRTDRV_IRFMT_LEARN_FORCESTRUC = 0x0200; - const int UUIRTDRV_IRFMT_LEARN_FORCEFREQ = 0x0400; - const int UUIRTDRV_IRFMT_LEARN_FREQDETECT = 0x0800; - - static readonly string[] Ports = new string[] { "Default", "Port 1", "Port 2", "Port 3" }; - - const int AbortLearn = -1; - const int AllowLearn = 0; - - #endregion Constants - - #region Variables - - RemoteHandler _remoteButtonHandler = null; - - string _blastPort = Ports[0]; - - int _repeatDelay; - int _blastRepeats; - int _learnTimeout; - - //ulong _learnCarrierFreq; - - string _lastCode = String.Empty; - DateTime _lastCodeTime = DateTime.Now; - - // ------- - - int _abortLearn = AllowLearn; - bool _learnTimedOut; - UUIRTReceiveCallbackDelegate _receiveCallback = null; - bool _isUsbUirtLoaded = false; - IntPtr _usbUirtHandle = IntPtr.Zero; - bool _disposed = false; - - #endregion Variables - - #region Deconstructor - - ~UirtTransceiver() - { - Dispose(false); - } - - #endregion Deconstructor - - #region IDisposable Members - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposeManagedResources) - { - if (!_disposed) - { - _disposed = true; - - if (disposeManagedResources) - { - // Dispose any managed resources. - } - - if (_isUsbUirtLoaded && _usbUirtHandle != new IntPtr(-1) && _usbUirtHandle != IntPtr.Zero) - { - UUIRTClose(_usbUirtHandle); - _usbUirtHandle = IntPtr.Zero; - _isUsbUirtLoaded = false; - } - } - } - - #endregion - - #region IIRServerPlugin Members - - public string Name { get { return "USB-UIRT"; } } - public string Version { get { return "1.0.3.3"; } } - public string Author { get { return "and-81"; } } - public string Description { get { return "Support for the USB-UIRT transceiver"; } } - public bool CanReceive { get { return true; } } - public bool CanTransmit { get { return true; } } - public bool CanLearn { get { return true; } } - public bool CanConfigure { get { return true; } } - - public RemoteHandler RemoteCallback - { - get { return _remoteButtonHandler; } - set { _remoteButtonHandler = value; } - } - - public KeyboardHandler KeyboardCallback { get { return null; } set { } } - - public MouseHandler MouseCallback { get { return null; } set { } } - - public string[] AvailablePorts { get { return Ports; } } - - public void Configure() - { - LoadSettings(); - - Configure config = new Configure(); - - config.RepeatDelay = _repeatDelay; - config.BlastRepeats = _blastRepeats; - config.LearnTimeout = _learnTimeout; - - if (config.ShowDialog() == DialogResult.OK) - { - _repeatDelay = config.RepeatDelay; - _blastRepeats = config.BlastRepeats; - _learnTimeout = config.LearnTimeout; - - SaveSettings(); - } - } - public bool Start() - { - LoadSettings(); - - _usbUirtHandle = UUIRTOpen(); - - if (_usbUirtHandle != new IntPtr(-1)) - { - _isUsbUirtLoaded = true; - - // Setup callack to receive IR messages - _receiveCallback = new UUIRTReceiveCallbackDelegate(UUIRTReceiveCallback); - UUIRTSetReceiveCallback(_usbUirtHandle, _receiveCallback, 0); - } - - return _isUsbUirtLoaded; - } - public void Suspend() { } - public void Resume() { } - public void Stop() - { - UUIRTClose(_usbUirtHandle); - - _usbUirtHandle = IntPtr.Zero; - _isUsbUirtLoaded = false; - } - - public bool Transmit(string file) - { - bool result = false; - - try - { - StreamReader streamReader = new StreamReader(file); - string irCode = streamReader.ReadToEnd(); - streamReader.Close(); - - // Set blaster port ... - if (_blastPort == Ports[1]) - irCode = "Z1" + irCode; - else if (_blastPort == Ports[2]) - irCode = "Z2" + irCode; - else if (_blastPort == Ports[3]) - irCode = "Z3" + irCode; - - result = UUIRTTransmitIR( - _usbUirtHandle, // Handle to USB-UIRT - irCode, // IR Code - UUIRTDRV_IRFMT_PRONTO, // Code Format - _blastRepeats, // Repeat Count - 0, // Inactivity Wait Time - IntPtr.Zero, // hEvent - 0, // reserved1 - 0 // reserved2 - ); - } - catch - { - result = false; - } - - return result; - } - public LearnStatus Learn(out byte[] data) - { - bool result = false; - - data = null; - - StringBuilder irCode = new StringBuilder("1", 2048); - _abortLearn = AllowLearn; - _learnTimedOut = false; - - //_learnCarrierFreq = 0; - - Timer timer = new Timer(); - timer.Interval = _learnTimeout; - timer.Tick += new EventHandler(timer_Tick); - timer.Enabled = true; - timer.Start(); - - //IRLearnCallbackDelegate learnCallback = new IRLearnCallbackDelegate(UUIRTLearnCallback); - - result = UirtTransceiver.UUIRTLearnIR( - _usbUirtHandle, // Handle to USB-UIRT - UirtTransceiver.UUIRTDRV_IRFMT_PRONTO | UirtTransceiver.UUIRTDRV_IRFMT_LEARN_FREQDETECT, // | UirtTransceiver.UUIRTDRV_IRFMT_LEARN_FORCERAW - irCode, // Where to put the IR Code - null, // Learn status callback - 0, // User data - ref _abortLearn, // Abort flag? - 0, - null, - null); - - timer.Stop(); - - //MessageBox.Show(_learnCarrierFreq.ToString()); - - if (_learnTimedOut) - { - return LearnStatus.Timeout; - } - else if (result) - { - data = Encoding.ASCII.GetBytes(irCode.ToString()); - - return LearnStatus.Success; - } - else - { - return LearnStatus.Failure; - } - } - - public bool SetPort(string port) - { - foreach (string availablePort in Ports) - { - if (port == availablePort) - { - _blastPort = availablePort; - return true; - } - } - - return false; - } - - #endregion IIRServerPlugin Members - - #region Implementation - - void LoadSettings() - { - try - { - XmlDocument doc = new XmlDocument(); - doc.Load(ConfigurationFile); - - _repeatDelay = int.Parse(doc.DocumentElement.Attributes["RepeatDelay"].Value); - _blastRepeats = int.Parse(doc.DocumentElement.Attributes["BlastRepeats"].Value); - _learnTimeout = int.Parse(doc.DocumentElement.Attributes["LearnTimeout"].Value); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - - _repeatDelay = 500; - _blastRepeats = 4; - _learnTimeout = 10000; - } - } - void SaveSettings() - { - try - { - XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8); - writer.Formatting = Formatting.Indented; - writer.Indentation = 1; - writer.IndentChar = (char)9; - writer.WriteStartDocument(true); - writer.WriteStartElement("settings"); // <settings> - - writer.WriteAttributeString("RepeatDelay", _repeatDelay.ToString()); - writer.WriteAttributeString("BlastRepeats", _blastRepeats.ToString()); - writer.WriteAttributeString("LearnTimeout", _learnTimeout.ToString()); - - writer.WriteEndElement(); // </settings> - writer.WriteEndDocument(); - writer.Close(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - void UUIRTReceiveCallback(string keyCode, IntPtr userData) - { - if (_remoteButtonHandler == null) - return; - - TimeSpan timeSpan = DateTime.Now - _lastCodeTime; - - if (keyCode == _lastCode) // Repeated button - { - if (timeSpan.Milliseconds > _repeatDelay) - { - _remoteButtonHandler(keyCode); - _lastCodeTime = DateTime.Now; - } - } - else - { - _remoteButtonHandler(keyCode); - _lastCodeTime = DateTime.Now; - } - - _lastCode = keyCode; - } - /* - void UUIRTLearnCallback(uint progress, uint sigQuality, ulong carrierFreq, IntPtr userData) - { - _learnCarrierFreq = carrierFreq; - //MessageBox.Show(_learnCarrierFreq.ToString()); - } - */ - void timer_Tick(object sender, EventArgs e) - { - _abortLearn = AbortLearn; - _learnTimedOut = true; - - ((Timer)sender).Stop(); - } - - #endregion Implementation - - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-08-23 15:02:18
|
Revision: 860 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=860&view=rev Author: and-81 Date: 2007-08-23 08:02:04 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLircServer.cs Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/irremote.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.resx trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.csproj Removed Paths: ------------- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Receiver.csproj Modified: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj 2007-08-23 15:02:04 UTC (rev 860) @@ -66,6 +66,7 @@ <DependentUpon>Configure.cs</DependentUpon> </Compile> <Compile Include="HcwTransceiver.cs" /> + <Compile Include="irremote.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> 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-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -20,100 +20,25 @@ #region Interop - [StructLayout(LayoutKind.Sequential)] - struct UUINFO - { - public int fwVersion; - public int protVersion; - public char fwDateDay; - public char fwDateMonth; - public char fwDateYear; - } - //Not used - //[StructLayout(LayoutKind.Sequential)] - //internal struct UUGPIO - //{ - // public byte[] irCode; - // public byte action; - // public byte duration; - //} + const int WM_ACTIVATE = 0x0006; + const int WM_POWERBROADCAST = 0x0218; + const int WA_INACTIVE = 0; + const int WA_ACTIVE = 1; + const int WA_CLICKACTIVE = 2; - [DllImport("uuirtdrv.dll")] - static extern IntPtr UUIRTOpen(); + const int PBT_APMRESUMEAUTOMATIC = 0x0012; + const int PBT_APMRESUMECRITICAL = 0x0006; - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTClose( - IntPtr hHandle); - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTGetDrvInfo(ref int puDrvVersion); - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTGetUUIRTInfo( - // IntPtr hHandle, - // ref UUINFO puuInfo); - - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTGetUUIRTConfig( - // IntPtr hHandle, - // ref uint puConfig); - - //[DllImport("uuirtdrv.dll")] - //[return: MarshalAs(UnmanagedType.Bool)] - //internal static extern bool UUIRTSetUUIRTConfig( - // IntPtr hHandle, - // uint uConfig); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTTransmitIR( - IntPtr hHandle, - string IRCode, - int codeFormat, - int repeatCount, - int inactivityWaitTime, - IntPtr hEvent, - int res1, - int res2); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTLearnIR( - IntPtr hHandle, - int codeFormat, - [MarshalAs(UnmanagedType.LPStr)] StringBuilder ircode, - IRLearnCallbackDelegate progressProc, - int userData, - ref int pAbort, - int param1, - [MarshalAs(UnmanagedType.AsAny)] Object o, - [MarshalAs(UnmanagedType.AsAny)] Object oo); - - [DllImport("uuirtdrv.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool UUIRTSetReceiveCallback( - IntPtr hHandle, - UUIRTReceiveCallbackDelegate receiveProc, - int none); - - //[DllImport("uuirtdrv.dll")] - //static extern bool UUIRTSetUUIRTGPIOCfg(IntPtr hHandle, int index, ref UUGPIO GpioSt); - - //[DllImport("uuirtdrv.dll")] - //static extern bool UUIRTGetUUIRTGPIOCfg(IntPtr hHandle, ref int numSlots, ref uint dwPortPins, - // ref UUGPIO GpioSt); - #endregion #region Delegates - delegate void UUIRTReceiveCallbackDelegate(string irCode, IntPtr userData); - delegate void IRLearnCallbackDelegate(uint progress, uint sigQuality, ulong carrierFreq, IntPtr userData); + //Sets up callback so that other forms can catch a key press + public delegate void HCWEvent(int keypress); + public event HCWEvent HCWKeyPressed; #endregion Delegates Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/irremote.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/irremote.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/irremote.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -0,0 +1,165 @@ +#region Copyright (C) 2005-2007 Team MediaPortal + +/* + * Copyright (C) 2005-2007 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Runtime.InteropServices; +using Microsoft.Win32; +using MediaPortal.GUI.Library; +using System.IO; + +namespace HcwTransceiver +{ + /// <summary> + /// Wrapper class for irremote.dll + /// </summary> + public static class irremote + { + #region DLL-Imports + + /// <summary> + /// The SetDllDirectory function adds a directory to the search path used to locate DLLs for the application. + /// http://msdn.microsoft.com/library/en-us/dllproc/base/setdlldirectory.asp + /// </summary> + /// <param name="PathName">Pointer to a null-terminated string that specifies the directory to be added to the search path.</param> + /// <returns></returns> + [DllImport("kernel32.dll")] + static extern bool SetDllDirectory( + string PathName); + + /// <summary> + /// Registers window handle with Hauppauge IR driver + /// </summary> + /// <param name="WindowHandle"></param> + /// <param name="Msg"></param> + /// <param name="Verbose"></param> + /// <param name="IRPort"></param> + /// <returns></returns> + [DllImport("irremote.dll")] + static extern bool IR_Open( + int WindowHandle, + uint Msg, + bool Verbose, + ushort IRPort); + + /// <summary> + /// Gets the received key code (new version, works for PVR-150 as well) + /// </summary> + /// <param name="RepeatCount"></param> + /// <param name="RemoteCode"></param> + /// <param name="KeyCode"></param> + /// <returns></returns> + [DllImport("irremote.dll")] + static extern bool IR_GetSystemKeyCode( + out int RepeatCount, + out int RemoteCode, + out int KeyCode); + + /// <summary> + /// Unregisters window handle from Hauppauge IR driver + /// </summary> + /// <param name="WindowHandle"></param> + /// <param name="Msg"></param> + /// <returns></returns> + [DllImport("irremote.dll")] + static extern bool IR_Close( + int WindowHandle, + uint Msg); + + #endregion + + + public static string CurrentVersion = "2.49.23332"; + + public static bool IRClose(IntPtr WindowHandle, uint Msg) + { + return IR_Close((int)WindowHandle, Msg); + } + + public static bool IRGetSystemKeyCode(out int RepeatCount, out int RemoteCode, out int KeyCode) + { + RepeatCount = 0; + RemoteCode = 0; + KeyCode = 0; + bool result = false; + try + { + result = IR_GetSystemKeyCode(out RepeatCount, out RemoteCode, out KeyCode); + } + catch (AccessViolationException) + { + } + catch (Exception ex) + { + Log.Info("HCW: Exception while querying remote: {0}", ex.Message); + } + return result; + } + + public static bool IROpen(IntPtr WindowHandle, uint Msg, bool Verbose, ushort IRPort) + { + return IR_Open((int)WindowHandle, Msg, Verbose, IRPort); + } + + public static bool IRSetDllDirectory(string PathName) + { + return SetDllDirectory(PathName); + } + + /// <summary> + /// Get the Hauppauge IR components installation path from the windows registry. + /// </summary> + /// <returns>Installation path of the Hauppauge IR components</returns> + public static string GetHCWPath() + { + string dllPath = null; + using (RegistryKey rkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Hauppauge WinTV Infrared Remote")) + { + if (rkey != null) + { + dllPath = rkey.GetValue("UninstallString").ToString(); + if (dllPath.IndexOf("UNir32") > 0) + dllPath = dllPath.Substring(0, dllPath.IndexOf("UNir32")); + else if (dllPath.IndexOf("UNIR32") > 0) + dllPath = dllPath.Substring(0, dllPath.IndexOf("UNIR32")); + } + } + return dllPath; + } + + /// <summary> + /// Returns the path of the DLL component + /// </summary> + /// <returns>DLL path</returns> + public static string GetDllPath() + { + string dllPath = GetHCWPath(); + if (!File.Exists(dllPath + "irremote.DLL")) + { + dllPath = null; + } + return dllPath; + } + } +} Copied: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver (from rev 859, trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver) Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Configure.Designer.cs 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.Designer.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -1,4 +1,4 @@ -namespace WinLircReceiver +namespace WinLircTransceiver { partial class Configure { @@ -43,6 +43,7 @@ this.groupBoxServerDetails = new System.Windows.Forms.GroupBox(); this.labelButtonReleaseTime = new System.Windows.Forms.Label(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.buttonCreateIRFiles = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownServerPort)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownButtonReleaseTime)).BeginInit(); this.groupBoxServerDetails.SuspendLayout(); @@ -51,10 +52,10 @@ // buttonOK // this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(104, 208); + this.buttonOK.Location = new System.Drawing.Point(104, 240); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(64, 24); - this.buttonOK.TabIndex = 3; + this.buttonOK.TabIndex = 4; this.buttonOK.Text = "OK"; this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); @@ -63,10 +64,10 @@ // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(176, 208); + this.buttonCancel.Location = new System.Drawing.Point(176, 240); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(64, 24); - this.buttonCancel.TabIndex = 4; + this.buttonCancel.TabIndex = 5; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); @@ -187,13 +188,25 @@ this.openFileDialog.Filter = "All Files|*.*"; this.openFileDialog.Title = "Locate WinLirc server application"; // + // buttonCreateIRFiles + // + this.buttonCreateIRFiles.Location = new System.Drawing.Point(8, 208); + this.buttonCreateIRFiles.Name = "buttonCreateIRFiles"; + this.buttonCreateIRFiles.Size = new System.Drawing.Size(104, 24); + this.buttonCreateIRFiles.TabIndex = 3; + this.buttonCreateIRFiles.Text = "Create IR files"; + this.toolTips.SetToolTip(this.buttonCreateIRFiles, "Click here to make IR Command files for use with this plugin"); + this.buttonCreateIRFiles.UseVisualStyleBackColor = true; + this.buttonCreateIRFiles.Click += new System.EventHandler(this.buttonCreateIRFiles_Click); + // // Configure // this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(248, 241); + this.ClientSize = new System.Drawing.Size(248, 272); + this.Controls.Add(this.buttonCreateIRFiles); this.Controls.Add(this.numericUpDownButtonReleaseTime); this.Controls.Add(this.labelButtonReleaseTime); this.Controls.Add(this.groupBoxServerDetails); @@ -231,5 +244,6 @@ private System.Windows.Forms.Label labelButtonReleaseTime; private System.Windows.Forms.NumericUpDown numericUpDownButtonReleaseTime; private System.Windows.Forms.OpenFileDialog openFileDialog; + private System.Windows.Forms.Button buttonCreateIRFiles; } } \ No newline at end of file Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Configure.cs 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Configure.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -7,7 +7,7 @@ using System.Net; using System.Windows.Forms; -namespace WinLircReceiver +namespace WinLircTransceiver { public partial class Configure : Form @@ -72,9 +72,13 @@ textBoxServerPath.Text = openFileDialog.FileName; } + private void buttonCreateIRFiles_Click(object sender, EventArgs e) + { + + } + #endregion Buttons - } } Added: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.Designer.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -0,0 +1,38 @@ +namespace WinLircTransceiver +{ + partial class CreateIRFile + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "CreateIRFile"; + } + + #endregion + } +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace WinLircTransceiver +{ + public partial class CreateIRFile : Form + { + public CreateIRFile() + { + InitializeComponent(); + } + } +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.resx =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.resx (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/CreateIRFile.resx 2007-08-23 15:02:04 UTC (rev 860) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/Properties/AssemblyInfo.cs 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/Properties/AssemblyInfo.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -6,11 +6,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("WinLirc Receiver")] +[assembly: AssemblyTitle("WinLirc Transceiver")] [assembly: AssemblyDescription("IR Server plugin to support WinLirc")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("and-81")] -[assembly: AssemblyProduct("WinLircReceiver")] +[assembly: AssemblyProduct("WinLircTransceiver")] [assembly: AssemblyCopyright("Aaron Dinnage")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Receiver.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -1,195 +0,0 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Diagnostics; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Windows.Forms; -using System.Xml; - -using IRServerPluginInterface; - -namespace WinLircReceiver -{ - - public class WinLircReceiver : IRServerPlugin, IConfigure, IRemoteReceiver, ITransmitIR - { - - #region Constants - - static readonly string ConfigurationFile = - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + - "\\IR Server Suite\\IR Server\\WinLirc Receiver.xml"; - - #endregion Constants - - #region Variables - - RemoteHandler _remoteButtonHandler = null; - WinLircServer _server; - - IPAddress _serverIP; - int _serverPort; - bool _startServer; - string _serverPath; - int _buttonReleaseTime; - - #endregion Variables - - #region Implementation - - public override string Name { get { return "WinLirc"; } } - public override string Version { get { return "1.0.3.3"; } } - public override string Author { get { return "and-81, original code for MediaPortal by Sven"; } } - public override string Description { get { return "Supports WinLirc as a reciever"; } } - - public override bool Start() - { - LoadSettings(); - - if (_startServer) - { - if (!WinLircServer.StartServer(_serverPath)) - return false; - } - - _server = new WinLircServer(_serverIP, _serverPort, TimeSpan.FromMilliseconds(_buttonReleaseTime)); - _server.CommandEvent += new WinLircServer.CommandEventHandler(CommandHandler); - - return true; - } - public override void Suspend() - { - Stop(); - } - public override void Resume() - { - Start(); - } - public override void Stop() - { - _server.CommandEvent -= new WinLircServer.CommandEventHandler(CommandHandler); - _server = null; - } - - public RemoteHandler RemoteCallback - { - get { return _remoteButtonHandler; } - set { _remoteButtonHandler = value; } - } - - public void Configure() - { - LoadSettings(); - - Configure config = new Configure(); - - config.ServerIP = _serverIP; - config.ServerPort = _serverPort; - config.StartServer = _startServer; - config.ServerPath = _serverPath; - config.ButtonReleaseTime = _buttonReleaseTime; - - if (config.ShowDialog() == DialogResult.OK) - { - _serverIP = config.ServerIP; - _serverPort = config.ServerPort; - _startServer = config.StartServer; - _serverPath = config.ServerPath; - _buttonReleaseTime = config.ButtonReleaseTime; - - SaveSettings(); - } - } - - public string[] AvailablePorts { get { return new string[] { "Default" }; } } - - public bool Transmit(string port, byte[] data) - { - string password, remoteName, buttonName, repeats; - - MemoryStream memoryStream = new MemoryStream(data); - - XmlDocument doc = new XmlDocument(); - doc.Load(memoryStream); - - password = doc.DocumentElement.Attributes["Password"].Value; - remoteName = doc.DocumentElement.Attributes["RemoteName"].Value; - buttonName = doc.DocumentElement.Attributes["ButtonName"].Value; - repeats = doc.DocumentElement.Attributes["Repeats"].Value; - - string output = String.Format("{0} {1} {2} {3}\n", password, remoteName, buttonName, repeats); - _server.Transmit(output); - - memoryStream.Close(); - - return true; - } - - void LoadSettings() - { - try - { - XmlDocument doc = new XmlDocument(); - doc.Load(ConfigurationFile); - - _serverIP = IPAddress.Parse(doc.DocumentElement.Attributes["ServerIP"].Value); - _serverPort = int.Parse(doc.DocumentElement.Attributes["ServerPort"].Value); - _startServer = bool.Parse(doc.DocumentElement.Attributes["StartServer"].Value); - _serverPath = doc.DocumentElement.Attributes["ServerPath"].Value; - _buttonReleaseTime = int.Parse(doc.DocumentElement.Attributes["ButtonReleaseTime"].Value); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - - _serverIP = IPAddress.Parse("127.0.0.1"); - _serverPort = 8765; - _startServer = false; - _serverPath = "winlirc.exe"; - _buttonReleaseTime = 200; - } - } - void SaveSettings() - { - try - { - XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8); - writer.Formatting = Formatting.Indented; - writer.Indentation = 1; - writer.IndentChar = (char)9; - writer.WriteStartDocument(true); - writer.WriteStartElement("settings"); // <settings> - - writer.WriteAttributeString("ServerIP", _serverIP.ToString()); - writer.WriteAttributeString("ServerPort", _serverPort.ToString()); - writer.WriteAttributeString("StartServer", _startServer.ToString()); - writer.WriteAttributeString("ServerPath", _serverPath); - writer.WriteAttributeString("ButtonReleaseTime", _buttonReleaseTime.ToString()); - - writer.WriteEndElement(); // </settings> - writer.WriteEndDocument(); - writer.Close(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - void CommandHandler(WinLircServer.Command cmd) - { - if (_remoteButtonHandler == null) - return; - - string buttonCode = cmd.Remote + ": " + cmd.Button; - - _remoteButtonHandler(buttonCode); - } - - #endregion Implementation - - } - -} Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.csproj 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Receiver.csproj 2007-08-23 15:02:04 UTC (rev 860) @@ -1,97 +0,0 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{E6A68244-8C31-44A9-9F85-B4A102B5F209}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>WinLircReceiver</RootNamespace> - <AssemblyName>WinLirc Receiver</AssemblyName> - <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>false</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <UseVSHostingProcess>false</UseVSHostingProcess> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>none</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants> - </DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <UseVSHostingProcess>false</UseVSHostingProcess> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <OutputPath>bin\x86\Debug\</OutputPath> - <DefineConstants>DEBUG</DefineConstants> - <TreatWarningsAsErrors>true</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" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Configure.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Configure.Designer.cs"> - <DependentUpon>Configure.cs</DependentUpon> - </Compile> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="WinLirc Receiver.cs" /> - <Compile Include="WinLircServer.cs" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> - <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> - <Name>IR Server Plugin Interface</Name> - <Private>False</Private> - </ProjectReference> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="Configure.resx"> - <DependentUpon>Configure.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> - <PropertyGroup> - <PostBuildEvent>copy "$(TargetFileName)" "\MediaPortal Development\Plugin Releases\IR Server Suite\IR Server Plugins\"</PostBuildEvent> - </PropertyGroup> -</Project> \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -0,0 +1,197 @@ +using System; +using System.Collections; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Windows.Forms; +using System.Xml; + +using IRServerPluginInterface; + +namespace WinLircTransceiver +{ + + public class WinLircTransceiver : IRServerPlugin, IConfigure, IRemoteReceiver, ITransmitIR + { + + #region Constants + + static readonly string ConfigurationFile = + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + + "\\IR Server Suite\\IR Server\\WinLirc Receiver.xml"; + + #endregion Constants + + #region Variables + + RemoteHandler _remoteButtonHandler = null; + WinLircServer _server; + + IPAddress _serverIP; + int _serverPort; + bool _startServer; + string _serverPath; + int _buttonReleaseTime; + + #endregion Variables + + #region Implementation + + public override string Name { get { return "WinLirc"; } } + public override string Version { get { return "1.0.3.3"; } } + public override string Author { get { return "and-81, original code for MediaPortal by Sven"; } } + public override string Description { get { return "Supports WinLirc as a Transciever"; } } + + public override bool Start() + { + LoadSettings(); + + if (_startServer) + { + if (!WinLircServer.StartServer(_serverPath)) + return false; + } + + _server = new WinLircServer(_serverIP, _serverPort, TimeSpan.FromMilliseconds(_buttonReleaseTime)); + _server.CommandEvent += new WinLircServer.CommandEventHandler(CommandHandler); + + return true; + } + public override void Suspend() + { + Stop(); + } + public override void Resume() + { + Start(); + } + public override void Stop() + { + _server.CommandEvent -= new WinLircServer.CommandEventHandler(CommandHandler); + _server = null; + } + + public RemoteHandler RemoteCallback + { + get { return _remoteButtonHandler; } + set { _remoteButtonHandler = value; } + } + + public void Configure() + { + LoadSettings(); + + Configure config = new Configure(); + + config.ServerIP = _serverIP; + config.ServerPort = _serverPort; + config.StartServer = _startServer; + config.ServerPath = _serverPath; + config.ButtonReleaseTime = _buttonReleaseTime; + + if (config.ShowDialog() == DialogResult.OK) + { + _serverIP = config.ServerIP; + _serverPort = config.ServerPort; + _startServer = config.StartServer; + _serverPath = config.ServerPath; + _buttonReleaseTime = config.ButtonReleaseTime; + + SaveSettings(); + } + } + + public string[] AvailablePorts { get { return new string[] { "Default" }; } } + + public bool Transmit(string port, byte[] data) + { + string password, remoteName, buttonName, repeats; + + MemoryStream memoryStream = new MemoryStream(data); + + XmlDocument doc = new XmlDocument(); + doc.Load(memoryStream); + + password = doc.DocumentElement.Attributes["Password"].Value; + remoteName = doc.DocumentElement.Attributes["RemoteName"].Value; + buttonName = doc.DocumentElement.Attributes["ButtonName"].Value; + repeats = doc.DocumentElement.Attributes["Repeats"].Value; + + string output = String.Format("{0} {1} {2} {3}\n", password, remoteName, buttonName, repeats); + + MessageBox.Show(output); + _server.Transmit(output); + + memoryStream.Close(); + + return true; + } + + void LoadSettings() + { + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(ConfigurationFile); + + _serverIP = IPAddress.Parse(doc.DocumentElement.Attributes["ServerIP"].Value); + _serverPort = int.Parse(doc.DocumentElement.Attributes["ServerPort"].Value); + _startServer = bool.Parse(doc.DocumentElement.Attributes["StartServer"].Value); + _serverPath = doc.DocumentElement.Attributes["ServerPath"].Value; + _buttonReleaseTime = int.Parse(doc.DocumentElement.Attributes["ButtonReleaseTime"].Value); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + + _serverIP = IPAddress.Parse("127.0.0.1"); + _serverPort = 8765; + _startServer = false; + _serverPath = "winlirc.exe"; + _buttonReleaseTime = 200; + } + } + void SaveSettings() + { + try + { + XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, System.Text.Encoding.UTF8); + writer.Formatting = Formatting.Indented; + writer.Indentation = 1; + writer.IndentChar = (char)9; + writer.WriteStartDocument(true); + writer.WriteStartElement("settings"); // <settings> + + writer.WriteAttributeString("ServerIP", _serverIP.ToString()); + writer.WriteAttributeString("ServerPort", _serverPort.ToString()); + writer.WriteAttributeString("StartServer", _startServer.ToString()); + writer.WriteAttributeString("ServerPath", _serverPath); + writer.WriteAttributeString("ButtonReleaseTime", _buttonReleaseTime.ToString()); + + writer.WriteEndElement(); // </settings> + writer.WriteEndDocument(); + writer.Close(); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + void CommandHandler(WinLircServer.Command cmd) + { + if (_remoteButtonHandler == null) + return; + + string buttonCode = cmd.Remote + ": " + cmd.Button; + + _remoteButtonHandler(buttonCode); + } + + #endregion Implementation + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.csproj (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.csproj 2007-08-23 15:02:04 UTC (rev 860) @@ -0,0 +1,103 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{E6A68244-8C31-44A9-9F85-B4A102B5F209}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>WinLircTransceiver</RootNamespace> + <AssemblyName>WinLirc Transceiver</AssemblyName> + <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>false</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants> + </DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <TreatWarningsAsErrors>true</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" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Configure.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Configure.Designer.cs"> + <DependentUpon>Configure.cs</DependentUpon> + </Compile> + <Compile Include="CreateIRFile.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="CreateIRFile.Designer.cs"> + <DependentUpon>CreateIRFile.cs</DependentUpon> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="WinLirc Transceiver.cs" /> + <Compile Include="WinLircServer.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> + <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> + <Name>IR Server Plugin Interface</Name> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Configure.resx"> + <DependentUpon>Configure.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <PostBuildEvent>copy "$(TargetFileName)" "\MediaPortal Development\Plugin Releases\IR Server Suite\IR Server Plugins\"</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLircServer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLircServer.cs 2007-08-23 13:19:30 UTC (rev 859) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLircServer.cs 2007-08-23 15:02:04 UTC (rev 860) @@ -31,7 +31,7 @@ using System.Net.Sockets; using System.Diagnostics; -namespace WinLircReceiver +namespace WinLircTransceiver { /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-11-30 12:18:12
|
Revision: 1111 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1111&view=rev Author: and-81 Date: 2007-11-30 04:18:10 -0800 (Fri, 30 Nov 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs 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-11-30 11:59:17 UTC (rev 1110) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-11-30 12:18:10 UTC (rev 1111) @@ -109,25 +109,25 @@ FirstPipeInstance = 0x00080000 } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DeviceInfoData { public int Size; public Guid Class; - public uint DevInst; + public int DevInst; public IntPtr Reserved; } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DeviceInterfaceData { public int Size; public Guid Class; - public uint Flags; - public uint Reserved; + public int Flags; + public IntPtr Reserved; } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct DeviceInterfaceDetailData { public int Size; @@ -351,9 +351,8 @@ IntPtr handle = SetupDiGetClassDevs(ref classGuid, null, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); - //int lastError = Marshal.GetLastWin32Error(); - //if (lastError != 0) - //throw new Win32Exception(lastError); + if (handle.ToInt32() == -1) + return null; for (int deviceIndex = 0; ; deviceIndex++) { @@ -393,7 +392,10 @@ } DeviceInterfaceDetailData deviceInterfaceDetailData = new DeviceInterfaceDetailData(); - deviceInterfaceDetailData.Size = 5; + if (IntPtr.Size == 8) + deviceInterfaceDetailData.Size = 8; + else + deviceInterfaceDetailData.Size = 5; if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, ref deviceInterfaceDetailData, cbData, IntPtr.Zero, IntPtr.Zero)) { Modified: trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs 2007-11-30 11:59:17 UTC (rev 1110) +++ trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs 2007-11-30 12:18:10 UTC (rev 1111) @@ -79,29 +79,30 @@ FirstPipeInstance = 0x00080000, } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DeviceInfoData { public int Size; public Guid Class; - public uint DevInst; + public int DevInst; public IntPtr Reserved; } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DeviceInterfaceData { public int Size; public Guid Class; - public uint Flags; - public uint Reserved; + public int Flags; + public IntPtr Reserved; } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct DeviceInterfaceDetailData { public int Size; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string DevicePath; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string DevicePath; } [DllImport("hid")] @@ -384,7 +385,10 @@ } DeviceInterfaceDetailData deviceInterfaceDetailData = new DeviceInterfaceDetailData(); - deviceInterfaceDetailData.Size = 5; + if (IntPtr.Size == 8) + deviceInterfaceDetailData.Size = 8; + else + deviceInterfaceDetailData.Size = 5; if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, ref deviceInterfaceDetailData, cbData, IntPtr.Zero, IntPtr.Zero)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-12-04 03:33:46
|
Revision: 1120 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1120&view=rev Author: and-81 Date: 2007-12-03 19:33:40 -0800 (Mon, 03 Dec 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs Property Changed: ---------------- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/ trunk/plugins/IR Server Suite/IR Server Plugins/WiimoteLib/ Property changes on: trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver ___________________________________________________________________ Name: svn:ignore + bin obj Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs 2007-12-04 00:45:02 UTC (rev 1119) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs 2007-12-04 03:33:40 UTC (rev 1120) @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.Drawing; +using System.Windows.Forms; using IRServerPluginInterface; @@ -15,20 +16,16 @@ public class WiiRemoteReceiver : IRServerPluginBase, IRemoteReceiver { - #region Delegates + #region Variables - delegate void UpdateWiimoteStateDelegate(WiimoteChangedEventArgs args); - delegate void UpdateExtensionChangedDelegate(WiimoteExtensionChangedEventArgs args); + RemoteHandler _remoteButtonHandler; - #endregion Delegates + Wiimote _wiimote; - #region Variables + WiimoteState _previousState; - RemoteHandler _remoteButtonHandler; - - Wiimote wm; - Bitmap b; - Graphics g; + int screenWidth = Screen.PrimaryScreen.WorkingArea.Width; + int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; #endregion Variables @@ -72,19 +69,16 @@ /// <returns>true if successful, otherwise false.</returns> public override bool Start() { - wm = new Wiimote(); + _wiimote = new Wiimote(); - wm.WiimoteChanged += new WiimoteChangedEventHandler(wm_WiimoteChanged); - wm.WiimoteExtensionChanged += new WiimoteExtensionChangedEventHandler(wm_WiimoteExtensionChanged); + _wiimote.WiimoteChanged += new WiimoteChangedEventHandler(WiimoteChanged); + _wiimote.WiimoteExtensionChanged += new WiimoteExtensionChangedEventHandler(WiimoteExtensionChanged); - b = new Bitmap(256, 192, PixelFormat.Format24bppRgb); + _wiimote.Connect(); + _wiimote.SetReportType(Wiimote.InputReport.IRAccel, true); + _wiimote.SetLEDs(false, true, true, false); + _wiimote.SetRumble(false); - g = Graphics.FromImage(b); - - wm.Connect(); - wm.SetReportType(Wiimote.InputReport.IRAccel, true); - wm.SetLEDs(false, true, true, false); - return true; } /// <summary> @@ -106,10 +100,12 @@ /// </summary> public override void Stop() { - if (wm == null) + if (_wiimote == null) return; - wm.Disconnect(); + _wiimote.SetLEDs(false, false, false, false); + _wiimote.SetRumble(false); + _wiimote.Disconnect(); } /// <summary> @@ -121,120 +117,136 @@ get { return _remoteButtonHandler; } set { _remoteButtonHandler = value; } } + + void WiimoteChanged(object sender, WiimoteChangedEventArgs args) + { + WiimoteState ws = args.WiimoteState; + if (_previousState != null) + { + if (ws.ButtonState.A && !_previousState.ButtonState.A) RemoteCallback("Wiimote_Button:A"); + if (ws.ButtonState.B && !_previousState.ButtonState.B) RemoteCallback("Wiimote_Button:B"); + if (ws.ButtonState.Home && !_previousState.ButtonState.Home) RemoteCallback("Wiimote_Button:Home"); + if (ws.ButtonState.Minus && !_previousState.ButtonState.Minus) RemoteCallback("Wiimote_Button:Minus"); + if (ws.ButtonState.One && !_previousState.ButtonState.One) RemoteCallback("Wiimote_Button:One"); + if (ws.ButtonState.Plus && !_previousState.ButtonState.Plus) RemoteCallback("Wiimote_Button:Plus"); + if (ws.ButtonState.Two && !_previousState.ButtonState.Two) RemoteCallback("Wiimote_Button:Two"); + if (ws.ButtonState.Down && !_previousState.ButtonState.Down) RemoteCallback("Wiimote_Pad:Down"); + if (ws.ButtonState.Left && !_previousState.ButtonState.Left) RemoteCallback("Wiimote_Pad:Left"); + if (ws.ButtonState.Right && !_previousState.ButtonState.Right) RemoteCallback("Wiimote_Pad:Right"); + if (ws.ButtonState.Up && !_previousState.ButtonState.Up) RemoteCallback("Wiimote_Pad:Up"); - private void UpdateExtensionChanged(WiimoteExtensionChangedEventArgs args) - { - chkExtension.Text = args.ExtensionType.ToString(); - chkExtension.Checked = args.Inserted; + if (ws.ExtensionType == ExtensionType.Nunchuk) + { + if (ws.NunchukState.C && !_previousState.NunchukState.C) RemoteCallback("WiimoteNunchuk_Button:C"); + if (ws.NunchukState.Z && !_previousState.NunchukState.Z) RemoteCallback("WiimoteNunchuk_Button:Z"); + } - if (args.Inserted) - wm.SetReportType(Wiimote.InputReport.IRExtensionAccel, true); - else - wm.SetReportType(Wiimote.InputReport.IRAccel, true); - } + if (ws.ExtensionType == ExtensionType.ClassicController) + { + if (ws.ClassicControllerState.ButtonState.A && !_previousState.ClassicControllerState.ButtonState.A) RemoteCallback("WiimoteClassic_Button:A"); + if (ws.ClassicControllerState.ButtonState.B && !_previousState.ClassicControllerState.ButtonState.B) RemoteCallback("WiimoteClassic_Button:B"); + if (ws.ClassicControllerState.ButtonState.Home && !_previousState.ClassicControllerState.ButtonState.Home) RemoteCallback("WiimoteClassic_Button:Home"); + if (ws.ClassicControllerState.ButtonState.Minus && !_previousState.ClassicControllerState.ButtonState.Minus) RemoteCallback("WiimoteClassic_Button:Minus"); + if (ws.ClassicControllerState.ButtonState.Plus && !_previousState.ClassicControllerState.ButtonState.Plus) RemoteCallback("WiimoteClassic_Button:Plus"); + if (ws.ClassicControllerState.ButtonState.X && !_previousState.ClassicControllerState.ButtonState.X) RemoteCallback("WiimoteClassic_Button:X"); + if (ws.ClassicControllerState.ButtonState.Y && !_previousState.ClassicControllerState.ButtonState.Y) RemoteCallback("WiimoteClassic_Button:Y"); + if (ws.ClassicControllerState.ButtonState.TriggerL && !_previousState.ClassicControllerState.ButtonState.TriggerL) RemoteCallback("WiimoteClassic_Button:TriggerL"); + if (ws.ClassicControllerState.ButtonState.TriggerR && !_previousState.ClassicControllerState.ButtonState.TriggerR) RemoteCallback("WiimoteClassic_Button:TriggerR"); + if (ws.ClassicControllerState.ButtonState.ZL && !_previousState.ClassicControllerState.ButtonState.ZL) RemoteCallback("WiimoteClassic_Button:ZL"); + if (ws.ClassicControllerState.ButtonState.ZR && !_previousState.ClassicControllerState.ButtonState.ZR) RemoteCallback("WiimoteClassic_Button:ZR"); - private void UpdateWiimoteState(WiimoteChangedEventArgs args) - { - WiimoteState ws = args.WiimoteState; + if (ws.ClassicControllerState.ButtonState.Down && !_previousState.ClassicControllerState.ButtonState.Down) RemoteCallback("WiimoteClassic_Pad:Down"); + if (ws.ClassicControllerState.ButtonState.Left && !_previousState.ClassicControllerState.ButtonState.Left) RemoteCallback("WiimoteClassic_Pad:Left"); + if (ws.ClassicControllerState.ButtonState.Right && !_previousState.ClassicControllerState.ButtonState.Right) RemoteCallback("WiimoteClassic_Pad:Right"); + if (ws.ClassicControllerState.ButtonState.Up && !_previousState.ClassicControllerState.ButtonState.Up) RemoteCallback("WiimoteClassic_Pad:Up"); + } - clbButtons.SetItemChecked(0, ws.ButtonState.A); - clbButtons.SetItemChecked(1, ws.ButtonState.B); - clbButtons.SetItemChecked(2, ws.ButtonState.Minus); - clbButtons.SetItemChecked(3, ws.ButtonState.Home); - clbButtons.SetItemChecked(4, ws.ButtonState.Plus); - clbButtons.SetItemChecked(5, ws.ButtonState.One); - clbButtons.SetItemChecked(6, ws.ButtonState.Two); - clbButtons.SetItemChecked(7, ws.ButtonState.Up); - clbButtons.SetItemChecked(8, ws.ButtonState.Down); - clbButtons.SetItemChecked(9, ws.ButtonState.Left); - clbButtons.SetItemChecked(10, ws.ButtonState.Right); - clbButtons.SetItemChecked(11, ws.NunchukState.C); - clbButtons.SetItemChecked(12, ws.NunchukState.Z); + if (ws.IRState.Found1 && ws.IRState.Found2) + { + int x = (int)(screenWidth - (ws.IRState.X1 + ws.IRState.X2) / 2 * screenWidth); + int y = (int)((ws.IRState.Y1 + ws.IRState.Y2) / 2 * screenHeight); - lblX.Text = ws.AccelState.X.ToString(); - lblY.Text = ws.AccelState.Y.ToString(); - lblZ.Text = ws.AccelState.Z.ToString(); + Cursor.Position = new Point(x, y); - if (ws.ExtensionType == ExtensionType.Nunchuk) - { - lblChukX.Text = ws.NunchukState.AccelState.X.ToString(); - lblChukY.Text = ws.NunchukState.AccelState.Y.ToString(); - lblChukZ.Text = ws.NunchukState.AccelState.Z.ToString(); + int prevX = (int)(screenWidth - (_previousState.IRState.X1 + _previousState.IRState.X2) / 2 * screenWidth); + int prevY = (int)((_previousState.IRState.Y1 + _previousState.IRState.Y2) / 2 * screenHeight); - lblChukJoyX.Text = ws.NunchukState.X.ToString(); - lblChukJoyY.Text = ws.NunchukState.Y.ToString(); - } + int deltaX = x - prevX; + int deltaY = y - prevY; - if (ws.ExtensionType == ExtensionType.ClassicController) - { - clbCCButtons.SetItemChecked(0, ws.ClassicControllerState.ButtonState.A); - clbCCButtons.SetItemChecked(1, ws.ClassicControllerState.ButtonState.B); - clbCCButtons.SetItemChecked(2, ws.ClassicControllerState.ButtonState.X); - clbCCButtons.SetItemChecked(3, ws.ClassicControllerState.ButtonState.Y); - clbCCButtons.SetItemChecked(4, ws.ClassicControllerState.ButtonState.Minus); - clbCCButtons.SetItemChecked(5, ws.ClassicControllerState.ButtonState.Home); - clbCCButtons.SetItemChecked(6, ws.ClassicControllerState.ButtonState.Plus); - clbCCButtons.SetItemChecked(7, ws.ClassicControllerState.ButtonState.Up); - clbCCButtons.SetItemChecked(8, ws.ClassicControllerState.ButtonState.Down); - clbCCButtons.SetItemChecked(9, ws.ClassicControllerState.ButtonState.Left); - clbCCButtons.SetItemChecked(10, ws.ClassicControllerState.ButtonState.Right); - clbCCButtons.SetItemChecked(11, ws.ClassicControllerState.ButtonState.ZL); - clbCCButtons.SetItemChecked(12, ws.ClassicControllerState.ButtonState.ZR); - clbCCButtons.SetItemChecked(13, ws.ClassicControllerState.ButtonState.TriggerL); - clbCCButtons.SetItemChecked(14, ws.ClassicControllerState.ButtonState.TriggerR); + Trace.WriteLine("DeltaX: " + deltaX.ToString() + " DeltaY: " + deltaY.ToString()); - lblXL.Text = ws.ClassicControllerState.XL.ToString(); - lblYL.Text = ws.ClassicControllerState.YL.ToString(); - lblXR.Text = ws.ClassicControllerState.XR.ToString(); - lblYR.Text = ws.ClassicControllerState.YR.ToString(); - - lblTriggerL.Text = ws.ClassicControllerState.TriggerL.ToString(); - lblTriggerR.Text = ws.ClassicControllerState.TriggerR.ToString(); + } } + else + _previousState = new WiimoteState(); + + //_previousState.AccelCalibrationInfo.X0 = ws.AccelCalibrationInfo.X0; + //_previousState.AccelCalibrationInfo.XG = ws.AccelCalibrationInfo.XG; + //_previousState.AccelCalibrationInfo.Y0 = ws.AccelCalibrationInfo.Y0; + //_previousState.AccelCalibrationInfo.YG = ws.AccelCalibrationInfo.YG; + //_previousState.AccelCalibrationInfo.Z0 = ws.AccelCalibrationInfo.Z0; + //_previousState.AccelCalibrationInfo.ZG = ws.AccelCalibrationInfo.ZG; - if (ws.IRState.Found1) - { - lblIR1.Text = ws.IRState.X1.ToString() + ", " + ws.IRState.Y1.ToString() + ", " + ws.IRState.Size1; - lblIR1Raw.Text = ws.IRState.RawX1.ToString() + ", " + ws.IRState.RawY1.ToString(); - } - if (ws.IRState.Found2) - { - lblIR2.Text = ws.IRState.X2.ToString() + ", " + ws.IRState.Y2.ToString() + ", " + ws.IRState.Size2; - lblIR2Raw.Text = ws.IRState.RawX2.ToString() + ", " + ws.IRState.RawY2.ToString(); - } + //_previousState.AccelState.RawX = ws.AccelState.RawX; + //_previousState.AccelState.RawY = ws.AccelState.RawY; + //_previousState.AccelState.RawZ = ws.AccelState.RawZ; + //_previousState.AccelState.X = ws.AccelState.X; + //_previousState.AccelState.Y = ws.AccelState.Y; + //_previousState.AccelState.Z = ws.AccelState.Z; - chkFound1.Checked = ws.IRState.Found1; - chkFound2.Checked = ws.IRState.Found2; + //_previousState.Battery = ws.Battery; - pbBattery.Value = (ws.Battery > 0xc8 ? 0xc8 : (int)ws.Battery); - float f = (((100.0f * 48.0f * (float)(ws.Battery / 48.0f))) / 192.0f); - lblBattery.Text = f.ToString("F"); + _previousState.ButtonState.A = ws.ButtonState.A; + _previousState.ButtonState.B = ws.ButtonState.B; + _previousState.ButtonState.Down = ws.ButtonState.Down; + _previousState.ButtonState.Home = ws.ButtonState.Home; + _previousState.ButtonState.Left = ws.ButtonState.Left; + _previousState.ButtonState.Minus = ws.ButtonState.Minus; + _previousState.ButtonState.One = ws.ButtonState.One; + _previousState.ButtonState.Plus = ws.ButtonState.Plus; + _previousState.ButtonState.Right = ws.ButtonState.Right; + _previousState.ButtonState.Two = ws.ButtonState.Two; + _previousState.ButtonState.Up = ws.ButtonState.Up; - g.Clear(Color.Black); - if (ws.IRState.Found1) - g.DrawEllipse(new Pen(Color.Red), (int)(ws.IRState.RawX1 / 4), (int)(ws.IRState.RawY1 / 4), ws.IRState.Size1 + 1, ws.IRState.Size1 + 1); - if (ws.IRState.Found2) - g.DrawEllipse(new Pen(Color.Blue), (int)(ws.IRState.RawX2 / 4), (int)(ws.IRState.RawY2 / 4), ws.IRState.Size2 + 1, ws.IRState.Size2 + 1); - if (ws.IRState.Found1 && ws.IRState.Found2) - g.DrawEllipse(new Pen(Color.Green), (int)(ws.IRState.RawMidX / 4), (int)(ws.IRState.RawMidY / 4), 2, 2); - pbIR.Image = b; - } + _previousState.Extension = ws.Extension; + _previousState.ExtensionType = ws.ExtensionType; + + _previousState.IRState.Found1 = ws.IRState.Found1; + _previousState.IRState.Found2 = ws.IRState.Found2; + _previousState.IRState.MidX = ws.IRState.MidX; + _previousState.IRState.MidY = ws.IRState.MidY; + _previousState.IRState.Mode = ws.IRState.Mode; + _previousState.IRState.RawMidX = ws.IRState.RawMidX; + _previousState.IRState.RawMidY = ws.IRState.RawMidY; + _previousState.IRState.RawX1 = ws.IRState.RawX1; + _previousState.IRState.RawX2 = ws.IRState.RawX2; + _previousState.IRState.RawY1 = ws.IRState.RawY1; + _previousState.IRState.RawY2 = ws.IRState.RawY2; + _previousState.IRState.Size1 = ws.IRState.Size1; + _previousState.IRState.Size2 = ws.IRState.Size2; + _previousState.IRState.X1 = ws.IRState.X1; + _previousState.IRState.X2 = ws.IRState.X2; + _previousState.IRState.Y1 = ws.IRState.Y1; + _previousState.IRState.Y2 = ws.IRState.Y2; - private void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) - { - BeginInvoke(new UpdateWiimoteStateDelegate(UpdateWiimoteState), args); + _previousState.NunchukState.C = ws.NunchukState.C; + _previousState.NunchukState.Z = ws.NunchukState.Z; + } - private void wm_WiimoteExtensionChanged(object sender, WiimoteExtensionChangedEventArgs args) + void WiimoteExtensionChanged(object sender, WiimoteExtensionChangedEventArgs args) { - BeginInvoke(new UpdateExtensionChangedDelegate(UpdateExtensionChanged), args); + if (args.Inserted) + _wiimote.SetReportType(Wiimote.InputReport.IRExtensionAccel, true); + else + _wiimote.SetReportType(Wiimote.InputReport.IRAccel, true); } + - - #endregion Implementation } Property changes on: trunk/plugins/IR Server Suite/IR Server Plugins/WiimoteLib ___________________________________________________________________ Name: svn:ignore + bin obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2007-11-30 11:59:18
|
Revision: 1110 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1110&view=rev Author: and-81 Date: 2007-11-30 03:59:17 -0800 (Fri, 30 Nov 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/RedEye Blaster.cs Modified: 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 2007-11-30 11:09:23 UTC (rev 1109) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs 2007-11-30 11:59:17 UTC (rev 1110) @@ -94,25 +94,25 @@ #region Structures - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DeviceInfoData { public int Size; public Guid Class; - public uint DevInst; + public int DevInst; public IntPtr Reserved; } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DeviceInterfaceData { public int Size; public Guid Class; - public uint Flags; - public uint Reserved; + public int Flags; + public IntPtr Reserved; } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct DeviceInterfaceDetailData { public int Size; @@ -322,8 +322,12 @@ } DeviceInterfaceDetailData deviceInterfaceDetailData = new DeviceInterfaceDetailData(); - deviceInterfaceDetailData.Size = 5; + if (IntPtr.Size == 8) + deviceInterfaceDetailData.Size = 8; + else + deviceInterfaceDetailData.Size = 5; + if (!SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, ref deviceInterfaceDetailData, cbData, IntPtr.Zero, IntPtr.Zero)) { SetupDiDestroyDeviceInfoList(handle); Modified: trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.Designer.cs 2007-11-30 11:09:23 UTC (rev 1109) +++ trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.Designer.cs 2007-11-30 11:59:17 UTC (rev 1110) @@ -1,4 +1,4 @@ -namespace SerialIRBlaster +namespace RedEyeBlaster { partial class Configure { Modified: trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.cs 2007-11-30 11:09:23 UTC (rev 1109) +++ trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/Configure.cs 2007-11-30 11:59:17 UTC (rev 1110) @@ -7,7 +7,7 @@ using System.Text; using System.Windows.Forms; -namespace SerialIRBlaster +namespace RedEyeBlaster { partial class Configure : Form Modified: trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/RedEye Blaster.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/RedEye Blaster.cs 2007-11-30 11:09:23 UTC (rev 1109) +++ trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/RedEye Blaster.cs 2007-11-30 11:59:17 UTC (rev 1110) @@ -50,9 +50,9 @@ static readonly string[] Ports = new string[] { "Default" }; - static const string BlastModeIRDA = "%"; - static const string BlastModeRC5 = "&"; - static const string BlastModeSky = "$"; + const string BlastModeIRDA = "%"; + const string BlastModeRC5 = "&"; + const string BlastModeSky = "$"; #endregion Constants This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-10 13:09:21
|
Revision: 1357 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1357&view=rev Author: and-81 Date: 2008-02-10 05:09:14 -0800 (Sun, 10 Feb 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/Properties/AssemblyInfo.cs Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Receiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/IrRemoteWrapper.cs trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/ReceiverWindow.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/irremote.cs Copied: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver (from rev 1349, trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver) Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Receiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Receiver.csproj (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Receiver.csproj 2008-02-10 13:09:14 UTC (rev 1357) @@ -0,0 +1,99 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{EE8F2C22-8BD3-4832-85F0-E6F67ED3AADB}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>HcwTransceiver</RootNamespace> + <AssemblyName>HCW Transceiver</AssemblyName> + <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>false</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>TRACE;DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + <DocumentationFile>bin\Debug\HCW Transceiver.XML</DocumentationFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants> + </DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <UseVSHostingProcess>false</UseVSHostingProcess> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <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" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Configure.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Configure.Designer.cs"> + <DependentUpon>Configure.cs</DependentUpon> + </Compile> + <Compile Include="HcwReceiver.cs" /> + <Compile Include="IrRemoteWrapper.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="ReceiverWindow.cs" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Configure.resx"> + <DependentUpon>Configure.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> + <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> + <Name>IR Server Plugin Interface</Name> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <PropertyGroup> + <PostBuildEvent> + </PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Transceiver.csproj =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HCW Transceiver.csproj 2008-02-08 23:50:57 UTC (rev 1349) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HCW Transceiver.csproj 2008-02-10 13:09:14 UTC (rev 1357) @@ -1,98 +0,0 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{EE8F2C22-8BD3-4832-85F0-E6F67ED3AADB}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>HcwTransceiver</RootNamespace> - <AssemblyName>HCW Transceiver</AssemblyName> - <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>false</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>TRACE;DEBUG</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <UseVSHostingProcess>false</UseVSHostingProcess> - <DocumentationFile>bin\Debug\HCW Transceiver.XML</DocumentationFile> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>none</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants> - </DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <UseVSHostingProcess>false</UseVSHostingProcess> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <OutputPath>bin\x86\Debug\</OutputPath> - <DefineConstants>DEBUG</DefineConstants> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <DebugType>full</DebugType> - <PlatformTarget>x86</PlatformTarget> - <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" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Configure.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Configure.Designer.cs"> - <DependentUpon>Configure.cs</DependentUpon> - </Compile> - <Compile Include="HcwTransceiver.cs" /> - <Compile Include="irremote.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="Configure.resx"> - <DependentUpon>Configure.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\IR Server Plugin Interface\IR Server Plugin Interface.csproj"> - <Project>{D8B3D28F-62CE-4CA7-86CE-B7EAD614A94C}</Project> - <Name>IR Server Plugin Interface</Name> - <Private>False</Private> - </ProjectReference> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> - <PropertyGroup> - <PostBuildEvent> - </PostBuildEvent> - </PropertyGroup> -</Project> \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwReceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwReceiver.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwReceiver.cs 2008-02-10 13:09:14 UTC (rev 1357) @@ -0,0 +1,226 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Windows.Forms; +using System.Xml; + +using Microsoft.Win32.SafeHandles; + +using IRServerPluginInterface; + +namespace HcwTransceiver +{ + + /// <summary> + /// IR Server plugin supporting Hauppauge devices. + /// </summary> + [CLSCompliant(false)] + public class HcwReceiver : IRServerPluginBase, IRemoteReceiver, IConfigure + { + + #region Delegates + + //Sets up callback so that other forms can catch a key press + delegate void HCWEvent(int keypress); + //event HCWEvent HCWKeyPressed; + + #endregion Delegates + + #region Constants + + static readonly string ConfigurationFile = + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + + "\\IR Server Suite\\IR Server\\HCW Transceiver.xml"; + + #endregion Constants + + #region Variables + + int _repeatDelay; + bool _stopIrExe; + bool _startIrExe; + + IrRemoteWrapper _irRemoteWrapper = null; + RemoteHandler _remoteButtonHandler = null; + + int _lastCode = 0; + DateTime _lastCodeTime = DateTime.Now; + + #endregion Variables + + #region Implementation + + /// <summary> + /// Name of the IR Server plugin. + /// </summary> + /// <value>The name.</value> + public override string Name { get { return "HCW Receiver"; } } + /// <summary> + /// IR Server plugin version. + /// </summary> + /// <value>The version.</value> + public override string Version { get { return "1.0.4.2"; } } + /// <summary> + /// The IR Server plugin's author. + /// </summary> + /// <value>The author.</value> + public override string Author { get { return "and-81, original MediaPortal code by mPod"; } } + /// <summary> + /// A description of the IR Server plugin. + /// </summary> + /// <value>The description.</value> + public override string Description { get { return "Support for Hauppauge devices"; } } + + /// <summary> + /// Start the IR Server plugin. + /// </summary> + public override void Start() + { + LoadSettings(); + + _irRemoteWrapper = new IrRemoteWrapper(); + _irRemoteWrapper.ButtonCallback = new ButtonReceived(ButtonCallback); + + if (_stopIrExe) + _irRemoteWrapper.StopIrExe(); + + _irRemoteWrapper.Start(); + } + /// <summary> + /// Suspend the IR Server plugin when computer enters standby. + /// </summary> + public override void Suspend() + { + //_irRemoteWrapper.Stop(); + } + /// <summary> + /// Resume the IR Server plugin when the computer returns from standby. + /// </summary> + public override void Resume() + { + //_irRemoteWrapper.Start(); + } + /// <summary> + /// Stop the IR Server plugin. + /// </summary> + public override void Stop() + { + _irRemoteWrapper.Stop(); + + if (_startIrExe) + _irRemoteWrapper.StartIrExe(); + } + + + /// <summary> + /// Configure the IR Server plugin. + /// </summary> + /// <param name="owner">The owner window to use for creating modal dialogs.</param> + public void Configure(IWin32Window owner) + { + LoadSettings(); + + Configure config = new Configure(); + + config.RepeatDelay = _repeatDelay; + + if (config.ShowDialog(owner) == DialogResult.OK) + { + _repeatDelay = config.RepeatDelay; + + SaveSettings(); + } + } + + + /// <summary> + /// Callback for remote button presses. + /// </summary> + /// <value>The remote callback.</value> + public RemoteHandler RemoteCallback + { + get { return _remoteButtonHandler; } + set { _remoteButtonHandler = value; } + } + + + void ButtonCallback(int button) + { + DateTime now = DateTime.Now; + TimeSpan timeSpan = now - _lastCodeTime; + + if (_lastCode != button || timeSpan.Milliseconds >= _repeatDelay) + { + if (_remoteButtonHandler != null) + _remoteButtonHandler(button.ToString()); + + _lastCodeTime = now; + } + + _lastCode = button; + } + + + void LoadSettings() + { + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(ConfigurationFile); + + _repeatDelay = int.Parse(doc.DocumentElement.Attributes["RepeatDelay"].Value); + _stopIrExe = bool.Parse(doc.DocumentElement.Attributes["StopIrExe"].Value); + _startIrExe = bool.Parse(doc.DocumentElement.Attributes["StartIrExe"].Value); + } +#if TRACE + catch (Exception ex) + { + Trace.WriteLine(ex.ToString()); +#else + catch + { +#endif + _repeatDelay = 500; + _stopIrExe = true; + _startIrExe = true; + } + } + void SaveSettings() + { + try + { + XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8); + writer.Formatting = Formatting.Indented; + writer.Indentation = 1; + writer.IndentChar = (char)9; + writer.WriteStartDocument(true); + writer.WriteStartElement("settings"); // <settings> + + writer.WriteAttributeString("RepeatDelay", _repeatDelay.ToString()); + writer.WriteAttributeString("StopIrExe", _stopIrExe.ToString()); + writer.WriteAttributeString("StartIrExe", _startIrExe.ToString()); + + writer.WriteEndElement(); // </settings> + writer.WriteEndDocument(); + writer.Close(); + } +#if TRACE + catch (Exception ex) + { + Trace.WriteLine(ex.ToString()); + } +#else + catch + { + } +#endif + } + + #endregion Implementation + + } + +} Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/HcwTransceiver.cs 2008-02-08 23:50:57 UTC (rev 1349) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/HcwTransceiver.cs 2008-02-10 13:09:14 UTC (rev 1357) @@ -1,191 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using System.Xml; - -using Microsoft.Win32.SafeHandles; - -using IRServerPluginInterface; - -namespace HcwTransceiver -{ - - /// <summary> - /// IR Server plugin supporting Hauppauge devices. - /// </summary> - [CLSCompliant(false)] - public class HcwTransceiver : IRServerPluginBase, IRemoteReceiver, IConfigure - { - - #region Delegates - - //Sets up callback so that other forms can catch a key press - delegate void HCWEvent(int keypress); - //event HCWEvent HCWKeyPressed; - - #endregion Delegates - - #region Constants - - static readonly string ConfigurationFile = - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + - "\\IR Server Suite\\IR Server\\HCW Transceiver.xml"; - - #endregion Constants - - #region Variables - - RemoteHandler _remoteButtonHandler = null; - - - int _repeatDelay; - - string _lastCode = String.Empty; - DateTime _lastCodeTime = DateTime.Now; - - #endregion Variables - - #region Implementation - - /// <summary> - /// Name of the IR Server plugin. - /// </summary> - /// <value>The name.</value> - public override string Name { get { return "HCW Receiver"; } } - /// <summary> - /// IR Server plugin version. - /// </summary> - /// <value>The version.</value> - public override string Version { get { return "1.0.4.2"; } } - /// <summary> - /// The IR Server plugin's author. - /// </summary> - /// <value>The author.</value> - public override string Author { get { return "and-81, original MediaPortal code by mPod"; } } - /// <summary> - /// A description of the IR Server plugin. - /// </summary> - /// <value>The description.</value> - public override string Description { get { return "Support for Hauppauge devices"; } } - - /// <summary> - /// Start the IR Server plugin. - /// </summary> - public override void Start() - { - LoadSettings(); - - - } - /// <summary> - /// Suspend the IR Server plugin when computer enters standby. - /// </summary> - public override void Suspend() - { - Stop(); - } - /// <summary> - /// Resume the IR Server plugin when the computer returns from standby. - /// </summary> - public override void Resume() - { - Start(); - } - /// <summary> - /// Stop the IR Server plugin. - /// </summary> - public override void Stop() - { - - } - - - /// <summary> - /// Configure the IR Server plugin. - /// </summary> - /// <param name="owner">The owner window to use for creating modal dialogs.</param> - public void Configure(IWin32Window owner) - { - LoadSettings(); - - Configure config = new Configure(); - - config.RepeatDelay = _repeatDelay; - - if (config.ShowDialog(owner) == DialogResult.OK) - { - _repeatDelay = config.RepeatDelay; - - SaveSettings(); - } - } - - - /// <summary> - /// Callback for remote button presses. - /// </summary> - /// <value>The remote callback.</value> - public RemoteHandler RemoteCallback - { - get { return _remoteButtonHandler; } - set { _remoteButtonHandler = value; } - } - - - void LoadSettings() - { - try - { - XmlDocument doc = new XmlDocument(); - doc.Load(ConfigurationFile); - - _repeatDelay = int.Parse(doc.DocumentElement.Attributes["RepeatDelay"].Value); - } -#if TRACE - catch (Exception ex) - { - Trace.WriteLine(ex.ToString()); -#else - catch - { -#endif - _repeatDelay = 500; - } - } - void SaveSettings() - { - try - { - XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8); - writer.Formatting = Formatting.Indented; - writer.Indentation = 1; - writer.IndentChar = (char)9; - writer.WriteStartDocument(true); - writer.WriteStartElement("settings"); // <settings> - - writer.WriteAttributeString("RepeatDelay", _repeatDelay.ToString()); - - writer.WriteEndElement(); // </settings> - writer.WriteEndDocument(); - writer.Close(); - } -#if TRACE - catch (Exception ex) - { - Trace.WriteLine(ex.ToString()); - } -#else - catch - { - } -#endif - } - - #endregion Implementation - - } - -} Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/IrRemoteWrapper.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/IrRemoteWrapper.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/IrRemoteWrapper.cs 2008-02-10 13:09:14 UTC (rev 1357) @@ -0,0 +1,234 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Threading; +using System.Windows.Forms; + +using Microsoft.Win32; + +namespace HcwTransceiver +{ + + /// <summary> + /// Callback for remote button press events. + /// </summary> + public delegate void ButtonReceived(int buttonCode); + + /// <summary> + /// Wrapper class for irremote.dll + /// </summary> + public class IrRemoteWrapper + { + + #region Interop + + /// <summary> + /// The SetDllDirectory function adds a directory to the search path used to locate DLLs for the application. + /// http://msdn.microsoft.com/library/en-us/dllproc/base/setdlldirectory.asp + /// </summary> + /// <param name="PathName">Pointer to a null-terminated string that specifies the directory to be added to the search path.</param> + /// <returns></returns> + [DllImport("kernel32.dll")] + static extern bool SetDllDirectory( + string PathName); + + /// <summary> + /// Registers window handle with Hauppauge IR driver + /// </summary> + /// <param name="WindowHandle"></param> + /// <param name="Msg"></param> + /// <param name="Verbose"></param> + /// <param name="IRPort"></param> + /// <returns></returns> + [DllImport("irremote.dll")] + static extern bool IR_Open( + IntPtr WindowHandle, + uint Msg, + bool Verbose, + ushort IRPort); + + /// <summary> + /// Gets the received key code (new version, works for PVR-150 as well) + /// </summary> + /// <param name="RepeatCount"></param> + /// <param name="RemoteCode"></param> + /// <param name="KeyCode"></param> + /// <returns></returns> + [DllImport("irremote.dll")] + static extern bool IR_GetSystemKeyCode( + out int RepeatCount, + out int RemoteCode, + out int KeyCode); + + /// <summary> + /// Unregisters window handle from Hauppauge IR driver + /// </summary> + /// <param name="WindowHandle"></param> + /// <param name="Msg"></param> + /// <returns></returns> + [DllImport("irremote.dll")] + static extern bool IR_Close( + IntPtr WindowHandle, + uint Msg); + + #endregion Interop + + #region Constants + + /// <summary> + /// Current Version. + /// </summary> + public const string CurrentVersion = "2.49.23332"; + + const int HCWPVR2 = 0x001E; // 45-Button Remote + const int HCWPVR = 0x001F; // 34-Button Remote + const int HCWCLASSIC = 0x0000; // 21-Button Remote + + const int WM_TIMER = 0x0113; + + #endregion Constants + + #region Variables + + ButtonReceived _buttonReceived; + + ReceiverWindow _window; + + #endregion Variables + + #region Properties + + /// <summary> + /// Gets or sets the button callback. + /// </summary> + /// <value>The button callback.</value> + public ButtonReceived ButtonCallback + { + get { return _buttonReceived; } + set { _buttonReceived = value; } + } + + #endregion Properties + + #region Constructor + + /// <summary> + /// Initializes a new instance of the <see cref="IrRemoteWrapper"/> class. + /// </summary> + public IrRemoteWrapper() + { + _window = new ReceiverWindow(); + _window.ProcMsg = new ProcessMessage(WndProc); + } + + #endregion Constructor + + #region Public Methods + + /// <summary> + /// Starts this instance. + /// </summary> + public void Start() + { + if (!IR_Open(_window.Handle, 0, false, 0)) + throw new ApplicationException("Failed to open IR device"); + } + + /// <summary> + /// Stops this instance. + /// </summary> + public void Stop() + { + if (!IR_Close(_window.Handle, 0)) + throw new ApplicationException("Failed to close IR device"); + } + + /// <summary> + /// Starts the ir.exe. + /// </summary> + public void StartIrExe() + { + if (Process.GetProcessesByName("Ir").Length == 0) + Process.Start(GetHCWPath() + "Ir.exe", "/QUIET"); + } + + /// <summary> + /// Stops the ir.exe. + /// </summary> + public void StopIrExe() + { + Process.Start(GetHCWPath() + "Ir.exe", "/QUIT"); + Thread.Sleep(500); + + if (Process.GetProcessesByName("Ir").Length != 0) + foreach (Process proc in Process.GetProcessesByName("Ir")) + proc.Kill(); + } + + #endregion Public Methods + + static bool IRSetDllDirectory(string PathName) + { + return SetDllDirectory(PathName); + } + + static string GetHCWPath() + { + string dllPath = null; + + using (RegistryKey rkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Hauppauge WinTV Infrared Remote")) + { + if (rkey != null) + { + dllPath = rkey.GetValue("UninstallString").ToString(); + if (dllPath.IndexOf("UNir32") > 0) + dllPath = dllPath.Substring(0, dllPath.IndexOf("UNir32")); + else if (dllPath.IndexOf("UNIR32") > 0) + dllPath = dllPath.Substring(0, dllPath.IndexOf("UNIR32")); + } + } + + return dllPath; + } + + static string GetDllPath() + { + string dllPath = GetHCWPath(); + if (!File.Exists(dllPath + "irremote.DLL")) + dllPath = null; + + return dllPath; + } + + void WndProc(ref Message m) + { + if (m.Msg != WM_TIMER) + return; + + int repeatCount = 0; + int remoteCode = 0; + int keyCode = 0; + if (!IR_GetSystemKeyCode(out repeatCount, out remoteCode, out keyCode)) + return; + + int buttonCode = keyCode; + switch (remoteCode) + { + case HCWCLASSIC: buttonCode = keyCode; break; + case HCWPVR: buttonCode = keyCode + 1000; break; + case HCWPVR2: buttonCode = keyCode + 2000; break; +#if TRACE + default: + Trace.WriteLine("IrRemoteWrapper - Unknown Remote Code: " + remoteCode); + break; +#endif + } + + if (_buttonReceived != null) + _buttonReceived(buttonCode); + } + + } + +} Modified: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/Properties/AssemblyInfo.cs 2008-02-08 23:50:57 UTC (rev 1349) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/Properties/AssemblyInfo.cs 2008-02-10 13:09:14 UTC (rev 1357) @@ -6,11 +6,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("HCW Transceiver")] -[assembly: AssemblyDescription("IR Server plugin to support the HCW transceiver")] +[assembly: AssemblyTitle("HCW Receiver")] +[assembly: AssemblyDescription("IR Server plugin to support the HCW Receiver")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HcwTransceiver")] +[assembly: AssemblyProduct("HcwReceiver")] [assembly: AssemblyCopyright("Aaron Dinnage")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Added: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/ReceiverWindow.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/ReceiverWindow.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/ReceiverWindow.cs 2008-02-10 13:09:14 UTC (rev 1357) @@ -0,0 +1,72 @@ +using System; +using System.Windows.Forms; + +namespace HcwTransceiver +{ + + #region Delegates + + /// <summary> + /// Windows message processing delegate. + /// </summary> + /// <param name="m">Windows message.</param> + delegate void ProcessMessage(ref Message m); + + #endregion Delegates + + /// <summary> + /// Use this class to receive windows messages. + /// </summary> + class ReceiverWindow : NativeWindow + { + + #region Variables + + ProcessMessage _processMessage; + + #endregion Variables + + #region Properties + + /// <summary> + /// Gets or Sets the Windows Message processing delegate. + /// </summary> + public ProcessMessage ProcMsg + { + get { return _processMessage; } + set { _processMessage = value; } + } + + #endregion Properties + + #region Constructor + + /// <summary> + /// Create a Windows Message receiving window object. + /// </summary> + public ReceiverWindow() + { + CreateParams createParams = new CreateParams(); + createParams.ExStyle = 0x80; + createParams.Style = unchecked((int)0x80000000); + + base.CreateHandle(createParams); + } + + #endregion Constructor + + #region Implementation + + protected override void WndProc(ref Message m) + { + if (_processMessage != null) + _processMessage(ref m); + + base.WndProc(ref m); + } + + #endregion Implementation + + } + +} Deleted: trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/irremote.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/HCW Transceiver/irremote.cs 2008-02-08 23:50:57 UTC (rev 1349) +++ trunk/plugins/IR Server Suite/IR Server Plugins/HCW Receiver/irremote.cs 2008-02-10 13:09:14 UTC (rev 1357) @@ -1,196 +0,0 @@ -#region Copyright (C) 2005-2007 Team MediaPortal - -/* - * Copyright (C) 2005-2007 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#endregion - -using System; -using System.Runtime.InteropServices; -using Microsoft.Win32; -//using MediaPortal.GUI.Library; -using System.IO; - -namespace HcwTransceiver -{ - - /// <summary> - /// Wrapper class for irremote.dll - /// </summary> - [CLSCompliant(false)] - public static class irremote - { - #region DLL-Imports - - /// <summary> - /// The SetDllDirectory function adds a directory to the search path used to locate DLLs for the application. - /// http://msdn.microsoft.com/library/en-us/dllproc/base/setdlldirectory.asp - /// </summary> - /// <param name="PathName">Pointer to a null-terminated string that specifies the directory to be added to the search path.</param> - /// <returns></returns> - [DllImport("kernel32.dll")] - static extern bool SetDllDirectory( - string PathName); - - /// <summary> - /// Registers window handle with Hauppauge IR driver - /// </summary> - /// <param name="WindowHandle"></param> - /// <param name="Msg"></param> - /// <param name="Verbose"></param> - /// <param name="IRPort"></param> - /// <returns></returns> - [DllImport("irremote.dll")] - static extern bool IR_Open( - int WindowHandle, - uint Msg, - bool Verbose, - ushort IRPort); - - /// <summary> - /// Gets the received key code (new version, works for PVR-150 as well) - /// </summary> - /// <param name="RepeatCount"></param> - /// <param name="RemoteCode"></param> - /// <param name="KeyCode"></param> - /// <returns></returns> - [DllImport("irremote.dll")] - static extern bool IR_GetSystemKeyCode( - out int RepeatCount, - out int RemoteCode, - out int KeyCode); - - /// <summary> - /// Unregisters window handle from Hauppauge IR driver - /// </summary> - /// <param name="WindowHandle"></param> - /// <param name="Msg"></param> - /// <returns></returns> - [DllImport("irremote.dll")] - static extern bool IR_Close( - int WindowHandle, - uint Msg); - - #endregion - - - /// <summary> - /// Current Version. - /// </summary> - public static string CurrentVersion = "2.49.23332"; - - /// <summary> - /// Close the device. - /// </summary> - /// <param name="WindowHandle">The window handle.</param> - /// <param name="Msg">The MSG.</param> - /// <returns><c>true</c> if successful; otherwise <c>false</c>.</returns> - public static bool IRClose(IntPtr WindowHandle, uint Msg) - { - return IR_Close((int)WindowHandle, Msg); - } - - /// <summary> - /// Get system key code. - /// </summary> - /// <param name="RepeatCount">The repeat count.</param> - /// <param name="RemoteCode">The remote code.</param> - /// <param name="KeyCode">The key code.</param> - /// <returns><c>true</c> if successful; otherwise <c>false</c>.</returns> - public static bool IRGetSystemKeyCode(out int RepeatCount, out int RemoteCode, out int KeyCode) - { - RepeatCount = 0; - RemoteCode = 0; - KeyCode = 0; - bool result = false; - try - { - result = IR_GetSystemKeyCode(out RepeatCount, out RemoteCode, out KeyCode); - } - catch (AccessViolationException) - { - } - catch (Exception ex) - { - Console.WriteLine("HCW: Exception while querying remote: {0}", ex.Message); - } - return result; - } - - /// <summary> - /// Opens the device. - /// </summary> - /// <param name="WindowHandle">The window handle.</param> - /// <param name="Msg">The MSG.</param> - /// <param name="Verbose">if set to <c>true</c> [verbose].</param> - /// <param name="IRPort">The IR port.</param> - /// <returns><c>true</c> if successful; otherwise <c>false</c>.</returns> - public static bool IROpen(IntPtr WindowHandle, uint Msg, bool Verbose, ushort IRPort) - { - return IR_Open((int)WindowHandle, Msg, Verbose, IRPort); - } - - /// <summary> - /// Set DLL directory. - /// </summary> - /// <param name="PathName">Name of the path.</param> - /// <returns><c>true</c> if successful; otherwise <c>false</c>.</returns> - public static bool IRSetDllDirectory(string PathName) - { - return SetDllDirectory(PathName); - } - - /// <summary> - /// Get the Hauppauge IR components installation path from the windows registry. - /// </summary> - /// <returns>Installation path of the Hauppauge IR components</returns> - public static string GetHCWPath() - { - string dllPath = null; - using (RegistryKey rkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Hauppauge WinTV Infrared Remote")) - { - if (rkey != null) - { - dllPath = rkey.GetValue("UninstallString").ToString(); - if (dllPath.IndexOf("UNir32") > 0) - dllPath = dllPath.Substring(0, dllPath.IndexOf("UNir32")); - else if (dllPath.IndexOf("UNIR32") > 0) - dllPath = dllPath.Substring(0, dllPath.IndexOf("UNIR32")); - } - } - return dllPath; - } - - /// <summary> - /// Returns the path of the DLL component - /// </summary> - /// <returns>DLL path</returns> - public static string GetDllPath() - { - string dllPath = GetHCWPath(); - if (!File.Exists(dllPath + "irremote.DLL")) - { - dllPath = null; - } - return dllPath; - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <an...@us...> - 2008-02-20 11:21:18
|
Revision: 1389 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1389&view=rev Author: and-81 Date: 2008-02-20 03:21:10 -0800 (Wed, 20 Feb 2008) Log Message: ----------- Property Changed: ---------------- trunk/plugins/IR Server Suite/IR Server Plugins/Ira Transceiver/ trunk/plugins/IR Server Suite/IR Server Plugins/Speech Receiver/ Property changes on: trunk/plugins/IR Server Suite/IR Server Plugins/Ira Transceiver ___________________________________________________________________ Name: svn:ignore + bin obj Property changes on: trunk/plugins/IR Server Suite/IR Server Plugins/Speech Receiver ___________________________________________________________________ Name: svn:ignore + bin obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |