-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from eszdman/dev
Dev
- Loading branch information
Showing
90 changed files
with
4,054 additions
and
1,046 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,3 +83,5 @@ lint/generated/ | |
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ | ||
/app/google-services.json | ||
/.idea/codeStyles/Project.xml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# For more information about using CMake with Android Studio, read the | ||
# documentation: https://d.android.com/studio/projects/add-native-code.html | ||
|
||
# Sets the minimum version of CMake required to build the native library. | ||
|
||
cmake_minimum_required(VERSION 3.4.1) | ||
|
||
# Creates and names a library, sets it as either STATIC | ||
# or SHARED, and provides the relative paths to its source code. | ||
# You can define multiple libraries, and CMake builds them for you. | ||
# Gradle automatically packages shared libraries with your APK. | ||
|
||
add_library( # Sets the name of the library. | ||
native-photon_accel | ||
|
||
# Sets the library as a shared library. | ||
SHARED | ||
|
||
# Provides a relative path to your source file(s). | ||
native-lib.cpp ) | ||
|
||
# Searches for a specified prebuilt library and stores the path as a | ||
# variable. Because CMake includes system libraries in the search path by | ||
# default, you only need to specify the name of the public NDK library | ||
# you want to add. CMake verifies that the library exists before | ||
# completing its build. | ||
|
||
find_library( # Sets the name of the path variable. | ||
log-lib | ||
|
||
# Specifies the name of the NDK library that | ||
# you want CMake to locate. | ||
log ) | ||
|
||
# Specifies libraries CMake should link to your target library. You | ||
# can link multiple libraries, such as libraries you define in this | ||
# build script, prebuilt third-party libraries, or system libraries. | ||
set_target_properties(native-photon_accel PROPERTIES OUTPUT_NAME "photon_accel") | ||
target_link_libraries( # Specifies the target library. | ||
native-photon_accel | ||
|
||
# Links the target library to the log library | ||
# included in the NDK. | ||
${log-lib} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <jni.h> | ||
#include <string> | ||
#include <android/log.h> | ||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "photon_native", __VA_ARGS__) | ||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "photon_native", __VA_ARGS__) | ||
extern "C" | ||
JNIEXPORT void JNICALL | ||
Java_com_eszdman_photoncamera_Wrapper_Test(JNIEnv *env, jclass clazz) { | ||
LOGD("Yeah, working"); | ||
} | ||
extern "C" | ||
JNIEXPORT jobject JNICALL | ||
Java_com_eszdman_photoncamera_Wrapper_ProcessOpenCL(JNIEnv *env, jclass clazz, jobject in) { | ||
// TODO: implement ProcessOpenCL() | ||
|
||
} |
Binary file not shown.
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/eszdman/photoncamera/Control/Gravity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.eszdman.photoncamera.Control; | ||
|
||
import android.content.Context; | ||
import android.hardware.Sensor; | ||
import android.hardware.SensorEvent; | ||
import android.hardware.SensorEventListener; | ||
import android.hardware.SensorManager; | ||
import android.util.Log; | ||
|
||
import com.eszdman.photoncamera.api.Interface; | ||
|
||
import java.nio.IntBuffer; | ||
|
||
public class Gravity { | ||
private static String TAG = "Gravity"; | ||
private SensorManager mSensorManager; | ||
private Sensor mGravitySensor; | ||
public float[] mGravity; | ||
|
||
|
||
public Gravity(){ | ||
mSensorManager = (SensorManager) Interface.i.mainActivity.getSystemService(Context.SENSOR_SERVICE); | ||
mGravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); | ||
|
||
} | ||
public void run(){ | ||
mSensorManager.registerListener(mGravityTracker,mGravitySensor,SensorManager.SENSOR_DELAY_FASTEST); | ||
} | ||
public void stop(){ | ||
mSensorManager.unregisterListener(mGravityTracker,mGravitySensor); | ||
} | ||
private SensorEventListener mGravityTracker = new SensorEventListener() { | ||
@Override | ||
public void onSensorChanged(SensorEvent sensorEvent) { | ||
if (mGravity == null) { | ||
mGravity = sensorEvent.values.clone(); | ||
} | ||
|
||
for (int i = 0; i < sensorEvent.values.length; i++) { | ||
mGravity[i] = sensorEvent.values[i]; | ||
} | ||
} | ||
|
||
@Override | ||
public void onAccuracyChanged(Sensor sensor, int i) { } | ||
}; | ||
public int getRotation() { | ||
|
||
if (mGravity == null) { | ||
return 90; | ||
} | ||
for(float f:mGravity) Log.d(TAG,"gravity:"+f); | ||
if (mGravity[2] > 9f) //pointing at the ground | ||
return 90; | ||
|
||
if (Math.abs(mGravity[0]) > Math.abs(mGravity[1])) { | ||
if (mGravity[0] > 0f) | ||
return 0; | ||
else | ||
return 180; | ||
} else { | ||
if (mGravity[1] > 1.5f) | ||
return 90; | ||
else | ||
return 270; | ||
} | ||
} | ||
public int getCameraRotation(){ | ||
return (Interface.i.camera.mSensorOrientation+Interface.i.gravity.getRotation()+270) % 360; | ||
} | ||
} |
Oops, something went wrong.