private void Form_Load(object sender, EventArgs e) { if (usbDevice.Open()) { usbDevice.Start(); } ScpDevice.RegisterNotify(Handle, new Guid(UsbDevice.DS3_USB_CLASS_GUID), ref m_UsbNotify); }
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); }
protected void Form_Load(object sender, EventArgs e) { Icon = Properties.Resources.Scp_All; ScpDevice.RegisterNotify(Handle, new Guid(UsbDevice.DS3_USB_CLASS_GUID), ref m_UsbNotify); ScpDevice.RegisterNotify(Handle, new Guid(BthDevice.DS3_BTH_CLASS_GUID), ref m_BthNotify); tmrUpdate.Enabled = true; btnStart_Click(sender, e); }
private void Form_Load(object sender, EventArgs e) { Icon = Properties.Resources.Scp_All; if (usbDevice.Open()) { usbDevice.Start(); } ScpDevice.RegisterNotify(Handle, new Guid(UsbDs3.USB_CLASS_GUID), ref m_UsbNotify); }
private void Form_Load(object sender, EventArgs e) { Icon = Resources.Scp_All; if (usbDevice.Open()) { usbDevice.Start(); } ScpDevice.RegisterNotify(Handle, UsbDs3.DeviceClassGuid, ref m_UsbNotify); }
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); }
protected void Form_Load(object sender, EventArgs e) { Icon = Properties.Resources.Scp_All; ScpDevice.RegisterNotify(Handle, new Guid(UsbDs3.USB_CLASS_GUID), ref m_Ds3Notify); ScpDevice.RegisterNotify(Handle, new Guid(UsbDs4.USB_CLASS_GUID), ref m_Ds4Notify); ScpDevice.RegisterNotify(Handle, new Guid(BthDongle.BTH_CLASS_GUID), ref m_BthNotify); LogDebug(DateTime.Now, String.Format("++ {0} {1}", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version.ToString())); tmrUpdate.Enabled = true; btnStart_Click(sender, e); }
private void Form_Load(object sender, EventArgs e) { Icon = Resources.Scp_All; ScpDevice.RegisterNotify(Handle, new Guid(UsbDs3.USB_CLASS_GUID), ref m_Ds3Notify); ScpDevice.RegisterNotify(Handle, new Guid(UsbDs4.USB_CLASS_GUID), ref m_Ds4Notify); ScpDevice.RegisterNotify(Handle, new Guid(BthDongle.BTH_CLASS_GUID), ref m_BthNotify); Log.DebugFormat("++ {0} [{1}]", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); tmrUpdate.Enabled = true; btnStart_Click(sender, e); }
private void Form_Load(object sender, EventArgs e) { Icon = Resources.Scp_All; ScpDevice.RegisterNotify(Handle, UsbDs3.DeviceClassGuid, ref m_Ds3Notify); ScpDevice.RegisterNotify(Handle, UsbDs4.DeviceClassGuid, ref m_Ds4Notify); ScpDevice.RegisterNotify(Handle, BthDongle.DeviceClassGuid, ref m_BthNotify); ScpDevice.RegisterNotify(Handle, UsbGenericGamepad.DeviceClassGuid, ref _genericNotify); Log.DebugFormat("++ {0} [{1}]", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); tmrUpdate.Enabled = true; btnStart_Click(sender, e); }
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); }
/// <summary> /// Registers a window to receive windows messages when a device is inserted/removed. Need to call this /// from a form when its handle has been created, not in the form constructor. Use form's OnHandleCreated override. /// </summary> /// <param name="hWnd">Handle to window that will receive messages</param> /// <param name="gClass">Class of devices to get messages for</param> /// <returns>A handle used when unregistering</returns> protected static IntPtr RegisterForUsbEvents(IntPtr hWnd, Guid gClass) { var retVal = IntPtr.Zero; return(ScpDevice.RegisterNotify(hWnd, gClass, ref retVal) ? retVal : IntPtr.Zero); }
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); }