public EmulatedController(int portIndex,
                           IInputDevice physicalDevice,
                           IInputDeviceInstance driverInstance,
                           IControllerLayout targetLayout,
                           IControllerElementMappingProfile layoutMapping)
 {
     this.PortIndex              = portIndex;
     this.PhysicalDevice         = physicalDevice;
     this.PhysicalDeviceInstance = driverInstance;
     this.TargetLayout           = targetLayout;
     this.LayoutMapping          = layoutMapping;
 }
        protected override void Configure(IObjectTypeDescriptor <IEmulatedPortDeviceEntry> descriptor)
        {
            descriptor.Name("ConnectedEmulatorController")
            .Description("Describe the connection state of the physical device plugged into an emulated port.");
            descriptor.Field("isConnected")
            .Description("Whether or not the physical device of the emulated controller is connected.")
            .Resolver(ctx =>
            {
                var devices = ctx.SnowflakeService <IDeviceEnumerator>();
                var entry   = ctx.Parent <IEmulatedPortDeviceEntry>();
                return(devices.IsPortDeviceConnected(entry));
            })
            .Type <NonNullType <BooleanType> >();
            descriptor.Field("controller")
            .Description("The emulated controller plugged into the port.")
            .Resolver(async ctx =>
            {
                var deviceEntry = ctx.Parent <IEmulatedPortDeviceEntry>();
                var inputConfig = ctx.SnowflakeService <IControllerElementMappingProfileStore>();
                var devices     = ctx.SnowflakeService <IDeviceEnumerator>();
                var stone       = ctx.SnowflakeService <IStoneProvider>();
                stone.Controllers.TryGetValue(deviceEntry.ControllerID, out var controllerLayout);
                IInputDevice physicalDevice                     = devices.GetPortDevice(deviceEntry);
                IInputDeviceInstance deviceInstance             = devices.GetPortDeviceInstance(deviceEntry);
                IControllerElementMappingProfile mappingProfile = await inputConfig.GetMappingsAsync(deviceEntry.ProfileGuid);

                return(new EmulatedController(deviceEntry.PortIndex, physicalDevice, deviceInstance, controllerLayout, mappingProfile));
            })
            .Type <NonNullType <EmulatedControllerType> >();
            descriptor.Field(c => c.PortIndex)
            .Description("The port index.")
            .Type <NonNullType <IntType> >();
            descriptor.Field("portDeviceEntry")
            .Description("The emulated port device entry.")
            .Resolver(ctx => ctx.Parent <IEmulatedPortDeviceEntry>())
            .Type <NonNullType <EmulatedPortDeviceEntryType> >();
        }