@@ -11,14 +11,16 @@ public class InputCoalescer : SimpleController
11
11
public InputCoalescer ( )
12
12
: base ( NullController . Instance . Definition ) { } // is Definition ever read on these subclasses? --yoshi
13
13
14
- protected virtual void ProcessSubsets ( string button , bool state ) { }
14
+ protected virtual void ProcessInput ( string button , bool state )
15
+ {
16
+ Buttons [ button ] = state ;
17
+ }
15
18
16
19
public void Receive ( InputEvent ie )
17
20
{
18
21
var state = ie . EventType is InputEventType . Press ;
19
22
var button = ie . LogicalButton . ToString ( ) ;
20
- Buttons [ button ] = state ;
21
- ProcessSubsets ( button , state ) ;
23
+ ProcessInput ( button , state ) ;
22
24
if ( state ) return ;
23
25
// when a button or modifier key is released, all modified key variants with it are released as well
24
26
foreach ( var k in Buttons . Keys . Where ( k =>
@@ -30,10 +32,21 @@ public void Receive(InputEvent ie)
30
32
31
33
public sealed class ControllerInputCoalescer : InputCoalescer
32
34
{
33
- protected override void ProcessSubsets ( string button , bool state )
35
+ protected override void ProcessInput ( string button , bool state )
34
36
{
35
37
// For controller input, we want Shift+X to register as both Shift and X (for Keyboard controllers)
36
38
foreach ( var s in button . Split ( '+' ) ) Buttons [ s ] = state ;
37
39
}
40
+
41
+ public override bool IsPressed ( string button )
42
+ {
43
+ // Since we split all inputs into their separate physical buttons, we need to check combinations here.
44
+ bool allPressed = true ;
45
+ foreach ( var individualButton in button . Split ( '+' ) )
46
+ {
47
+ allPressed &= Buttons . GetValueOrDefault ( individualButton ) ;
48
+ }
49
+ return allPressed ;
50
+ }
38
51
}
39
52
}
0 commit comments