Beispiel #1
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);
            }
        }
Beispiel #2
0
        private void RootHub_USBReport(object sender, ReportEventArgs e)
        {
            //if ((sender as UsbDevice).PadId != (DsPadId)deviceNum)
            //    return;

            deviceClass.Cross.Value    = ((byte)e.Report[11] & (1 << 6)) != 0;
            deviceClass.Circle.Value   = ((byte)e.Report[11] & (1 << 5)) != 0;
            deviceClass.Square.Value   = ((byte)e.Report[11] & (1 << 7)) != 0;
            deviceClass.Triangle.Value = ((byte)e.Report[11] & (1 << 4)) != 0;

            deviceClass.L1.Value = ((byte)e.Report[11] & (1 << 2)) != 0;
            deviceClass.R1.Value = ((byte)e.Report[11] & (1 << 3)) != 0;

            deviceClass.L3.Value = ((byte)e.Report[10] & (1 << 1)) != 0;
            deviceClass.R3.Value = ((byte)e.Report[10] & (1 << 2)) != 0;

            deviceClass.DUp.Value    = ((byte)e.Report[10] & (1 << 4)) != 0;
            deviceClass.DDown.Value  = ((byte)e.Report[10] & (1 << 6)) != 0;
            deviceClass.DLeft.Value  = ((byte)e.Report[10] & (1 << 7)) != 0;
            deviceClass.DRight.Value = ((byte)e.Report[10] & (1 << 5)) != 0;

            deviceClass.L2.Value = e.Report[26] / 255f;
            deviceClass.R2.Value = e.Report[27] / 255f;

            deviceClass.LSx.Value = SafeStickValue(e.Report[14] - 127) / 127f;
            deviceClass.LSy.Value = SafeStickValue(e.Report[15] - 127) / 127f;
            deviceClass.RSx.Value = SafeStickValue(e.Report[16] - 127) / 127f;
            deviceClass.RSy.Value = SafeStickValue(e.Report[17] - 127) / 127f;

            deviceClass.Select.Value = ((byte)e.Report[10] & (1 << 0)) != 0;
            deviceClass.Start.Value  = ((byte)e.Report[10] & (1 << 3)) != 0;

            deviceClass.PS.Value = ((byte)e.Report[12] & (1 << 0)) != 0;

            deviceClass.vCross.Value    = e.Report[32] / 255f;
            deviceClass.vCircle.Value   = e.Report[31] / 255f;
            deviceClass.vSquare.Value   = e.Report[33] / 255f;
            deviceClass.vTriangle.Value = e.Report[30] / 255f;

            //Console.WriteLine(String.Join(" ", e.Report));
        }
Beispiel #3
0
 protected virtual void On_Report(object sender, ReportEventArgs e)
 {
     if (Report != null) Report(sender, e);
 }
Beispiel #4
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 (Global.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)
                    {
                    }
                }
            }
        }
Beispiel #5
0
        protected override void OnHidReportReceived(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;
            }

            // skip broadcast if native feed is disabled
            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)
                    {
                        /* This might happen if the client disconnects while sending the
                         * response is still in progress. The exception can be ignored. */
                    }
                }
            }
        }
Beispiel #6
0
 protected virtual void OnHidReportReceived(object sender, ReportEventArgs e)
 {
     if (Report != null) Report(sender, e);
 }
Beispiel #7
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 = m_Cache[serial].Report;
            var rumble = m_Cache[serial].Rumble;
            var 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)
            {
                var Large = rumble[3];
                var Small = 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)
                return;

            // TODO: implement feed!
        }