Exemple #1
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Scarlet.Crush Productions DSx Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                            Assembly.GetExecutingAssembly().GetName().Version);

            Log.InfoFormat("Setting working directory to {0}", GlobalConfiguration.AppDirectory);
            Directory.SetCurrentDirectory(GlobalConfiguration.AppDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle  = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            var installTask = Task.Factory.StartNew(() =>
            {
                if (GlobalConfiguration.Instance.ForceBluetoothDriverReinstallation)
                {
                    DriverInstaller.InstallBluetoothDongles(
                        ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.BluetoothHost));
                }

                if (GlobalConfiguration.Instance.ForceDs3DriverReinstallation)
                {
                    DriverInstaller.InstallDualShock3Controllers(
                        ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.DualShock3));
                }

                if (GlobalConfiguration.Instance.ForceDs4DriverReinstallation)
                {
                    DriverInstaller.InstallDualShock4Controllers(
                        ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.DualSHock4));
                }
            });

            installTask.ContinueWith(task =>
            {
                Log.FatalFormat("Error during driver installation: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            try
            {
                rootHub.Open();
                rootHub.Start();
            }
            catch (RootHubAlreadyStartedException rhex)
            {
                Log.FatalFormat("Couldn't start the root hub: {0}", rhex.Message);
                Stop();
                return;
            }

            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs3.DeviceClassGuid, ref _ds3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs4.DeviceClassGuid, ref _ds4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, BthDongle.DeviceClassGuid, ref _bthNotify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify, false);
        }
Exemple #2
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Scarlet.Crush Productions DS3 Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                            Assembly.GetExecutingAssembly().GetName().Version);

            Log.InfoFormat("Setting working directory to {0}", WorkingDirectory);
            Directory.SetCurrentDirectory(WorkingDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle  = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            var installTask = Task.Factory.StartNew(() =>
            {
                if (Settings.Default.InstallBluetoothDongles)
                {
                    DriverInstaller.InstallBluetoothDongles();
                }

                if (Settings.Default.InstallDualShock3Controllers)
                {
                    DriverInstaller.InstallDualShock3Controllers();
                }

                if (Settings.Default.InstallDualShock4Controllers)
                {
                    DriverInstaller.InstallDualShock4Controllers();
                }
            });

            installTask.ContinueWith(task =>
            {
                Log.FatalFormat("Error during driver installation: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            try
            {
                rootHub.Open();
                rootHub.Start();
            }
            catch (RootHubAlreadyStartedException rhex)
            {
                Log.FatalFormat("Couldn't start the root hub: {0}", rhex.Message);
                Stop();
                return;
            }

            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs3.USB_CLASS_GUID), ref _mDs3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs4.USB_CLASS_GUID), ref _mDs4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(BthDongle.BTH_CLASS_GUID), ref _mBthNotify, false);
        }
Exemple #3
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Scarlet.Crush Productions DSx Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                    Assembly.GetExecutingAssembly().GetName().Version);

            Log.InfoFormat("Setting working directory to {0}", GlobalConfiguration.AppDirectory);
            Directory.SetCurrentDirectory(GlobalConfiguration.AppDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            var installTask = Task.Factory.StartNew(() =>
            {
                if (GlobalConfiguration.Instance.ForceBluetoothDriverReinstallation)
                    DriverInstaller.InstallBluetoothDongles(
                        ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.BluetoothHost));

                if (GlobalConfiguration.Instance.ForceDs3DriverReinstallation)
                    DriverInstaller.InstallDualShock3Controllers(
                        ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.DualShock3));

                if (GlobalConfiguration.Instance.ForceDs4DriverReinstallation)
                    DriverInstaller.InstallDualShock4Controllers(
                        ScpDeviceCollection.Instance.Devices.Where(d => d.DeviceType == WdiUsbDeviceType.DualSHock4));
            });

            installTask.ContinueWith(task =>
            {
                Log.FatalFormat("Error during driver installation: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            try
            {
                rootHub.Open();
                rootHub.Start();
            }
            catch (RootHubAlreadyStartedException rhex)
            {
                Log.FatalFormat("Couldn't start the root hub: {0}", rhex.Message);
                Stop();
                return;
            }

            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs3.DeviceClassGuid, ref _ds3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs4.DeviceClassGuid, ref _ds4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, BthDongle.DeviceClassGuid, ref _bthNotify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify, false);
        }
Exemple #4
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Scarlet.Crush Productions DS3 Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                    Assembly.GetExecutingAssembly().GetName().Version);

            Log.InfoFormat("Setting working directory to {0}", WorkingDirectory);
            Directory.SetCurrentDirectory(WorkingDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            var installTask = Task.Factory.StartNew(() =>
            {
                if (Settings.Default.InstallBluetoothDongles)
                    DriverInstaller.InstallBluetoothDongles();

                if (Settings.Default.InstallDualShock3Controllers)
                    DriverInstaller.InstallDualShock3Controllers();

                if (Settings.Default.InstallDualShock4Controllers)
                    DriverInstaller.InstallDualShock4Controllers();
            });

            installTask.ContinueWith(task =>
            {
                Log.FatalFormat("Error during driver installation: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            try
            {
                rootHub.Open();
                rootHub.Start();
            }
            catch (RootHubAlreadyStartedException rhex)
            {
                Log.FatalFormat("Couldn't start the root hub: {0}", rhex.Message);
                Stop();
                return;
            }

            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs3.USB_CLASS_GUID), ref _mDs3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs4.USB_CLASS_GUID), ref _mDs4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(BthDongle.BTH_CLASS_GUID), ref _mBthNotify, false);
        }
Exemple #5
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Scarlet.Crush Productions DS3 Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                    Assembly.GetExecutingAssembly().GetName().Version);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            rootHub.Open();
            rootHub.Start();

            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs3.USB_CLASS_GUID), ref _mDs3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs4.USB_CLASS_GUID), ref _mDs4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(BthDongle.BTH_CLASS_GUID), ref _mBthNotify, false);
        }
        protected override void OnStart(String[] args)
        {
            EventLog.WriteEntry("Scarlet.Crush Productions DS3 Service Started", System.Diagnostics.EventLogEntryType.Information, 1);

            try { if (File.Exists(m_Log))
                  {
                      File.Delete(m_Log);
                  }
            }
            catch { }

            OnDebug(this, new DebugEventArgs(String.Format("++ {0} {1}", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version.ToString())));

            m_ControlHandler = new ScpDevice.ServiceControlHandlerEx(ServiceControlHandler);
            m_ServiceHandle  = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, m_ControlHandler, IntPtr.Zero);

            rootHub.Open();
            rootHub.Start();

            ScpDevice.RegisterNotify(m_ServiceHandle, new Guid(UsbDevice.DS3_USB_CLASS_GUID), ref m_UsbNotify, false);
            ScpDevice.RegisterNotify(m_ServiceHandle, new Guid(BthDevice.DS3_BTH_CLASS_GUID), ref m_BthNotify, false);
        }
Exemple #7
0
        protected override void OnStart(string[] args)
        {
            var sw = Stopwatch.StartNew();

            Log.Info("Scarlet.Crush Productions DSx Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                    Assembly.GetExecutingAssembly().GetName().Version);

            Log.DebugFormat("Setting working directory to {0}", GlobalConfiguration.AppDirectory);
            Directory.SetCurrentDirectory(GlobalConfiguration.AppDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            var installTask = Task.Factory.StartNew(() =>
            {
                using (var db = new ScpDb())
                {
                    var bthDevices = db.Engine.GetAllDbEntities<WdiDeviceInfo>(ScpDb.TableDevices)
                        .Where(d => d.Value.DeviceType == WdiUsbDeviceType.BluetoothHost)
                        .Select(d => d.Value);

                    if (GlobalConfiguration.Instance.ForceBluetoothDriverReinstallation)
                        DriverInstaller.InstallBluetoothDongles(bthDevices);

                    var ds3Devices = db.Engine.GetAllDbEntities<WdiDeviceInfo>(ScpDb.TableDevices)
                        .Where(d => d.Value.DeviceType == WdiUsbDeviceType.DualShock3)
                        .Select(d => d.Value);

                    if (GlobalConfiguration.Instance.ForceDs3DriverReinstallation)
                        DriverInstaller.InstallDualShock3Controllers(ds3Devices);

                    var ds4Devices = db.Engine.GetAllDbEntities<WdiDeviceInfo>(ScpDb.TableDevices)
                        .Where(d => d.Value.DeviceType == WdiUsbDeviceType.DualSHock4)
                        .Select(d => d.Value);

                    if (GlobalConfiguration.Instance.ForceDs4DriverReinstallation)
                        DriverInstaller.InstallDualShock4Controllers(ds4Devices);
                }
            });

            installTask.ContinueWith(task =>
            {
                Log.FatalFormat("Error during driver installation: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            Log.DebugFormat("Time spent 'till Root Hub start: {0}", sw.Elapsed);

            var hubStartTask = Task.Factory.StartNew(() =>
            {
                rootHub.Open();
                rootHub.Start();
            });

            hubStartTask.ContinueWith(task =>
            {
                Log.FatalFormat("Couldn't start the root hub: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            Log.DebugFormat("Time spent 'till registering notifications: {0}", sw.Elapsed);

            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs3.DeviceClassGuid, ref _ds3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs4.DeviceClassGuid, ref _ds4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, BthDongle.DeviceClassGuid, ref _bthNotify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify, false);

            Log.DebugFormat("Total Time spent in Service Start method: {0}", sw.Elapsed);
        }
Exemple #8
0
        protected override void OnStart(string[] args)
        {
            var sw = Stopwatch.StartNew();

            Log.Info("Scarlet.Crush Productions DSx Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                            Assembly.GetExecutingAssembly().GetName().Version);

            Log.DebugFormat("Setting working directory to {0}", GlobalConfiguration.AppDirectory);
            Directory.SetCurrentDirectory(GlobalConfiguration.AppDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle  = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            var installTask = Task.Factory.StartNew(() =>
            {
                using (var db = new ScpDb())
                {
                    var bthDevices = db.Engine.GetAllDbEntities <WdiDeviceInfo>(ScpDb.TableDevices)
                                     .Where(d => d.Value.DeviceType == WdiUsbDeviceType.BluetoothHost)
                                     .Select(d => d.Value);

                    if (GlobalConfiguration.Instance.ForceBluetoothDriverReinstallation)
                    {
                        DriverInstaller.InstallBluetoothDongles(bthDevices);
                    }

                    var ds3Devices = db.Engine.GetAllDbEntities <WdiDeviceInfo>(ScpDb.TableDevices)
                                     .Where(d => d.Value.DeviceType == WdiUsbDeviceType.DualShock3)
                                     .Select(d => d.Value);

                    if (GlobalConfiguration.Instance.ForceDs3DriverReinstallation)
                    {
                        DriverInstaller.InstallDualShock3Controllers(ds3Devices);
                    }

                    var ds4Devices = db.Engine.GetAllDbEntities <WdiDeviceInfo>(ScpDb.TableDevices)
                                     .Where(d => d.Value.DeviceType == WdiUsbDeviceType.DualSHock4)
                                     .Select(d => d.Value);

                    if (GlobalConfiguration.Instance.ForceDs4DriverReinstallation)
                    {
                        DriverInstaller.InstallDualShock4Controllers(ds4Devices);
                    }
                }
            });

            installTask.ContinueWith(task =>
            {
                Log.FatalFormat("Error during driver installation: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            Log.DebugFormat("Time spent 'till Root Hub start: {0}", sw.Elapsed);

            var hubStartTask = Task.Factory.StartNew(() =>
            {
                rootHub.Open();
                rootHub.Start();
            });

            hubStartTask.ContinueWith(task =>
            {
                Log.FatalFormat("Couldn't start the root hub: {0}", task.Exception);
                Stop();
            }, TaskContinuationOptions.OnlyOnFaulted);

            Log.DebugFormat("Time spent 'till registering notifications: {0}", sw.Elapsed);

            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs3.DeviceClassGuid, ref _ds3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbDs4.DeviceClassGuid, ref _ds4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, BthDongle.DeviceClassGuid, ref _bthNotify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify, false);

            Log.DebugFormat("Total Time spent in Service Start method: {0}", sw.Elapsed);
        }
Exemple #9
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Scarlet.Crush Productions DS3 Service Started");

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                    Assembly.GetExecutingAssembly().GetName().Version);

            Log.InfoFormat("Settings working directory to {0}", WorkingDirectory);
            Directory.SetCurrentDirectory(WorkingDirectory);

            _mControlHandler = ServiceControlHandler;
            _mServiceHandle = ScpDevice.RegisterServiceCtrlHandlerEx(ServiceName, _mControlHandler, IntPtr.Zero);

            // install compatible bluetooth dongles
            if(Settings.Default.InstallBluetoothDongles)
            {
                var bthDrivers = IniConfig.Instance.BthDongleDriver;

                foreach (var hardwareId in bthDrivers.HardwareIds)
                {
                    Log.DebugFormat("DeviceGUID = {0}", bthDrivers.DeviceGuid);
                    Log.DebugFormat("HardwareId = {0}", hardwareId);
                    var result = WdiWrapper.Instance.InstallWinUsbDriver(hardwareId, bthDrivers.DeviceGuid, "Driver",
                        "BthDongle.inf",
                        IntPtr.Zero);
                    Log.DebugFormat("result = {0}", result);
                }
            }

            // install compatible DS3 controllers
            if(Settings.Default.InstallDualShock3Controllers)
            {
                var ds3Drivers = IniConfig.Instance.Ds3Driver;

                foreach (var hardwareId in ds3Drivers.HardwareIds)
                {
                    Log.DebugFormat("DeviceGUID = {0}", ds3Drivers.DeviceGuid);
                    Log.DebugFormat("HardwareId = {0}", hardwareId);
                    var result = WdiWrapper.Instance.InstallWinUsbDriver(hardwareId, ds3Drivers.DeviceGuid, "Driver",
                        "Ds3Controller.inf", IntPtr.Zero);
                    Log.DebugFormat("result = {0}", result);
                }
            }

            // install compatible DS4 controllers
            if(Settings.Default.InstallDualShock4Controllers)
            {
                var ds4Drivers = IniConfig.Instance.Ds4Driver;

                foreach (var hardwareId in ds4Drivers.HardwareIds)
                {
                    Log.DebugFormat("DeviceGUID = {0}", ds4Drivers.DeviceGuid);
                    Log.DebugFormat("HardwareId = {0}", hardwareId);
                    var result = WdiWrapper.Instance.InstallWinUsbDriver(hardwareId, ds4Drivers.DeviceGuid, "Driver",
                        "Ds4Controller.inf", IntPtr.Zero);
                    Log.DebugFormat("result = {0}", result);
                }
            }

            try
            {
                rootHub.Open();
                rootHub.Start();
            }
            catch (RootHubAlreadyStartedException rhex)
            {
                Log.FatalFormat("Couldn't start the ScpService: {0}", rhex.Message);
                Stop();
                return;
            }

            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs3.USB_CLASS_GUID), ref _mDs3Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(UsbDs4.USB_CLASS_GUID), ref _mDs4Notify, false);
            ScpDevice.RegisterNotify(_mServiceHandle, new Guid(BthDongle.BTH_CLASS_GUID), ref _mBthNotify, false);
        }