Properly split touch events between regions outside the StreamView and the OSC

This restores the ability to use area outside the StreamView for the virtual trackpad and adds the ability to use OSC and the non-StreamView region for input at the same time.

Fixes #1129
This commit is contained in:
Cameron Gutman
2022-09-20 22:29:54 -05:00
parent 2c498ce707
commit e1c0472069
2 changed files with 21 additions and 0 deletions

View File

@@ -239,6 +239,21 @@ public class Game extends Activity implements SurfaceHolder.Callback,
streamView.setOnTouchListener(this);
streamView.setInputCallbacks(this);
// Listen for touch events outside of the game surface to enable trackpad mode
// to work on areas outside of the StreamView itself. We use a separate View
// for this rather than just handling it at the Activity level, because that
// allows proper touch splitting, which the OSC relies upon.
View backgroundTouchView = findViewById(R.id.backgroundTouchView);
backgroundTouchView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// We pass this to handleMotionEvent() as if it came from the Activity-level
// onTouchEvent() callback, otherwise it will assume it's from the StreamView
// and compute the incorrect video bounds when handling absolute input.
return handleMotionEvent(null, event);
}
});
boolean needsInputBatching = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// Request unbuffered input event dispatching for all input classes we handle here.

View File

@@ -4,6 +4,12 @@
android:layout_height="match_parent"
tools:context=".Game" >
<View
android:id="@+id/backgroundTouchView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<com.limelight.ui.StreamView
android:id="@+id/surfaceView"
android:layout_width="match_parent"