Renaming our HID classes.
Now using namespace alias in demo.
1.1 --- a/Hid/HidDevice.cs Sun Mar 15 20:30:00 2015 +0100
1.2 +++ b/Hid/HidDevice.cs Sun Mar 15 20:44:15 2015 +0100
1.3 @@ -32,7 +32,7 @@
1.4 /// Represent a HID device.
1.5 /// Rename to RawInputDevice?
1.6 /// </summary>
1.7 - public class HidDevice: IDisposable
1.8 + public class Device: IDisposable
1.9 {
1.10 /// <summary>
1.11 /// Unique name of that HID device.
1.12 @@ -74,7 +74,7 @@
1.13 /// Class constructor will fetch this object properties from HID sub system.
1.14 /// </summary>
1.15 /// <param name="hRawInputDevice">Device Handle as provided by RAWINPUTHEADER.hDevice, typically accessed as rawinput.header.hDevice</param>
1.16 - public HidDevice(IntPtr hRawInputDevice)
1.17 + public Device(IntPtr hRawInputDevice)
1.18 {
1.19 //Try construct and rollback if needed
1.20 try
1.21 @@ -93,7 +93,7 @@
1.22 /// <summary>
1.23 /// Make sure dispose is called even if the user forgot about it.
1.24 /// </summary>
1.25 - ~HidDevice()
1.26 + ~Device()
1.27 {
1.28 Dispose();
1.29 }
2.1 --- a/Hid/HidEvent.cs Sun Mar 15 20:30:00 2015 +0100
2.2 +++ b/Hid/HidEvent.cs Sun Mar 15 20:44:15 2015 +0100
2.3 @@ -52,7 +52,7 @@
2.4 /// Represent a HID event.
2.5 /// TODO: Rename this into HidRawInput?
2.6 /// </summary>
2.7 - public class HidEvent : IDisposable
2.8 + public class Event : IDisposable
2.9 {
2.10 public bool IsValid { get; private set; }
2.11 public bool IsForeground { get; private set; }
2.12 @@ -68,7 +68,7 @@
2.13 public bool IsRepeat { get { return RepeatCount != 0; } }
2.14 public uint RepeatCount { get; private set; }
2.15
2.16 - public HidDevice Device { get; private set; }
2.17 + public Device Device { get; private set; }
2.18 public RAWINPUT RawInput { get {return iRawInput;} }
2.19 private RAWINPUT iRawInput;
2.20
2.21 @@ -83,7 +83,7 @@
2.22 //TODO: We need a collection of input report
2.23 public byte[] InputReport { get; private set; }
2.24 //
2.25 - public delegate void HidEventRepeatDelegate(HidEvent aHidEvent);
2.26 + public delegate void HidEventRepeatDelegate(Event aHidEvent);
2.27 public event HidEventRepeatDelegate OnHidEventRepeat;
2.28
2.29 private System.Timers.Timer Timer { get; set; }
2.30 @@ -115,7 +115,7 @@
2.31 /// Initialize an HidEvent from a WM_INPUT message
2.32 /// </summary>
2.33 /// <param name="hRawInputDevice">Device Handle as provided by RAWINPUTHEADER.hDevice, typically accessed as rawinput.header.hDevice</param>
2.34 - public HidEvent(Message aMessage, HidEventRepeatDelegate aRepeatDelegate)
2.35 + public Event(Message aMessage, HidEventRepeatDelegate aRepeatDelegate)
2.36 {
2.37 RepeatCount = 0;
2.38 IsValid = false;
2.39 @@ -163,7 +163,7 @@
2.40 if (RawInput.header.hDevice != IntPtr.Zero)
2.41 {
2.42 //Get various information about this HID device
2.43 - Device = new HidDevice(RawInput.header.hDevice);
2.44 + Device = new Device(RawInput.header.hDevice);
2.45 }
2.46
2.47 if (RawInput.header.dwType == Win32.RawInputDeviceType.RIM_TYPEHID) //Check that our raw input is HID
2.48 @@ -406,7 +406,7 @@
2.49 Timer.Enabled = true;
2.50 }
2.51
2.52 - static private void OnRepeatTimerElapsed(object sender, ElapsedEventArgs e, HidEvent aHidEvent)
2.53 + static private void OnRepeatTimerElapsed(object sender, ElapsedEventArgs e, Event aHidEvent)
2.54 {
2.55 if (aHidEvent.IsStray)
2.56 {
3.1 --- a/Hid/HidHandler.cs Sun Mar 15 20:30:00 2015 +0100
3.2 +++ b/Hid/HidHandler.cs Sun Mar 15 20:44:15 2015 +0100
3.3 @@ -33,18 +33,18 @@
3.4 /// <summary>
3.5 /// Our HID handler manages raw input registrations, processes WM_INPUT messages and broadcasts HID events in return.
3.6 /// </summary>
3.7 - public class HidHandler
3.8 + public class Handler
3.9 {
3.10 - public delegate void HidEventHandler(object aSender, HidEvent aHidEvent);
3.11 + public delegate void HidEventHandler(object aSender, Event aHidEvent);
3.12 public event HidEventHandler OnHidEvent;
3.13 - List<HidEvent> iHidEvents;
3.14 + List<Event> iHidEvents;
3.15
3.16
3.17 public bool IsRegistered { get; private set; }
3.18
3.19 - public HidHandler(RAWINPUTDEVICE[] aRawInputDevices)
3.20 + public Handler(RAWINPUTDEVICE[] aRawInputDevices)
3.21 {
3.22 - iHidEvents=new List<HidEvent>();
3.23 + iHidEvents=new List<Event>();
3.24 IsRegistered = Function.RegisterRawInputDevices(aRawInputDevices, (uint)aRawInputDevices.Length, (uint)Marshal.SizeOf(aRawInputDevices[0]));
3.25 }
3.26
3.27 @@ -60,7 +60,7 @@
3.28 return;
3.29 }
3.30
3.31 - HidEvent hidEvent = new HidEvent(aMessage, OnHidEventRepeat);
3.32 + Event hidEvent = new Event(aMessage, OnHidEventRepeat);
3.33 hidEvent.DebugWrite();
3.34
3.35 if (!hidEvent.IsValid || !hidEvent.IsGeneric)
3.36 @@ -93,7 +93,7 @@
3.37 OnHidEvent(this, hidEvent);
3.38 }
3.39
3.40 - public void OnHidEventRepeat(HidEvent aHidEvent)
3.41 + public void OnHidEventRepeat(Event aHidEvent)
3.42 {
3.43 //Broadcast our events
3.44 OnHidEvent(this, aHidEvent);
4.1 --- a/MainForm.cs Sun Mar 15 20:30:00 2015 +0100
4.2 +++ b/MainForm.cs Sun Mar 15 20:44:15 2015 +0100
4.3 @@ -25,19 +25,19 @@
4.4 using System.Data;
4.5 using System.Diagnostics;
4.6 using System.Runtime.InteropServices;
4.7 -using SharpLib.Hid;
4.8 +using Hid = SharpLib.Hid;
4.9 using SharpLib.Win32;
4.10
4.11 namespace HidDemo
4.12 {
4.13 /// <summary>
4.14 - /// Summary description for Form1.
4.15 + /// MainForm for our HID demo.
4.16 /// </summary>
4.17 public partial class MainForm : System.Windows.Forms.Form
4.18 {
4.19 - private HidHandler iHidHandler;
4.20 + private Hid.Handler iHidHandler;
4.21
4.22 - public delegate void OnHidEventDelegate(object aSender, SharpLib.Hid.HidEvent aHidEvent);
4.23 + public delegate void OnHidEventDelegate(object aSender, Hid.Event aHidEvent);
4.24
4.25 public MainForm()
4.26 {
4.27 @@ -114,7 +114,7 @@
4.28 //rid[i].hwndTarget = aHWND;
4.29
4.30
4.31 - iHidHandler = new SharpLib.Hid.HidHandler(rid);
4.32 + iHidHandler = new SharpLib.Hid.Handler(rid);
4.33 if (!iHidHandler.IsRegistered)
4.34 {
4.35 Debug.WriteLine("Failed to register raw input devices: " + Marshal.GetLastWin32Error().ToString());
4.36 @@ -122,7 +122,7 @@
4.37 iHidHandler.OnHidEvent += HandleHidEventThreadSafe;
4.38 }
4.39
4.40 - public void HandleHidEventThreadSafe(object aSender, SharpLib.Hid.HidEvent aHidEvent)
4.41 + public void HandleHidEventThreadSafe(object aSender, SharpLib.Hid.Event aHidEvent)
4.42 {
4.43 if (aHidEvent.IsStray)
4.44 {
5.1 --- a/Win32/RawInput.cs Sun Mar 15 20:30:00 2015 +0100
5.2 +++ b/Win32/RawInput.cs Sun Mar 15 20:44:15 2015 +0100
5.3 @@ -196,7 +196,7 @@
5.4 //For each our device add a node to our treeview
5.5 foreach (RAWINPUTDEVICELIST device in ridList)
5.6 {
5.7 - SharpLib.Hid.HidDevice hidDevice=new SharpLib.Hid.HidDevice(device.hDevice);
5.8 + SharpLib.Hid.Device hidDevice=new SharpLib.Hid.Device(device.hDevice);
5.9
5.10 TreeNode node = null;
5.11 if (hidDevice.Product != null && hidDevice.Product.Length > 1)
5.12 @@ -233,7 +233,7 @@
5.13 {
5.14 foreach (HIDP_VALUE_CAPS caps in hidDevice.InputValueCapabilities)
5.15 {
5.16 - string des = SharpLib.Hid.HidDevice.InputValueCapabilityDescription(caps);
5.17 + string des = SharpLib.Hid.Device.InputValueCapabilityDescription(caps);
5.18 if (des != null)
5.19 {
5.20 node.Nodes.Add(des);