# HG changeset patch # User sl # Date 1415125892 -3600 # Node ID 82a61d3d2706763fd3ad94e00424adfa1026efae Initial contribution. Partly working with PCS-MCE. diff -r 000000000000 -r 82a61d3d2706 App.ico Binary file App.ico has changed diff -r 000000000000 -r 82a61d3d2706 AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AssemblyInfo.cs Tue Nov 04 19:31:32 2014 +0100 @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// 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("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff -r 000000000000 -r 82a61d3d2706 Form1.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Form1.cs Tue Nov 04 19:31:32 2014 +0100 @@ -0,0 +1,137 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using BruceThomas.Devices.RemoteControl; + +namespace RemoteControlSample +{ + /// + /// Summary description for Form1. + /// + public class Form1 : System.Windows.Forms.Form + { + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private System.Windows.Forms.Label label1; + private RemoteControlDevice _remote; + private System.Windows.Forms.Label label2; + private Timer _timer; + + public Form1() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + _timer = new Timer(); + _timer.Interval = 3000; + _timer.Enabled = false; + _timer.Tick +=new EventHandler(_timer_Tick); + _remote = new RemoteControlDevice(); + _remote.ButtonPressed +=new BruceThomas.Devices.RemoteControl.RemoteControlDevice.RemoteControlDeviceEventHandler(_remote_ButtonPressed); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(736, 266); + this.label1.TabIndex = 0; + this.label1.Text = "Ready..."; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label2 + // + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label2.Location = new System.Drawing.Point(72, 32); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(576, 23); + this.label2.TabIndex = 1; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // Form1 + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.BackColor = System.Drawing.Color.LightSteelBlue; + this.ClientSize = new System.Drawing.Size(736, 266); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "Form1"; + this.Text = "Remote Control Sample"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new Form1()); + } + + private void Form1_Load(object sender, System.EventArgs e) + { + + } + + + protected override void WndProc(ref Message message) + { + _remote.ProcessMessage(message); + base.WndProc(ref message); + } + + private void _remote_ButtonPressed(object sender, RemoteControlEventArgs e) + { + _timer.Enabled = false; + label1.Text = e.Button.ToString(); + label2.Text = e.Device.ToString(); + _timer.Enabled = true; + } + + private void _timer_Tick(object sender, EventArgs e) + { + _timer.Enabled = false; + label1.Text = "Ready..."; + } + } +} diff -r 000000000000 -r 82a61d3d2706 Form1.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Form1.resx Tue Nov 04 19:31:32 2014 +0100 @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + Form1 + + + True + + + 80 + + + True + + + Private + + \ No newline at end of file diff -r 000000000000 -r 82a61d3d2706 RemoteControlDevice.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemoteControlDevice.cs Tue Nov 04 19:31:32 2014 +0100 @@ -0,0 +1,589 @@ +using System; +using System.Windows.Forms; +using System.Runtime.InteropServices; +using System.Diagnostics; + + +namespace BruceThomas.Devices.RemoteControl +{ + public enum InputDevice + { + Key, + Mouse, + OEM + } + + + public enum RemoteControlButton + { + Clear, + Down, + Left, + Digit0, + Digit1, + Digit2, + Digit3, + Digit4, + Digit5, + Digit6, + Digit7, + Digit8, + Digit9, + Enter, + Right, + Up, + + Back, + ChannelDown, + ChannelUp, + FastForward, + VolumeMute, + Pause, + Play, + PlayPause, + Record, + PreviousTrack, + Rewind, + NextTrack, + Stop, + VolumeDown, + VolumeUp, + + RecordedTV, + Guide, + LiveTV, + Details, + DVDMenu, + DVDAngle, + DVDAudio, + DVDSubtitle, + MyMusic, + MyPictures, + MyVideos, + MyTV, + OEM1, + OEM2, + StandBy, + TVJump, + + Unknown + } + + + #region RemoteControlEventArgs + + public class RemoteControlEventArgs : EventArgs + { + RemoteControlButton _rcb; + InputDevice _device; + + public RemoteControlEventArgs(RemoteControlButton rcb, InputDevice device) + { + _rcb = rcb; + _device = device; + } + + + public RemoteControlEventArgs() + { + _rcb = RemoteControlButton.Unknown; + _device = InputDevice.Key; + } + + + public RemoteControlButton Button + { + get { return _rcb; } + set { _rcb = value; } + } + + public InputDevice Device + { + get { return _device; } + set { _device = value; } + } + } + + #endregion RemoteControlEventArgs + + + public sealed class RemoteControlDevice + { + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + internal struct RAWINPUTDEVICE + { + [MarshalAs(UnmanagedType.U2)] + public ushort usUsagePage; + [MarshalAs(UnmanagedType.U2)] + public ushort usUsage; + [MarshalAs(UnmanagedType.U4)] + public int dwFlags; + public IntPtr hwndTarget; + } + + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + internal struct RAWINPUTHEADER + { + [MarshalAs(UnmanagedType.U4)] + public int dwType; + [MarshalAs(UnmanagedType.U4)] + public int dwSize; + public IntPtr hDevice; + [MarshalAs(UnmanagedType.U4)] + public int wParam; + } + + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + internal struct RAWHID + { + [MarshalAs(UnmanagedType.U4)] + public int dwSizeHid; + [MarshalAs(UnmanagedType.U4)] + public int dwCount; + // + //BYTE bRawData[1]; + } + + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + internal struct BUTTONSSTR + { + [MarshalAs(UnmanagedType.U2)] + public ushort usButtonFlags; + [MarshalAs(UnmanagedType.U2)] + public ushort usButtonData; + } + + + [StructLayout(LayoutKind.Explicit, Pack = 1)] + internal struct RAWMOUSE + { + [MarshalAs(UnmanagedType.U2)] + [FieldOffset (0)] public ushort usFlags; + [MarshalAs(UnmanagedType.U4)] + [FieldOffset (4)] public uint ulButtons; + [FieldOffset (4)] public BUTTONSSTR buttonsStr; + [MarshalAs(UnmanagedType.U4)] + [FieldOffset (8)] public uint ulRawButtons; + [MarshalAs(UnmanagedType.U4)] + [FieldOffset (12)] public int lLastX; + [MarshalAs(UnmanagedType.U4)] + [FieldOffset (16)] public int lLastY; + [MarshalAs(UnmanagedType.U4)] + [FieldOffset (20)] public uint ulExtraInformation; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + internal struct RAWKEYBOARD + { + [MarshalAs(UnmanagedType.U2)] + public ushort MakeCode; + [MarshalAs(UnmanagedType.U2)] + public ushort Flags; + [MarshalAs(UnmanagedType.U2)] + public ushort Reserved; + [MarshalAs(UnmanagedType.U2)] + public ushort VKey; + [MarshalAs(UnmanagedType.U4)] + public uint Message; + [MarshalAs(UnmanagedType.U4)] + public uint ExtraInformation; + } + + + [StructLayout(LayoutKind.Explicit, Pack=1)] + internal struct RAWINPUT + { + [FieldOffset (0)] public RAWINPUTHEADER header; + [FieldOffset (16)] public RAWMOUSE mouse; + [FieldOffset (16)] public RAWKEYBOARD keyboard; + [FieldOffset (16)] public RAWHID hid; + } + + + [DllImport("User32.dll")] + extern static bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevice, uint uiNumDevices, uint cbSize); + + [DllImport("User32.dll")] + extern static uint GetRawInputData(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader); + + + private const int WM_KEYDOWN = 0x0100; + private const int WM_APPCOMMAND = 0x0319; + private const int WM_INPUT = 0x00FF; + + private const int APPCOMMAND_BROWSER_BACKWARD = 1; + private const int APPCOMMAND_VOLUME_MUTE = 8; + private const int APPCOMMAND_VOLUME_DOWN = 9; + private const int APPCOMMAND_VOLUME_UP = 10; + private const int APPCOMMAND_MEDIA_NEXTTRACK = 11; + private const int APPCOMMAND_MEDIA_PREVIOUSTRACK = 12; + private const int APPCOMMAND_MEDIA_STOP = 13; + private const int APPCOMMAND_MEDIA_PLAY_PAUSE = 14; + private const int APPCOMMAND_MEDIA_PLAY = 46; + private const int APPCOMMAND_MEDIA_PAUSE = 47; + private const int APPCOMMAND_MEDIA_RECORD = 48; + private const int APPCOMMAND_MEDIA_FAST_FORWARD = 49; + private const int APPCOMMAND_MEDIA_REWIND = 50; + private const int APPCOMMAND_MEDIA_CHANNEL_UP = 51; + private const int APPCOMMAND_MEDIA_CHANNEL_DOWN = 52; + + private const int RAWINPUT_DETAILS = 0x209; + private const int RAWINPUT_GUIDE = 0x8D; + private const int RAWINPUT_TVJUMP = 0x25; + private const int RAWINPUT_STANDBY = 0x82; + private const int RAWINPUT_OEM1 = 0x80; + private const int RAWINPUT_OEM2 = 0x81; + private const int RAWINPUT_MYTV = 0x46; + private const int RAWINPUT_MYVIDEOS = 0x4A; + private const int RAWINPUT_MYPICTURES = 0x49; + private const int RAWINPUT_MYMUSIC = 0x47; + private const int RAWINPUT_RECORDEDTV = 0x48; + private const int RAWINPUT_DVDANGLE = 0x4B; + private const int RAWINPUT_DVDAUDIO = 0x4C; + private const int RAWINPUT_DVDMENU = 0x24; + private const int RAWINPUT_DVDSUBTITLE = 0x4D; + + private const int RIM_TYPEMOUSE = 0; + private const int RIM_TYPEKEYBOARD = 1; + private const int RIM_TYPEHID = 2; + + private const int RID_INPUT = 0x10000003; + private const int RID_HEADER = 0x10000005; + + private const int FAPPCOMMAND_MASK = 0xF000; + private const int FAPPCOMMAND_MOUSE = 0x8000; + private const int FAPPCOMMAND_KEY = 0; + private const int FAPPCOMMAND_OEM = 0x1000; + + public delegate void RemoteControlDeviceEventHandler(object sender, RemoteControlEventArgs e); + public event RemoteControlDeviceEventHandler ButtonPressed; + + + //------------------------------------------------------------- + // constructors + //------------------------------------------------------------- + + public RemoteControlDevice() + { + // Register the input device to receive the commands from the + // remote device. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/remote_control.asp + // for the vendor defined usage page. + + RAWINPUTDEVICE[] rid = new RAWINPUTDEVICE[3]; + + rid[0].usUsagePage = 0xFFBC; + rid[0].usUsage = 0x88; + rid[0].dwFlags = 0; + + rid[1].usUsagePage = 0x0C; + rid[1].usUsage = 0x01; + rid[1].dwFlags = 0; + + rid[2].usUsagePage = 0x0C; + rid[2].usUsage = 0x80; + rid[2].dwFlags = 0; + + if (!RegisterRawInputDevices(rid, + (uint) rid.Length, + (uint) Marshal.SizeOf(rid[0])) + ) + { + throw new ApplicationException("Failed to register raw input devices."); + } + } + + + //------------------------------------------------------------- + // methods + //------------------------------------------------------------- + + public void ProcessMessage(Message message) + { + int param; + + switch (message.Msg) + { + case WM_KEYDOWN: + param = message.WParam.ToInt32(); + ProcessKeyDown(param); + break; + case WM_APPCOMMAND: + param = message.LParam.ToInt32(); + ProcessAppCommand(param); + break; + case WM_INPUT: + ProcessInputCommand(ref message); + message.Result = new IntPtr(0); + break; + } + + } + + + //------------------------------------------------------------- + // methods (helpers) + //------------------------------------------------------------- + + private void ProcessKeyDown(int param) + { + RemoteControlButton rcb = RemoteControlButton.Unknown; + + switch (param) + { + case (int) Keys.Escape: + rcb = RemoteControlButton.Clear; + break; + case (int) Keys.Down: + rcb = RemoteControlButton.Down; + break; + case (int) Keys.Left: + rcb = RemoteControlButton.Left; + break; + case (int) Keys.D0: + rcb = RemoteControlButton.Digit0; + break; + case (int) Keys.D1: + rcb = RemoteControlButton.Digit1; + break; + case (int) Keys.D2: + rcb = RemoteControlButton.Digit2; + break; + case (int) Keys.D3: + rcb = RemoteControlButton.Digit3; + break; + case (int) Keys.D4: + rcb = RemoteControlButton.Digit4; + break; + case (int) Keys.D5: + rcb = RemoteControlButton.Digit5; + break; + case (int) Keys.D6: + rcb = RemoteControlButton.Digit6; + break; + case (int) Keys.D7: + rcb = RemoteControlButton.Digit7; + break; + case (int) Keys.D8: + rcb = RemoteControlButton.Digit8; + break; + case (int) Keys.D9: + rcb = RemoteControlButton.Digit9; + break; + case (int) Keys.Enter: + rcb = RemoteControlButton.Enter; + break; + case (int) Keys.Right: + rcb = RemoteControlButton.Right; + break; + case (int) Keys.Up: + rcb = RemoteControlButton.Up; + break; + } + + if (this.ButtonPressed != null && rcb != RemoteControlButton.Unknown) + this.ButtonPressed(this, new RemoteControlEventArgs(rcb, GetDevice(param))); + } + + + private void ProcessAppCommand(int param) + { + RemoteControlButton rcb = RemoteControlButton.Unknown; + + int cmd = (int) (((ushort) (param >> 16)) & ~FAPPCOMMAND_MASK); + + switch (cmd) + { + case APPCOMMAND_BROWSER_BACKWARD: + rcb = RemoteControlButton.Back; + break; + case APPCOMMAND_MEDIA_CHANNEL_DOWN: + rcb = RemoteControlButton.ChannelDown; + break; + case APPCOMMAND_MEDIA_CHANNEL_UP: + rcb = RemoteControlButton.ChannelUp; + break; + case APPCOMMAND_MEDIA_FAST_FORWARD: + rcb = RemoteControlButton.FastForward; + break; + case APPCOMMAND_VOLUME_MUTE: + rcb = RemoteControlButton.VolumeMute; + break; + case APPCOMMAND_MEDIA_PAUSE: + rcb = RemoteControlButton.Pause; + break; + case APPCOMMAND_MEDIA_PLAY: + rcb = RemoteControlButton.Play; + break; + case APPCOMMAND_MEDIA_PLAY_PAUSE: + rcb = RemoteControlButton.PlayPause; + break; + case APPCOMMAND_MEDIA_RECORD: + rcb = RemoteControlButton.Record; + break; + case APPCOMMAND_MEDIA_PREVIOUSTRACK: + rcb = RemoteControlButton.PreviousTrack; + break; + case APPCOMMAND_MEDIA_REWIND: + rcb = RemoteControlButton.Rewind; + break; + case APPCOMMAND_MEDIA_NEXTTRACK: + rcb = RemoteControlButton.NextTrack; + break; + case APPCOMMAND_MEDIA_STOP: + rcb = RemoteControlButton.Stop; + break; + case APPCOMMAND_VOLUME_DOWN: + rcb = RemoteControlButton.VolumeDown; + break; + case APPCOMMAND_VOLUME_UP: + rcb = RemoteControlButton.VolumeUp; + break; + } + + if (this.ButtonPressed != null && rcb != RemoteControlButton.Unknown) + this.ButtonPressed(this, new RemoteControlEventArgs(rcb, GetDevice(param))); + } + + + private void ProcessInputCommand(ref Message message) + { + RemoteControlButton rcb = RemoteControlButton.Unknown; + uint dwSize = 0; + + uint sizeOfHeader=(uint)Marshal.SizeOf(typeof(RAWINPUTHEADER)); + + //Get the size of our raw input data. + GetRawInputData(message.LParam, RID_INPUT, IntPtr.Zero, ref dwSize, sizeOfHeader); + + //Allocate a large enough buffer + IntPtr buffer = Marshal.AllocHGlobal((int) dwSize); + try + { + if(buffer == IntPtr.Zero) + return; + + //Now read our RAWINPUT data + if (GetRawInputData(message.LParam, RID_INPUT, buffer, ref dwSize, (uint) Marshal.SizeOf(typeof(RAWINPUTHEADER))) != dwSize) + { + return; + } + + //Cast our buffer + RAWINPUT raw = (RAWINPUT)Marshal.PtrToStructure(buffer, typeof(RAWINPUT)); + + //Check that our raw input is HID + if (raw.header.dwType == RIM_TYPEHID && raw.hid.dwSizeHid>0) + { + //Allocate a buffer for one HID message + byte[] bRawData = new byte[raw.hid.dwSizeHid]; + + //Compute the address from which to copy our HID message + int pRawData = 0; + unsafe + { + byte* source = (byte*)buffer; + source += sizeof(RAWINPUTHEADER) + sizeof(RAWHID); + //source += 1; + pRawData = (int)source; + } + //int pRawData = buffer.ToUint32() + Marshal.SizeOf(typeof(RAWINPUT)) + 1; + + //Marshal.Copy(new IntPtr(pRawData), bRawData, 0, raw.hid.dwSizeHid - 1); + Marshal.Copy(new IntPtr(pRawData), bRawData, 0, raw.hid.dwSizeHid); + //int rawData = bRawData[0] | bRawData[1] << 8; + int rawData = bRawData[1]; //Get button code + Debug.WriteLine("HID " + raw.hid.dwCount + "/" + raw.hid.dwSizeHid + ":" + bRawData[0].ToString("X") + bRawData[1].ToString("X")); + + switch (rawData) + { + case RAWINPUT_DETAILS: + rcb = RemoteControlButton.Details; + break; + case RAWINPUT_GUIDE: + rcb = RemoteControlButton.Guide; + break; + case RAWINPUT_TVJUMP: + rcb = RemoteControlButton.TVJump; + break; + case RAWINPUT_STANDBY: + rcb = RemoteControlButton.StandBy; + break; + case RAWINPUT_OEM1: + rcb = RemoteControlButton.OEM1; + break; + case RAWINPUT_OEM2: + rcb = RemoteControlButton.OEM2; + break; + case RAWINPUT_MYTV: + rcb = RemoteControlButton.MyTV; + break; + case RAWINPUT_MYVIDEOS: + rcb = RemoteControlButton.MyVideos; + break; + case RAWINPUT_MYPICTURES: + rcb = RemoteControlButton.MyPictures; + break; + case RAWINPUT_MYMUSIC: + rcb = RemoteControlButton.MyMusic; + break; + case RAWINPUT_RECORDEDTV: + rcb = RemoteControlButton.RecordedTV; + break; + case RAWINPUT_DVDANGLE: + rcb = RemoteControlButton.DVDAngle; + break; + case RAWINPUT_DVDAUDIO: + rcb = RemoteControlButton.DVDAudio; + break; + case RAWINPUT_DVDMENU: + rcb = RemoteControlButton.DVDMenu; + break; + case RAWINPUT_DVDSUBTITLE: + rcb = RemoteControlButton.DVDSubtitle; + break; + } + + if (rcb != RemoteControlButton.Unknown && this.ButtonPressed != null) + this.ButtonPressed(this, new RemoteControlEventArgs(rcb, GetDevice(message.LParam.ToInt32()))); + } + else if(raw.header.dwType == RIM_TYPEMOUSE) + { + // do mouse handling... + } + else if(raw.header.dwType == RIM_TYPEKEYBOARD) + { + // do keyboard handling... + } + } + finally + { + Marshal.FreeHGlobal(buffer); + } + } + + + private InputDevice GetDevice(int param) + { + InputDevice inputDevice; + + switch ((int) (((ushort) (param >> 16)) & FAPPCOMMAND_MASK)) + { + case FAPPCOMMAND_OEM: + inputDevice = InputDevice.OEM; + break; + case FAPPCOMMAND_MOUSE: + inputDevice = InputDevice.Mouse; + break; + default: + inputDevice = InputDevice.Key; + break; + } + + return inputDevice; + } + } +} diff -r 000000000000 -r 82a61d3d2706 RemoteControlSample.csproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemoteControlSample.csproj Tue Nov 04 19:31:32 2014 +0100 @@ -0,0 +1,155 @@ + + + + Local + 7.10.3077 + 2.0 + {F676C5E5-266C-439A-98C4-EF21CB9957F2} + Debug + AnyCPU + App.ico + + RemoteControlSample + + JScript + Grid + IE50 + false + WinExe + RemoteControlSample + OnBuildSuccess + + + + v2.0 + + + 0.0 + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + bin\Debug\ + false + 285212672 + false + + DEBUG;TRACE + + true + 4096 + false + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + TRACE + + false + 4096 + false + + true + false + false + false + 4 + none + prompt + + + true + bin\x86\Debug\ + DEBUG;TRACE + 285212672 + 4096 + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + 285212672 + true + 4096 + x86 + prompt + MinimumRecommendedRules.ruleset + + + + System + + + System.Data + + + System.Drawing + + + System.Windows.Forms + + + System.XML + + + + + Code + + + Form + + + Code + + + + Form1.cs + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + + + + \ No newline at end of file diff -r 000000000000 -r 82a61d3d2706 RemoteControlSample.sln --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemoteControlSample.sln Tue Nov 04 19:31:32 2014 +0100 @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteControlSample", "RemoteControlSample.csproj", "{F676C5E5-266C-439A-98C4-EF21CB9957F2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Debug|x86.ActiveCfg = Debug|x86 + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Debug|x86.Build.0 = Debug|x86 + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Release|Any CPU.Build.0 = Release|Any CPU + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Release|x86.ActiveCfg = Release|x86 + {F676C5E5-266C-439A-98C4-EF21CB9957F2}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal