コード例 #1
0
        public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path)
        {
            if (_mSuspended)
            {
                return(DsPadId.None);
            }

            var classGuid = Guid.Parse(Class);

            // forward message for wired DS4 to usb hub
            if (classGuid == UsbDs4.DeviceClassGuid)
            {
                return(_usbHub.Notify(notification, Class, path));
            }

            // forward message for wired DS3 to usb hub
            if (classGuid == UsbDs3.DeviceClassGuid)
            {
                return(_usbHub.Notify(notification, Class, path));
            }

            // forward message for wired Generic Gamepad to usb hub
            if (classGuid == UsbGenericGamepad.DeviceClassGuid)
            {
                return(_usbHub.Notify(notification, Class, path));
            }

            // forward message for any wireless device to bluetooth hub
            if (classGuid == BthDongle.DeviceClassGuid)
            {
                _bthHub.Notify(notification, Class, path);
            }

            return(DsPadId.None);
        }
コード例 #2
0
        public override DsPadId Notify(ScpDevice.Notified notification, string Class, string Path)
        {
            if (_mSuspended)
            {
                return(DsPadId.None);
            }

            // forward message for wired DS4 to usb hub
            if (Class == UsbDs4.USB_CLASS_GUID)
            {
                return(_usbHub.Notify(notification, Class, Path));
            }

            // forward message for wired DS3 to usb hub
            if (Class == UsbDs3.USB_CLASS_GUID)
            {
                return(_usbHub.Notify(notification, Class, Path));
            }

            // forward message for any wireless device to bluetooth hub
            if (Class == BthDongle.BTH_CLASS_GUID)
            {
                _bthHub.Notify(notification, Class, Path);
            }

            return(DsPadId.None);
        }
コード例 #3
0
        public virtual DsPadId Notify(ScpDevice.Notified notification, string Class, string path)
        {
            switch (notification)
            {
            case ScpDevice.Notified.Arrival:
                break;

            case ScpDevice.Notified.Removal:
                break;
            }

            return(DsPadId.None);
        }
コード例 #4
0
ファイル: BthHub.cs プロジェクト: zw5/WiinUPro
        public override DsPadId Notify(ScpDevice.Notified Notification, String Class, String Path)
        {
            LogDebug(String.Format("++ Notify [{0}] [{1}] [{2}]", Notification, Class, Path));

            switch (Notification)
            {
            case ScpDevice.Notified.Arrival:
            {
                if (Device.State != DsState.Connected)
                {
                    BthDongle Arrived = new BthDongle();

                    if (Arrived.Open(Path))
                    {
                        LogDebug(String.Format("-- Device Arrival [{0}]", Arrived.Local));

                        Device.Close();
                        Device = Arrived;

                        Device.Arrival += new EventHandler <ArrivalEventArgs>(On_Arrival);
                        Device.Debug   += new EventHandler <DebugEventArgs>  (On_Debug);
                        Device.Report  += new EventHandler <ReportEventArgs> (On_Report);

                        if (m_Started)
                        {
                            Device.Start();
                        }
                        break;
                    }

                    Arrived.Close();
                    Arrived.Dispose();
                }
            }
            break;

            case ScpDevice.Notified.Removal:

                if (Device.Path == Path)
                {
                    LogDebug(String.Format("-- Device Removal [{0}]", Device.Local));

                    Device.Stop();
                }
                break;
            }

            return(DsPadId.None);
        }
コード例 #5
0
        public override DsPadId Notify(ScpDevice.Notified notification, string Class, string Path)
        {
            Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, Path);

            switch (notification)
            {
            case ScpDevice.Notified.Arrival:
            {
                if (_device.State != DsState.Connected)
                {
                    var arrived = new BthDongle();

                    if (arrived.Open(Path))
                    {
                        Log.DebugFormat("-- Device Arrival [{0}]", arrived.Local);

                        _device.Close();
                        _device = arrived;

                        _device.Arrival += On_Arrival;
                        _device.Report  += On_Report;

                        if (m_Started)
                        {
                            _device.Start();
                        }
                        break;
                    }

                    arrived.Close();
                    arrived.Dispose();
                }
            }
            break;

            case ScpDevice.Notified.Removal:

                if (_device.Path == Path)
                {
                    Log.DebugFormat("-- Device Removal [{0}]", _device.Local);

                    _device.Stop();
                }
                break;
            }

            return(DsPadId.None);
        }
コード例 #6
0
        public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path)
        {
            Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path);

            switch (notification)
            {
            case ScpDevice.Notified.Arrival:
            {
                if (_device.State != DsState.Connected)
                {
                    var arrived = new BthDongle();

                    if (arrived.Open(path))
                    {
                        Log.DebugFormat("-- Device Arrival [{0}]", arrived.BluetoothHostAddress.AsFriendlyName());

                        _device.Close();
                        _device = arrived;

                        _device.DeviceArrived     += OnDeviceArrival;
                        _device.HidReportReceived += OnHidReportReceived;

                        if (m_Started)
                        {
                            _device.Start();
                        }
                        break;
                    }

                    arrived.Close();
                    arrived.Dispose();
                }
            }
            break;

            case ScpDevice.Notified.Removal:

                if (_device.Path == path)
                {
                    Log.DebugFormat("-- Device Removal [{0}]", _device.BluetoothHostAddress.AsFriendlyName());

                    _device.Stop();
                }
                break;
            }

            return(DsPadId.None);
        }
コード例 #7
0
ファイル: RootHub.cs プロジェクト: tuutuu803/ScpDS3
        public override DsPadId Notify(ScpDevice.Notified Notification, String Class, String Path)
        {
            if (!m_Suspended)
            {
                if (Class == UsbDs3.USB_CLASS_GUID)
                {
                    return(usbHub.Notify(Notification, Class, Path));
                }

                if (Class == BthDongle.BTH_CLASS_GUID)
                {
                    bthHub.Notify(Notification, Class, Path);
                }
            }

            return(DsPadId.None);
        }
コード例 #8
0
        public virtual Ds3PadId Notify(ScpDevice.Notified Notification, String Class, String Path)
        {
            if (!m_Suspended)
            {
                if (Class == UsbDevice.DS3_USB_CLASS_GUID)
                {
                    return(usbHub.Notify(Notification, Class, Path));
                }

                if (Class == BthDevice.DS3_BTH_CLASS_GUID)
                {
                    bthHub.Notify(Notification, Class, Path);
                }
            }

            return(Ds3PadId.None);
        }
コード例 #9
0
ファイル: UsbHub.cs プロジェクト: zultharion/ScpServer
        public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path)
        {
            Log.InfoFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path);

            var classGuid = Guid.Parse(Class);

            switch (notification)
            {
            case ScpDevice.Notified.Arrival:
            {
                var arrived = new UsbDevice();

                if (classGuid == UsbDs3.DeviceClassGuid)
                {
                    arrived = new UsbDs3();
                    Log.Debug("-- DualShock 3 Arrival Event");
                }

                if (classGuid == UsbDs4.DeviceClassGuid)
                {
                    arrived = new UsbDs4();
                    Log.Debug("-- DualShock 4 Arrival Event");
                }

                if (classGuid == UsbGenericGamepad.DeviceClassGuid)
                {
                    arrived = UsbGenericGamepad.DeviceFactory(path);

                    // unknown or unsupported device
                    if (arrived == null)
                    {
                        break;
                    }

                    Log.Debug("-- Generic Gamepad Arrival Event");
                }

                Log.InfoFormat("Arrival event for GUID {0} received", classGuid);

                if (arrived.Open(path))
                {
                    Log.InfoFormat("-- Device Arrival [{0}]", arrived.Local);

                    if (!Apply3RdPartyWorkaroundsForDs3(ref arrived, path: path))
                    {
                        break;
                    }

                    if (LogArrival(arrived))
                    {
                        if (_devices[(byte)arrived.PadId].IsShutdown)
                        {
                            _devices[(byte)arrived.PadId].IsShutdown = false;

                            _devices[(byte)arrived.PadId].Close();
                            _devices[(byte)arrived.PadId] = arrived;

                            return(arrived.PadId);
                        }
                        arrived.HidReportReceived += OnHidReportReceived;

                        _devices[(byte)arrived.PadId].Close();
                        _devices[(byte)arrived.PadId] = arrived;

                        if (m_Started)
                        {
                            arrived.Start();
                        }
                        return(arrived.PadId);
                    }
                }

                arrived.Close();
            }
            break;

            case ScpDevice.Notified.Removal:
            {
                foreach (var t in _devices.Where(t => t.State == DsState.Connected && path == t.Path))
                {
                    Log.InfoFormat("-- Device Removal [{0}]", t.Local);

                    // play disconnect sound
                    if (GlobalConfiguration.Instance.IsUsbDisconnectSoundEnabled)
                    {
                        AudioPlayer.Instance.PlayCustomFile(GlobalConfiguration.Instance.UsbDisconnectSoundFile);
                    }

                    t.Stop();
                }
            }
            break;
            }

            return(DsPadId.None);
        }
コード例 #10
0
        public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path)
        {
            Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path);

            var classGuid = Guid.Parse(Class);

            switch (notification)
            {
            case ScpDevice.Notified.Arrival: {
                var arrived = new UsbDevice();

                if (classGuid == UsbDs3.DeviceClassGuid)
                {
                    arrived = new UsbDs3();
                    Log.Info("DualShock 3 plugged in via Usb");
                }

                if (classGuid == UsbDs4.DeviceClassGuid)
                {
                    arrived = new UsbDs4();
                    Log.Info("DualShock 4 plugged in via Usb");
                }

                if (classGuid == UsbGenericGamepad.DeviceClassGuid)
                {
                    arrived = UsbGenericGamepad.DeviceFactory(path);

                    // unknown or unsupported device
                    if (arrived == null)
                    {
                        break;
                    }

                    Log.Debug("Generic Gamepad plugged in via Usb");
                }

                Log.DebugFormat("Arrival event for GUID {0} received", classGuid);

                if (arrived.Open(path))
                {
                    Log.DebugFormat("Device MAC address: {0}", arrived.DeviceAddress.AsFriendlyName());

                    if (!Apply3RdPartyWorkaroundsForDs3(ref arrived, path: path))
                    {
                        break;
                    }

                    if (LogArrival(arrived))
                    {
                        if (_devices[(byte)arrived.PadId].IsShutdown)
                        {
                            _devices[(byte)arrived.PadId].IsShutdown = false;

                            _devices[(byte)arrived.PadId].Close();
                            _devices[(byte)arrived.PadId] = arrived;

                            return(arrived.PadId);
                        }
                        arrived.HidReportReceived += OnHidReportReceived;

                        _devices[(byte)arrived.PadId].Close();
                        _devices[(byte)arrived.PadId] = arrived;

                        if (m_Started)
                        {
                            arrived.Start();
                        }
                        return(arrived.PadId);
                    }
                }
                else
                {
                    Log.FatalFormat("Couldn't open device {0}", path);
                }

                arrived.Close();
            }
            break;

            case ScpDevice.Notified.Removal: {
                foreach (var t in _devices.Where(t => t.State == DsState.Connected && path == t.Path))
                {
                    Log.InfoFormat("Device with MAC address {0} unplugged from Usb", t.DeviceAddress.AsFriendlyName());
                    t.Stop();
                }
            }
            break;
            }

            return(DsPadId.None);
        }
コード例 #11
0
        public override DsPadId Notify(ScpDevice.Notified notification, String Class, String Path)
        {
            Log.InfoFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, Path);

            switch (notification)
            {
            case ScpDevice.Notified.Arrival:
            {
                UsbDevice arrived = new UsbDevice();

                if (string.Equals(Class, UsbDs3.USB_CLASS_GUID, StringComparison.CurrentCultureIgnoreCase))
                {
                    arrived = new UsbDs3();
                    Log.Debug("-- DS3 Arrival Event");
                }

                if (string.Equals(Class, UsbDs4.USB_CLASS_GUID, StringComparison.CurrentCultureIgnoreCase))
                {
                    arrived = new UsbDs4();
                    Log.Debug("-- DS4 Arrival Event");
                }

                Log.InfoFormat("Arrival event for GUID {0} received", Class);

                if (arrived.Open(Path))
                {
                    Log.InfoFormat("-- Device Arrival [{0}]", arrived.Local);

                    if (LogArrival(arrived))
                    {
                        if (_device[(Byte)arrived.PadId].IsShutdown)
                        {
                            _device[(Byte)arrived.PadId].IsShutdown = false;

                            _device[(Byte)arrived.PadId].Close();
                            _device[(Byte)arrived.PadId] = arrived;

                            return(arrived.PadId);
                        }
                        else
                        {
                            arrived.Report += new EventHandler <ReportEventArgs>(On_Report);

                            _device[(Byte)arrived.PadId].Close();
                            _device[(Byte)arrived.PadId] = arrived;

                            if (m_Started)
                            {
                                arrived.Start();
                            }
                            return(arrived.PadId);
                        }
                    }
                }

                arrived.Close();
            }
            break;

            case ScpDevice.Notified.Removal:
            {
                for (Int32 index = 0; index < _device.Length; index++)
                {
                    if (_device[index].State == DsState.Connected && Path == _device[index].Path)
                    {
                        Log.InfoFormat("-- Device Removal [{0}]", _device[index].Local);

                        _device[index].Stop();
                    }
                }
            }
            break;
            }

            return(DsPadId.None);
        }
コード例 #12
0
ファイル: UsbHub.cs プロジェクト: tuutuu803/ScpDS3
        public override DsPadId Notify(ScpDevice.Notified Notification, String Class, String Path)
        {
            LogDebug(String.Format("++ Notify [{0}] [{1}] [{2}]", Notification, Class, Path));

            switch (Notification)
            {
            case ScpDevice.Notified.Arrival:
            {
                UsbDevice Arrived = new UsbDevice();

                if (Class.ToUpper() == UsbDs3.USB_CLASS_GUID.ToUpper())
                {
                    Arrived = new UsbDs3(); LogDebug("-- DS3 Arrival Event");
                }

                if (Arrived.Open(Path))
                {
                    LogDebug(String.Format("-- Device Arrival [{0}]", Arrived.Local));

                    if (LogArrival(Arrived))
                    {
                        if (Device[(Byte)Arrived.PadId].IsShutdown)
                        {
                            Device[(Byte)Arrived.PadId].IsShutdown = false;

                            Device[(Byte)Arrived.PadId].Close();
                            Device[(Byte)Arrived.PadId] = Arrived;

                            return(Arrived.PadId);
                        }
                        else
                        {
                            Arrived.Debug  += new EventHandler <DebugEventArgs> (On_Debug);
                            Arrived.Report += new EventHandler <ReportEventArgs>(On_Report);

                            Device[(Byte)Arrived.PadId].Close();
                            Device[(Byte)Arrived.PadId] = Arrived;

                            if (m_Started)
                            {
                                Arrived.Start();
                            }
                            return(Arrived.PadId);
                        }
                    }
                }

                Arrived.Close();
            }
            break;

            case ScpDevice.Notified.Removal:
            {
                for (Int32 Index = 0; Index < Device.Length; Index++)
                {
                    if (Device[Index].State == DsState.Connected && Path == Device[Index].Path)
                    {
                        LogDebug(String.Format("-- Device Removal [{0}]", Device[Index].Local));

                        Device[Index].Stop();
                    }
                }
            }
            break;
            }

            return(DsPadId.None);
        }