Exemplo n.º 1
0
        /// <summary>
        /// A function that calls each frame
        /// </summary>
        public void OnUpdateFrame()
        {
            if (m_pauseTick)
            {
                return;
            }

            if (m_first)
            {
                m_configForm.enumerateDevices();
                m_first = false;
            }

            JoystickApi.Update();

            setReverserPos();
            setHandlePos();
            setSwitchState();
        }
Exemplo n.º 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();
            }
        }