You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
api-impl{-jni}: make view.onTouchEvent work, misc stuff to make input work for Unity games
onTouchEvent was previously incorrectly handled in GLSurfaceView; move it to View so that it works properly with any of it's descendants. This is done by reusing the existing setOnTouchListener implementation and changing it to use GtkEventControllerLegacy which provides motion events. Technically some of the code is in WrapperWidget.c since every widget calls wrapper_widget_set_jobject and we already have related code there.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "../sk_area/sk_area.h"
|
||||
|
||||
#include "../generated_headers/android_view_View.h"
|
||||
|
||||
#include "WrapperWidget.h"
|
||||
|
||||
G_DEFINE_TYPE(WrapperWidget, wrapper_widget, GTK_TYPE_WIDGET)
|
||||
@@ -122,4 +124,10 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
|
||||
// add a callback for when the widget is mapped, which will call onMeasure to figure out what size the widget wants to be
|
||||
g_signal_connect(wrapper, "map", G_CALLBACK(on_mapped), NULL);
|
||||
}
|
||||
|
||||
jmethodID ontouchevent_method = _METHOD(_CLASS(jobj), "onTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
||||
if (ontouchevent_method != handle_cache.view.onTouchEvent) {
|
||||
/* use gtk_widget_get_first_child since the jobject may not have the "widget" variable set yet */
|
||||
_setOnTouchListener(env, jobj, gtk_widget_get_first_child(wrapper), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user