-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
XInputGamepadManager.cs
50 lines (45 loc) · 1.47 KB
/
XInputGamepadManager.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
using Buttplug.Core;
using SharpDX.XInput;
namespace Buttplug.Server.Managers.XInputGamepadManager
{
public class XInputGamepadManager : DeviceSubtypeManager
{
public XInputGamepadManager(IButtplugLogManager aLogManager)
: base(aLogManager)
{
BpLogger.Info("Loading XInput Gamepad Manager");
}
public override void StartScanning()
{
BpLogger.Info("XInputGamepadManager start scanning");
var controllers = new[]
{
new Controller(UserIndex.One),
new Controller(UserIndex.Two),
new Controller(UserIndex.Three),
new Controller(UserIndex.Four),
};
foreach (var c in controllers)
{
if (!c.IsConnected)
{
continue;
}
BpLogger.Debug($"Found connected XInput Gamepad for Index {c.UserIndex}");
var device = new XInputGamepadDevice(LogManager, c);
InvokeDeviceAdded(new DeviceAddedEventArgs(device));
InvokeScanningFinished();
}
}
public override void StopScanning()
{
// noop
BpLogger.Info("XInputGamepadManager stop scanning");
}
public override bool IsScanning()
{
// noop
return false;
}
}
}