Skip to content

Commit 8e3d2b8

Browse files
committed
fix: API 24/25 can not handleMotion
1 parent b49ced1 commit 8e3d2b8

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

app/src/main/java/com/limelight/Game.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,7 +2824,6 @@ private float[] getNormalizedCoordinates(View streamView, float rawX, float rawY
28242824

28252825
// Returns true if the event was consumed
28262826
// NB: View is only present if called from a view callback
2827-
@RequiresApi(api = Build.VERSION_CODES.O)
28282827
private boolean handleMotionEvent(View view, MotionEvent event) {
28292828
// Pass through mouse/touch/joystick input if we're not grabbing
28302829
if (!grabbedInput) {
@@ -3269,11 +3268,7 @@ private boolean handleMotionEvent(View view, MotionEvent event) {
32693268

32703269
@Override
32713270
public boolean onGenericMotionEvent(MotionEvent event) {
3272-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
3273-
return handleMotionEvent(null, event) || super.onGenericMotionEvent(event);
3274-
}
3275-
3276-
return false;
3271+
return handleMotionEvent(null, event) || super.onGenericMotionEvent(event);
32773272
}
32783273

32793274
private void updateMousePosition(View touchedView, MotionEvent event) {
@@ -3359,10 +3354,7 @@ private void updateMousePosition(View touchedView, MotionEvent event) {
33593354

33603355
@Override
33613356
public boolean onGenericMotion(View view, MotionEvent event) {
3362-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
3363-
return handleMotionEvent(view, event);
3364-
}
3365-
return false;
3357+
return handleMotionEvent(view, event);
33663358
}
33673359

33683360
@SuppressLint("ClickableViewAccessibility")
@@ -3373,14 +3365,12 @@ public boolean onTouch(View view, MotionEvent event) {
33733365
//
33743366
// NB: This is still needed even when we call the newer requestUnbufferedDispatch()!
33753367
// Add a configuration to allow view.requestUnbufferedDispatch to be disabled.
3376-
if (!prefConfig.syncTouchEventWithDisplay) {
3368+
// requestUnbufferedDispatch(MotionEvent) requires API 30 (Android 11)
3369+
if (!prefConfig.syncTouchEventWithDisplay && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
33773370
view.requestUnbufferedDispatch(event);
33783371
}
33793372
}
3380-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
3381-
return handleMotionEvent(view, event); //Y700平板上, onTouch的调用频率为120Hz
3382-
}
3383-
return false;
3373+
return handleMotionEvent(view, event); //Y700平板上, onTouch的调用频率为120Hz
33843374
}
33853375

33863376
@Override
@@ -4663,10 +4653,8 @@ public StreamView getActiveStreamView() {
46634653
return streamView;
46644654
}
46654655

4666-
public void getHandleMotionEvent(StreamView streamView, MotionEvent event) {
4667-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
4668-
handleMotionEvent(streamView, event);
4669-
}
4656+
public boolean getHandleMotionEvent(StreamView streamView, MotionEvent event) {
4657+
return handleMotionEvent(streamView, event);
46704658
}
46714659

46724660
/**

0 commit comments

Comments
 (0)