Пример #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);
        }
Пример #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);
        }
Пример #3
0
        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);
        }
Пример #4
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);
        }