Parse() public method

Translates an ScpHidReport to an Xbox 360 compatible byte array.
public Parse ( ScpControl.Shared.Core.ScpHidReport inputReport ) : ScpControl.Shared.XInput.XINPUT_GAMEPAD
inputReport ScpControl.Shared.Core.ScpHidReport The to translate.
return ScpControl.Shared.XInput.XINPUT_GAMEPAD
Exemplo n.º 1
0
        protected override void On_Report(object sender, ReportEventArgs e)
        {
            int serial = e.Report[(int)DsOffset.Pad];
            var model  = (DsModel)e.Report[(int)DsOffset.Model];

            var report = _mCache[serial].Report;
            var rumble = _mCache[serial].Rumble;
            var mapped = _mCache[serial].Mapped;

            if (scpMap.Remap(model, serial, _mPad[serial].Local, e.Report, mapped))
            {
                _scpBus.Parse(mapped, report, model);
            }
            else
            {
                _scpBus.Parse(e.Report, report, model);
            }

            if (_scpBus.Report(report, rumble) && (DsState)e.Report[1] == DsState.Connected)
            {
                var Large = rumble[3];
                var Small = rumble[4];

                if (rumble[1] == 0x08 && (Large != _mXInput[serial][0] || Small != _mXInput[serial][1]))
                {
                    _mXInput[serial][0] = Large;
                    _mXInput[serial][1] = Small;

                    Pad[serial].Rumble(Large, Small);
                }
            }

            if ((DsState)e.Report[1] != DsState.Connected)
            {
                _mXInput[serial][0] = _mXInput[serial][1] = 0;
                _mNative[serial][0] = _mNative[serial][1] = 0;
            }

            if (GlobalConfiguration.Instance.DisableNative)
            {
                return;
            }

            lock (this)
            {
                // send native controller inputs to subscribed clients
                foreach (
                    var channel in _nativeFeedSubscribers.Select(nativeFeedSubscriber => nativeFeedSubscriber.Value))
                {
                    try
                    {
                        channel.SendAsync(e.Report);
                    }
                    catch (AggregateException)
                    {
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected virtual void On_Report(object sender, ReportEventArgs e)
        {
            Byte[] Rumble = new Byte[8];
            Byte[] Report = new Byte[28];

            Int32 Serial = scpBus.Parse(e.Report, Report);

            if (scpBus.Report(Report, Rumble) && (DeviceState)e.Report[1] == DeviceState.Connected)
            {
                Byte Big   = (Byte)(Rumble[3]);
                Byte Small = (Byte)(Rumble[4] > 0 ? 1 : 0);

                if (Rumble[1] == 0x08 && (Big != m_XInput[Serial][0] || Small != m_XInput[Serial][1]))
                {
                    m_XInput[Serial][0] = Big;
                    m_XInput[Serial][1] = Small;

                    Pad[Serial].Rumble(Big, Small);
                }
            }

            if ((DeviceState)e.Report[1] != DeviceState.Connected)
            {
                m_XInput[Serial][0] = m_XInput[Serial][1] = 0;
                m_Native[Serial][0] = m_Native[Serial][1] = 0;
            }

            m_Client.Send(e.Report, e.Report.Length, m_ClientEp);
        }
Exemplo n.º 3
0
        protected override void On_Report(object sender, ReportEventArgs e)
        {
            Int32   Serial = e.Report[(Int32)DsOffset.Pad];
            DsModel Model  = (DsModel)e.Report[(Int32)DsOffset.Model];

            Byte[] Report = m_Cache[Serial].Report;
            Byte[] Rumble = m_Cache[Serial].Rumble;
            Byte[] Mapped = m_Cache[Serial].Mapped;

            if (scpMap.Remap(Model, Serial, m_Pad[Serial].Local, e.Report, Mapped))
            {
                scpBus.Parse(Mapped, Report, Model);
            }
            else
            {
                scpBus.Parse(e.Report, Report, Model);
            }

            if (scpBus.Report(Report, Rumble) && (DsState)e.Report[1] == DsState.Connected)
            {
                Byte Large = (Byte)(Rumble[3]);
                Byte Small = (Byte)(Rumble[4]);

                if (Rumble[1] == 0x08 && (Large != m_XInput[Serial][0] || Small != m_XInput[Serial][1]))
                {
                    m_XInput[Serial][0] = Large;
                    m_XInput[Serial][1] = Small;

                    Pad[Serial].Rumble(Large, Small);
                }
            }

            if ((DsState)e.Report[1] != DsState.Connected)
            {
                m_XInput[Serial][0] = m_XInput[Serial][1] = 0;
                m_Native[Serial][0] = m_Native[Serial][1] = 0;
            }

            if (!Global.DisableNative)
            {
                m_Client.Send(e.Report, e.Report.Length, m_ClientEp);
            }
        }
Exemplo n.º 4
0
        protected override void OnHidReportReceived(object sender, ScpHidReport e)
        {
            var serial = (int)e.PadId;
            var model  = e.Model;

            var report = _mCache[serial].Report;
            var rumble = _mCache[serial].Rumble;

            DualShockProfileManager.Instance.PassThroughAllProfiles(e);

            ScpPlugins.Instance.Process(e);

            _scpBus.Parse(e, report, model);

            if (_scpBus.Report(report, rumble) && (DsState)e.RawBytes[1] == DsState.Connected)
            {
                var large = rumble[3];
                var small = rumble[4];

                if (rumble[1] == 0x08 && (large != _mXInput[serial][0] || small != _mXInput[serial][1]))
                {
                    _mXInput[serial][0] = large;
                    _mXInput[serial][1] = small;

                    Pad[serial].Rumble(large, small);
                }
            }

            if ((DsState)e.RawBytes[1] != DsState.Connected)
            {
                _mXInput[serial][0] = _mXInput[serial][1] = 0;
                _mNative[serial][0] = _mNative[serial][1] = 0;
            }

            // skip broadcast if native feed is disabled
            if (GlobalConfiguration.Instance.DisableNative)
            {
                return;
            }

            // send native controller inputs to subscribed clients
            foreach (
                var channel in _nativeFeedSubscribers.Select(nativeFeedSubscriber => nativeFeedSubscriber.Value))
            {
                try
                {
                    channel.SendAsync(e.RawBytes);
                }
                catch (AggregateException)
                {
                    /* This might happen if the client disconnects while sending the
                     * response is still in progress. The exception can be ignored. */
                }
            }
        }
Exemplo n.º 5
0
        protected override void OnHidReportReceived(object sender, ScpHidReport e)
        {
            // get current pad ID
            var serial = (int)e.PadId;

            if (GlobalConfiguration.Instance.ProfilesEnabled)
            {
                // pass current report through user profiles
                DualShockProfileManager.Instance.PassThroughAllProfiles(e);
            }

            if (e.PadState == DsState.Connected)
            {
                // translate current report to Xbox format and send it to bus device
                XOutputWrapper.Instance.SetState((uint)serial, _scpBus.Parse(e));

                // set currently assigned XInput slot
                Pads[serial].XInputSlot = XOutputWrapper.Instance.GetRealIndex((uint)serial);

                byte largeMotor = 0;
                byte smallMotor = 0;

                // forward rumble request to pad
                if (XOutputWrapper.Instance.GetState((uint)serial, ref largeMotor, ref smallMotor) &&
                    (largeMotor != _vibration[serial][0] || smallMotor != _vibration[serial][1]))
                {
                    _vibration[serial][0] = largeMotor;
                    _vibration[serial][1] = smallMotor;

                    Pads[serial].Rumble(largeMotor, smallMotor);
                }
            }
            else
            {
                // reset rumble/vibration to off state
                _vibration[serial][0] = _vibration[serial][1] = 0;
                _mNative[serial][0]   = _mNative[serial][1] = 0;

                if (GlobalConfiguration.Instance.AlwaysDisconnectVirtualBusDevice)
                {
                    _scpBus.Unplug(_scpBus.IndexToSerial((byte)e.PadId));
                }
            }

            // skip broadcast if native feed is disabled
            if (GlobalConfiguration.Instance.DisableNative)
            {
                return;
            }

            // send native controller inputs to subscribed clients
            foreach (
                var channel in _nativeFeedSubscribers.Select(nativeFeedSubscriber => nativeFeedSubscriber.Value))
            {
                try
                {
                    channel.SendAsync(e.RawBytes);
                }
                catch (AggregateException)
                {
                    /* This might happen if the client disconnects while sending the
                     * response is still in progress. The exception can be ignored. */
                }
            }
        }
Exemplo n.º 6
0
        protected override void OnHidReportReceived(object sender, ScpHidReport e)
        {
            // get current pad ID
            var serial = (int)e.PadId;

            // get cached status data
            var report = _cache[serial].Report;
            var rumble = _cache[serial].Rumble;

            // pass current report through user profiles
            DualShockProfileManager.Instance.PassThroughAllProfiles(e);

            // pass current report through user scripts
            ScpMapperPlugins.Instance.Process(e);

            // translate current report to Xbox format
            _scpBus.Parse(e, report);

            if (_scpBus.Report(report, rumble) && e.PadState == DsState.Connected)
            {
                var large = rumble[3];
                var small = rumble[4];

                if (rumble[1] == 0x08 && (large != _mXInput[serial][0] || small != _mXInput[serial][1]))
                {
                    _mXInput[serial][0] = large;
                    _mXInput[serial][1] = small;

                    Pads[serial].Rumble(large, small);
                }
            }

            if (e.PadState != DsState.Connected)
            {
                // reset rumble/vibration to off state
                _mXInput[serial][0] = _mXInput[serial][1] = 0;
                _mNative[serial][0] = _mNative[serial][1] = 0;

                if (GlobalConfiguration.Instance.AlwaysDisconnectVirtualBusDevice)
                {
                    _scpBus.Unplug(_scpBus.IndexToSerial((byte)e.PadId));
                }
            }

            // skip broadcast if native feed is disabled
            if (GlobalConfiguration.Instance.DisableNative)
            {
                return;
            }

            // send native controller inputs to subscribed clients
            foreach (
                var channel in _nativeFeedSubscribers.Select(nativeFeedSubscriber => nativeFeedSubscriber.Value))
            {
                try
                {
                    channel.SendAsync(e.RawBytes);
                }
                catch (AggregateException)
                {
                    /* This might happen if the client disconnects while sending the
                     * response is still in progress. The exception can be ignored. */
                }
            }
        }