@@ -5075,6 +5075,69 @@ public void Actions_CompositesReportControlThatTriggeredTheCompositeInCallback()
50755075 LogAssert . NoUnexpectedReceived ( ) ;
50765076 }
50775077
5078+ [ Test ]
5079+ [ Category ( "Actions" ) ]
5080+ // Test for case 1183314
5081+ public void Actions_CompositesInDifferentMapsTiedToSameControlsWork ( )
5082+ {
5083+ var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
5084+ var gamepad = InputSystem . AddDevice < Gamepad > ( ) ;
5085+
5086+ InputSystem . RegisterInteraction < LogInteraction > ( ) ;
5087+
5088+ var map1 = new InputActionMap ( "map1" ) ;
5089+ var action1 = map1 . AddAction ( "action" ) ;
5090+ action1 . AddBinding ( "<Gamepad>/leftStick" ) ;
5091+ action1 . AddCompositeBinding ( "Dpad" )
5092+ . With ( "Up" , "<Keyboard>/w" )
5093+ . With ( "Down" , "<Keyboard>/s" )
5094+ . With ( "Left" , "<Keyboard>/a" )
5095+ . With ( "Right" , "<Keyboard>/d" ) ;
5096+ var map2 = new InputActionMap ( "map2" ) ;
5097+ var action2 = map2 . AddAction ( "action" ) ;
5098+ action2 . AddBinding ( "<Gamepad>/leftStick" ) ;
5099+ action2 . AddCompositeBinding ( "Dpad" )
5100+ . With ( "Up" , "<Keyboard>/w" )
5101+ . With ( "Down" , "<Keyboard>/s" )
5102+ . With ( "Left" , "<Keyboard>/a" )
5103+ . With ( "Right" , "<Keyboard>/d" ) ;
5104+
5105+ var asset = ScriptableObject . CreateInstance < InputActionAsset > ( ) ;
5106+ asset . AddActionMap ( map1 ) ;
5107+ asset . AddActionMap ( map2 ) ;
5108+ asset . Enable ( ) ;
5109+
5110+
5111+ InputControl performedControl1 = null ;
5112+ InputControl performedControl2 = null ;
5113+ action1 . performed += ctx => performedControl1 = ctx . control ;
5114+ action2 . performed += ctx => performedControl2 = ctx . control ;
5115+
5116+ InputSystem . QueueStateEvent ( keyboard , new KeyboardState ( Key . A ) ) ;
5117+ InputSystem . Update ( ) ;
5118+
5119+ Assert . That ( performedControl1 , Is . EqualTo ( keyboard . aKey ) ) ;
5120+ performedControl1 = null ;
5121+ Assert . That ( performedControl2 , Is . EqualTo ( keyboard . aKey ) ) ;
5122+ performedControl2 = null ;
5123+
5124+ InputSystem . QueueStateEvent ( keyboard , new KeyboardState ( Key . A , Key . W ) ) ;
5125+ InputSystem . Update ( ) ;
5126+
5127+ Assert . That ( performedControl1 , Is . EqualTo ( keyboard . wKey ) ) ;
5128+ performedControl1 = null ;
5129+ Assert . That ( performedControl2 , Is . EqualTo ( keyboard . wKey ) ) ;
5130+ performedControl2 = null ;
5131+
5132+ InputSystem . QueueStateEvent ( keyboard , new KeyboardState ( Key . A ) ) ;
5133+ InputSystem . Update ( ) ;
5134+
5135+ InputSystem . QueueStateEvent ( keyboard , new KeyboardState ( ) ) ;
5136+ InputSystem . Update ( ) ;
5137+
5138+ LogAssert . NoUnexpectedReceived ( ) ;
5139+ }
5140+
50785141 [ Preserve ]
50795142 private class CompositeWithVector2Part : InputBindingComposite < Vector2 >
50805143 {
0 commit comments