# HG changeset patch # User StephaneLenclud # Date 1426448655 -3600 # Node ID baabcd5cdf8cd36d5fa44a1cf114b23ad6b3117e # Parent e2acfa51664f0931d500ea033bdb26cae52698e2 Renaming our HID classes. Now using namespace alias in demo. diff -r e2acfa51664f -r baabcd5cdf8c Hid/HidDevice.cs --- a/Hid/HidDevice.cs Sun Mar 15 20:30:00 2015 +0100 +++ b/Hid/HidDevice.cs Sun Mar 15 20:44:15 2015 +0100 @@ -32,7 +32,7 @@ /// Represent a HID device. /// Rename to RawInputDevice? /// - public class HidDevice: IDisposable + public class Device: IDisposable { /// /// Unique name of that HID device. @@ -74,7 +74,7 @@ /// Class constructor will fetch this object properties from HID sub system. /// /// Device Handle as provided by RAWINPUTHEADER.hDevice, typically accessed as rawinput.header.hDevice - public HidDevice(IntPtr hRawInputDevice) + public Device(IntPtr hRawInputDevice) { //Try construct and rollback if needed try @@ -93,7 +93,7 @@ /// /// Make sure dispose is called even if the user forgot about it. /// - ~HidDevice() + ~Device() { Dispose(); } diff -r e2acfa51664f -r baabcd5cdf8c Hid/HidEvent.cs --- a/Hid/HidEvent.cs Sun Mar 15 20:30:00 2015 +0100 +++ b/Hid/HidEvent.cs Sun Mar 15 20:44:15 2015 +0100 @@ -52,7 +52,7 @@ /// Represent a HID event. /// TODO: Rename this into HidRawInput? /// - public class HidEvent : IDisposable + public class Event : IDisposable { public bool IsValid { get; private set; } public bool IsForeground { get; private set; } @@ -68,7 +68,7 @@ public bool IsRepeat { get { return RepeatCount != 0; } } public uint RepeatCount { get; private set; } - public HidDevice Device { get; private set; } + public Device Device { get; private set; } public RAWINPUT RawInput { get {return iRawInput;} } private RAWINPUT iRawInput; @@ -83,7 +83,7 @@ //TODO: We need a collection of input report public byte[] InputReport { get; private set; } // - public delegate void HidEventRepeatDelegate(HidEvent aHidEvent); + public delegate void HidEventRepeatDelegate(Event aHidEvent); public event HidEventRepeatDelegate OnHidEventRepeat; private System.Timers.Timer Timer { get; set; } @@ -115,7 +115,7 @@ /// Initialize an HidEvent from a WM_INPUT message /// /// Device Handle as provided by RAWINPUTHEADER.hDevice, typically accessed as rawinput.header.hDevice - public HidEvent(Message aMessage, HidEventRepeatDelegate aRepeatDelegate) + public Event(Message aMessage, HidEventRepeatDelegate aRepeatDelegate) { RepeatCount = 0; IsValid = false; @@ -163,7 +163,7 @@ if (RawInput.header.hDevice != IntPtr.Zero) { //Get various information about this HID device - Device = new HidDevice(RawInput.header.hDevice); + Device = new Device(RawInput.header.hDevice); } if (RawInput.header.dwType == Win32.RawInputDeviceType.RIM_TYPEHID) //Check that our raw input is HID @@ -406,7 +406,7 @@ Timer.Enabled = true; } - static private void OnRepeatTimerElapsed(object sender, ElapsedEventArgs e, HidEvent aHidEvent) + static private void OnRepeatTimerElapsed(object sender, ElapsedEventArgs e, Event aHidEvent) { if (aHidEvent.IsStray) { diff -r e2acfa51664f -r baabcd5cdf8c Hid/HidHandler.cs --- a/Hid/HidHandler.cs Sun Mar 15 20:30:00 2015 +0100 +++ b/Hid/HidHandler.cs Sun Mar 15 20:44:15 2015 +0100 @@ -33,18 +33,18 @@ /// /// Our HID handler manages raw input registrations, processes WM_INPUT messages and broadcasts HID events in return. /// - public class HidHandler + public class Handler { - public delegate void HidEventHandler(object aSender, HidEvent aHidEvent); + public delegate void HidEventHandler(object aSender, Event aHidEvent); public event HidEventHandler OnHidEvent; - List iHidEvents; + List iHidEvents; public bool IsRegistered { get; private set; } - public HidHandler(RAWINPUTDEVICE[] aRawInputDevices) + public Handler(RAWINPUTDEVICE[] aRawInputDevices) { - iHidEvents=new List(); + iHidEvents=new List(); IsRegistered = Function.RegisterRawInputDevices(aRawInputDevices, (uint)aRawInputDevices.Length, (uint)Marshal.SizeOf(aRawInputDevices[0])); } @@ -60,7 +60,7 @@ return; } - HidEvent hidEvent = new HidEvent(aMessage, OnHidEventRepeat); + Event hidEvent = new Event(aMessage, OnHidEventRepeat); hidEvent.DebugWrite(); if (!hidEvent.IsValid || !hidEvent.IsGeneric) @@ -93,7 +93,7 @@ OnHidEvent(this, hidEvent); } - public void OnHidEventRepeat(HidEvent aHidEvent) + public void OnHidEventRepeat(Event aHidEvent) { //Broadcast our events OnHidEvent(this, aHidEvent); diff -r e2acfa51664f -r baabcd5cdf8c MainForm.cs --- a/MainForm.cs Sun Mar 15 20:30:00 2015 +0100 +++ b/MainForm.cs Sun Mar 15 20:44:15 2015 +0100 @@ -25,19 +25,19 @@ using System.Data; using System.Diagnostics; using System.Runtime.InteropServices; -using SharpLib.Hid; +using Hid = SharpLib.Hid; using SharpLib.Win32; namespace HidDemo { /// - /// Summary description for Form1. + /// MainForm for our HID demo. /// public partial class MainForm : System.Windows.Forms.Form { - private HidHandler iHidHandler; + private Hid.Handler iHidHandler; - public delegate void OnHidEventDelegate(object aSender, SharpLib.Hid.HidEvent aHidEvent); + public delegate void OnHidEventDelegate(object aSender, Hid.Event aHidEvent); public MainForm() { @@ -114,7 +114,7 @@ //rid[i].hwndTarget = aHWND; - iHidHandler = new SharpLib.Hid.HidHandler(rid); + iHidHandler = new SharpLib.Hid.Handler(rid); if (!iHidHandler.IsRegistered) { Debug.WriteLine("Failed to register raw input devices: " + Marshal.GetLastWin32Error().ToString()); @@ -122,7 +122,7 @@ iHidHandler.OnHidEvent += HandleHidEventThreadSafe; } - public void HandleHidEventThreadSafe(object aSender, SharpLib.Hid.HidEvent aHidEvent) + public void HandleHidEventThreadSafe(object aSender, SharpLib.Hid.Event aHidEvent) { if (aHidEvent.IsStray) { diff -r e2acfa51664f -r baabcd5cdf8c Win32/RawInput.cs --- a/Win32/RawInput.cs Sun Mar 15 20:30:00 2015 +0100 +++ b/Win32/RawInput.cs Sun Mar 15 20:44:15 2015 +0100 @@ -196,7 +196,7 @@ //For each our device add a node to our treeview foreach (RAWINPUTDEVICELIST device in ridList) { - SharpLib.Hid.HidDevice hidDevice=new SharpLib.Hid.HidDevice(device.hDevice); + SharpLib.Hid.Device hidDevice=new SharpLib.Hid.Device(device.hDevice); TreeNode node = null; if (hidDevice.Product != null && hidDevice.Product.Length > 1) @@ -233,7 +233,7 @@ { foreach (HIDP_VALUE_CAPS caps in hidDevice.InputValueCapabilities) { - string des = SharpLib.Hid.HidDevice.InputValueCapabilityDescription(caps); + string des = SharpLib.Hid.Device.InputValueCapabilityDescription(caps); if (des != null) { node.Nodes.Add(des);