# HG changeset patch
# User StephaneLenclud
# Date 1471790120 -7200
# Node ID cadc4e4302c6ab2d29c1abfecec561d0a57eebca
# Parent 0220cb84df588cf049bc3cc55d6b5880a1edde41
Removing now redundant specific HID EAR events.
diff -r 0220cb84df58 -r cadc4e4302c6 Server/Events/EventHidConsumerControl.cs
--- a/Server/Events/EventHidConsumerControl.cs Sun Aug 21 16:30:58 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.Serialization;
-using Ear = SharpLib.Ear;
-using Hid = SharpLib.Hid;
-
-namespace SharpDisplayManager
-{
- [DataContract]
- [Ear.AttributeObject(Id = "Event.Hid.ConsumerControl", Name = "HID Consumer Control", Description = "Corresponding HID message received.")]
- public class EventHidConsumerControl : Ear.Event
- {
- public EventHidConsumerControl()
- {
- }
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.ConsumerControl.Usage",
- Name = "Usage",
- Description = "The usage corresponding to your remote button."
- )]
- public Hid.Usage.ConsumerControl Usage { get; set; }
-
- ///
- /// Make sure we distinguish between various configuration of this event
- ///
- ///
- public override string Brief()
- {
- return Name + ": " + Usage.ToString();
- }
-
- ///
- ///
- ///
- ///
- ///
- public override bool Equals(object obj)
- {
- if (obj is EventHidConsumerControl)
- {
- EventHidConsumerControl e = (EventHidConsumerControl)obj;
- bool res = (e.Usage == Usage);
- return res;
- }
-
- return false;
- }
- }
-}
diff -r 0220cb84df58 -r cadc4e4302c6 Server/Events/EventHidKeyboard.cs
--- a/Server/Events/EventHidKeyboard.cs Sun Aug 21 16:30:58 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.Serialization;
-using System.Windows.Forms;
-using Ear = SharpLib.Ear;
-using Hid = SharpLib.Hid;
-
-namespace SharpDisplayManager
-{
- [DataContract]
- [Ear.AttributeObject(Id = "Event.Hid.Keyboard", Name = "HID Keyboard", Description = "Corresponding HID message received.")]
- public class EventHidKeyboard : Ear.Event
- {
- public EventHidKeyboard()
- {
- }
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.Keyboard.Key",
- Name = "Key",
- Description = "The virtual key code."
- )]
- public Keys Key { get; set; }
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.Keyboard.IsKeyUp",
- Name = "Key Up",
- Description = "Key up if set, key down otherwise."
- )]
- public bool IsKeyUp { get; set; } = true;
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.Keyboard.HasModifierShift",
- Name = "Shift",
- Description = "Shift modifier applied."
- )]
- public bool HasModifierShift { get; set; } = false;
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.Keyboard.HasModifierControl",
- Name = "Control",
- Description = "Control modifier applied."
- )]
- public bool HasModifierControl { get; set; } = false;
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.Keyboard.HasModifierAlt",
- Name = "Alt",
- Description = "Alt modifier applied."
- )]
- public bool HasModifierAlt { get; set; } = false;
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.Keyboard.HasModifierWindows",
- Name = "Windows",
- Description = "Windows modifier applied."
- )]
- public bool HasModifierWindows { get; set; } = false;
-
-
-
- ///
- /// Make sure we distinguish between various configuration of this event
- ///
- ///
- public override string Brief()
- {
- string brief = Name + ": " + Key.ToString();
-
- if (IsKeyUp)
- {
- brief += " (UP)";
- }
- else
- {
- brief += " (DOWN)";
- }
-
- if (HasModifierAlt)
- {
- brief += " + ALT";
- }
-
- if (HasModifierControl)
- {
- brief += " + CTRL";
- }
-
- if (HasModifierShift)
- {
- brief += " + SHIFT";
- }
-
- if (HasModifierWindows)
- {
- brief += " + WIN";
- }
-
- return brief;
- }
-
- ///
- ///
- ///
- ///
- ///
- public override bool Equals(object obj)
- {
- if (obj is EventHidKeyboard)
- {
- EventHidKeyboard e = (EventHidKeyboard)obj;
- return e.Key == Key
- && e.IsKeyUp == IsKeyUp
- && e.HasModifierAlt == HasModifierAlt
- && e.HasModifierControl == HasModifierControl
- && e.HasModifierShift == HasModifierShift
- && e.HasModifierWindows == HasModifierWindows;
- }
-
- return false;
- }
- }
-}
diff -r 0220cb84df58 -r cadc4e4302c6 Server/Events/EventHidWindowsMediaCenter.cs
--- a/Server/Events/EventHidWindowsMediaCenter.cs Sun Aug 21 16:30:58 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.Serialization;
-using Ear = SharpLib.Ear;
-using Hid = SharpLib.Hid;
-
-namespace SharpDisplayManager
-{
- [DataContract]
- [Ear.AttributeObject(Id = "Event.Hid.WindowsMediaCenter", Name = "HID Windows Media Center", Description = "Corresponding HID message received.")]
- public class EventHidWindowsMediaCenter : Ear.Event
- {
- public EventHidWindowsMediaCenter()
- {
- }
-
- [DataMember]
- [Ear.AttributeObjectProperty
- (
- Id = "HID.WMC.Usage",
- Name = "Usage",
- Description = "The usage corresponding to your remote button."
- )]
- public Hid.Usage.WindowsMediaCenterRemoteControl Usage { get; set; }
-
- ///
- /// Make sure we distinguish between various configuration of this event
- ///
- ///
- public override string Brief()
- {
- return Name + ": " + Usage.ToString();
- }
-
- ///
- ///
- ///
- ///
- ///
- public override bool Equals(object obj)
- {
- if (obj is EventHidWindowsMediaCenter)
- {
- EventHidWindowsMediaCenter e = (EventHidWindowsMediaCenter)obj;
- bool res = (e.Usage == Usage);
- return res;
- }
-
- return false;
- }
-
- }
-}
diff -r 0220cb84df58 -r cadc4e4302c6 Server/FormMain.Hid.cs
--- a/Server/FormMain.Hid.cs Sun Aug 21 16:30:58 2016 +0200
+++ b/Server/FormMain.Hid.cs Sun Aug 21 16:35:20 2016 +0200
@@ -95,8 +95,6 @@
}
-
-
///
/// Here we receive HID events from our HID library.
///
@@ -119,63 +117,12 @@
else
{
//Trigger corresponding EAR event if any
- {
- EventHid e = new EventHid();
- e.Copy(aHidEvent);
- Properties.Settings.Default.EarManager.TriggerEvent(e);
- }
-
- if (aHidEvent.IsGeneric)
- {
- if (aHidEvent.Usages.Count == 0)
- {
- //No usage, nothing to do then
- return;
- }
-
- //We are in the proper thread
- if (aHidEvent.UsagePage == (ushort) Hid.UsagePage.WindowsMediaCenterRemoteControl)
- {
- //Trigger events as needed
- EventHidWindowsMediaCenter e = new EventHidWindowsMediaCenter
- {
- Usage = (Hid.Usage.WindowsMediaCenterRemoteControl) aHidEvent.Usages[0]
- };
- Properties.Settings.Default.EarManager.TriggerEvent(e);
- }
- else if (aHidEvent.UsagePage == (ushort) Hid.UsagePage.Consumer)
- {
- //Trigger matching events if any
- EventHidConsumerControl e = new EventHidConsumerControl
- {
- Usage = (Hid.Usage.ConsumerControl) aHidEvent.Usages[0]
- };
- Properties.Settings.Default.EarManager.TriggerEvent(e);
- }
- }
- else if (aHidEvent.IsKeyboard)
- {
- //Trigger matching events if any
- EventHidKeyboard e = new EventHidKeyboard
- {
- Key = aHidEvent.VirtualKey,
- IsKeyUp = aHidEvent.IsButtonUp,
- HasModifierAlt = aHidEvent.HasModifierAlt,
- HasModifierControl = aHidEvent.HasModifierControl,
- HasModifierShift = aHidEvent.HasModifierShift,
- HasModifierWindows = aHidEvent.HasModifierWindows,
- };
- Properties.Settings.Default.EarManager.TriggerEvent(e);
- }
-
+ EventHid e = new EventHid();
+ e.Copy(aHidEvent);
+ Properties.Settings.Default.EarManager.TriggerEvent(e);
}
}
-
-
-
-
-
///
/// We need to handle WM_INPUT.
///
diff -r 0220cb84df58 -r cadc4e4302c6 Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Sun Aug 21 16:30:58 2016 +0200
+++ b/Server/SharpDisplayManager.csproj Sun Aug 21 16:35:20 2016 +0200
@@ -180,9 +180,6 @@
-
-
-
Form