示例#1
0
        public IList <EmuControllerInfo> GetEmuControllers()
        {
            List <EmuControllerInfo> devices = new List <EmuControllerInfo>();

            // All active EmuController devices will be returned when quering PnPEntities
            // matching EmuController classGuid.
            foreach (ManagementObject queryObj in Mos.Get())
            {
                EmuControllerInfo info = new EmuControllerInfo(queryObj);
                devices.Add(info);
            }

            return(devices);
        }
示例#2
0
        /// <summary>
        /// Establishes a connection with EmuController device
        /// to send input state reports.
        ///
        /// </summary>
        /// <param name="instanceInfo">Parameter containg the data required to connect to the Emucontroller device.
        /// The available EmuControllerInfo objects are contained in the 'ConnectedEmuControllerDevices' which is populated
        /// automatically when initializing EmuControllerClient.</param>
        public bool ConnectInputClient(EmuControllerInfo instanceInfo)
        {
            if (InputPipeClient != null && InputPipeClient.IsConnected)
            {
                return(false);
            }

            InstanceInfo = instanceInfo;

            InputPipeClient = new NamedPipeClientStream(".", instanceInfo.HardwareId + InputPipeSuffix, PipeDirection.Out);
            InputPipeClient.Connect(PipeTimeOut);

            InputPipeClient.ReadMode = PipeTransmissionMode.Message;

            return(true);
        }
示例#3
0
        /// <summary>
        /// Establishes a connection with EmuController device
        /// to receive FFB data from applications.
        ///
        /// </summary>
        /// <param name="instanceInfo">Parameter containg the data required to connect to the Emucontroller device.
        /// The available EmuControllerInfo objects are contained in the 'ConnectedEmuControllerDevices' which is populated
        /// automatically when initializing EmuControllerClient.</param>
        public bool ConnectFFBClient(EmuControllerInfo instanceInfo)
        {
            if (FFBPipeClient != null && FFBPipeClient.IsConnected)
            {
                return(false);
            }

            InstanceInfo = instanceInfo;

            FFBPipeClient = new NamedPipeClientStream(".", InstanceInfo.HardwareId + FFBPipeSuffix, PipeDirection.InOut);
            FFBPipeClient.Connect(PipeTimeOut);

            FFBPipeClient.ReadMode = PipeTransmissionMode.Message;

            TaskCancelToken = new CancellationTokenSource();

            _ = Task.Run(() => GetFFBMessages(), TaskCancelToken.Token).ConfigureAwait(false);

            return(true);
        }