예제 #1
0
        private void setReverserPos()
        {
            var axises = JoystickApi.GetAxises();

            InputTranslator.TranslateReverserPosition(axises, out _reverserPos);

            for (int i = 16; i < 19; i++)
            {
                OnKeyUp(new InputEventArgs(Controls[i]));
            }

            if (_reverserPos != _lastReverserPos)
            {
                OnKeyDown(new InputEventArgs(Controls[17 - _reverserPos]));
            }

            _lastReverserPos = _reverserPos;
        }
예제 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            JoystickApi.Update();

            if (JoystickApi.currentDevice != -1)
            {
                var buttonsState = JoystickApi.GetButtonsState();
                var axises       = JoystickApi.GetAxises();

                int lastNotchPosition = _notchPosition;
                if (InputTranslator.TranslateNotchPosition(buttonsState, out _notchPosition))
                {
                    _notchPosition = lastNotchPosition;
                }
                InputTranslator.TranslateReverserPosition(axises, out _reverserPosition);

                {
                    uint notchButtonsState;

                    InputTranslator.MakeBitFromNotchButtons(buttonsState, out notchButtonsState);

                    txtInfoBt7.Text  = ((notchButtonsState & (uint)InputTranslator.BT7_10_Pressed.BT7) != 0) ? "1" : "0";
                    txtInfoBt8.Text  = ((notchButtonsState & (uint)InputTranslator.BT7_10_Pressed.BT8) != 0) ? "1" : "0";
                    txtInfoBt9.Text  = ((notchButtonsState & (uint)InputTranslator.BT7_10_Pressed.BT9) != 0) ? "1" : "0";
                    txtInfoBt10.Text = ((notchButtonsState & (uint)InputTranslator.BT7_10_Pressed.BT10) != 0) ? "1" : "0";
                }

                {
                    if (_reverserPosition > 0)
                    {
                        txtInfoUp.Text   = "1";
                        txtInfoDown.Text = "0";
                    }
                    else if (_reverserPosition < 0)
                    {
                        txtInfoUp.Text   = "0";
                        txtInfoDown.Text = "1";
                    }
                    else
                    {
                        txtInfoUp.Text   = "0";
                        txtInfoDown.Text = "0";
                    }
                }

                string notchPositionString;
                string reverserPositionString;

                if (_notchPosition > 0)
                {
                    notchPositionString = string.Format("P{0}", _notchPosition);
                }
                else if (_notchPosition < 0)
                {
                    if (_notchPosition > -9)
                    {
                        notchPositionString = string.Format("B{0}", _notchPosition);
                    }
                    else
                    {
                        notchPositionString = "EB";
                    }
                }
                else
                {
                    notchPositionString = "N";
                }

                if (_reverserPosition > 0)
                {
                    reverserPositionString = "F";
                }
                else if (_reverserPosition < 0)
                {
                    reverserPositionString = "B";
                }
                else
                {
                    reverserPositionString = "N";
                }

                labelTch.Text      = notchPositionString;
                labelReverser.Text = reverserPositionString;

                configurateSwitch();
            }
            else
            {
                enumerateDevices();
            }
        }