mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-30 11:02:31 -06:00
71 lines
3 KiB
Java
71 lines
3 KiB
Java
package androidx.media3.exoplayer.video.spherical;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.PointF;
|
|
import android.view.GestureDetector;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import androidx.media3.exoplayer.video.spherical.OrientationListener;
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class TouchTracker extends GestureDetector.SimpleOnGestureListener implements View.OnTouchListener, OrientationListener.Listener {
|
|
static final float MAX_PITCH_DEGREES = 45.0f;
|
|
private final GestureDetector gestureDetector;
|
|
private final Listener listener;
|
|
private final float pxPerDegrees;
|
|
private final PointF previousTouchPointPx = new PointF();
|
|
private final PointF accumulatedTouchOffsetDegrees = new PointF();
|
|
private volatile float roll = 3.1415927f;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface Listener {
|
|
void onScrollChange(PointF pointF);
|
|
|
|
default boolean onSingleTapUp(MotionEvent motionEvent) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@Override // androidx.media3.exoplayer.video.spherical.OrientationListener.Listener
|
|
public void onOrientationChange(float[] fArr, float f) {
|
|
this.roll = -f;
|
|
}
|
|
|
|
public TouchTracker(Context context, Listener listener, float f) {
|
|
this.listener = listener;
|
|
this.pxPerDegrees = f;
|
|
this.gestureDetector = new GestureDetector(context, this);
|
|
}
|
|
|
|
@Override // android.view.View.OnTouchListener
|
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
return this.gestureDetector.onTouchEvent(motionEvent);
|
|
}
|
|
|
|
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
|
public boolean onDown(MotionEvent motionEvent) {
|
|
this.previousTouchPointPx.set(motionEvent.getX(), motionEvent.getY());
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
|
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
|
|
float x = (motionEvent2.getX() - this.previousTouchPointPx.x) / this.pxPerDegrees;
|
|
float y = (motionEvent2.getY() - this.previousTouchPointPx.y) / this.pxPerDegrees;
|
|
this.previousTouchPointPx.set(motionEvent2.getX(), motionEvent2.getY());
|
|
double d = this.roll;
|
|
float cos = (float) Math.cos(d);
|
|
float sin = (float) Math.sin(d);
|
|
this.accumulatedTouchOffsetDegrees.x -= (cos * x) - (sin * y);
|
|
this.accumulatedTouchOffsetDegrees.y += (sin * x) + (cos * y);
|
|
PointF pointF = this.accumulatedTouchOffsetDegrees;
|
|
pointF.y = Math.max(-45.0f, Math.min(MAX_PITCH_DEGREES, pointF.y));
|
|
this.listener.onScrollChange(this.accumulatedTouchOffsetDegrees);
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
|
public boolean onSingleTapUp(MotionEvent motionEvent) {
|
|
return this.listener.onSingleTapUp(motionEvent);
|
|
}
|
|
}
|