Exemplo n.º 1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            joystick.Poll();

            joystick.GetCurrentState();

            var datas = joystick.GetBufferedData();

            if (datas.Length > 0 && !firstRun)
            {
                foreach (var item in datas)
                {
                    JoystickUpdate x = datas[0];
                    if (x.Offset != JoystickOffset.Buttons4 && x.Value > 0)
                    {
                        buttonColor = new JoystickButtonToColor {
                            Button = x.Offset, Color = new LEDBulb(), ButtonType = buttonType, PressedBrightness = 64, ReleasedBrightness = 255
                        };
                        timer.Stop();
                        DialogHost.CloseDialogCommand.Execute(buttonColor, this);
                    }
                }
            }

            firstRun = false;
        }
Exemplo n.º 2
0
 private void OnAxisChanged(JoystickUpdate state)
 {
     AxisChanged?.Invoke(this, new AxisChangedEventArgs()
     {
         AxisId = (int)state.Offset, Value = state.Value, Device = null
     });
 }
Exemplo n.º 3
0
        public IMiRoboCommand ProvideCommand(JoystickUpdate update)
        {
            switch (update.Offset)
            {
            case JoystickOffset.Buttons9:
                return(new ManualStartCommand());

            case JoystickOffset.Buttons8:
                return(new ManualStopCommand());

            case JoystickOffset.RotationY:
                return(new MoveBackwardCommand(update.Value));

            case JoystickOffset.RotationX:
                return(new MoveForwardCommand(update.Value));

            case JoystickOffset.X when Math.Abs(update.Value - ushort.MaxValue / 2) > 20000:
                if (update.Value > ushort.MaxValue / 2)
                {
                    return(new MoveRightCommand(30));
                }
                else
                {
                    return(new MoveLeftCommand(30));
                }

            default:
                return(null);
            }
            ;
        }
Exemplo n.º 4
0
 public CustomDiUpdate(JoystickUpdate update)
 {
     Value = update.Value;
     Index = CustomDiHelper.AxisOffsets.IndexOf(update.Offset);
     if (Index > -1)
     {
         Type = MapType.Axis;
         return;
     }
     Index = CustomDiHelper.SliderOffsets.IndexOf(update.Offset);
     if (Index > -1)
     {
         Type = MapType.Slider;
         return;
     }
     Index = CustomDiHelper.PovOffsets.IndexOf(update.Offset);
     if (Index > -1)
     {
         Type = MapType.POV;
         return;
     }
     Index = CustomDiHelper.ButtonOffsets.IndexOf(update.Offset);
     if (Index > -1)
     {
         Type = MapType.Button;
         return;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 必要に応じて軸ボタンの上げ下げイベントを発生する
        /// </summary>
        /// <param name="target">軸ボタン番号 0=-X 1=+X ... 5=+Z</param>
        /// <param name="data"></param>
        /// <param name="currentMode">直前のボタン状態 true=押されていた</param>
        /// <returns>上げ下げイベント発生時true</returns>
        private bool bDoUpDownCore(int target, JoystickUpdate data, bool lastMode)
        {
            if (this.bButtonState[target] == lastMode)
            {
                STInputEvent e = new STInputEvent()
                {
                    nKey       = target,
                    b押された      = !lastMode,
                    nTimeStamp = CSoundManager.rcPerformanceTimer.nサウンドタイマーのシステム時刻msへの変換(data.Timestamp),
                    nVelocity  = (lastMode) ? 0 : CInputManager.n通常音量
                };
                this.listInputEvent.Add(e);

                this.bButtonState[target] = !lastMode;
                if (lastMode)
                {
                    this.bButtonPullUp[target] = true;
                }
                else
                {
                    this.bButtonPushDown[target] = true;
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        //private CTimer timer;

        private void bButtonUpDown(JoystickUpdate data, int axisdata, int target, int contrary)         // #26871 2011.12.3 軸の反転に対応するためにリファクタ
        {
            int targetsign = (target < contrary) ? -1 : 1;

            if (Math.Abs(axisdata) > 500 && (targetsign == Math.Sign(axisdata)))                        // 軸の最大値の半分を超えていて、かつ
            {
                if (bDoUpDownCore(target, data, false))                                                 // 直前までは超えていなければ、今回ON
                {
                    //Debug.WriteLine( "X-ON " + data.TimeStamp + " " + axisdata );
                }
                else
                {
                    //Debug.WriteLine( "X-ONx " + data.TimeStamp + " " + axisdata );
                }
                bDoUpDownCore(contrary, data, true);                                                        // X軸+ == ON から X軸-のONレンジに来たら、X軸+はOFF
            }
            else if ((axisdata <= 0 && targetsign <= 0) || (axisdata >= 0 && targetsign >= 0))              // 軸の最大値の半分を超えておらず、かつ
            {
                //Debug.WriteLine( "X-OFF? " + data.TimeStamp + " " + axisdata );
                if (bDoUpDownCore(target, data, true))                                                          // 直前までは超えていたのならば、今回OFF
                {
                    //Debug.WriteLine( "X-OFF " + data.TimeStamp + " " + axisdata );
                }
                else if (bDoUpDownCore(contrary, data, true))                                                   // X軸+ == ON から X軸-のOFFレンジにきたら、X軸+はOFF
                {
                    //Debug.WriteLine( "X-OFFx " + data.TimeStamp + " " + axisdata );
                }
            }
        }
Exemplo n.º 7
0
 public void Poll()
 {
     data[0] = new JoystickUpdate()
     {
         RawOffset = (int)JoystickOffset.Slider1, Sequence = 0, Timestamp = 0, Value = JitterDetection.Threshold * 100
     };
 }
Exemplo n.º 8
0
        public StickEventArgs(JoystickUpdate state, StickStatus last_stickstatus) : base(state)
        {
            StickStatus = last_stickstatus;
            switch (state.Offset)
            {
            case JoystickOffset.X:
                StickStatus.X = state.Value;
                break;

            case JoystickOffset.Y:
                StickStatus.Y = state.Value;
                break;

            case JoystickOffset.Z:
                StickStatus.Z = state.Value;
                break;

            case JoystickOffset.RotationX:
                StickStatus.RX = state.Value;
                break;

            case JoystickOffset.RotationY:
                StickStatus.RY = state.Value;
                break;

            case JoystickOffset.RotationZ:
                StickStatus.RZ = state.Value;
                break;
            }
        }
        private void ProcessPOVs(GameController controller, IEnumerable <JoystickUpdate> updates, IProgress <GameControllerProgressArgs> progress)
        {
            GameControllerPOVDirection  previousPOVDirection = GameControllerPOVDirection.UNMAPPED;
            GameControllerButtonMapping previousMapping      = null;

            foreach (JoystickUpdate state in updates)
            {
                if (_PreviousPOVState.Timestamp != 0)
                {
                    // Get previous stuff
                    previousPOVDirection = GameController.GetPOVDirection(_PreviousPOVState);
                    previousMapping      = controller.ButtonMappings.Where(m => m.JoystickOffset == _PreviousPOVState.Offset && m.POVDirection == previousPOVDirection).FirstOrDefault();
                }
                GameControllerPOVDirection povDirection = GameController.GetPOVDirection(state);
                if (povDirection == GameControllerPOVDirection.UNMAPPED)
                {
                    if (previousMapping != null)
                    {
                        ProcessButtonMapping(previousMapping, -1, progress);
                    }
                    _PreviousPOVState = new JoystickUpdate();
                }
                else
                {
                    if (povDirection != previousPOVDirection && previousPOVDirection != GameControllerPOVDirection.UNMAPPED)
                    {
                        // switch from one direction to another without coming up so need to UP the previous mapping.
                        ProcessButtonMapping(previousMapping, -1, progress);
                    }
                    GameControllerButtonMapping mapping = controller.ButtonMappings.Where(m => m.JoystickOffset == state.Offset && m.POVDirection == povDirection).FirstOrDefault();
                    ProcessButtonMapping(mapping, state.Value, progress);
                    _PreviousPOVState = state;
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets if button is pressed. Null if not the same as requested.
        /// </summary>
        /// <param name="button"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public static bool?GetButtonPressDirectInput(JoystickButton button, JoystickUpdate state)
        {
            if (button == null)
            {
                return(null);
            }

            if ((JoystickOffset)button.Button != state.Offset)
            {
                return(null);
            }

            // POV
            if (button.Button >= 32 && button.Button <= 44)
            {
                if (state.Value == button.PovDirection)
                {
                    return(true);
                }
                return(false);
            }

            // Normal button
            if (button.Button >= 48 && button.Button <= 175)
            {
                return(state.Value != 0);
            }
            return(null);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Listens input for Virtua-R Limit
        /// </summary>
        /// <param name="state">JoystickUpdate state.</param>
        /// <param name="useSto0Z">Use stoozes special driving controls.</param>
        /// <param name="joystickMapping">Joystick mapping.</param>
        private static void VrlInput(JoystickUpdate state, bool useSto0Z, JoystickMapping joystickMapping)
        {
            PlayerButtons playerButtons = InputCode.PlayerOneButtons;

            HandleDefaultWheelControls(state, joystickMapping, useSto0Z);
            HandleDefaultSpecialButtons(state, joystickMapping, playerButtons);
        }
Exemplo n.º 12
0
        public StatePacket(JoystickUpdate state)
        {
            //get the offset of the state
            Offset = state.Offset.ToString();

            //get the value of the state
            Value = Convert.ToUInt16(state.Value);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Listens input for Sega Sonic.
        /// </summary>
        /// <param name="state">JoystickUpdate state.</param>
        /// <param name="joystickMapping">Joystick mapping.</param>
        private static void SegaSonicInput(JoystickUpdate state, JoystickMapping joystickMapping)
        {
            var playerButtons = InputCode.PlayerOneButtons;

            HandleDefaultWheelControls(state, joystickMapping);
            HandleDefaultSpecialButtons(state, joystickMapping, playerButtons);
            playerButtons.Button1 = GetButtonPress(joystickMapping.SonicItem, state);
        }
Exemplo n.º 14
0
        static ParseUpdateResult parseUpdate(JoystickUpdate update, PartialJoystickState state)
        {
            JoystickButtons btn  = (JoystickButtons)update.Offset;
            string          data = btn.ToString();

            switch (btn)
            {
            case JoystickButtons.X:
            case JoystickButtons.A:
            case JoystickButtons.B:
            case JoystickButtons.Y:
            case JoystickButtons.LB:
            case JoystickButtons.RB:
            case JoystickButtons.LT:
            case JoystickButtons.RT:
            case JoystickButtons.BACK:
            case JoystickButtons.START:
            case JoystickButtons.LJ:
            case JoystickButtons.RJ:
                data += " " + (update.Value == 128 ? 1 : 0);
                break;

            case JoystickButtons.POV:     //Top, Bottom, Left, Right
                double val = update.Value / 100;
                val   = ((val > 180.0) && (val < 360.0)) ? val - 360.0 : val;
                val   = (update.Value == -1) ? -1 : val;
                data += " " + ((update.Value == 0) || (update.Value == 4500) || (update.Value == 31500) ? 1 : 0) + " "
                        + ((update.Value == 18000) || (update.Value == 13500) || (update.Value == 22500) ? 1 : 0) + " "
                        + ((update.Value == 27000) || (update.Value == 22500) || (update.Value == 31500) ? 1 : 0) + " "
                        + ((update.Value == 9000) || (update.Value == 4500) || (update.Value == 13500) ? 1 : 0) + " " + (val).ToString();
                break;

            case JoystickButtons.LX:
                state.lx = deadband(((update.Value / 65535.0) - 0.5) * 2.0, 0.05);
                data     = "L " + calcJoystick(state.lx, state.ly);
                break;

            case JoystickButtons.LY:
                state.ly = deadband(((update.Value / 65535.0) - 0.5) * -2.0, 0.05);
                data     = "L " + calcJoystick(state.lx, state.ly);
                break;

            case JoystickButtons.RX:
                state.rx = deadband(((update.Value / 65535.0) - 0.5) * 2.0, 0.05);
                data     = "R " + calcJoystick(state.rx, state.ry);
                break;

            case JoystickButtons.RY:
                state.ry = deadband(((update.Value / 65535.0) - 0.5) * -2.0, 0.05);
                data     = "R " + calcJoystick(state.rx, state.ry);
                break;

            default:
                data = update.ToString();
                break;
            }
            return(new ParseUpdateResult(state, data));
        }
        private void ProcessUpdate(JoystickUpdate update)
        {
            GameControllerButtonMapping unsetButtonMapping = null;
            GameControllerAxisMapping   unsetAxisMapping   = null;
            string name = "<Unknown>";

            _Controller.JoystickObjects.TryGetValue(update.Offset, out name);

            if (_CurrentSetting == GameControllerCurrentSetting.ButtonCommand && update.RawOffset >= 48 && update.RawOffset <= 175)
            {
                if (SelectedButtonMapping != null)
                {
                    SelectedButtonMapping.JoystickOffset = update.Offset;
                    SelectedButtonMapping.Name           = name;
                    unsetButtonMapping = Controller.ButtonMappings.Where(m => m.Command != SelectedButtonMapping.Command && m.JoystickOffset == update.Offset).FirstOrDefault();
                }
            }
            else if (_CurrentSetting == GameControllerCurrentSetting.ButtonCommand && update.RawOffset >= 32 && update.RawOffset <= 44) // POV controls
            {
                if (SelectedButtonMapping != null)
                {
                    GameControllerPOVDirection direction = GameController.GetPOVDirection(update);
                    if (direction != GameControllerPOVDirection.UNMAPPED)
                    {
                        SelectedButtonMapping.JoystickOffset = update.Offset;
                        SelectedButtonMapping.Name           = $"{name} ({direction})";
                        SelectedButtonMapping.POVDirection   = direction;
                        unsetButtonMapping = Controller.ButtonMappings.Where(m => m.Command != SelectedButtonMapping.Command && m.JoystickOffset == update.Offset && m.POVDirection == direction).FirstOrDefault();
                    }
                }
            }
            else if (update.RawOffset <= 20) // Axis
            {
                if (_CurrentSetting == GameControllerCurrentSetting.AxisCommand)
                {
                    if (SelectedAxisMapping != null)
                    {
                        SelectedAxisMapping.JoystickOffset = update.Offset;
                        SelectedAxisMapping.Name           = name;
                        unsetAxisMapping = Controller.AxisMappings.Where(m => m.Command != SelectedAxisMapping.Command && m.JoystickOffset == update.Offset).FirstOrDefault();
                    }
                }
            }

            if (unsetButtonMapping != null)
            {
                unsetButtonMapping.JoystickOffset = null;
                unsetButtonMapping.Name           = null;
                unsetButtonMapping.POVDirection   = GameControllerPOVDirection.UNMAPPED;
            }

            if (unsetAxisMapping != null)
            {
                unsetAxisMapping.Name             = null;
                unsetAxisMapping.JoystickOffset   = null;
                unsetAxisMapping.ReverseDirection = false;
            }
        }
Exemplo n.º 16
0
 private void GoldenGunGuns(JoystickUpdate state, PlayerButtons playerButtons, JoystickMapping joystickMapping)
 {
     HandleDefaultSpecialButtons(state, joystickMapping, playerButtons);
     GetDirectionPress(playerButtons, joystickMapping.GunUp, state, Direction.Right);
     GetDirectionPress(playerButtons, joystickMapping.GunDown, state, Direction.Left);
     GetDirectionPress(playerButtons, joystickMapping.GunLeft, state, Direction.Down);
     GetDirectionPress(playerButtons, joystickMapping.GunRight, state, Direction.Up);
     playerButtons.Button1 = GetButtonPress(joystickMapping.GunTrigger, state);
 }
Exemplo n.º 17
0
        public EventController(Joystick joystick, JoystickUpdate joystickUpdate) : base()
        {
            Joystick       = joystick;
            JoystickUpdate = joystickUpdate;

            Type        = GetEventType();
            POVState    = GetPOVState();
            Button      = GetButton();
            ButtonValue = GetButtonState();
        }
Exemplo n.º 18
0
 /// <summary>
 /// Determines whether [is relevant update] [the specified state].
 /// </summary>
 /// <param name="state">The state.</param>
 /// <returns>
 ///   <c>true</c> if [is relevant update] [the specified state]; otherwise, <c>false</c>.
 /// </returns>
 private bool IsRelevantUpdate(JoystickUpdate state)
 {
     return
         (state.Offset >= JoystickOffset.Buttons0 &&
          state.Offset <= JoystickOffset.Buttons127 &&
          state.Value == 128 ||
          // POV XBOX ONE.
          (state.RawOffset == 32 && (state.Value == JoystickConstants.POV_UP_BUTTON_VALUE || state.Value == JoystickConstants.POV_RIGHT_BUTTONS_VALUE || state.Value == JoystickConstants.POV_DOWN_BUTTONS_VALUE || state.Value == JoystickConstants.POV_LEFT_BUTTONS_VALUE)) ||
          // POV DINPUT.
          ((state.Offset.ToString() == "X" || state.Offset.ToString() == "Y") && (state.Value == 0 || state.Value == UInt16.MaxValue)));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Listens input for Initial D6.
 /// </summary>
 /// <param name="state">JoystickUpdate state.</param>
 /// <param name="useSto0Z">Use stoozes special driving controls.</param>
 /// <param name="joystickMapping">Joystick mapping.</param>
 private static void InitialD6Input(JoystickUpdate state, bool useSto0Z, JoystickMapping joystickMapping)
 {
     HandleDefaultWheelControls(state, joystickMapping, useSto0Z);
     HandleDefaultSpecialButtons(state, joystickMapping, InputCode.PlayerOneButtons);
     InputCode.PlayerOneButtons.Button1 = GetButtonPress(joystickMapping.InitialD6ViewChange, state);
     InputCode.PlayerOneButtons.Up      = GetButtonPress(joystickMapping.InitialD6MenuUp, state);
     InputCode.PlayerOneButtons.Down    = GetButtonPress(joystickMapping.InitialD6MenuDown, state);
     InputCode.PlayerOneButtons.Left    = GetButtonPress(joystickMapping.InitialD6MenuLeft, state);
     InputCode.PlayerOneButtons.Right   = GetButtonPress(joystickMapping.InitialD6MenuRight, state);
     InputCode.PlayerTwoButtons.Up      = GetButtonPress(joystickMapping.InitialD6ShiftUp, state);
     InputCode.PlayerTwoButtons.Down    = GetButtonPress(joystickMapping.InitialD6ShiftDown, state);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Listens input for Standard JVS ABDE button layout. Some games use this. (TX1/2 various game testing)
 /// </summary>
 /// <param name="state">JoystickUpdate state.</param>
 /// <param name="playerButtons">Player whos buttons to populate.</param>
 /// <param name="joystickMapping">Joystick mapping.</param>
 private static void StandardJvsAbdeController(JoystickUpdate state, PlayerButtons playerButtons, JoystickMapping joystickMapping)
 {
     HandleDefaultSpecialButtons(state, joystickMapping, playerButtons);
     GetDirectionPress(playerButtons, joystickMapping.Up, state, Direction.Up);
     GetDirectionPress(playerButtons, joystickMapping.Down, state, Direction.Down);
     GetDirectionPress(playerButtons, joystickMapping.Left, state, Direction.Left);
     GetDirectionPress(playerButtons, joystickMapping.Right, state, Direction.Right);
     playerButtons.Button1 = GetButtonPress(joystickMapping.Button1, state);
     playerButtons.Button2 = GetButtonPress(joystickMapping.Button2, state);
     playerButtons.Button4 = GetButtonPress(joystickMapping.Button3, state);
     playerButtons.Button5 = GetButtonPress(joystickMapping.Button4, state);
 }
        public RLocalButtonState KeyStateToStructure(JoystickUpdate update, bool raw)
        {
            var buttonState = new RLocalButtonState();

            buttonState.value    = update.Value;
            buttonState.rawInput = update.Offset.ToString();

            buttonState.button = RLocalInput.MapButtonToId[buttonState.rawInput];

            //if (!map.TryGetValue(buttonName, out buttonState.button)) return null;

            return(buttonState);
        }
Exemplo n.º 22
0
            public JoystickUpdate[] GetBufferedData()
            {
                if (TestData == null)
                {
                    throw new Exception("forced exception");
                }

                var returnData = new JoystickUpdate[TestData.Length];

                TestData.CopyTo(returnData, 0);
                TestData = new JoystickUpdate[_dataBufferSize];
                return(returnData);
            }
Exemplo n.º 23
0
 public ButtonEventArgs(JoystickUpdate state) : base(state)
 {
     ID = state.RawOffset - 48;
     if (state.Value == 0)
     {
         Released = true;
         Pressed  = false;
     }
     else
     {
         Pressed  = false;
         Released = true;
     }
 }
Exemplo n.º 24
0
 private void JoystickOffsetY(JoystickUpdate joystickUpdate)
 {
     if (joystickUpdate.Value < 32511)
     {
         InputDeviceVerticalAxisUpEvent?.Invoke(this, new JoystickValueEventArgs {
             Value = joystickUpdate.Value
         });
     }
     else if (joystickUpdate.Value > 32511)
     {
         InputDeviceVerticalAxisDownEvent?.Invoke(this, new JoystickValueEventArgs {
             Value = joystickUpdate.Value
         });
     }
 }
Exemplo n.º 25
0
 private void JoystickOffsetX(JoystickUpdate joystickUpdate)
 {
     if (joystickUpdate.Value < 32511)
     {
         InputDeviceHorizontalAxisLeftEvent?.Invoke(this, new JoystickValueEventArgs {
             Value = joystickUpdate.Value
         });
     }
     else if (joystickUpdate.Value > 32511)
     {
         InputDeviceHorizontalAxisRightEvent?.Invoke(this, new JoystickValueEventArgs {
             Value = joystickUpdate.Value
         });
     }
 }
Exemplo n.º 26
0
 private void JoystickOffsetButtons10(JoystickUpdate joystickUpdate)
 {
     if (joystickUpdate.Value == 0)
     {
         InputDeviceButton10UpEvent?.Invoke(this, new JoystickValueEventArgs {
             Value = joystickUpdate.Value
         });
     }
     else if (joystickUpdate.Value > 0)
     {
         InputDeviceButton10DownEvent?.Invoke(this, new JoystickValueEventArgs {
             Value = joystickUpdate.Value
         });
     }
 }
Exemplo n.º 27
0
        private void OnJoystickUpdated(object sender, JoystickUpdate update)
        {
            if (update.Offset != _joystickOffset)
            {
                return;
            }

            if (update.Value == 0)
            {
                return; //Button released
            }

            //Invoking click on main thread
            Invoke(new Action(() => { _takeSinglePhotoButton.PerformClick(); }));
        }
Exemplo n.º 28
0
        private JoystickUpdate MapValue(JoystickUpdate input)
        {
            if (input.Offset == JoystickOffset.Y || input.Offset == JoystickOffset.RotationZ || input.Offset == JoystickOffset.Z || input.Offset == JoystickOffset.X)
            {
                if (input.Value < _center + _deadband && input.Value > _center - _deadband)
                {
                    input.Value = 0;
                }
                else
                {
                    input.Value = remap(input.Value, 0, 65535, 100, -100);
                }
            }

            return(input);
        }
Exemplo n.º 29
0
        public DPadEventArgs(JoystickUpdate state) : base(state)
        {
            if (state.Value == -1)
            {
                Released = true;
                return;
            }
            switch (state.Value / 4500)
            {
            case 0:
                UP = true;
                break;

            case 1:
                UP    = true;
                RIGHT = true;
                break;

            case 2:
                RIGHT = true;
                break;

            case 3:
                RIGHT = true;
                DOWN  = true;
                break;

            case 4:
                DOWN = true;
                break;

            case 5:
                DOWN = true;
                LEFT = true;
                break;

            case 6:
                LEFT = true;
                break;

            case 7:
                LEFT = true;
                UP   = true;
                break;
            }
        }
Exemplo n.º 30
0
        static ControllerUpdate parseUpdate(JoystickUpdate update, JoystickControlUpdate l, JoystickControlUpdate r, double direction)
        {
            JoystickButtons btn = (JoystickButtons)update.Offset;

            switch (btn)
            {
            case JoystickButtons.X:
            case JoystickButtons.A:
            case JoystickButtons.B:
            case JoystickButtons.Y:
            case JoystickButtons.LB:
            case JoystickButtons.RB:
            case JoystickButtons.LT:
            case JoystickButtons.RT:
            case JoystickButtons.BACK:
            case JoystickButtons.START:
            case JoystickButtons.LJ:
            case JoystickButtons.RJ:
                return(new ButtonUpdate(btn, update.Value == 128));

            //case JoystickButtons.POV: //Top, Bottom, Left, Right
            //    double val = update.Value / 100;
            //    val = ((val > 180.0) && (val < 360.0)) ? val - 360.0 : val;
            //    val = (update.Value == -1) ? -1 : val;
            //    data += " " + ((update.Value == 0) || (update.Value == 4500) || (update.Value == 31500) ? 1 : 0) + " "
            //                + ((update.Value == 18000) || (update.Value == 13500) || (update.Value == 22500) ? 1 : 0) + " "
            //                + ((update.Value == 27000) || (update.Value == 22500) || (update.Value == 31500) ? 1 : 0) + " "
            //                + ((update.Value == 9000) || (update.Value == 4500) || (update.Value == 13500) ? 1 : 0) + " " + (val).ToString();
            //    break;
            case JoystickButtons.LX:
                return(new JoystickControlUpdate(btn, deadband(((update.Value / 65535.0) - 0.5) * -2.0 * direction, 0.25), l.y));

            case JoystickButtons.LY:
                return(new JoystickControlUpdate(btn, l.x, deadband(((update.Value / 65535.0) - 0.5) * 2.0 * direction, 0.25)));

            case JoystickButtons.RX:
                return(new JoystickControlUpdate(btn, deadband(((update.Value / 65535.0) - 0.5) * -2.0 * direction, 0.25), r.y));

            case JoystickButtons.RY:
                return(new JoystickControlUpdate(btn, r.x, deadband(((update.Value / 65535.0) - 0.5) * 2.0 * direction, 0.25)));

            default:
                return(null);
            }
        }