From: <an...@us...> - 2007-12-04 14:18:38
|
Revision: 1123 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1123&view=rev Author: and-81 Date: 2007-12-04 06:18:35 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/IR File Tool/IrDecoder.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/MenuForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Program.cs trunk/plugins/IR Server Suite/Applications/Web Remote/Program.cs trunk/plugins/IR Server Suite/Applications/Web Remote/WebServer.cs trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs trunk/plugins/IR Server Suite/Documentation/new.html trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/RawInput.cs trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/Girder Plugin.cs trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/GirderPluginWrapper.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IrDecoder.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/RedEye Blaster.cs trunk/plugins/IR Server Suite/IR Server Plugins/Serial IR Blaster/Serial IR Blaster.cs trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 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.csproj trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLirc Transceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Transceiver/WinLircServer.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/X10Transceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/XBCDRC Receiver/XBCDRC Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite.sln trunk/plugins/IR Server Suite/Input Service/Input Service/InputService.cs trunk/plugins/IR Server Suite/Input Service/Input Service/InputServiceInstaller.cs trunk/plugins/IR Server Suite/Input Service/Input Service/Program.cs trunk/plugins/IR Server Suite/Input Service/Input Service Configuration/Program.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/InputMapper/InputHandler.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/ExternalChannels.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/ExternalChannels.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/MacroEditor.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/PluginSetup.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs Added Paths: ----------- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Mouse.cs trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.cs trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.resx Modified: trunk/plugins/IR Server Suite/Applications/IR File Tool/IrDecoder.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR File Tool/IrDecoder.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/IR File Tool/IrDecoder.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.Text; namespace IrFileTool Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MacroEditor.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; +#if TRACE using System.Diagnostics; +#endif using System.Drawing; using System.IO; using System.Text; Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MainForm.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; +#if TRACE +using System.Diagnostics; +#endif using System.Drawing; -using System.Diagnostics; using System.IO; using System.Net; using System.Text; Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/MenuForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/MenuForm.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/MenuForm.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; +#if TRACE using System.Diagnostics; +#endif using System.Drawing; using System.IO; using System.Text; @@ -788,9 +790,7 @@ Command(tag.Substring(TagCommand.Length)); else if (tag.StartsWith(TagEject, StringComparison.OrdinalIgnoreCase)) Eject(tag.Substring(TagEject.Length)); - } - } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -30,6 +30,8 @@ internal static readonly string FolderMacros = Common.FolderAppData + "Translator\\Macro\\"; + const string ProcessCommandThreadName = "ProcessCommand"; + #endregion Constants #region Variables @@ -96,16 +98,11 @@ { ProcessCommandLine(args); } -#if TRACE catch (Exception ex) { - Trace.WriteLine(ex.ToString()); + MessageBox.Show(ex.ToString(), "Translator - Error processing command line", MessageBoxButtons.OK, MessageBoxIcon.Error); } -#else - catch - { - } -#endif + return; } @@ -987,20 +984,25 @@ /// <summary> /// Given a command this method processes the request accordingly. + /// Throws exceptions only if run synchronously, if async exceptions are logged instead. /// </summary> /// <param name="command">Command to process.</param> /// <param name="async">Process command asynchronously?</param> internal static void ProcessCommand(string command, bool async) { - if (String.IsNullOrEmpty(command)) - throw new ArgumentNullException("command"); - if (async) { - Thread newThread = new Thread(new ParameterizedThreadStart(ProcCommand)); - newThread.Name = "ProcessCommand"; - newThread.Priority = ThreadPriority.BelowNormal; - newThread.Start(command); + try + { + Thread newThread = new Thread(new ParameterizedThreadStart(ProcCommand)); + newThread.Name = ProcessCommandThreadName; + newThread.Priority = ThreadPriority.BelowNormal; + newThread.Start(command); + } + catch (Exception ex) + { + IrssLog.Error(ex.ToString()); + } } else { @@ -1015,84 +1017,100 @@ /// <param name="commandObj">Command string to process.</param> static void ProcCommand(object commandObj) { - string command = commandObj as string; + try + { + if (commandObj == null) + throw new ArgumentNullException("commandObj"); - if (command.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase)) - { - string fileName = FolderMacros + command.Substring(Common.CmdPrefixMacro.Length) + Common.FileExtensionMacro; - ProcMacro(fileName); + string command = commandObj as string; + + if (String.IsNullOrEmpty(command)) + throw new ArgumentException("commandObj translates to empty or null string", "commandObj"); + + if (command.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase)) + { + string fileName = FolderMacros + command.Substring(Common.CmdPrefixMacro.Length) + Common.FileExtensionMacro; + ProcMacro(fileName); + } + else if (command.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixBlast.Length)); + BlastIR(Common.FolderIRCommands + commands[0] + Common.FileExtensionIR, commands[1]); + } + else if (command.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitRunCommand(command.Substring(Common.CmdPrefixRun.Length)); + Common.ProcessRunCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitSerialCommand(command.Substring(Common.CmdPrefixSerial.Length)); + Common.ProcessSerialCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length)); + Common.ProcessWindowMessageCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase)) + { + string keyCommand = command.Substring(Common.CmdPrefixKeys.Length); + if (_inConfiguration) + MessageBox.Show(keyCommand, Common.UITextKeys, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + Common.ProcessKeyCommand(keyCommand); + } + else if (command.StartsWith(Common.CmdPrefixMouse, StringComparison.OrdinalIgnoreCase)) + { + string mouseCommand = command.Substring(Common.CmdPrefixMouse.Length); + Common.ProcessMouseCommand(mouseCommand); + } + else if (command.StartsWith(Common.CmdPrefixEject, StringComparison.OrdinalIgnoreCase)) + { + string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); + Common.ProcessEjectCommand(ejectCommand); + } + else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.OrdinalIgnoreCase)) + { + if (!Common.Hibernate()) + IrssLog.Warn("Hibernate request was rejected by another application."); + } + else if (command.StartsWith(Common.CmdPrefixLogOff, StringComparison.OrdinalIgnoreCase)) + { + if (!Common.LogOff()) + IrssLog.Warn("LogOff request failed."); + } + else if (command.StartsWith(Common.CmdPrefixReboot, StringComparison.OrdinalIgnoreCase)) + { + if (!Common.Reboot()) + IrssLog.Warn("Reboot request failed."); + } + else if (command.StartsWith(Common.CmdPrefixShutdown, StringComparison.OrdinalIgnoreCase)) + { + if (!Common.ShutDown()) + IrssLog.Warn("ShutDown request failed."); + } + else if (command.StartsWith(Common.CmdPrefixStandby, StringComparison.OrdinalIgnoreCase)) + { + if (!Common.Standby()) + IrssLog.Warn("Standby request was rejected by another application."); + } + else if (command.StartsWith(Common.CmdPrefixTranslator, StringComparison.OrdinalIgnoreCase)) + { + ShowOSD(); + } + else + { + throw new ArgumentException(String.Format("Cannot process unrecognized command \"{0}\"", command), "command"); + } } - else if (command.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase)) + catch (Exception ex) { - string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixBlast.Length)); - BlastIR(Common.FolderIRCommands + commands[0] + Common.FileExtensionIR, commands[1]); - } - else if (command.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase)) - { - string[] commands = Common.SplitRunCommand(command.Substring(Common.CmdPrefixRun.Length)); - Common.ProcessRunCommand(commands); - } - else if (command.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase)) - { - string[] commands = Common.SplitSerialCommand(command.Substring(Common.CmdPrefixSerial.Length)); - Common.ProcessSerialCommand(commands); - } - else if (command.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase)) - { - string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length)); - Common.ProcessWindowMessageCommand(commands); - } - else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase)) - { - string keyCommand = command.Substring(Common.CmdPrefixKeys.Length); - if (_inConfiguration) - MessageBox.Show(keyCommand, Common.UITextKeys, MessageBoxButtons.OK, MessageBoxIcon.Information); + if (Thread.CurrentThread.Name.Equals(ProcessCommandThreadName, StringComparison.OrdinalIgnoreCase)) + IrssLog.Error(ex.ToString()); else - Common.ProcessKeyCommand(keyCommand); + throw ex; } - else if (command.StartsWith(Common.CmdPrefixMouse, StringComparison.OrdinalIgnoreCase)) - { - string mouseCommand = command.Substring(Common.CmdPrefixMouse.Length); - Common.ProcessMouseCommand(mouseCommand); - } - else if (command.StartsWith(Common.CmdPrefixEject, StringComparison.OrdinalIgnoreCase)) - { - string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); - Common.ProcessEjectCommand(ejectCommand); - } - else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.OrdinalIgnoreCase)) - { - if (!Common.Hibernate()) - IrssLog.Warn("Hibernate request was rejected by another application."); - } - else if (command.StartsWith(Common.CmdPrefixLogOff, StringComparison.OrdinalIgnoreCase)) - { - if (!Common.LogOff()) - IrssLog.Warn("LogOff request failed."); - } - else if (command.StartsWith(Common.CmdPrefixReboot, StringComparison.OrdinalIgnoreCase)) - { - if (!Common.Reboot()) - IrssLog.Warn("Reboot request failed."); - } - else if (command.StartsWith(Common.CmdPrefixShutdown, StringComparison.OrdinalIgnoreCase)) - { - if (!Common.ShutDown()) - IrssLog.Warn("ShutDown request failed."); - } - else if (command.StartsWith(Common.CmdPrefixStandby, StringComparison.OrdinalIgnoreCase)) - { - if (!Common.Standby()) - IrssLog.Warn("Standby request was rejected by another application."); - } - else if (command.StartsWith(Common.CmdPrefixTranslator, StringComparison.OrdinalIgnoreCase)) - { - ShowOSD(); - } - else - { - throw new ArgumentException(String.Format("Cannot process unrecognized command \"{0}\"", command), "command"); - } } /// <summary> @@ -1240,6 +1258,20 @@ Common.LogOff(); break; } + + case Common.XmlTagBeep: + { + string[] commands = Common.SplitBeepCommand(commandProperty); + Common.ProcessBeepCommand(commands); + break; + } + + case Common.XmlTagDisplay: + { + string[] commands = Common.SplitDisplayModeCommand(commandProperty); + Common.ProcessDisplayModeCommand(commands); + break; + } } } } Modified: trunk/plugins/IR Server Suite/Applications/Web Remote/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Web Remote/Program.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/Web Remote/Program.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -2,6 +2,9 @@ using System.Collections; using System.Collections.Generic; using System.Data; +#if TRACE +using System.Diagnostics; +#endif using System.Drawing; using System.IO; using System.Net; @@ -12,10 +15,6 @@ using System.Windows.Forms; using System.Xml; -#if TRACE -using System.Diagnostics; -#endif - using IrssComms; using IrssUtils; using IrssUtils.Forms; Modified: trunk/plugins/IR Server Suite/Applications/Web Remote/WebServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Web Remote/WebServer.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Applications/Web Remote/WebServer.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,16 +1,15 @@ using System; +#if TRACE +using System.Diagnostics; +#endif +using System.IO; using System.Net; using System.Net.Sockets; -using System.IO; using System.Text; using System.Threading; using System.Web; using System.Windows.Forms; -#if TRACE -using System.Diagnostics; -#endif - using IrssUtils; namespace WebRemote Modified: trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Common/IrssComms/ClientManager.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.Net; using System.Net.Sockets; using System.Text; Modified: trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Common/IrssComms/GenericPCQueue.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,7 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.Threading; namespace IrssComms Modified: trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Common/IrssComms/Server.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.Net; using System.Net.Sockets; using System.Text; Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/IrssLog.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,5 +1,7 @@ using System; +#if TRACE using System.Diagnostics; +#endif using System.IO; namespace IrssUtils Modified: trunk/plugins/IR Server Suite/Documentation/new.html =================================================================== --- trunk/plugins/IR Server Suite/Documentation/new.html 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/Documentation/new.html 2007-12-04 14:18:35 UTC (rev 1123) @@ -25,6 +25,7 @@ <LI>Added support for Girder 3.x plugins, still experimental at this stage. Expect to see improvements in this area, like multiple Girder plugins active at the same time.</LI> <LI>Virtual Remote now has a companion application called Web Remote, with a built in web server for simulating a remote control over the web.</LI> <LI>Added support for the RedEye blaster device.</LI> +<LI>Added support for the Nintendo Wii Remote (no analog stick or accelerometer support yet).</LI> </UL></P> <BR> Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/Custom HID Receiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.ComponentModel; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.Runtime.InteropServices; using System.Text; @@ -70,8 +72,7 @@ } #endregion Constructor - - + /// <summary> /// Name of the IR Server plugin. /// </summary> @@ -155,8 +156,7 @@ SaveSettings(); } } - - + /// <summary> /// Callback for remote button presses. /// </summary> @@ -200,11 +200,16 @@ _useAllBytes = bool.Parse(doc.DocumentElement.Attributes["UseAllBytes"].Value); _repeatDelay = int.Parse(doc.DocumentElement.Attributes["RepeatDelay"].Value); } +#if TRACE catch (Exception ex) { Trace.WriteLine(ex.ToString()); +#else + catch + { +#endif - _device.usUsage = 0x00; + _device.usUsage = 0x00; _device.usUsagePage = 0x00; _inputByte = 3; @@ -239,10 +244,16 @@ writer.WriteEndDocument(); writer.Close(); } +#if TRACE catch (Exception ex) { Trace.WriteLine(ex.ToString()); } +#else + catch + { + } +#endif } bool RegisterForRawInput(RawInput.RAWINPUTDEVICE device) @@ -341,7 +352,9 @@ foreach (byte b in newArray) str.Append(String.Format("{0:X2} ", b)); +#if TRACE Trace.WriteLine(str.ToString()); +#endif if (_remoteHandler != null) _remoteHandler(str.ToString()); Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/RawInput.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/RawInput.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Custom HID Receiver/RawInput.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Windows.Forms; - #if TRACE using System.Diagnostics; #endif +using System.Runtime.InteropServices; +using System.Windows.Forms; using Microsoft.Win32; 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-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/FusionRemote Receiver/FusionRemoteReceiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -2,7 +2,9 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.Runtime.InteropServices; using System.Text; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/Girder Plugin.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/Girder Plugin.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/Girder Plugin.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.ComponentModel; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.Windows.Forms; using System.Xml; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/GirderPluginWrapper.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/GirderPluginWrapper.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Girder Plugin/GirderPluginWrapper.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,12 +1,11 @@ using System; +#if TRACE +using System.Diagnostics; +#endif using System.Runtime.InteropServices; using System.Text; using System.Threading; -#if TRACE -using System.Diagnostics; -#endif - namespace GirderPlugin { 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-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IRMan Receiver/IRMan Receiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.IO.Ports; using System.Text; 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-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IRTrans Transceiver/IRTransTransceiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -2,7 +2,9 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.Net.Sockets; using System.Runtime.InteropServices; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IgorPlug Receiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.Runtime.InteropServices; using System.Text; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IrDecoder.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IrDecoder.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/IgorPlug Receiver/IrDecoder.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.Text; namespace IgorPlugReceiver Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/IrDecoder.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.Text; namespace MicrosoftMceTransceiver 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-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/RedEye Blaster/RedEye Blaster.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.IO.Ports; using System.Text; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Serial IR Blaster/Serial IR Blaster.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Serial IR Blaster/Serial IR Blaster.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Serial IR Blaster/Serial IR Blaster.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.IO.Ports; using System.Text; Modified: trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2007-12-04 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,5 +1,7 @@ using System; +#if TRACE using System.Diagnostics; +#endif using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; Added: trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Mouse.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Mouse.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Mouse.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -0,0 +1,87 @@ +using System; +using System.Runtime.InteropServices; + +namespace WiiRemoteReceiver +{ + + /// <summary> + /// Win32 native method wrapper for Mouse control functions. + /// </summary> + static class Mouse + { + + #region Interop + + [DllImport("user32")] + static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo); + + #endregion Interop + + #region Enumerations + + /// <summary> + /// Used to simulate mouse actions. + /// </summary> + [Flags] + public enum MouseEvents + { + None = 0x0000, + Move = 0x0001, + LeftDown = 0x0002, + LeftUp = 0x0004, + RightDown = 0x0008, + RightUp = 0x0010, + MiddleDown = 0x0020, + MiddleUp = 0x0040, + Scroll = 0x0800, + Absolute = 0x8000, + } + + /// <summary> + /// Used to simulate mouse wheel scrolling. + /// </summary> + public enum ScrollDir + { + None = 0, + Up = 120, + Down = -120, + } + + #endregion Enumerations + + #region Public Methods + + /// <summary> + /// Simulates mouse button actions. + /// </summary> + /// <param name="flags">The button action to simulate.</param> + public static void Button(MouseEvents flags) + { + mouse_event((int)flags, 0, 0, 0, IntPtr.Zero); + } + + /// <summary> + /// Simulate mouse movements. + /// </summary> + /// <param name="dx">Movement on the X axis.</param> + /// <param name="dy">Movement on the Y axis.</param> + /// <param name="absolute">If true, dx and dy are taken as absolute position. If false, dx and dy are taken as relative to the current position.</param> + public static void Move(int dx, int dy, bool absolute) + { + mouse_event((int)(absolute ? MouseEvents.Move | MouseEvents.Absolute : MouseEvents.Move), dx, dy, 0, IntPtr.Zero); + } + + /// <summary> + /// Simulates mouse wheel scrolling. + /// </summary> + /// <param name="direction">The direction to scroll.</param> + public static void Scroll(ScrollDir direction) + { + mouse_event((int)MouseEvents.Scroll, 0, 0, (int)direction, IntPtr.Zero); + } + + #endregion Public Methods + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.Designer.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -0,0 +1,226 @@ +namespace WiiRemoteReceiver +{ + partial class Setup + { + /// <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.labelMouseSensitivity = new System.Windows.Forms.Label(); + this.numericUpDownMouseSensitivity = new System.Windows.Forms.NumericUpDown(); + this.checkBoxHandleMouseLocal = new System.Windows.Forms.CheckBox(); + this.checkBoxNunchukMouse = new System.Windows.Forms.CheckBox(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.checkBoxLED1 = new System.Windows.Forms.CheckBox(); + this.checkBoxLED2 = new System.Windows.Forms.CheckBox(); + this.checkBoxLED3 = new System.Windows.Forms.CheckBox(); + this.checkBoxLED4 = new System.Windows.Forms.CheckBox(); + this.groupBoxLEDs = new System.Windows.Forms.GroupBox(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMouseSensitivity)).BeginInit(); + this.groupBoxLEDs.SuspendLayout(); + this.SuspendLayout(); + // + // labelMouseSensitivity + // + this.labelMouseSensitivity.Location = new System.Drawing.Point(8, 80); + this.labelMouseSensitivity.Name = "labelMouseSensitivity"; + this.labelMouseSensitivity.Size = new System.Drawing.Size(112, 20); + this.labelMouseSensitivity.TabIndex = 2; + this.labelMouseSensitivity.Text = "Mouse sensitivity:"; + this.labelMouseSensitivity.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // numericUpDownMouseSensitivity + // + this.numericUpDownMouseSensitivity.DecimalPlaces = 1; + this.numericUpDownMouseSensitivity.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownMouseSensitivity.Location = new System.Drawing.Point(120, 80); + this.numericUpDownMouseSensitivity.Maximum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownMouseSensitivity.Minimum = new decimal(new int[] { + 10, + 0, + 0, + -2147483648}); + this.numericUpDownMouseSensitivity.Name = "numericUpDownMouseSensitivity"; + this.numericUpDownMouseSensitivity.Size = new System.Drawing.Size(80, 20); + this.numericUpDownMouseSensitivity.TabIndex = 3; + this.numericUpDownMouseSensitivity.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.numericUpDownMouseSensitivity.Value = new decimal(new int[] { + 15, + 0, + 0, + 65536}); + // + // checkBoxHandleMouseLocal + // + this.checkBoxHandleMouseLocal.AutoSize = true; + this.checkBoxHandleMouseLocal.Checked = true; + this.checkBoxHandleMouseLocal.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxHandleMouseLocal.Location = new System.Drawing.Point(8, 16); + this.checkBoxHandleMouseLocal.Name = "checkBoxHandleMouseLocal"; + this.checkBoxHandleMouseLocal.Size = new System.Drawing.Size(126, 17); + this.checkBoxHandleMouseLocal.TabIndex = 0; + this.checkBoxHandleMouseLocal.Text = "Handle mouse locally"; + this.checkBoxHandleMouseLocal.UseVisualStyleBackColor = true; + // + // checkBoxNunchukMouse + // + this.checkBoxNunchukMouse.AutoSize = true; + this.checkBoxNunchukMouse.Checked = true; + this.checkBoxNunchukMouse.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxNunchukMouse.Location = new System.Drawing.Point(8, 48); + this.checkBoxNunchukMouse.Name = "checkBoxNunchukMouse"; + this.checkBoxNunchukMouse.Size = new System.Drawing.Size(140, 17); + this.checkBoxNunchukMouse.TabIndex = 1; + this.checkBoxNunchukMouse.Text = "Use Nunchuk as mouse"; + this.checkBoxNunchukMouse.UseVisualStyleBackColor = true; + // + // 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(88, 184); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(56, 24); + this.buttonOK.TabIndex = 5; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + 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(152, 184); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(56, 24); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // checkBoxLED1 + // + this.checkBoxLED1.Location = new System.Drawing.Point(8, 24); + this.checkBoxLED1.Name = "checkBoxLED1"; + this.checkBoxLED1.Size = new System.Drawing.Size(40, 24); + this.checkBoxLED1.TabIndex = 0; + this.checkBoxLED1.Text = "1"; + this.checkBoxLED1.UseVisualStyleBackColor = true; + // + // checkBoxLED2 + // + this.checkBoxLED2.Checked = true; + this.checkBoxLED2.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxLED2.Location = new System.Drawing.Point(56, 24); + this.checkBoxLED2.Name = "checkBoxLED2"; + this.checkBoxLED2.Size = new System.Drawing.Size(40, 24); + this.checkBoxLED2.TabIndex = 1; + this.checkBoxLED2.Text = "2"; + this.checkBoxLED2.UseVisualStyleBackColor = true; + // + // checkBoxLED3 + // + this.checkBoxLED3.Checked = true; + this.checkBoxLED3.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxLED3.Location = new System.Drawing.Point(104, 24); + this.checkBoxLED3.Name = "checkBoxLED3"; + this.checkBoxLED3.Size = new System.Drawing.Size(40, 24); + this.checkBoxLED3.TabIndex = 2; + this.checkBoxLED3.Text = "3"; + this.checkBoxLED3.UseVisualStyleBackColor = true; + // + // checkBoxLED4 + // + this.checkBoxLED4.Location = new System.Drawing.Point(152, 24); + this.checkBoxLED4.Name = "checkBoxLED4"; + this.checkBoxLED4.Size = new System.Drawing.Size(40, 24); + this.checkBoxLED4.TabIndex = 3; + this.checkBoxLED4.Text = "4"; + this.checkBoxLED4.UseVisualStyleBackColor = true; + // + // groupBoxLEDs + // + this.groupBoxLEDs.Controls.Add(this.checkBoxLED1); + this.groupBoxLEDs.Controls.Add(this.checkBoxLED4); + this.groupBoxLEDs.Controls.Add(this.checkBoxLED2); + this.groupBoxLEDs.Controls.Add(this.checkBoxLED3); + this.groupBoxLEDs.Location = new System.Drawing.Point(8, 112); + this.groupBoxLEDs.Name = "groupBoxLEDs"; + this.groupBoxLEDs.Size = new System.Drawing.Size(200, 56); + this.groupBoxLEDs.TabIndex = 4; + this.groupBoxLEDs.TabStop = false; + this.groupBoxLEDs.Text = "Remote LEDs"; + // + // Setup + // + 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(216, 217); + this.Controls.Add(this.groupBoxLEDs); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.checkBoxNunchukMouse); + this.Controls.Add(this.labelMouseSensitivity); + this.Controls.Add(this.numericUpDownMouseSensitivity); + this.Controls.Add(this.checkBoxHandleMouseLocal); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(224, 244); + this.Name = "Setup"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Wii Remote Setup"; + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMouseSensitivity)).EndInit(); + this.groupBoxLEDs.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelMouseSensitivity; + private System.Windows.Forms.NumericUpDown numericUpDownMouseSensitivity; + private System.Windows.Forms.CheckBox checkBoxHandleMouseLocal; + private System.Windows.Forms.CheckBox checkBoxNunchukMouse; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.CheckBox checkBoxLED1; + private System.Windows.Forms.CheckBox checkBoxLED2; + private System.Windows.Forms.CheckBox checkBoxLED3; + private System.Windows.Forms.CheckBox checkBoxLED4; + private System.Windows.Forms.GroupBox groupBoxLEDs; + } +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.cs (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace WiiRemoteReceiver +{ + + /// <summary> + /// Setup form for Wii Remote Receiver IR Server Plugin. + /// </summary> + public partial class Setup : Form + { + + #region Properties + + /// <summary> + /// Gets or sets a value indicating whether to handle mouse commands locally or to pass them on to the IR Server. + /// </summary> + /// <value><c>true</c> to handle the mouse commands locally; otherwise, <c>false</c>.</value> + public bool HandleMouseLocal + { + get { return checkBoxHandleMouseLocal.Checked; } + set { checkBoxHandleMouseLocal.Checked = value; } + } + + /// <summary> + /// Gets or sets a value indicating whether to use the nunchuk as a mouse control. + /// </summary> + /// <value><c>true</c> if the nunchuk is used as a mouse; otherwise, <c>false</c>.</value> + public bool UseNunchukAsMouse + { + get { return checkBoxNunchukMouse.Checked; } + set { checkBoxNunchukMouse.Checked = value; } + } + + /// <summary> + /// Gets or sets the mouse sensitivity. + /// </summary> + /// <value>The mouse sensitivity.</value> + public double MouseSensitivity + { + get { return Decimal.ToInt32(numericUpDownMouseSensitivity.Value); } + set { numericUpDownMouseSensitivity.Value = new Decimal(value); } + } + + /// <summary> + /// Gets or sets a value indicating LED state. + /// </summary> + /// <value><c>true</c> if LED1 is on; otherwise, <c>false</c>.</value> + public bool LED1 + { + get { return checkBoxLED1.Checked; } + set { checkBoxLED1.Checked = value; } + } + /// <summary> + /// Gets or sets a value indicating LED state. + /// </summary> + /// <value><c>true</c> if LED2 is on; otherwise, <c>false</c>.</value> + public bool LED2 + { + get { return checkBoxLED2.Checked; } + set { checkBoxLED2.Checked = value; } + } + /// <summary> + /// Gets or sets a value indicating LED state. + /// </summary> + /// <value><c>true</c> if LED1 is on; otherwise, <c>false</c>.</value> + public bool LED3 + { + get { return checkBoxLED3.Checked; } + set { checkBoxLED3.Checked = value; } + } + /// <summary> + /// Gets or sets a value indicating LED state. + /// </summary> + /// <value><c>true</c> if LED4 is on; otherwise, <c>false</c>.</value> + public bool LED4 + { + get { return checkBoxLED4.Checked; } + set { checkBoxLED4.Checked = value; } + } + + #endregion Properties + + #region Constructor + + /// <summary> + /// Initializes a new instance of the <see cref="Setup"/> class. + /// </summary> + public Setup() + { + InitializeComponent(); + } + + #endregion Constructor + + private void buttonOK_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + private void buttonCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + } + +} Added: trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.resx =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.resx (rev 0) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Setup.resx 2007-12-04 14:18:35 UTC (rev 1123) @@ -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/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 04:31:00 UTC (rev 1122) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Wii Remote Receiver/Wii Remote Receiver.cs 2007-12-04 14:18:35 UTC (rev 1123) @@ -1,7 +1,10 @@ using System; +#if TRACE using System.Diagnostics; +#endif using System.Drawing; using System.Windows.Forms; +using System.Xml; using IRServerPluginInterface; @@ -13,20 +16,38 @@ /// <summary> /// IR Server Plugin for the Wii Remote. /// </summary> - public class WiiRemoteReceiver : IRServerPluginBase, IRemoteReceiver, IMouseReceiver + public class WiiRemoteReceiver : IRServerPluginBase, IRemoteReceiver, IMouseReceiver, IConfigure { + #region Constants + + static readonly string ConfigurationFile = + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + + "\\IR Server Suite\\IR Server\\Wii Remote Receiver.xml"; + + + #endregion Constants + #region Variables RemoteHandler _remoteButtonHandler; MouseHandler _mouseHandler; + bool _handleMouseLocally = true; + bool _useNunchukAsMouse = false; + double _mouseSensitivity = 1.5; + + bool _led1 = false; + bool _led2 = true; + bool _led3 = true; + bool _led4 = false; + Wiimote _wiimote; WiimoteState _previousState; - int screenWidth = Screen.PrimaryScreen.WorkingArea.Width; - int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; + int _screenWidth = Screen.PrimaryScreen.WorkingArea.Width; + int _screenHeight = Screen.PrimaryScreen.WorkingArea.Height; #endregion Variables @@ -51,7 +72,7 @@ /// A description of the IR Server plugin. /// </summary> /// <value>The description.</value> - public override string Description { get { return "Supports the Wii Remote"; } } + public override string Description { get { return "Supports the Nintendo Wii Remote"; } } /// <summary> /// Detect the presence of this device. Devices that cannot be detected will always return false. @@ -70,6 +91,8 @@ /// <returns>true if successful, otherwise false.</returns> public override bool Start() { + LoadSettings(); + _wiimote = new Wiimote(); _wiimote.WiimoteChanged += new WiimoteChangedEventHandler(WiimoteChanged); @@ -77,7 +100,7 @@ _wiimote.Connect(); _wiimote.SetReportType(Wiimote.InputReport.IRAccel, true); - _wiimote.SetLEDs(false, true, true, false); + _wiimote.SetLEDs(_led1, _led2, _led3, _led4); _wiimote.SetRumble(false); return true; @@ -110,6 +133,39 @@ } /// <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(); + + Setup setup = new Setup(); + + setup.HandleMouseLocal = _handleMouseLocally; + setup.UseNunchukAsMouse = _useNunchukAsMouse; + setup.MouseSensitivity = _mouseSensitivity; + setup.LED1 = _led1; + setup.LED2 = _led2; + setup.LED3 = _led3; + setup.LED4 = _led4; + + + if (setup.ShowDialog(owner) == DialogResult.OK) + { + _handleMouseLocally = setup.HandleMouseLocal; + _useNunchukAsMouse = setup.UseNunchukAsMouse; + _mouseSensitivity = setup.MouseSensitivity; + _led1 = setup.LED1; + _led2 = setup.LED2; + _led3 = setup.LED3; + _led4 = setup.LED4; + + SaveSettings(); + } + } + + /// <summary> /// Callback for remote button presses. /// </summary> /// <value>The remote callback.</value> @@ -129,7 +185,71 @@ set { _mouseHandler = value; } } + void LoadSettings() + { + XmlDocument doc = new XmlDocument(); + try { doc.Load(ConfigurationFile); } + catch { return; } + + try { _handleMouseLocally = bool.Parse(doc.DocumentElement.Attributes["HandleMouseLocally"].Value); } + catch { } + + try { _useNunchukAsMouse = bool.Parse(doc.DocumentElement.Attributes["UseNunchukAsMouse"].Value); } + catch { } + + try { _mouseSensitivity = double.Parse(doc.DocumentElement.Attributes["MouseSensitivity"].Value); } + catch { } + + try { _led1 = bool.Parse(doc.DocumentElement.Attributes["LED1"].Value); } + catch { } + try { _led2 = bool.Parse(doc.DocumentElement.Attributes["LED2"].Value); } + catch { } + try { _led3 = bool.Parse(doc.DocumentElement.Attributes["LED3"].Value); } + catch { } + try { _led4 = bool.Parse(doc.DocumentElement.Attributes["LED4"].Value); } + catch { } + } + void SaveSettings() + { + try + { + using (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("HandleMouseLocally", _handleMouseLocally.ToString()); + writer.WriteAttributeString("UseNunchukAsMouse", _useNunchukAsMouse.ToString()); + writer.WriteAttributeString("MouseSensitivity", _mouseSensitivity.ToString()); + + writer.WriteAttributeString("LED1", _led1.ToString()); + writer.WriteAttributeString("LED2", _led2.ToString()); + writer.WriteAttributeString("LED3", _led3.ToString()); + writer.WriteAttributeString("LED4", _l... [truncated message content] |