forked from TASEmulators/BizHawk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultitrackAdapter.cs
More file actions
58 lines (50 loc) · 1.73 KB
/
MultitrackAdapter.cs
File metadata and controls
58 lines (50 loc) · 1.73 KB
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
#nullable enable
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
{
/// <summary>
/// Used to enable recording a subset of a controller's buttons, while keeping the existing inputs for the other buttons.
/// Also used to allow TAStudio to clear (or otherwise edit) a subset of input columns.
/// </summary>
internal class MultitrackAdapter : IController
{
/// <summary>
/// Input states in this definition will come from <see cref="ActiveSource"/>. All others will come from <see cref="BackingSource"/>.
/// </summary>
public ControllerDefinition ActiveDefinition { get; set; }
public IController ActiveSource { get; set; }
public IController BackingSource { get; set; }
public ControllerDefinition Definition => BackingSource.Definition;
public MultitrackAdapter(IController active, IController backing, ControllerDefinition activeDefinition)
{
ActiveSource = active;
BackingSource = backing;
ActiveDefinition = activeDefinition;
}
public bool IsPressed(string button)
{
if (ActiveDefinition.BoolButtons.Contains(button))
{
return ActiveSource.IsPressed(button);
}
else
{
return BackingSource.IsPressed(button);
}
}
public int AxisValue(string name)
{
if (ActiveDefinition.Axes.ContainsKey(name))
{
return ActiveSource.AxisValue(name);
}
else
{
return BackingSource.AxisValue(name);
}
}
public IReadOnlyCollection<(string Name, int Strength)> GetHapticsSnapshot() => throw new NotImplementedException(); // don't use this
public void SetHapticChannelStrength(string name, int strength) => throw new NotImplementedException(); // don't use this
}
}