Skip to content

Instantly share code, notes, and snippets.

@victorkp

victorkp/Example.java Secret

Last active Feb 4, 2020
Embed
What would you like to do?
/**
* IDs for varoius EyeGestures
*/
private class GestureIds {
public int BLINK_ID;
public int WINK_ID;
public int DOUBLE_BLINK_ID;
public int DOUBLE_WINK_ID;
public int LOOK_AT_SCREEN_ID;
public int LOOK_AWAY_FROM_SCREEN_ID;
public GestureIds() {
BLINK_ID = EyeGesture.BLINK.getId();
WINK_ID = EyeGesture.WINK.getId();
DOUBLE_BLINK_ID = EyeGesture.DOUBLE_BLINK.getId();
DOUBLE_WINK_ID = EyeGesture.DOUBLE_WINK.getId();
LOOK_AT_SCREEN_ID = EyeGesture.LOOK_AT_SCREEN.getId();
LOOK_AWAY_FROM_SCREEN_ID = EyeGesture.LOOK_AWAY_FROM_SCREEN.getId();
}
}
/****
**** Somewhere in onCreate/onResume/Whatever init method
****/
mGestureIds = new GestureIds();
// Setup for the eye gestures
mEyeGestureManager = EyeGestureManager.from(mContext);
mEyeGestureListener = new EyeGestureManager.Listener(){
public void onDetected(EyeGesture gesture) {
Log.i("EyeGestureListener", "Gesture: " + gesture.getId());
int id = gesture.getId();
if(id == mGestureIds.WINK_ID || id == mGestureIds.DOUBLE_WINK_ID) {
mSleepLevel += MODIFIER_WINK;
Log.d("EyeGesture", "Wink");
} else if (id == mGestureIds.BLINK_ID || id == mGestureIds.DOUBLE_BLINK_ID){
Log.d("EyeGesture", "Blink");
} else if (id == mGestureIds.LOOK_AT_SCREEN_ID || id == mGestureIds.LOOK_AWAY_FROM_SCREEN_ID) {
Log.d("EyeGesture", "Screen");
}
}
};
package com.google.android.glass.eye;
import android.os.Parcel;
import android.os.Parcelable;
public enum EyeGesture implements Parcelable {
BLINK, DOFF, DON, DOUBLE_BLINK, DOUBLE_WINK, LOOK_AT_SCREEN, LOOK_AWAY_FROM_SCREEN, WINK;
public int getId() {
return -1;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel arg0, int arg1) {
}
}
package com.google.android.glass.eye;
import android.content.Context;
public class EyeGestureManager {
public static final int INFINITE_TIMEOUT = -1;
public static final String SERVICE_NAME = "eye_gesture";
public interface Listener {
public void onDetected(EyeGesture gesture);
}
public static EyeGestureManager from(Context paramContext) {
return null;
}
public void activateGazeLogging(boolean paramBoolean) {
}
public boolean applyAndSaveCalibration(EyeGesture paramEyeGesture) {
return false;
}
public boolean clearCalibration(EyeGesture paramEyeGesture) {
return false;
}
public void enableGazeService(boolean paramBoolean) {
}
public boolean endCalibrationInterval(EyeGesture paramEyeGesture) {
return false;
}
public boolean isCalibrationComplete(EyeGesture paramEyeGesture) {
return false;
}
public boolean isGazeLogging() {
return false;
}
public boolean isRegistered() {
return false;
}
public boolean isSupported(EyeGesture paramEyeGesture) {
return false;
}
public boolean loadCalibration(EyeGesture paramEyeGesture) {
return false;
}
public boolean register(EyeGesture gesture, EyeGestureManager.Listener listener){
return false;
}
public boolean startCalibrationInterval(EyeGesture paramEyeGesture) {
return false;
}
public boolean unregister(EyeGesture gesture, EyeGestureManager.Listener listener) {
return false;
}
public boolean addListener(EyeGesture gesture, EyeGestureManager.Listener listener, boolean bool) {
return false;
}
public boolean removeListener(EyeGesture gesture, EyeGestureManager.Listener listener) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.