mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-02-16 02:20:55 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user