File tree Expand file tree Collapse file tree
Packages/com.unity.inputsystem/InputSystem/Devices Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -499,6 +499,40 @@ public void Layouts_CanFindLayoutFromDeviceDescription()
499499 Assert . That ( layout , Is . EqualTo ( "MyDevice" ) ) ;
500500 }
501501
502+ [ Test ]
503+ [ Category ( "Layouts" ) ]
504+ public void Layouts_CanMatchLayoutBasedOnCapabilitiesFromJson ( )
505+ {
506+ const string json = @"
507+ {
508+ ""name"" : ""CapabilityTestLayout"",
509+ ""extend"" : ""Gamepad"",
510+ ""device"" : {
511+ ""capabilities"" : [
512+ { ""path"" : ""vendorId"", ""value"" : ""9999"" }
513+ ]
514+ }
515+ }" ;
516+
517+ InputSystem . RegisterLayout ( json ) ;
518+
519+ try
520+ {
521+ var matchedLayout = InputSystem . TryFindMatchingLayout (
522+ new InputDeviceDescription
523+ {
524+ deviceClass = "Gamepad" ,
525+ capabilities = @"{""vendorId"":""9999""}"
526+ } ) ;
527+
528+ Assert . That ( matchedLayout , Is . EqualTo ( "CapabilityTestLayout" ) ) ;
529+ }
530+ finally
531+ {
532+ InputSystem . RemoveLayout ( "CapabilityTestLayout" ) ;
533+ }
534+ }
535+
502536 [ Test ]
503537 [ Category ( "Layouts" ) ]
504538 public void Layouts_CanFindAllLayoutsBasedOnGivenLayout ( )
Original file line number Diff line number Diff line change @@ -564,6 +564,7 @@ internal struct MatcherJson
564564 public string [ ] versions ;
565565 public Capability [ ] capabilities ;
566566
567+ [ Serializable ]
567568 public struct Capability
568569 {
569570 public string path ;
You can’t perform that action at this time.
0 commit comments