changed input script

This commit is contained in:
2024-06-07 16:21:40 +02:00
parent dd37b52e83
commit 495aaa9b09

View File

@@ -111,9 +111,7 @@ public class InputProcessor {
while (this.exercisesRemaining > 0) { while (this.exercisesRemaining > 0) {
if ( this.totalChecks == 0 || this.selfRotationVectorPaths == null if ( this.totalChecks == 0 || this.selfRotationVectorPaths == null
|| this.selfRotationVectorPaths.length == 0 || this.selfRotationVectorPaths.length == 0)
|| this.selfRotationVectorPaths[0].size() == 0
|| this.selfRotationVectorPaths[1].size() == 0)
continue; continue;
boolean isFaulty = this.isFaultyMovement(); boolean isFaulty = this.isFaultyMovement();
@@ -420,10 +418,10 @@ public class InputProcessor {
* Function for checking whether the last movement was faulty * Function for checking whether the last movement was faulty
*/ */
public boolean isFaultyMovement() { public boolean isFaultyMovement() {
boolean[] deviceMovementStatus = new boolean[selfRotationVectorPaths.length]; boolean upMovementDetected = false;
boolean downMovementDetected = false;
for (int i = 0; i < selfRotationVectorPaths.length; i++) { for (List<Vector3f> path : selfRotationVectorPaths) {
List<Vector3f> path = selfRotationVectorPaths[i];
if (path.size() < 2) { if (path.size() < 2) {
continue; // Skip if there are not enough points to compare continue; // Skip if there are not enough points to compare
} }
@@ -434,17 +432,16 @@ public class InputProcessor {
float y1 = firstPoint.y; float y1 = firstPoint.y;
float y2 = lastPoint.y; float y2 = lastPoint.y;
// Assuming that a good movement is when y2 is greater than y1 if (y2 > y1) {
deviceMovementStatus[i] = y2 > y1; upMovementDetected = true;
} } else if (y2 < y1) {
downMovementDetected = true;
}
// Return true for faulty movement if any device has faulty movement if (upMovementDetected && downMovementDetected) {
for (boolean isGood : deviceMovementStatus) { return false; // Return false for faulty movement if both up and down movements are detected
if (!isGood) {
return true;
} }
} }
return false; return true; // Return true for faulty movement if only up or down movement is detected
} }}
}