Skip to content

Patch SDLSurface to allow touch to be intercepted by python application #3157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- a/src/main/java/org/libsdl/app/SDLSurface.java
+++ b/src/main/java/org/libsdl/app/SDLSurface.java
@@ -193,9 +193,22 @@
return SDLActivity.handleKeyEvent(v, keyCode, event, null);
}

+ public interface OnInterceptTouchListener {
+ boolean onTouch(MotionEvent ev);
+ }
+
+ private OnInterceptTouchListener mOnInterceptTouchListener = null;
+
+ public void setInterceptTouchListener(OnInterceptTouchListener listener) {
+ this.mOnInterceptTouchListener = listener;
+ }
+
// Touch events
@Override
public boolean onTouch(View v, MotionEvent event) {
+ if (mOnInterceptTouchListener != null)
+ if (mOnInterceptTouchListener.onTouch(event))
+ return false;
/* Ref: http://developer.android.com/training/gestures/multi.html */
int touchDevId = event.getDeviceId();
final int pointerCount = event.getPointerCount();
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/src/main/java/org/libsdl/app/SDLSurface.java
+++ b/src/main/java/org/libsdl/app/SDLSurface.java
@@ -232,9 +232,23 @@
}
}

+ public interface OnInterceptTouchListener {
+ boolean onTouch(MotionEvent ev);
+ }
+
+ private OnInterceptTouchListener mOnInterceptTouchListener = null;
+
+ public void setInterceptTouchListener(OnInterceptTouchListener listener) {
+ this.mOnInterceptTouchListener = listener;
+ }
+
// Touch events
@Override
public boolean onTouch(View v, MotionEvent event) {
+ // Allow touch to be intercepted by python application
+ if (mOnInterceptTouchListener != null)
+ if (mOnInterceptTouchListener.onTouch(event))
+ return false;
/* Ref: http://developer.android.com/training/gestures/multi.html */
int touchDevId = event.getDeviceId();
final int pointerCount = event.getPointerCount();
Loading