[ion/simulator/android] Fix haptic feddback type return

This commit is contained in:
Hugo Saint-Vignes
2021-02-03 11:47:30 +01:00
parent 11ef4bd996
commit 05e6fbbcca
2 changed files with 6 additions and 3 deletions

View File

@@ -10,9 +10,12 @@ bool isEnabled() {
JNIEnv * env = static_cast<JNIEnv *>(SDL_AndroidGetJNIEnv());
jobject activity = static_cast<jobject>(SDL_AndroidGetActivity());
jclass j_class = env->FindClass("com/numworks/calculator/EpsilonActivity");
// TODO : GetMethodID is relatively costly, and could be performed only once.
jmethodID j_methodId = env->GetMethodID(j_class,"hapticFeedbackIsEnabled", "()Z");
return env->CallObjectMethod(activity, j_methodId);
if (j_methodId == 0) {
return false;
}
return (env->CallBooleanMethod(activity, j_methodId) != JNI_FALSE);
}
}

View File

@@ -25,7 +25,7 @@ void shutdown() {
}
void rumble() {
if (isEnabled() && sSDLHaptic) {
if (sSDLHaptic && isEnabled()) {
SDL_HapticRumblePlay(sSDLHaptic, 1.0, 40);
}
}