-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputEvent.cs
63 lines (59 loc) · 1.63 KB
/
InputEvent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KeyReplace
{
[Serializable]
public class InputEvent
{
public InputEventType type;
/// <summary>
/// If this is a mouse input, then vk is the MouseButton code
/// If this is a keyboard input, then vk is the Vk.
/// </summary>
public int vk;
public ModifierKey modifiers;
public InputEvent(InputEventType type, int vk, ModifierKey modifiers)
{
this.type = type;
this.vk = vk;
this.modifiers = modifiers;
}
public override bool Equals(object obj)
{
if (!(obj is InputEvent))
return false;
InputEvent a = (InputEvent)obj;
return this.type == a.type && this.vk == a.vk && this.modifiers == a.modifiers;
}
public override int GetHashCode()
{
return vk + ((int)modifiers << 8) + ((int)type << 11);
}
public override string ToString()
{
return Macro.GetKeyString(vk, modifiers) + (type == InputEventType.KeyPress ? "" : " " + type.ToString().Replace("Key", "").ToLower());
//just display 'B press' as 'B', for example.
}
}
public enum SpecialKey
{
OriginalKey = -2,
MouseLeft = -3,
MouseMid = -4,
MouseRight = -5,
MouseX1 = -6,
MouseX2 = -7
}
public enum InputEventType
{
None,
KeyDown,
KeyUp,
KeyPress,
MouseDown,
MouseUp
}
}