Ejemplo n.º 1
0
 private void Awake()
 {
     if (!this.playerIndexSet || !this.prevState.IsConnected)
     {
         for (int i = 0; i < 4; i++)
         {
             PlayerIndex playerIndex = (PlayerIndex)i;
             if (!GamePad.GetState(playerIndex, GamePadDeadZone.None).IsConnected)
             {
                 this.directInput = true;
             }
             else
             {
                 this.directInput    = false;
                 this.playerIndex    = playerIndex;
                 this.playerIndexSet = true;
             }
         }
     }
     for (int j = 0; j < (int)this.inputsIn.Length; j++)
     {
         this.inputsIn[j] = new InputThread.InputStruct();
     }
     for (int k = 0; k < (int)this.inputsOut.Length; k++)
     {
         this.inputsOut[k] = new InputThread.InputStruct();
     }
     this._lastFrameData = new InputThread.InputStruct();
     this._threadActive  = true;
     this._updateThread  = new Thread(new ThreadStart(this.SuperFastLoop));
     this._updateThread.Start();
     this._time = Time.time;
     this.reset = new AutoResetEvent(false);
 }
Ejemplo n.º 2
0
 private void InputUpdate()
 {
     this.prevState = this.state;
     this.state     = GamePad.GetState(this.playerIndex);
     if (this._pos < this._maxLength)
     {
         if (this.state.IsConnected)
         {
             InputThread.InputStruct       inputStruct = this.inputsIn[this._pos];
             InputFilter                   inputFilter = this.leftXFilter;
             GamePadThumbSticks            thumbSticks = this.state.ThumbSticks;
             GamePadThumbSticks.StickValue left        = thumbSticks.Left;
             inputStruct.leftX = inputFilter.Filter((double)left.X);
             InputThread.InputStruct inputStruct1 = this.inputsIn[this._pos];
             InputFilter             inputFilter1 = this.leftYFilter;
             thumbSticks        = this.state.ThumbSticks;
             left               = thumbSticks.Left;
             inputStruct1.leftY = inputFilter1.Filter((double)left.Y);
             InputThread.InputStruct inputStruct2 = this.inputsIn[this._pos];
             InputFilter             inputFilter2 = this.rightXFilter;
             thumbSticks         = this.state.ThumbSticks;
             left                = thumbSticks.Right;
             inputStruct2.rightX = inputFilter2.Filter((double)left.X);
             InputThread.InputStruct inputStruct3 = this.inputsIn[this._pos];
             InputFilter             inputFilter3 = this.rightYFilter;
             thumbSticks                        = this.state.ThumbSticks;
             left                               = thumbSticks.Right;
             inputStruct3.rightY                = inputFilter3.Filter((double)left.Y);
             this.inputsIn[this._pos].time      = DateTime.UtcNow.Ticks;
             this.inputsIn[this._pos].leftXVel  = this.GetVel(this.inputsIn[this._pos].leftX, this._lastFrameData.leftX, this.inputsIn[this._pos].time, this._lastFrameData.time);
             this.inputsIn[this._pos].leftYVel  = this.GetVel(this.inputsIn[this._pos].leftY, this._lastFrameData.leftY, this.inputsIn[this._pos].time, this._lastFrameData.time);
             this.inputsIn[this._pos].rightXVel = this.GetVel(this.inputsIn[this._pos].rightX, this._lastFrameData.rightX, this.inputsIn[this._pos].time, this._lastFrameData.time);
             this.inputsIn[this._pos].rightYVel = this.GetVel(this.inputsIn[this._pos].rightY, this._lastFrameData.rightY, this.inputsIn[this._pos].time, this._lastFrameData.time);
             this._lastFrameData.leftX          = this.inputsIn[this._pos].leftX;
             this._lastFrameData.leftY          = this.inputsIn[this._pos].leftY;
             this._lastFrameData.rightX         = this.inputsIn[this._pos].rightX;
             this._lastFrameData.rightY         = this.inputsIn[this._pos].rightY;
             this._lastFrameData.time           = this.inputsIn[this._pos].time;
             this._pos++;
             return;
         }
         this.inputsIn[this._pos].leftX     = this.leftXFilter.Filter((double)((Mathf.Abs(this.inputController.player.GetAxis("LeftStickX")) < 0.1f ? 0f : this.inputController.player.GetAxis("LeftStickX"))));
         this.inputsIn[this._pos].leftY     = this.leftYFilter.Filter((double)this.inputController.player.GetAxis("LeftStickY"));
         this.inputsIn[this._pos].rightX    = this.rightXFilter.Filter((double)((Mathf.Abs(this.inputController.player.GetAxis("RightStickX")) < 0.1f ? 0f : this.inputController.player.GetAxis("RightStickX"))));
         this.inputsIn[this._pos].rightY    = this.rightYFilter.Filter((double)this.inputController.player.GetAxis("RightStickY"));
         this.inputsIn[this._pos].time      = DateTime.UtcNow.Ticks;
         this.inputsIn[this._pos].leftXVel  = this.GetVel(this.inputsIn[this._pos].leftX, this._lastFrameData.leftX, this.inputsIn[this._pos].time, this._lastFrameData.time);
         this.inputsIn[this._pos].leftYVel  = this.GetVel(this.inputsIn[this._pos].leftY, this._lastFrameData.leftY, this.inputsIn[this._pos].time, this._lastFrameData.time);
         this.inputsIn[this._pos].rightXVel = this.GetVel(this.inputsIn[this._pos].rightX, this._lastFrameData.rightX, this.inputsIn[this._pos].time, this._lastFrameData.time);
         this.inputsIn[this._pos].rightYVel = this.GetVel(this.inputsIn[this._pos].rightY, this._lastFrameData.rightY, this.inputsIn[this._pos].time, this._lastFrameData.time);
         this._lastFrameData.leftX          = this.inputsIn[this._pos].leftX;
         this._lastFrameData.leftY          = this.inputsIn[this._pos].leftY;
         this._lastFrameData.rightX         = this.inputsIn[this._pos].rightX;
         this._lastFrameData.rightY         = this.inputsIn[this._pos].rightY;
         this._lastFrameData.time           = this.inputsIn[this._pos].time;
         this._pos++;
     }
 }