示例#1
0
        // Use this for initialization
        void Start()
        {
            validateData    = new Regex("(-)*([0-9])+.([0-9])+");
            framerateFilter = new CircularList <float>(60);

            lastUpdate          = System.DateTime.Now;
            actualRotation      = Quaternion.identity;
            baselineRotation    = Quaternion.identity;
            invBaselineRotation = Quaternion.identity;
            lastRotation        = Quaternion.identity;

            headActualRotation      = Quaternion.identity;
            headBaselineRotation    = Quaternion.identity;
            headInvBaselineRotation = Quaternion.identity;

            //Icredibly enough the Unity orientation methods work OK in Japan
            Input.gyro.enabled    = true;
            orientationFilter     = new CircularList <Quaternion>(FilterSize);
            headOrientationFilter = new CircularList <Quaternion>(FilterSize);

            StartCoroutine(FPS());
            CommToAndroid.CallAndroidMethod("setGameObject", this.name);

            if (SystemInfo.deviceType == DeviceType.Handheld)
            {
                SensorMode currentSensor = (SensorMode)System.Enum.Parse(typeof(SensorMode), CommToAndroid.CallAndroidMethod <string>("getSensorMode"));
                if (currentSensor != SourceIMU)
                {
                    SetSourceIMU(SourceIMU);
                }
            }
        }
示例#2
0
        public void SetSourceIMU(SensorMode imu)
        {
            SourceIMU = imu;
            if (SourceIMU != SensorMode.External)
            {
                CommToAndroid.CallAndroidMethod("setSensorMode", SourceIMU.ToString());
            }

            updateCount = 0;
            sensorChangedSetBaseline = false;
        }
示例#3
0
        void SynchUseMagt(string magt)
        {
            useMagnetometer = bool.Parse(magt);

            if (SystemInfo.deviceType != DeviceType.Handheld)
            {
                return;
            }

            CommToAndroid.CallAndroidMethod("toggleMagnetometer");
        }
示例#4
0
        void SynchSensorMode(string sensorMode)
        {
            SourceIMU = (SensorMode)System.Enum.Parse(typeof(SensorMode), sensorMode);;

            if (SystemInfo.deviceType != DeviceType.Handheld)
            {
                return;
            }

            if (SourceIMU != SensorMode.External)
            {
                CommToAndroid.CallAndroidMethod("setSensorMode", SourceIMU.ToString());
            }
        }
示例#5
0
        // Use this for initialization
        void Start()
        {
            //2- sets the right touch input type
            //The EPSON Moverio works with a mouse simulator, not with a touch interface
            TouchInputType = InputType.Mouse;
            if (SystemInfo.deviceModel.CompareTo("samsung SGH-I257M") == 0)
            {
                TouchInputType = InputType.Touch;
            }

            if (SystemInfo.deviceType == DeviceType.Handheld)
            {
                isAndroid = true;
                if (!isJNIInitialized && resetMousePointerOnTouchEnded)
                {
                    CommToAndroid.CallAndroidMethod("setPermissionsForInputDevice");
                }
            }
        }
示例#6
0
        void mipTouchEnded(Vector2 position, Vector2 origin, System.TimeSpan lenght)
        {
            if (touchStarted)
            {
                touchStarted = false;
                if ((System.DateTime.Now - timeLastReset).TotalMilliseconds < FingerUpTimeOut)
                {
                    return;
                }

                MoverioTouchpadEventArgs args = new MoverioTouchpadEventArgs(MoverioTouchpadEventType.TouchEnded);
                args.Position = position;
                args.Origin   = origin;
                args.Duration = lenght;

                MessageBroker.BroadcastAll("OnTouchEnded", args);

                if (isAndroid && resetMousePointerOnTouchEnded)
                {
                    if (!isJNIInitialized)
                    {
                        CommToAndroid.CallAndroidMethod("setDisplaySize", Screen.width, Screen.height);
                        CommToAndroid.CallAndroidMethod("openMouseCursor", "UnityMoverioBT200");

                        isJNIInitialized = true;
                    }
                    else
                    {
                        CommToAndroid.CallAndroidMethod("mouseMove", -1, -1);
                        CommToAndroid.CallAndroidMethod("mouseMove", 180, 100);
                    }

                    touchOrigin       = Input.mousePosition;
                    touchLastPosition = Input.mousePosition;
                    timeLastReset     = System.DateTime.Now;
                }
            }
        }