/// <summary> /// Create a human readable string out of this object. /// </summary> /// <returns></returns> public override string ToString() { if (!IsValid) { return("HID: Invalid HidEvent"); } // string res = "==== HidEvent ====\n"; res += Device.ToString(); if (IsGeneric) { res += "Generic\n"; } if (IsKeyboard) { res += "Keyboard\n"; } if (IsMouse) { res += "Mouse\n"; } res += "Foreground: " + IsForeground + "\n"; res += "UsagePage: 0x" + UsagePage.ToString("X4") + "\n"; res += "UsageCollection: 0x" + UsageCollection.ToString("X4") + "\n"; foreach (var usage in Usages) { res += "Usage: 0x" + usage.ToString("X4") + "\n"; } res += "==================\n"; return(res); }
public ListViewItem ToListViewItem() { //TODO: What to do with multiple usage var usage = ""; var usagePage = (UsagePage)UsagePage; switch (usagePage) { case Hid.UsagePage.Consumer: usage = ((ConsumerControl)Usages[0]).ToString(); break; case Hid.UsagePage.WindowsMediaCenterRemoteControl: usage = ((WindowsMediaCenterRemoteControl)Usages[0]).ToString(); break; } var item = new ListViewItem(new[] { usage, UsagePage.ToString("X2"), UsageCollection.ToString("X2"), RepeatCount.ToString(), Time.ToString("HH:mm:ss:fff") }); return(item); }
/// <summary> /// Print information about this device to our debug output. /// </summary> public void DebugWrite() { if (!IsValid) { Debug.WriteLine("==== Invalid HidEvent"); return; } Device.DebugWrite(); if (IsGeneric) { Debug.WriteLine("==== Generic"); } if (IsKeyboard) { Debug.WriteLine("==== Keyboard"); } if (IsMouse) { Debug.WriteLine("==== Mouse"); } Debug.WriteLine("==== Foreground: " + IsForeground); Debug.WriteLine("==== UsagePage: 0x" + UsagePage.ToString("X4")); Debug.WriteLine("==== UsageCollection: 0x" + UsageCollection.ToString("X4")); foreach (var usage in Usages) { Debug.WriteLine("==== Usage: 0x" + usage.ToString("X4")); } }