Removing now redundant specific HID EAR events.
1.1 --- a/Server/Events/EventHidConsumerControl.cs Sun Aug 21 16:30:58 2016 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,55 +0,0 @@
1.4 -using System;
1.5 -using System.Collections.Generic;
1.6 -using System.Linq;
1.7 -using System.Text;
1.8 -using System.Threading.Tasks;
1.9 -using System.Runtime.Serialization;
1.10 -using Ear = SharpLib.Ear;
1.11 -using Hid = SharpLib.Hid;
1.12 -
1.13 -namespace SharpDisplayManager
1.14 -{
1.15 - [DataContract]
1.16 - [Ear.AttributeObject(Id = "Event.Hid.ConsumerControl", Name = "HID Consumer Control", Description = "Corresponding HID message received.")]
1.17 - public class EventHidConsumerControl : Ear.Event
1.18 - {
1.19 - public EventHidConsumerControl()
1.20 - {
1.21 - }
1.22 -
1.23 - [DataMember]
1.24 - [Ear.AttributeObjectProperty
1.25 - (
1.26 - Id = "HID.ConsumerControl.Usage",
1.27 - Name = "Usage",
1.28 - Description = "The usage corresponding to your remote button."
1.29 - )]
1.30 - public Hid.Usage.ConsumerControl Usage { get; set; }
1.31 -
1.32 - /// <summary>
1.33 - /// Make sure we distinguish between various configuration of this event
1.34 - /// </summary>
1.35 - /// <returns></returns>
1.36 - public override string Brief()
1.37 - {
1.38 - return Name + ": " + Usage.ToString();
1.39 - }
1.40 -
1.41 - /// <summary>
1.42 - ///
1.43 - /// </summary>
1.44 - /// <param name="obj"></param>
1.45 - /// <returns></returns>
1.46 - public override bool Equals(object obj)
1.47 - {
1.48 - if (obj is EventHidConsumerControl)
1.49 - {
1.50 - EventHidConsumerControl e = (EventHidConsumerControl)obj;
1.51 - bool res = (e.Usage == Usage);
1.52 - return res;
1.53 - }
1.54 -
1.55 - return false;
1.56 - }
1.57 - }
1.58 -}
2.1 --- a/Server/Events/EventHidKeyboard.cs Sun Aug 21 16:30:58 2016 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,138 +0,0 @@
2.4 -using System;
2.5 -using System.Collections.Generic;
2.6 -using System.Linq;
2.7 -using System.Text;
2.8 -using System.Threading.Tasks;
2.9 -using System.Runtime.Serialization;
2.10 -using System.Windows.Forms;
2.11 -using Ear = SharpLib.Ear;
2.12 -using Hid = SharpLib.Hid;
2.13 -
2.14 -namespace SharpDisplayManager
2.15 -{
2.16 - [DataContract]
2.17 - [Ear.AttributeObject(Id = "Event.Hid.Keyboard", Name = "HID Keyboard", Description = "Corresponding HID message received.")]
2.18 - public class EventHidKeyboard : Ear.Event
2.19 - {
2.20 - public EventHidKeyboard()
2.21 - {
2.22 - }
2.23 -
2.24 - [DataMember]
2.25 - [Ear.AttributeObjectProperty
2.26 - (
2.27 - Id = "HID.Keyboard.Key",
2.28 - Name = "Key",
2.29 - Description = "The virtual key code."
2.30 - )]
2.31 - public Keys Key { get; set; }
2.32 -
2.33 - [DataMember]
2.34 - [Ear.AttributeObjectProperty
2.35 - (
2.36 - Id = "HID.Keyboard.IsKeyUp",
2.37 - Name = "Key Up",
2.38 - Description = "Key up if set, key down otherwise."
2.39 - )]
2.40 - public bool IsKeyUp { get; set; } = true;
2.41 -
2.42 - [DataMember]
2.43 - [Ear.AttributeObjectProperty
2.44 - (
2.45 - Id = "HID.Keyboard.HasModifierShift",
2.46 - Name = "Shift",
2.47 - Description = "Shift modifier applied."
2.48 - )]
2.49 - public bool HasModifierShift { get; set; } = false;
2.50 -
2.51 - [DataMember]
2.52 - [Ear.AttributeObjectProperty
2.53 - (
2.54 - Id = "HID.Keyboard.HasModifierControl",
2.55 - Name = "Control",
2.56 - Description = "Control modifier applied."
2.57 - )]
2.58 - public bool HasModifierControl { get; set; } = false;
2.59 -
2.60 - [DataMember]
2.61 - [Ear.AttributeObjectProperty
2.62 - (
2.63 - Id = "HID.Keyboard.HasModifierAlt",
2.64 - Name = "Alt",
2.65 - Description = "Alt modifier applied."
2.66 - )]
2.67 - public bool HasModifierAlt { get; set; } = false;
2.68 -
2.69 - [DataMember]
2.70 - [Ear.AttributeObjectProperty
2.71 - (
2.72 - Id = "HID.Keyboard.HasModifierWindows",
2.73 - Name = "Windows",
2.74 - Description = "Windows modifier applied."
2.75 - )]
2.76 - public bool HasModifierWindows { get; set; } = false;
2.77 -
2.78 -
2.79 -
2.80 - /// <summary>
2.81 - /// Make sure we distinguish between various configuration of this event
2.82 - /// </summary>
2.83 - /// <returns></returns>
2.84 - public override string Brief()
2.85 - {
2.86 - string brief = Name + ": " + Key.ToString();
2.87 -
2.88 - if (IsKeyUp)
2.89 - {
2.90 - brief += " (UP)";
2.91 - }
2.92 - else
2.93 - {
2.94 - brief += " (DOWN)";
2.95 - }
2.96 -
2.97 - if (HasModifierAlt)
2.98 - {
2.99 - brief += " + ALT";
2.100 - }
2.101 -
2.102 - if (HasModifierControl)
2.103 - {
2.104 - brief += " + CTRL";
2.105 - }
2.106 -
2.107 - if (HasModifierShift)
2.108 - {
2.109 - brief += " + SHIFT";
2.110 - }
2.111 -
2.112 - if (HasModifierWindows)
2.113 - {
2.114 - brief += " + WIN";
2.115 - }
2.116 -
2.117 - return brief;
2.118 - }
2.119 -
2.120 - /// <summary>
2.121 - ///
2.122 - /// </summary>
2.123 - /// <param name="obj"></param>
2.124 - /// <returns></returns>
2.125 - public override bool Equals(object obj)
2.126 - {
2.127 - if (obj is EventHidKeyboard)
2.128 - {
2.129 - EventHidKeyboard e = (EventHidKeyboard)obj;
2.130 - return e.Key == Key
2.131 - && e.IsKeyUp == IsKeyUp
2.132 - && e.HasModifierAlt == HasModifierAlt
2.133 - && e.HasModifierControl == HasModifierControl
2.134 - && e.HasModifierShift == HasModifierShift
2.135 - && e.HasModifierWindows == HasModifierWindows;
2.136 - }
2.137 -
2.138 - return false;
2.139 - }
2.140 - }
2.141 -}
3.1 --- a/Server/Events/EventHidWindowsMediaCenter.cs Sun Aug 21 16:30:58 2016 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,56 +0,0 @@
3.4 -using System;
3.5 -using System.Collections.Generic;
3.6 -using System.Linq;
3.7 -using System.Text;
3.8 -using System.Threading.Tasks;
3.9 -using System.Runtime.Serialization;
3.10 -using Ear = SharpLib.Ear;
3.11 -using Hid = SharpLib.Hid;
3.12 -
3.13 -namespace SharpDisplayManager
3.14 -{
3.15 - [DataContract]
3.16 - [Ear.AttributeObject(Id = "Event.Hid.WindowsMediaCenter", Name = "HID Windows Media Center", Description = "Corresponding HID message received.")]
3.17 - public class EventHidWindowsMediaCenter : Ear.Event
3.18 - {
3.19 - public EventHidWindowsMediaCenter()
3.20 - {
3.21 - }
3.22 -
3.23 - [DataMember]
3.24 - [Ear.AttributeObjectProperty
3.25 - (
3.26 - Id = "HID.WMC.Usage",
3.27 - Name = "Usage",
3.28 - Description = "The usage corresponding to your remote button."
3.29 - )]
3.30 - public Hid.Usage.WindowsMediaCenterRemoteControl Usage { get; set; }
3.31 -
3.32 - /// <summary>
3.33 - /// Make sure we distinguish between various configuration of this event
3.34 - /// </summary>
3.35 - /// <returns></returns>
3.36 - public override string Brief()
3.37 - {
3.38 - return Name + ": " + Usage.ToString();
3.39 - }
3.40 -
3.41 - /// <summary>
3.42 - ///
3.43 - /// </summary>
3.44 - /// <param name="obj"></param>
3.45 - /// <returns></returns>
3.46 - public override bool Equals(object obj)
3.47 - {
3.48 - if (obj is EventHidWindowsMediaCenter)
3.49 - {
3.50 - EventHidWindowsMediaCenter e = (EventHidWindowsMediaCenter)obj;
3.51 - bool res = (e.Usage == Usage);
3.52 - return res;
3.53 - }
3.54 -
3.55 - return false;
3.56 - }
3.57 -
3.58 - }
3.59 -}
4.1 --- a/Server/FormMain.Hid.cs Sun Aug 21 16:30:58 2016 +0200
4.2 +++ b/Server/FormMain.Hid.cs Sun Aug 21 16:35:20 2016 +0200
4.3 @@ -95,8 +95,6 @@
4.4 }
4.5
4.6
4.7 -
4.8 -
4.9 /// <summary>
4.10 /// Here we receive HID events from our HID library.
4.11 /// </summary>
4.12 @@ -119,63 +117,12 @@
4.13 else
4.14 {
4.15 //Trigger corresponding EAR event if any
4.16 - {
4.17 - EventHid e = new EventHid();
4.18 - e.Copy(aHidEvent);
4.19 - Properties.Settings.Default.EarManager.TriggerEvent(e);
4.20 - }
4.21 -
4.22 - if (aHidEvent.IsGeneric)
4.23 - {
4.24 - if (aHidEvent.Usages.Count == 0)
4.25 - {
4.26 - //No usage, nothing to do then
4.27 - return;
4.28 - }
4.29 -
4.30 - //We are in the proper thread
4.31 - if (aHidEvent.UsagePage == (ushort) Hid.UsagePage.WindowsMediaCenterRemoteControl)
4.32 - {
4.33 - //Trigger events as needed
4.34 - EventHidWindowsMediaCenter e = new EventHidWindowsMediaCenter
4.35 - {
4.36 - Usage = (Hid.Usage.WindowsMediaCenterRemoteControl) aHidEvent.Usages[0]
4.37 - };
4.38 - Properties.Settings.Default.EarManager.TriggerEvent(e);
4.39 - }
4.40 - else if (aHidEvent.UsagePage == (ushort) Hid.UsagePage.Consumer)
4.41 - {
4.42 - //Trigger matching events if any
4.43 - EventHidConsumerControl e = new EventHidConsumerControl
4.44 - {
4.45 - Usage = (Hid.Usage.ConsumerControl) aHidEvent.Usages[0]
4.46 - };
4.47 - Properties.Settings.Default.EarManager.TriggerEvent(e);
4.48 - }
4.49 - }
4.50 - else if (aHidEvent.IsKeyboard)
4.51 - {
4.52 - //Trigger matching events if any
4.53 - EventHidKeyboard e = new EventHidKeyboard
4.54 - {
4.55 - Key = aHidEvent.VirtualKey,
4.56 - IsKeyUp = aHidEvent.IsButtonUp,
4.57 - HasModifierAlt = aHidEvent.HasModifierAlt,
4.58 - HasModifierControl = aHidEvent.HasModifierControl,
4.59 - HasModifierShift = aHidEvent.HasModifierShift,
4.60 - HasModifierWindows = aHidEvent.HasModifierWindows,
4.61 - };
4.62 - Properties.Settings.Default.EarManager.TriggerEvent(e);
4.63 - }
4.64 -
4.65 + EventHid e = new EventHid();
4.66 + e.Copy(aHidEvent);
4.67 + Properties.Settings.Default.EarManager.TriggerEvent(e);
4.68 }
4.69 }
4.70
4.71 -
4.72 -
4.73 -
4.74 -
4.75 -
4.76 /// <summary>
4.77 /// We need to handle WM_INPUT.
4.78 /// </summary>
5.1 --- a/Server/SharpDisplayManager.csproj Sun Aug 21 16:30:58 2016 +0200
5.2 +++ b/Server/SharpDisplayManager.csproj Sun Aug 21 16:35:20 2016 +0200
5.3 @@ -180,9 +180,6 @@
5.4 <Compile Include="ClientData.cs" />
5.5 <Compile Include="EarManager.cs" />
5.6 <Compile Include="Events\EventHid.cs" />
5.7 - <Compile Include="Events\EventHidConsumerControl.cs" />
5.8 - <Compile Include="Events\EventHidKeyboard.cs" />
5.9 - <Compile Include="Events\EventHidWindowsMediaCenter.cs" />
5.10 <Compile Include="FormEditObject.cs">
5.11 <SubType>Form</SubType>
5.12 </Compile>