Skip to content

Commit

Permalink
Support Oculus SDK 0.2.5. Removed calibration of Mag Cal.
Browse files Browse the repository at this point in the history
  • Loading branch information
StellaArtois authored and mabrowning committed Oct 11, 2013
1 parent fa6d2a4 commit 2a64052
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .public_rev
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8c74fdc80cddca527c3cecad1091184343845405
1c0ca29e061c9a6e784d823e476426d52fb2c7da
5 changes: 0 additions & 5 deletions src/com/mtbs3d/minecrift/MCHydra.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,6 @@ public void resetOrigin() {
resetOrigin = true;
}

@Override
public boolean isCorrecting() {
return false;
}

@Override
public void resetOriginRotation() {
resetOriginRotation = true;
Expand Down
97 changes: 3 additions & 94 deletions src/com/mtbs3d/minecrift/MCOculus.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ public class MCOculus extends OculusRift //OculusRift does most of the heavy lif
public static final int NOT_CALIBRATING = 0;
public static final int CALIBRATE_AWAITING_FIRST_ORIGIN = 1;
public static final int CALIBRATE_AT_FIRST_ORIGIN = 2;
public static final int CALIBRATE_AWAITING_MAG_CAL = 3;
public static final int CALIBRATE_MAG_CAL_WAIT = 4;
public static final int CALIBRATE_AWAITING_SECOND_ORIGIN = 5;
public static final int CALIBRATE_AT_SECOND_ORIGIN = 6;
public static final int CALIBRATE_COOLDOWN = 7;

public static final long COOLDOWNTIME_MS = 1000L;
public static final long MAG_CAL_REPOLL_TIME_MS = 200L;

private boolean isCalibrated = false;
private long coolDownStart = 0L;
private long lastUpdateAt = 0L;
private int calibrationStep = NOT_CALIBRATING;
private int MagCalSampleCount = 0;
private boolean forceMagCalibration = false; // Don't force mag cal initially
Expand All @@ -48,14 +42,6 @@ public String getID() {
public void resetOrigin() {
}

@Override
public boolean isCorrecting() {
if (!isInitialized())
return false;

return _isYawCorrectionInProgress();
}

@Override
public void beginAutomaticCalibration()
{
Expand Down Expand Up @@ -86,32 +72,11 @@ public String getCalibrationStep()
switch (calibrationStep)
{
case CALIBRATE_AWAITING_FIRST_ORIGIN:
case CALIBRATE_AWAITING_SECOND_ORIGIN:
{
step = "Look ahead and press SPACEBAR";
break;
}
case CALIBRATE_AT_FIRST_ORIGIN:
case CALIBRATE_AWAITING_MAG_CAL:
case CALIBRATE_MAG_CAL_WAIT:
{
switch (MagCalSampleCount)
{
case 0:
step = String.format("Look forward (%d/4)", new Object[] {Integer.valueOf(MagCalSampleCount)});
break;
case 1:
step = String.format("Look all the way left (%d/4)", new Object[] {Integer.valueOf(MagCalSampleCount)});
break;
case 2:
step = String.format("Look all the way right (%d/4)", new Object[] {Integer.valueOf(MagCalSampleCount)});
break;
default:
step = String.format("Look all the way up (%d/4)", new Object[] {Integer.valueOf(MagCalSampleCount)});
break;
}
break;
}
case CALIBRATE_COOLDOWN:
{
step = "Done!";
Expand All @@ -134,11 +99,6 @@ public void eventNotification(int eventId)
calibrationStep = CALIBRATE_AT_FIRST_ORIGIN;
processCalibration();
}
else if (calibrationStep == CALIBRATE_AWAITING_SECOND_ORIGIN)
{
calibrationStep = CALIBRATE_AT_SECOND_ORIGIN;
processCalibration();
}
break;
}
case IBasePlugin.EVENT_CALIBRATION_SET_ORIGIN:
Expand Down Expand Up @@ -178,65 +138,14 @@ private void processCalibration()
{
_reset();

// When calibration is called the first time after startup,
// don't force mag calibration if the mag cal is already setup
// (probably from the Oculus profile). After that, always
// force.
// Calibration of Mag cal is now handled solely by the Oculus config utility.

boolean doCalibration = true;
if (!forceMagCalibration)
{
if (_isCalibrated())
doCalibration = false;

// From now on force calibration
forceMagCalibration = true;
}

if (doCalibration)
{
_beginAutomaticCalibration();
MagCalSampleCount = 0;
calibrationStep = CALIBRATE_AWAITING_MAG_CAL;
}
else
{
MagCalSampleCount = 0;
lastUpdateAt = 0;
calibrationStep = CALIBRATE_AT_SECOND_ORIGIN;
}
break;
}
case CALIBRATE_AWAITING_MAG_CAL:
{
MagCalSampleCount = _updateAutomaticCalibration();
if (_isCalibrated())
{
lastUpdateAt = 0;
calibrationStep = CALIBRATE_AWAITING_SECOND_ORIGIN;
}
else
{
lastUpdateAt = System.currentTimeMillis();
calibrationStep = CALIBRATE_MAG_CAL_WAIT;
}
break;
}
case CALIBRATE_MAG_CAL_WAIT:
{
if ((System.currentTimeMillis() - lastUpdateAt) > MAG_CAL_REPOLL_TIME_MS)
{
lastUpdateAt = 0;
calibrationStep = CALIBRATE_AWAITING_MAG_CAL;
}
break;
}
case CALIBRATE_AT_SECOND_ORIGIN:
{
MagCalSampleCount = 0;
coolDownStart = System.currentTimeMillis();
calibrationStep = CALIBRATE_COOLDOWN;
resetOrigin();
notifyListeners(IBasePlugin.EVENT_CALIBRATION_SET_ORIGIN);

break;
}
case CALIBRATE_COOLDOWN:
Expand Down
3 changes: 0 additions & 3 deletions src/com/mtbs3d/minecrift/api/IOrientationProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,4 @@ public interface IOrientationProvider extends IBasePlugin {
* Resets the current position/orientation to the origin
*/
public void resetOrigin();

/* Is orientation adjustment taking place? */
public boolean isCorrecting();
}

0 comments on commit 2a64052

Please sign in to comment.