示例#1
0
 private void OnFeedPacketReceived(DsPacket data)
 {
     if (NativeFeedReceived != null)
     {
         NativeFeedReceived(this, data);
     }
 }
示例#2
0
 private void OnFeedPacketReceived(DsPacket data)
 {
     if (NativeFeedReceived != null)
     {
         NativeFeedReceived(this, data);
     }
 }
示例#3
0
 protected virtual void LogPacket(DsPacket Data)
 {
     if (Packet != null)
     {
         Packet(this, Data);
     }
 }
示例#4
0
        public virtual Boolean Remap(String Target, DsPacket Packet)
        {
            Boolean Remapped = false;

            try
            {
                if (m_Active)
                {
                    Byte[] Output = new Byte[Packet.Native.Length];

                    switch (Packet.Detail.Model)
                    {
                    case DsModel.DS3: if (m_Mapper.RemapDs3(m_Mapper.Map[Target], Packet.Native, Output))
                        {
                            Array.Copy(Output, Packet.Native, Output.Length); Packet.Remapped();
                        }
                        break;

                    case DsModel.DS4: if (m_Mapper.RemapDs4(m_Mapper.Map[Target], Packet.Native, Output))
                        {
                            Array.Copy(Output, Packet.Native, Output.Length); Packet.Remapped();
                        }
                        break;
                    }

                    Remapped = true;
                }
            }
            catch { }

            return(Remapped);
        }
示例#5
0
        public virtual void Sample(object sender, DsPacket Packet)
        {
            lock (this)
            {
                if (Packet.Detail.Pad == Pad)
                {
                    if (Packet.Detail.State == DsState.Connected)
                    {
                        switch (Packet.Detail.Model)
                        {
                        case DsModel.DS3:

                            try { SampleDs3(Packet); }
                            catch { };
                            break;

                        case DsModel.DS4:

                            try { SampleDs4(Packet); }
                            catch { }
                            break;
                        }
                    }
                    else
                    {
                        try { Reset(); }
                        catch { }
                    }
                }
            }
        }
示例#6
0
        public bool Start()
        {
            try
            {
                if (!m_Active)
                {
                    #region WCF client

                    var address = new EndpointAddress(new Uri("net.tcp://localhost:26760/ScpRootHubService"));
                    var binding = new NetTcpBinding();
                    var factory = new ChannelFactory <IScpCommandService>(binding, address);

                    _rootHub = factory.CreateChannel(address);

                    #endregion

                    #region Feed client

                    var rootHubFeedChannel = new ScpNativeFeedChannel(_rxFeedClient);
                    rootHubFeedChannel.Receiver.SubscribeOn(TaskPoolScheduler.Default).Subscribe(buffer =>
                    {
                        if (buffer.Length <= 0)
                        {
                            return;
                        }

                        var packet = new DsPacket();

                        OnFeedPacketReceived(packet.Load(buffer));
                    });

                    _rxFeedClient.ConnectAsync();

                    #endregion

                    if (_rootHub != null)
                    {
                        _xmlMap.LoadXml(_rootHub.GetXml());
                        _xmlMapper.Initialize(_xmlMap);
                    }
                    else
                    {
                        Log.Error("Couldn't initialize XML mapper");
                    }

                    m_Active = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return(m_Active);
        }
示例#7
0
        public virtual void Sample(object sender, DsPacket Packet)
        {
            lock (this)
            {
                if (Packet.Detail.Pad == Pad)
                {
                    if (Packet.Detail.State == DsState.Connected)
                    {
                        switch (Packet.Detail.Model)
                        {
                        case DsModel.DS3:

                            try
                            {
                                SampleDs3(Packet);
                            }
                            catch (Exception ex)
                            {
                                Log.ErrorFormat("Unexpected error sampling DS3 packet: {0}", ex);
                            }
                            break;

                        case DsModel.DS4:

                            try
                            {
                                SampleDs4(Packet);
                            }
                            catch (Exception ex)
                            {
                                Log.ErrorFormat("Unexpected error sampling DS4 packet: {0}", ex);
                            }
                            break;
                        }
                    }
                    else
                    {
                        try
                        {
                            Reset();
                        }
                        catch (Exception ex)
                        {
                            Log.ErrorFormat("Unexpected error: {0}", ex);
                        }
                    }
                }
            }
        }
示例#8
0
        public bool Remap(string target, DsPacket packet)
        {
            var remapped = false;

            try
            {
                if (m_Active)
                {
                    if (!_xmlMapper.Map.Any())
                    {
                        return(false);
                    }

                    var output = new byte[packet.Native.Length];

                    switch (packet.Detail.Model)
                    {
                    case DsModel.DS3:
                        if (_xmlMapper.RemapDs3(_xmlMapper.Map[target], packet.Native, output))
                        {
                            Array.Copy(output, packet.Native, output.Length);
                            packet.Remapped();
                        }
                        break;

                    case DsModel.DS4:
                        if (_xmlMapper.RemapDs4(_xmlMapper.Map[target], packet.Native, output))
                        {
                            Array.Copy(output, packet.Native, output.Length);
                            packet.Remapped();
                        }
                        break;
                    }

                    remapped = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return(remapped);
        }
示例#9
0
文件: ScpProxy.cs 项目: zw5/WiinUPro
        protected virtual void NativeFeed_Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            DsPacket Packet = new DsPacket();

            Byte[] Buffer = new Byte[ReportEventArgs.Length];

            while (!NativeFeed_Worker.CancellationPending)
            {
                try
                {
                    m_Client.Client.Receive(Buffer);
                    LogPacket(Packet.Load(Buffer));
                }
                catch { }
            }

            m_Client.Close();
            e.Cancel = true;
        }
示例#10
0
        private void Parse(object sender, DsPacket e)
        {
            lock (this)
            {
                if (e.Detail.Pad == (DsPadId)m_SelectedPad)
                {
                    if (e.Detail.State != DsState.Connected)
                    {
                        ResetControls();
                        return;
                    }

                    scpProxy.Remap(m_SelectedProfile, e);

                    switch (e.Detail.Model)
                    {
                        case DsModel.DS3:
                            {
                                axLX.Value = e.Axis(Ds3Axis.LX);
                                axLY.Value = e.Axis(Ds3Axis.LY);
                                axRX.Value = e.Axis(Ds3Axis.RX);
                                axRY.Value = e.Axis(Ds3Axis.RY);

                                axL1.Value = e.Axis(Ds3Axis.L1);
                                axR1.Value = e.Axis(Ds3Axis.R1);
                                axL2.Value = e.Axis(Ds3Axis.L2);
                                axR2.Value = e.Axis(Ds3Axis.R2);

                                axL3.Value = (Byte)(e.Button(Ds3Button.L3) ? 255 : 0);
                                axR3.Value = (Byte)(e.Button(Ds3Button.R3) ? 255 : 0);

                                axSH.Value = (Byte)(e.Button(Ds3Button.Select) ? 255 : 0);
                                axOP.Value = (Byte)(e.Button(Ds3Button.Start) ? 255 : 0);

                                axT.Value = e.Axis(Ds3Axis.Triangle);
                                axC.Value = e.Axis(Ds3Axis.Circle);
                                axX.Value = e.Axis(Ds3Axis.Cross);
                                axS.Value = e.Axis(Ds3Axis.Square);

                                axU.Value = e.Axis(Ds3Axis.Up);
                                axR.Value = e.Axis(Ds3Axis.Right);
                                axD.Value = e.Axis(Ds3Axis.Down);
                                axL.Value = e.Axis(Ds3Axis.Left);

                                axPS.Value = (Byte)(e.Button(Ds3Button.PS) ? 255 : 0);
                            }
                            break;

                        case DsModel.DS4:
                            {
                                axLX.Value = e.Axis(Ds4Axis.LX);
                                axLY.Value = e.Axis(Ds4Axis.LY);
                                axRX.Value = e.Axis(Ds4Axis.RX);
                                axRY.Value = e.Axis(Ds4Axis.RY);

                                axL2.Value = e.Axis(Ds4Axis.L2);
                                axR2.Value = e.Axis(Ds4Axis.R2);

                                axL1.Value = (Byte)(e.Button(Ds4Button.L1) ? 255 : 0);
                                axR1.Value = (Byte)(e.Button(Ds4Button.R1) ? 255 : 0);
                                axL3.Value = (Byte)(e.Button(Ds4Button.L3) ? 255 : 0);
                                axR3.Value = (Byte)(e.Button(Ds4Button.R3) ? 255 : 0);

                                axSH.Value = (Byte)(e.Button(Ds4Button.Share) ? 255 : 0);
                                axOP.Value = (Byte)(e.Button(Ds4Button.Options) ? 255 : 0);

                                axT.Value = (Byte)(e.Button(Ds4Button.Triangle) ? 255 : 0);
                                axC.Value = (Byte)(e.Button(Ds4Button.Circle) ? 255 : 0);
                                axX.Value = (Byte)(e.Button(Ds4Button.Cross) ? 255 : 0);
                                axS.Value = (Byte)(e.Button(Ds4Button.Square) ? 255 : 0);

                                axU.Value = (Byte)(e.Button(Ds4Button.Up) ? 255 : 0);
                                axR.Value = (Byte)(e.Button(Ds4Button.Right) ? 255 : 0);
                                axD.Value = (Byte)(e.Button(Ds4Button.Down) ? 255 : 0);
                                axL.Value = (Byte)(e.Button(Ds4Button.Left) ? 255 : 0);

                                axPS.Value = (Byte)(e.Button(Ds4Button.PS) ? 255 : 0);
                                axTP.Value = (Byte)(e.Button(Ds4Button.TouchPad) ? 255 : 0);
                            }
                            break;
                    }
                }
            }
        }
示例#11
0
        protected override void SampleDs3(DsPacket Packet)
        {
            m_Enb = Toggle(m_Enb, Packet.Button(Ds3Button.PS | Ds3Button.Start), ref m_Enabled);

            if (m_Enabled)
            {
                base.SampleDs3(Packet);

                m_LMB = Mouse (m_LMB, Packet.Button(Ds3Button.R1      ), KbmPost.MouseButtons.Left );
                m_RMB = Mouse (m_RMB, Packet.Button(Ds3Button.L1      ), KbmPost.MouseButtons.Right);

                m_Ent = Button(m_Ent, Packet.Button(Ds3Button.Cross   ), Keys.Enter,    false);
                m_Esc = Button(m_Esc, Packet.Button(Ds3Button.Circle  ), Keys.Escape,   false);
                m_Tab = Button(m_Tab, Packet.Button(Ds3Button.Square  ), Keys.Tab,      false);
                m_Spc = Button(m_Spc, Packet.Button(Ds3Button.Triangle), Keys.Space,    false);

                m_PgU = Button(m_PgU, Packet.Button(Ds3Button.R2      ), Keys.PageUp,   true );
                m_PgD = Button(m_PgD, Packet.Button(Ds3Button.L2      ), Keys.PageDown, true );

                m_CuU = Button(m_CuU, Packet.Button(Ds3Button.Up      ), Keys.Up,       true );
                m_CuD = Button(m_CuD, Packet.Button(Ds3Button.Down    ), Keys.Down,     true );
                m_CuL = Button(m_CuL, Packet.Button(Ds3Button.Left    ), Keys.Left,     true );
                m_CuR = Button(m_CuR, Packet.Button(Ds3Button.Right   ), Keys.Right,    true );
            }
        }
示例#12
0
 protected virtual void SampleDs4(DsPacket Packet)
 {
     m_dx = Mouse(Packet.Axis(Ds4Axis.RX), m_vx);
     m_dy = Mouse(Packet.Axis(Ds4Axis.RY), m_vy);
 }
示例#13
0
        public bool Remap(string target, DsPacket packet)
        {
            var remapped = false;

            try
            {
                if (m_Active)
                {
                    if (!m_Mapper.Map.Any())
                        return false;

                    var output = new byte[packet.Native.Length];

                    switch (packet.Detail.Model)
                    {
                        case DsModel.DS3:
                            if (m_Mapper.RemapDs3(m_Mapper.Map[target], packet.Native, output))
                            {
                                Array.Copy(output, packet.Native, output.Length);
                                packet.Remapped();
                            }
                            break;
                        case DsModel.DS4:
                            if (m_Mapper.RemapDs4(m_Mapper.Map[target], packet.Native, output))
                            {
                                Array.Copy(output, packet.Native, output.Length);
                                packet.Remapped();
                            }
                            break;
                    }

                    remapped = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return remapped;
        }
示例#14
0
 protected virtual void SampleDs4(DsPacket Packet)
 {
     m_dx = Mouse(Packet.Axis(Ds4Axis.RX), m_vx);
     m_dy = Mouse(Packet.Axis(Ds4Axis.RY), m_vy);
 }
示例#15
0
        public virtual void Sample(object sender, DsPacket Packet)
        {
            lock (this)
            {
                if (Packet.Detail.Pad == Pad)
                {
                    if (Packet.Detail.State == DsState.Connected)
                    {
                        switch (Packet.Detail.Model)
                        {
                            case DsModel.DS3:

                                try
                                {
                                    SampleDs3(Packet);
                                }
                                catch (Exception ex)
                                {
                                    Log.ErrorFormat("Unexpected error: {0}", ex);
                                }
                                break;

                            case DsModel.DS4:

                                try
                                {
                                    SampleDs4(Packet);
                                }
                                catch (Exception ex)
                                {
                                    Log.ErrorFormat("Unexpected error: {0}", ex);
                                }
                                break;
                        }
                    }
                    else
                    {
                        try
                        {
                            Reset();
                        }
                        catch (Exception ex)
                        {
                            Log.ErrorFormat("Unexpected error: {0}", ex);
                        }
                    }
                }
            }
        }