• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / Key2Joy / 6599225437

21 Oct 2023 07:19PM UTC coverage: 44.768% (-7.8%) from 52.519%
6599225437

Pull #50

github

web-flow
Merge 2fe0423ed into 14b7ce9a7
Pull Request #50: Add XInput in preparation for gamepad triggers + add xmldoc

758 of 2325 branches covered (0.0%)

Branch coverage included in aggregate %.

2834 of 2834 new or added lines in 98 files covered. (100.0%)

3875 of 8024 relevant lines covered (48.29%)

13037.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.12
/Core/Key2Joy.Core/Mapping/Triggers/Keyboard/KeyboardTrigger.cs
1
using System;
2
using System.Text.Json.Serialization;
3
using System.Windows.Forms;
4
using Key2Joy.Contracts.Mapping;
5
using Key2Joy.Contracts.Mapping.Triggers;
6
using Key2Joy.LowLevelInput;
7

8
namespace Key2Joy.Mapping.Triggers.Keyboard;
9

10
[Trigger(
11
    Description = "Keyboard Event"
12
)]
13
public class KeyboardTrigger : CoreTrigger, IPressState, IProvideReverseAspect, IReturnInputHash, IEquatable<KeyboardTrigger>
14
{
15
    public const string PREFIX_UNIQUE = nameof(KeyboardTrigger);
16

17
    public Keys Keys { get; set; }
82✔
18

19
    public PressState PressState { get; set; }
82✔
20

21
    [JsonConstructor]
22
    public KeyboardTrigger(string name)
23
        : base(name)
82✔
24
    { }
82✔
25

26
    public override AbstractTriggerListener GetTriggerListener() => KeyboardTriggerListener.Instance;
×
27

28
    /// <inheritdoc/>
29
    public void MakeReverse(AbstractMappingAspect aspect)
30
        => CommonReverseAspect.MakeReversePressState(this, aspect);
×
31

32
    public static int GetInputHashFor(Keys keys) => (int)keys;
×
33

34
    public int GetInputHash() => GetInputHashFor(this.Keys);
×
35

36
    // Keep Press and Release together while sorting
37
    public override int CompareTo(AbstractMappingAspect other)
38
    {
39
        if (other == null || other is not KeyboardTrigger otherKeyboardTrigger)
×
40
        {
41
            return base.CompareTo(other);
×
42
        }
43

44
        return $"{this.Keys}#{(int)this.PressState}"
×
45
            .CompareTo($"{otherKeyboardTrigger.Keys}#{(int)otherKeyboardTrigger.PressState}");
×
46
    }
47

48
    public override bool Equals(object obj)
49
    {
50
        if (obj is not KeyboardTrigger other)
×
51
        {
52
            return false;
×
53
        }
54

55
        return this.Equals(other);
×
56
    }
57

58
    public bool Equals(KeyboardTrigger other) => this.Keys == other.Keys
×
59
            && this.PressState == other.PressState;
×
60

61
    public override string ToString()
62
    {
63
        var format = "(keyboard) {1} {0}";
×
64
        return format.Replace("{0}", this.Keys.ToString())
×
65
            .Replace("{1}", Enum.GetName(typeof(PressState), this.PressState));
×
66
    }
67

68
    public KeyboardState GetKeyboardState()
69
    {
70
        if (this.PressState == PressState.Press)
×
71
        {
72
            return KeyboardState.KeyDown;
×
73
        }
74

75
        return KeyboardState.KeyUp;
×
76
    }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc