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

luttje / Key2Joy / 6598306412

21 Oct 2023 03:54PM UTC coverage: 45.09% (-7.4%) from 52.519%
6598306412

Pull #50

github

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

751 of 2289 branches covered (0.0%)

Branch coverage included in aggregate %.

2384 of 2384 new or added lines in 80 files covered. (100.0%)

3845 of 7904 relevant lines covered (48.65%)

15964.61 hits per line

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

19.35
/Core/Key2Joy.Core/LowLevelInput/SimulatedGamePad/SimulatedGamePad.cs
1
using System.Reflection;
2
using SimWinInput;
3

4
namespace Key2Joy.LowLevelInput.SimulatedGamePad;
5

6
/// <summary>
7
/// Implementation based on https://github.com/DavidRieman/SimWinInput
8
/// </summary>
9
public class SimulatedGamePad : ISimulatedGamePad
10
{
11
    private const string GAMEPAD_NAME = "Simulated";
12

13
    /// <inheritdoc />
14
    public int Index { get; private set; }
36✔
15

16
    private bool isPluggedIn = false;
17
    private readonly IGamePadInfo gamePadInfo;
18

19
    public SimulatedGamePad(int index)
36✔
20
    {
21
        this.Index = index;
36✔
22
        this.gamePadInfo = new GamePadInfo(index, GAMEPAD_NAME);
36✔
23
    }
36✔
24

25
    public IGamePadInfo GetInfo()
26
        => this.gamePadInfo;
×
27

28
    /// <inheritdoc />
29
    public void PlugIn()
30
    {
31
        SimGamePad.Instance.PlugIn(this.Index);
×
32
        this.isPluggedIn = true;
×
33

34
        // Ensure the state starts reset fixes problem where other (real) gamepad may get button stuck
35
        this.ResetState();
×
36
        this.Update();
×
37
    }
×
38

39
    /// <inheritdoc />
40
    public bool GetIsPluggedIn()
41
        => this.isPluggedIn;
8✔
42

43
    /// <inheritdoc />
44
    public void Unplug()
45
    {
46
        SimGamePad.Instance.Unplug(this.Index);
×
47
        this.isPluggedIn = false;
×
48
    }
×
49

50
    /// <inheritdoc />
51
    public void Use(GamePadControl control, int holdTimeMS = 50)
52
    {
53
        SimGamePad.Instance.Use(control, this.Index, holdTimeMS);
×
54
        this.gamePadInfo.OnActivityOccurred();
×
55
    }
×
56

57
    /// <inheritdoc />
58
    public void SetControl(GamePadControl control)
59
    {
60
        SimGamePad.Instance.SetControl(control, this.Index);
×
61
        this.gamePadInfo.OnActivityOccurred();
×
62
    }
×
63

64
    /// <inheritdoc />
65
    public void ReleaseControl(GamePadControl control)
66
    {
67
        SimGamePad.Instance.ReleaseControl(control, this.Index);
×
68
        this.gamePadInfo.OnActivityOccurred();
×
69
    }
×
70

71
    /// <inheritdoc />
72
    public SimulatedGamePadState GetState()
73
        => SimGamePad.Instance.State[this.Index];
×
74

75
    /// <inheritdoc />
76
    public void ResetState()
77
    {
78
        SimGamePad.Instance.State[this.Index].Reset();
×
79
        this.gamePadInfo.OnActivityOccurred();
×
80
    }
×
81

82
    /// <inheritdoc />
83
    public void Update()
84
    {
85
        SimGamePad.Instance.Update(this.Index);
×
86
        this.gamePadInfo.OnActivityOccurred();
×
87
    }
×
88
}
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