コード例 #1
0
        IEnumerator DetectAxis(Step step)
        {
            inputMapper.Init();

            ResetJoystickThumbs();

            InputMapperItem m;

            switch (step)
            {
            case Step.Yaw:
                invertValue = leftJoystickLeftRightInvert.isOn ? -1 : 1;
                break;

            case Step.Throttle:
                invertValue = leftJoystickUpDownInvert.isOn ? -1 : 1;
                break;

            case Step.Roll:
                invertValue = rightJoystickLeftRightInvert.isOn ? -1 : 1;
                break;

            case Step.Pitch:
                invertValue = rightJoystickUpDownInvert.isOn ? -1 : 1;
                break;
            }

            while (cancelAxisDetection == false)
            {
                m = inputMapper.SelectActiveAxis();

                if (m != null)
                {
                    m.invertValue = invertValue;

                    switch (step)
                    {
                    case Step.Yaw:
                        m.trim     = trimHorizontalLeftSlider.GetValue();
                        m.scale    = scaleHorizontalLeftSlider.GetValue();
                        m.deadzone = deadzoneHorizontalLeftSlider.GetValue();
                        break;

                    case Step.Throttle:
                        m.trim     = trimVerticalLeftSlider.GetValue();
                        m.scale    = scaleVerticalLeftSlider.GetValue();
                        m.deadzone = deadzoneVerticalLeftSlider.GetValue();
                        break;

                    case Step.Roll:
                        m.trim     = trimHorizontalRightSlider.GetValue();
                        m.scale    = scaleHorizontalRightSlider.GetValue();
                        m.deadzone = deadzoneHorizontalRightSlider.GetValue();
                        break;

                    case Step.Pitch:
                        m.trim     = trimVerticalRightSlider.GetValue();
                        m.scale    = scaleVerticalRightSlider.GetValue();
                        m.deadzone = deadzoneVerticalRightSlider.GetValue();
                        break;
                    }

                    UpdateInputMap(step, m);

                    float v = InputHelper.GetInputAxis(m.axisName);

                    //Debug.Log(string.Format("m.invertValue={0}", m.invertValue));

                    //Debug.Log(string.Format("InputHelper.GetInputAxis(m.axisName)  m.axisName={0} raw v={1}", m.axisName, v));

                    v = m.ApplyInvertTrimScale(v);

                    //Debug.Log(string.Format("InputHelper.GetInputAxis(m.axisName)  m.axisName={0} m.trim={1} m.scale={2} v={3}", m.axisName, m.trim, m.scale, v));

                    switch (step)
                    {
                    case Step.Yaw:
                        leftThumbMover.LeftRight(v, m.minValue, m.maxValue);
                        break;

                    case Step.Throttle:
                        leftThumbMover.UpDown(v, m.minValue, m.maxValue);
                        break;

                    case Step.Roll:
                        rightThumbMover.LeftRight(v, m.minValue, m.maxValue);
                        break;

                    case Step.Pitch:
                        rightThumbMover.UpDown(v, m.minValue, m.maxValue);
                        break;
                    }
                }

                DisableDroneRacerInput();

                yield return(new WaitForSeconds(updateFreq));
            }

            axisDetectionActive = false;

            //Debug.Log("DetectAxis() end");
        }