Support vibration for Android and iOS

This commit is contained in:
volzhs 2019-08-18 00:27:29 +09:00
parent 86371b7298
commit 4061e5bb75
15 changed files with 68 additions and 0 deletions

View file

@ -62,6 +62,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance) {
_init_input_devices = p_env->GetMethodID(cls, "initInputDevices", "()V");
_get_surface = p_env->GetMethodID(cls, "getSurface", "()Landroid/view/Surface;");
_is_activity_resumed = p_env->GetMethodID(cls, "isActivityResumed", "()Z");
_vibrate = p_env->GetMethodID(cls, "vibrate", "(I)V");
}
GodotJavaWrapper::~GodotJavaWrapper() {
@ -211,3 +212,10 @@ bool GodotJavaWrapper::is_activity_resumed() {
return false;
}
}
void GodotJavaWrapper::vibrate(int p_duration_ms) {
if (_vibrate) {
JNIEnv *env = ThreadAndroid::get_env();
env->CallVoidMethod(godot_instance, _vibrate, p_duration_ms);
}
}