• 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

16.67
/Core/Key2Joy.Core/LowLevelInput/XInput/NativeXInput.cs
1
using System.Runtime.InteropServices;
2

3
namespace Key2Joy.LowLevelInput.XInput;
4

5
/// <summary>
6
/// Handles XInput functionality by calling native functions.
7
/// </summary>
8
/// <seealso href="https://www.codeproject.com/Articles/492473/Using-XInput-to-access-an-Xbox-360-Controller-in-M"/>
9
public class NativeXInput : IXInput
10
{
11
    [DllImport("xinput1_4.dll", EntryPoint = "XInputGetState")]
12
    private static extern int InternalXInputGetState(int dwUserIndex, ref XInputState pState);
13

14
    [DllImport("xinput1_4.dll", EntryPoint = "XInputSetState")]
15
    private static extern int InternalXInputSetState(int dwUserIndex, ref XInputVibration pVibration);
16

17
    [DllImport("xinput1_4.dll", EntryPoint = "XInputGetCapabilities")]
18
    private static extern int InternalXInputGetCapabilities(int dwUserIndex, int dwFlags, ref XInputCapabilities pCapabilities);
19

20
    [DllImport("xinput1_4.dll", EntryPoint = "XInputGetBatteryInformation")]
21
    private static extern int InternalXInputGetBatteryInformation(int dwUserIndex, byte devType, ref XInputBatteryInformation pBatteryInformation);
22

23
    [DllImport("xinput1_4.dll", EntryPoint = "XInputGetKeystroke")]
24
    private static extern int InternalXInputGetKeystroke(int dwUserIndex, int dwReserved, ref XInputKeystroke pKeystroke);
25

26
    /// <inheritdoc />
27
    public XInputResultCode XInputGetState(int userIndex, ref XInputState inputState)
28
        => XInputResult.FromResult(InternalXInputGetState(userIndex, ref inputState));
8✔
29

30
    /// <inheritdoc />
31
    public XInputResultCode XInputSetState(int userIndex, ref XInputVibration vibrationInfo)
32
        => XInputResult.FromResult(InternalXInputSetState(userIndex, ref vibrationInfo));
×
33

34
    /// <inheritdoc />
35
    public XInputResultCode XInputGetCapabilities(int userIndex, CapabilityRequestFlag flags, ref XInputCapabilities capabilities)
36
        => XInputResult.FromResult(InternalXInputGetCapabilities(userIndex, (int)flags, ref capabilities));
×
37

38
    /// <inheritdoc />
39
    public XInputResultCode XInputGetBatteryInformation(int userIndex, BatteryDeviceType deviceType, ref XInputBatteryInformation batteryInformation)
40
        => XInputResult.FromResult(InternalXInputGetBatteryInformation(userIndex, (byte)deviceType, ref batteryInformation));
×
41

42
    /// <inheritdoc />
43
    public XInputResultCode XInputGetKeystroke(int userIndex, int reserved, ref XInputKeystroke keystrokeData)
44
        => XInputResult.FromResult(InternalXInputGetKeystroke(userIndex, reserved, ref keystrokeData));
×
45

46
    /// <summary>
47
    /// Get capabilities for the specified controller.
48
    /// </summary>
49
    /// <param name="userIndex"></param>
50
    /// <param name="capabilities"></param>
51
    /// <returns></returns>
52
    public XInputResultCode XInputGetCapabilities(int userIndex, ref XInputCapabilities capabilities)
53
        => XInputResult.FromResult(InternalXInputGetCapabilities(userIndex, (int)CapabilityRequestFlag.XINPUT_FLAG_GAMEPAD, ref capabilities));
×
54
}
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

© 2025 Coveralls, Inc