mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 03:47:18 +01:00
207 lines
14 KiB
Java
207 lines
14 KiB
Java
package androidx.compose.ui.input.pointer;
|
|
|
|
import android.util.SparseBooleanArray;
|
|
import android.util.SparseLongArray;
|
|
import android.view.MotionEvent;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.compose.runtime.internal.StabilityInferred;
|
|
import androidx.compose.ui.geometry.Offset;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Metadata;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@StabilityInferred(parameters = 0)
|
|
@Metadata(d1 = {"\u0000\\\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\b\u0001\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u001f\u0010\u0013\u001a\u0004\u0018\u00010\u00142\u0006\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u0018H\u0000¢\u0006\u0002\b\u0019J\u000e\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u0011J\u0010\u0010\u001d\u001a\u00020\u001b2\u0006\u0010\u0015\u001a\u00020\u0016H\u0002J\u0010\u0010\u001e\u001a\u00020\u001b2\u0006\u0010\u0015\u001a\u00020\u0016H\u0002J\u0014\u0010\u001f\u001a\u00020 *\u00020\u00162\u0006\u0010\u001c\u001a\u00020\u0011H\u0002J\u0017\u0010!\u001a\u00020\"2\u0006\u0010#\u001a\u00020\u0011H\u0002¢\u0006\u0004\b$\u0010%J\u0010\u0010&\u001a\u00020\u001b2\u0006\u0010\u0015\u001a\u00020\u0016H\u0002J(\u0010'\u001a\u00020\u000f2\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0015\u001a\u00020\u00162\u0006\u0010(\u001a\u00020\u00112\u0006\u0010)\u001a\u00020 H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0006\u001a\u00020\u00078\u0000X\u0081\u0004¢\u0006\u000e\n\u0000\u0012\u0004\b\b\u0010\u0003\u001a\u0004\b\t\u0010\nR\u000e\u0010\u000b\u001a\u00020\fX\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u000f0\u000eX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006*"}, d2 = {"Landroidx/compose/ui/input/pointer/MotionEventAdapter;", "", "<init>", "()V", "nextId", "", "motionEventToComposePointerIdMap", "Landroid/util/SparseLongArray;", "getMotionEventToComposePointerIdMap$ui_release$annotations", "getMotionEventToComposePointerIdMap$ui_release", "()Landroid/util/SparseLongArray;", "activeHoverIds", "Landroid/util/SparseBooleanArray;", "pointers", "", "Landroidx/compose/ui/input/pointer/PointerInputEventData;", "previousToolType", "", "previousSource", "convertToPointerInputEvent", "Landroidx/compose/ui/input/pointer/PointerInputEvent;", "motionEvent", "Landroid/view/MotionEvent;", "positionCalculator", "Landroidx/compose/ui/input/pointer/PositionCalculator;", "convertToPointerInputEvent$ui_release", "endStream", "", "pointerId", "addFreshIds", "removeStaleIds", "hasPointerId", "", "getComposePointerId", "Landroidx/compose/ui/input/pointer/PointerId;", "motionEventPointerId", "getComposePointerId-_I2yYro", "(I)J", "clearOnDeviceChange", "createPointerInputEventData", "index", "pressed", "ui_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
@SourceDebugExtension({"SMAP\nMotionEventAdapter.android.kt\nKotlin\n*S Kotlin\n*F\n+ 1 MotionEventAdapter.android.kt\nandroidx/compose/ui/input/pointer/MotionEventAdapter\n+ 2 Offset.kt\nandroidx/compose/ui/geometry/OffsetKt\n+ 3 InlineClassHelper.kt\nandroidx/compose/ui/util/InlineClassHelperKt\n+ 4 MathHelpers.kt\nandroidx/compose/ui/util/MathHelpersKt\n*L\n1#1,349:1\n30#2:350\n30#2:354\n30#2:359\n30#2:363\n53#3,3:351\n53#3,3:355\n53#3,3:360\n53#3,3:364\n139#4:358\n*S KotlinDebug\n*F\n+ 1 MotionEventAdapter.android.kt\nandroidx/compose/ui/input/pointer/MotionEventAdapter\n*L\n256#1:350\n260#1:354\n284#1:359\n316#1:363\n256#1:351,3\n260#1:355,3\n284#1:360,3\n316#1:364,3\n283#1:358\n*E\n"})
|
|
/* loaded from: classes13.dex */
|
|
public final class MotionEventAdapter {
|
|
public static final int $stable = 8;
|
|
private long nextId;
|
|
|
|
@NotNull
|
|
private final SparseLongArray motionEventToComposePointerIdMap = new SparseLongArray();
|
|
|
|
@NotNull
|
|
private final SparseBooleanArray activeHoverIds = new SparseBooleanArray();
|
|
|
|
@NotNull
|
|
private final List<PointerInputEventData> pointers = new ArrayList();
|
|
private int previousToolType = -1;
|
|
private int previousSource = -1;
|
|
|
|
private final void addFreshIds(MotionEvent motionEvent) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked != 0 && actionMasked != 5) {
|
|
if (actionMasked != 9) {
|
|
return;
|
|
}
|
|
int pointerId = motionEvent.getPointerId(0);
|
|
if (this.motionEventToComposePointerIdMap.indexOfKey(pointerId) < 0) {
|
|
SparseLongArray sparseLongArray = this.motionEventToComposePointerIdMap;
|
|
long j = this.nextId;
|
|
this.nextId = 1 + j;
|
|
sparseLongArray.put(pointerId, j);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
int actionIndex = motionEvent.getActionIndex();
|
|
int pointerId2 = motionEvent.getPointerId(actionIndex);
|
|
if (this.motionEventToComposePointerIdMap.indexOfKey(pointerId2) < 0) {
|
|
SparseLongArray sparseLongArray2 = this.motionEventToComposePointerIdMap;
|
|
long j2 = this.nextId;
|
|
this.nextId = 1 + j2;
|
|
sparseLongArray2.put(pointerId2, j2);
|
|
if (motionEvent.getToolType(actionIndex) == 3) {
|
|
this.activeHoverIds.put(pointerId2, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void clearOnDeviceChange(MotionEvent motionEvent) {
|
|
if (motionEvent.getPointerCount() != 1) {
|
|
return;
|
|
}
|
|
int toolType = motionEvent.getToolType(0);
|
|
int source = motionEvent.getSource();
|
|
if (toolType == this.previousToolType && source == this.previousSource) {
|
|
return;
|
|
}
|
|
this.previousToolType = toolType;
|
|
this.previousSource = source;
|
|
this.activeHoverIds.clear();
|
|
this.motionEventToComposePointerIdMap.clear();
|
|
}
|
|
|
|
private final PointerInputEventData createPointerInputEventData(PositionCalculator positionCalculator, MotionEvent motionEvent, int index, boolean pressed) {
|
|
long m5874toRawOffsetdBAh8RU;
|
|
long mo6024screenToLocalMKHz9U;
|
|
long j;
|
|
int i = index;
|
|
long m5873getComposePointerId_I2yYro = m5873getComposePointerId_I2yYro(motionEvent.getPointerId(index));
|
|
float pressure = motionEvent.getPressure(index);
|
|
long j2 = 4294967295L;
|
|
long m4394copydBAh8RU$default = Offset.m4394copydBAh8RU$default(Offset.m4392constructorimpl((Float.floatToRawIntBits(motionEvent.getY(index)) & 4294967295L) | (Float.floatToRawIntBits(motionEvent.getX(index)) << 32)), 0.0f, 0.0f, 3, null);
|
|
if (i == 0) {
|
|
m5874toRawOffsetdBAh8RU = Offset.m4392constructorimpl((Float.floatToRawIntBits(motionEvent.getRawY()) & 4294967295L) | (Float.floatToRawIntBits(motionEvent.getRawX()) << 32));
|
|
mo6024screenToLocalMKHz9U = positionCalculator.mo6024screenToLocalMKHz9U(m5874toRawOffsetdBAh8RU);
|
|
} else {
|
|
m5874toRawOffsetdBAh8RU = MotionEventHelper.INSTANCE.m5874toRawOffsetdBAh8RU(motionEvent, i);
|
|
mo6024screenToLocalMKHz9U = positionCalculator.mo6024screenToLocalMKHz9U(m5874toRawOffsetdBAh8RU);
|
|
}
|
|
int toolType = motionEvent.getToolType(index);
|
|
int m6022getUnknownT8wyACA = toolType != 0 ? toolType != 1 ? toolType != 2 ? toolType != 3 ? toolType != 4 ? PointerType.INSTANCE.m6022getUnknownT8wyACA() : PointerType.INSTANCE.m6018getEraserT8wyACA() : PointerType.INSTANCE.m6019getMouseT8wyACA() : PointerType.INSTANCE.m6020getStylusT8wyACA() : PointerType.INSTANCE.m6021getTouchT8wyACA() : PointerType.INSTANCE.m6022getUnknownT8wyACA();
|
|
ArrayList arrayList = new ArrayList(motionEvent.getHistorySize());
|
|
int historySize = motionEvent.getHistorySize();
|
|
int i2 = 0;
|
|
while (i2 < historySize) {
|
|
float historicalX = motionEvent.getHistoricalX(i, i2);
|
|
float historicalY = motionEvent.getHistoricalY(i, i2);
|
|
long j3 = j2;
|
|
if ((Float.floatToRawIntBits(historicalX) & Integer.MAX_VALUE) >= 2139095040 || (Float.floatToRawIntBits(historicalY) & Integer.MAX_VALUE) >= 2139095040) {
|
|
j = m5874toRawOffsetdBAh8RU;
|
|
} else {
|
|
long floatToRawIntBits = Float.floatToRawIntBits(historicalX);
|
|
j = m5874toRawOffsetdBAh8RU;
|
|
long m4392constructorimpl = Offset.m4392constructorimpl((Float.floatToRawIntBits(historicalY) & j3) | (floatToRawIntBits << 32));
|
|
arrayList.add(new HistoricalChange(motionEvent.getHistoricalEventTime(i2), m4392constructorimpl, m4392constructorimpl, null));
|
|
}
|
|
i2++;
|
|
i = index;
|
|
m5874toRawOffsetdBAh8RU = j;
|
|
j2 = j3;
|
|
}
|
|
return new PointerInputEventData(m5873getComposePointerId_I2yYro, motionEvent.getEventTime(), m5874toRawOffsetdBAh8RU, mo6024screenToLocalMKHz9U, pressed, pressure, m6022getUnknownT8wyACA, this.activeHoverIds.get(motionEvent.getPointerId(index), false), arrayList, motionEvent.getActionMasked() == 8 ? Offset.m4392constructorimpl((Float.floatToRawIntBits((-motionEvent.getAxisValue(9)) + 0.0f) & j2) | (Float.floatToRawIntBits(motionEvent.getAxisValue(10)) << 32)) : Offset.INSTANCE.m4416getZeroF1C5BW0(), m4394copydBAh8RU$default, null);
|
|
}
|
|
|
|
/* renamed from: getComposePointerId-_I2yYro, reason: not valid java name */
|
|
private final long m5873getComposePointerId_I2yYro(int motionEventPointerId) {
|
|
long j;
|
|
int indexOfKey = this.motionEventToComposePointerIdMap.indexOfKey(motionEventPointerId);
|
|
if (indexOfKey >= 0) {
|
|
j = this.motionEventToComposePointerIdMap.valueAt(indexOfKey);
|
|
} else {
|
|
long j2 = this.nextId;
|
|
this.nextId = 1 + j2;
|
|
this.motionEventToComposePointerIdMap.put(motionEventPointerId, j2);
|
|
j = j2;
|
|
}
|
|
return PointerId.m5923constructorimpl(j);
|
|
}
|
|
|
|
private final boolean hasPointerId(MotionEvent motionEvent, int i) {
|
|
int pointerCount = motionEvent.getPointerCount();
|
|
for (int i2 = 0; i2 < pointerCount; i2++) {
|
|
if (motionEvent.getPointerId(i2) == i) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private final void removeStaleIds(MotionEvent motionEvent) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 1 || actionMasked == 6) {
|
|
int pointerId = motionEvent.getPointerId(motionEvent.getActionIndex());
|
|
if (!this.activeHoverIds.get(pointerId, false)) {
|
|
this.motionEventToComposePointerIdMap.delete(pointerId);
|
|
this.activeHoverIds.delete(pointerId);
|
|
}
|
|
}
|
|
if (this.motionEventToComposePointerIdMap.size() > motionEvent.getPointerCount()) {
|
|
for (int size = this.motionEventToComposePointerIdMap.size() - 1; -1 < size; size--) {
|
|
int keyAt = this.motionEventToComposePointerIdMap.keyAt(size);
|
|
if (!hasPointerId(motionEvent, keyAt)) {
|
|
this.motionEventToComposePointerIdMap.removeAt(size);
|
|
this.activeHoverIds.delete(keyAt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
public final PointerInputEvent convertToPointerInputEvent$ui_release(@NotNull MotionEvent motionEvent, @NotNull PositionCalculator positionCalculator) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 3 || actionMasked == 4) {
|
|
this.motionEventToComposePointerIdMap.clear();
|
|
this.activeHoverIds.clear();
|
|
return null;
|
|
}
|
|
clearOnDeviceChange(motionEvent);
|
|
addFreshIds(motionEvent);
|
|
boolean z = actionMasked == 9 || actionMasked == 7 || actionMasked == 10;
|
|
boolean z2 = actionMasked == 8;
|
|
if (z) {
|
|
this.activeHoverIds.put(motionEvent.getPointerId(motionEvent.getActionIndex()), true);
|
|
}
|
|
int actionIndex = actionMasked != 1 ? actionMasked != 6 ? -1 : motionEvent.getActionIndex() : 0;
|
|
this.pointers.clear();
|
|
int pointerCount = motionEvent.getPointerCount();
|
|
int i = 0;
|
|
while (i < pointerCount) {
|
|
this.pointers.add(createPointerInputEventData(positionCalculator, motionEvent, i, (z || i == actionIndex || (z2 && motionEvent.getButtonState() == 0)) ? false : true));
|
|
i++;
|
|
}
|
|
removeStaleIds(motionEvent);
|
|
return new PointerInputEvent(motionEvent.getEventTime(), this.pointers, motionEvent);
|
|
}
|
|
|
|
public final void endStream(int pointerId) {
|
|
this.activeHoverIds.delete(pointerId);
|
|
this.motionEventToComposePointerIdMap.delete(pointerId);
|
|
}
|
|
|
|
@NotNull
|
|
/* renamed from: getMotionEventToComposePointerIdMap$ui_release, reason: from getter */
|
|
public final SparseLongArray getMotionEventToComposePointerIdMap() {
|
|
return this.motionEventToComposePointerIdMap;
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getMotionEventToComposePointerIdMap$ui_release$annotations() {
|
|
}
|
|
}
|