// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/Constants.java
// public class Constants {
//     public static final int FLOAT_SIZE_BYTES = 4;
//     public static final int SHORT_SIZE_BYTES = 2;
//     //Sensor
//     public static final int SENSOR_ACC= Sensor.TYPE_ACCELEROMETER;
//     public static final int SENSOR_MAG=Sensor.TYPE_MAGNETIC_FIELD;
//     public static final int SENSOR_ROT=Sensor.TYPE_ROTATION_VECTOR;
// 
// }
// 
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/SensorUtils.java
// public class SensorUtils {
//     private static float[] mTmp = new float[16];
//     private static float[] oTmp = new float[16];
// 
//     //by default, the coordinate is remapped to landscape
//     public static void sensorRotationVectorToMatrix(SensorEvent event, int deviceRotation, float[] output) {
//         float[] values = event.values;
//         switch (deviceRotation){
//             case Surface.ROTATION_0:
//                 SensorManager.getRotationMatrixFromVector(output, values);
//                 break;
//             default:
//                 SensorManager.getRotationMatrixFromVector(mTmp, values);
//                 SensorManager.remapCoordinateSystem(mTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, output);
//         }
//         Matrix.rotateM(output, 0, 90.0F, 1.0F, 0.0F, 0.0F);
//     }
// 
//     public static void getOrientation(SensorEvent event,float[] output){
//         //sensorRotationVectorToMatrix(event,oTmp);
//         SensorManager.getRotationMatrixFromVector(oTmp, event.values);
//         SensorManager.getOrientation(oTmp,output);
//     }
// 
//     public static void getOrientationFromRotationMatrix(float[] rotationMatrix,float[] output){
//         SensorManager.getOrientation(rotationMatrix,output);
//     }
// }
// 
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/StatusHelper.java
// public class StatusHelper {
//     private PanoStatus panoStatus;
//     private PanoMode panoDisPlayMode;
//     private PanoMode panoInteractiveMode;
//     private Context context;
//     public StatusHelper(Context context) {
//         this.context = context;
//     }
// 
//     public Context getContext() {
//         return context;
//     }
// 
//     public PanoStatus getPanoStatus() {
//         return panoStatus;
//     }
// 
//     public void setPanoStatus(PanoStatus panoStatus) {
//         this.panoStatus = panoStatus;
//     }
// 
//     public PanoMode getPanoDisPlayMode() {
//         return panoDisPlayMode;
//     }
// 
//     public void setPanoDisPlayMode(PanoMode panoDisPlayMode) {
//         this.panoDisPlayMode = panoDisPlayMode;
//     }
// 
//     public PanoMode getPanoInteractiveMode() {
//         return panoInteractiveMode;
//     }
// 
//     public void setPanoInteractiveMode(PanoMode panoInteractiveMode) {
//         this.panoInteractiveMode = panoInteractiveMode;
//     }
// }


import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.view.Surface;
import com.martin.ads.vrlib.constant.Constants;
import com.martin.ads.vrlib.utils.SensorUtils;
import com.martin.ads.vrlib.utils.StatusHelper;
package com.martin.ads.vrlib;




/**
 * Project: Pano360
 * Package: com.martin.ads.pano360
 * Created by Ads on 2016/5/2.
 */
public class SensorEventHandler implements SensorEventListener {

    public static String TAG = "SensorEventHandler";

    private float[] rotationMatrix = new float[16];

    //private float[] orientationData=new float[3];

    private StatusHelper statusHelper;
    private SensorHandlerCallback sensorHandlerCallback;

    private boolean sensorRegistered;
    private SensorManager sensorManager;

    private int mDeviceRotation;

    public void init(){
        sensorRegistered=false;
        sensorManager = (SensorManager) statusHelper.getContext()
                .getSystemService(Context.SENSOR_SERVICE);
        Sensor sensorRot = sensorManager.getDefaultSensor(Constants.SENSOR_ROT);
        if (sensorRot==null) return;
        sensorManager.registerListener(this, sensorRot, SensorManager.SENSOR_DELAY_GAME);
        sensorRegistered=true;
    }

    public void releaseResources(){
        if (!sensorRegistered || sensorManager==null) return;
        sensorManager.unregisterListener(this);
        sensorRegistered = false;
    }


    @Override
    public void onSensorChanged(SensorEvent event) {
        if (event.accuracy != 0){
            int type = event.sensor.getType();
            switch (type){
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/Constants.java
// public class Constants {
//     public static final int FLOAT_SIZE_BYTES = 4;
//     public static final int SHORT_SIZE_BYTES = 2;
//     //Sensor
//     public static final int SENSOR_ACC= Sensor.TYPE_ACCELEROMETER;
//     public static final int SENSOR_MAG=Sensor.TYPE_MAGNETIC_FIELD;
//     public static final int SENSOR_ROT=Sensor.TYPE_ROTATION_VECTOR;
// 
// }
// 
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/SensorUtils.java
// public class SensorUtils {
//     private static float[] mTmp = new float[16];
//     private static float[] oTmp = new float[16];
// 
//     //by default, the coordinate is remapped to landscape
//     public static void sensorRotationVectorToMatrix(SensorEvent event, int deviceRotation, float[] output) {
//         float[] values = event.values;
//         switch (deviceRotation){
//             case Surface.ROTATION_0:
//                 SensorManager.getRotationMatrixFromVector(output, values);
//                 break;
//             default:
//                 SensorManager.getRotationMatrixFromVector(mTmp, values);
//                 SensorManager.remapCoordinateSystem(mTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, output);
//         }
//         Matrix.rotateM(output, 0, 90.0F, 1.0F, 0.0F, 0.0F);
//     }
// 
//     public static void getOrientation(SensorEvent event,float[] output){
//         //sensorRotationVectorToMatrix(event,oTmp);
//         SensorManager.getRotationMatrixFromVector(oTmp, event.values);
//         SensorManager.getOrientation(oTmp,output);
//     }
// 
//     public static void getOrientationFromRotationMatrix(float[] rotationMatrix,float[] output){
//         SensorManager.getOrientation(rotationMatrix,output);
//     }
// }
// 
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/StatusHelper.java
// public class StatusHelper {
//     private PanoStatus panoStatus;
//     private PanoMode panoDisPlayMode;
//     private PanoMode panoInteractiveMode;
//     private Context context;
//     public StatusHelper(Context context) {
//         this.context = context;
//     }
// 
//     public Context getContext() {
//         return context;
//     }
// 
//     public PanoStatus getPanoStatus() {
//         return panoStatus;
//     }
// 
//     public void setPanoStatus(PanoStatus panoStatus) {
//         this.panoStatus = panoStatus;
//     }
// 
//     public PanoMode getPanoDisPlayMode() {
//         return panoDisPlayMode;
//     }
// 
//     public void setPanoDisPlayMode(PanoMode panoDisPlayMode) {
//         this.panoDisPlayMode = panoDisPlayMode;
//     }
// 
//     public PanoMode getPanoInteractiveMode() {
//         return panoInteractiveMode;
//     }
// 
//     public void setPanoInteractiveMode(PanoMode panoInteractiveMode) {
//         this.panoInteractiveMode = panoInteractiveMode;
//     }
// }


// Path: vrlib/src/main/java/com/martin/ads/vrlib/SensorEventHandler.java
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.view.Surface;
import com.martin.ads.vrlib.constant.Constants;
import com.martin.ads.vrlib.utils.SensorUtils;
import com.martin.ads.vrlib.utils.StatusHelper;

package com.martin.ads.vrlib;




/**
 * Project: Pano360
 * Package: com.martin.ads.pano360
 * Created by Ads on 2016/5/2.
 */
public class SensorEventHandler implements SensorEventListener {

    public static String TAG = "SensorEventHandler";

    private float[] rotationMatrix = new float[16];

    //private float[] orientationData=new float[3];

    private StatusHelper statusHelper;
    private SensorHandlerCallback sensorHandlerCallback;

    private boolean sensorRegistered;
    private SensorManager sensorManager;

    private int mDeviceRotation;

    public void init(){
        sensorRegistered=false;
        sensorManager = (SensorManager) statusHelper.getContext()
                .getSystemService(Context.SENSOR_SERVICE);
        Sensor sensorRot = sensorManager.getDefaultSensor(Constants.SENSOR_ROT);
        if (sensorRot==null) return;
        sensorManager.registerListener(this, sensorRot, SensorManager.SENSOR_DELAY_GAME);
        sensorRegistered=true;
    }

    public void releaseResources(){
        if (!sensorRegistered || sensorManager==null) return;
        sensorManager.unregisterListener(this);
        sensorRegistered = false;
    }


    @Override
    public void onSensorChanged(SensorEvent event) {
        if (event.accuracy != 0){
            int type = event.sensor.getType();
            switch (type){
                case Constants.SENSOR_ROT: