Example #1
0
        public List <IMessageHandler> CreateHandlers(HttpListenerContext context, Func <MessageBase, Task> sendFunction)
        {
            string emulatorName = context.Request.Url.LocalPath.Replace("/MicrosoftXbox360/", "");
            var    emulator     = emulatorService.FindEmulator <IXboxEmulator>(DeviceTypes.MicrosoftXbox360, emulatorName);
            var    device       = emulator.CreateDevice();

            return(new List <IMessageHandler>
            {
                new DebugMessageHandler(),
                new XboxInputMessageHandler(device),
            });
        }
Example #2
0
        public List <IMessageHandler> CreateHandlers(HttpListenerContext context, SenderFunction sendFunction)
        {
            string emulatorName = context.Request.Url.LocalPath.Replace($"/{DeviceType}/", "");
            var    emulator     = emulatorService.FindEmulator <IXboxEmulator>(DeviceTypes.MicrosoftXbox360, emulatorName);
            var    device       = emulator.CreateDevice();

            return(new List <IMessageHandler>
            {
                new DebugMessageHandler(),
                new XboxFeedbackMessageHandler(device, sendFunction.GetTyped <XboxFeedbackMessage>()),
                new XboxInputMessageHandler(device),
            });
        }
Example #3
0
        public IMessageHandler CreateHandler(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction)
        {
            string    emulatorName = PathRegex.Match(context.Request.Path.Value).Groups[1].Value;
            Emulators emulatorType = Enum.Parse <Emulators>(emulatorName);
            var       emulator     = emulatorService.FindEmulator <IDs4Emulator>(DeviceTypes.SonyDualShock4, emulatorType);
            var       device       = emulator.CreateDs4Device();
            DeviceDisconnectedEventHandler disconnectedEvent = (sender, args) => closeFunction();

            device.Closed += disconnectedEvent;
            var ip = context.Request.HttpContext.Connection.RemoteIpAddress?.ToString();

            emulatedControllersService.Add(new NetworkDeviceInfo
            {
                Device     = device,
                IPAddress  = ip,
                DeviceType = DeviceTypes.SonyDualShock4,
                Emulator   = emulator.Emulator,
            });
            return(new Ds4InputRequestHandler(closeFunction, sendFunction, device, emulatedControllersService, disconnectedEvent));
        }
Example #4
0
        public List <IMessageHandler> CreateHandlers(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction)
        {
            string emulatorName = context.Request.Path.Value.Replace($"/ws/{DeviceType}/", "");
            var    emulator     = emulatorService.FindEmulator <IDs4Emulator>(XOutput.Emulation.DeviceTypes.SonyDualShock4, emulatorName);
            var    device       = emulator.CreateDs4Device();
            DeviceDisconnectedEvent disconnectedEvent = (sender, args) => closeFunction();

            device.Closed += disconnectedEvent;
            var ip = context.Request.HttpContext.Connection.RemoteIpAddress?.ToString();

            deviceInfoService.Add(new NetworkDeviceInfo
            {
                Device     = device,
                IPAddress  = ip,
                DeviceType = XOutput.Emulation.DeviceTypes.SonyDualShock4,
                Emulator   = emulator.Name,
            });
            return(new List <IMessageHandler>
            {
                new DebugMessageHandler(),
                new Ds4FeedbackMessageHandler(device, sendFunction.GetTyped <Ds4FeedbackMessage>()),
                new Ds4InputMessageHandler(device, disconnectedEvent),
            });
        }