Keep native side paused on "system" onResume()

This commit is contained in:
Aaron Culliney 2015-04-14 22:02:48 -07:00
parent 883403e6e8
commit c48e72c27f
5 changed files with 23 additions and 12 deletions

View File

@ -68,7 +68,7 @@ public class Apple2Activity extends Activity {
private native void nativeIncreaseCPUSpeed(); private native void nativeIncreaseCPUSpeed();
private native void nativeDecreaseCPUSpeed(); private native void nativeDecreaseCPUSpeed();
public native void nativeOnResume(); public native void nativeOnResume(boolean isSystemResume);
public native void nativeOnPause(); public native void nativeOnPause();
public native void nativeOnQuit(); public native void nativeOnQuit();
@ -192,7 +192,7 @@ public class Apple2Activity extends Activity {
super.onResume(); super.onResume();
Log.d(TAG, "onResume()"); Log.d(TAG, "onResume()");
mView.onResume(); mView.onResume();
nativeOnResume(); nativeOnResume(/*isSystemResume:*/true);
} }
@Override @Override
@ -447,13 +447,13 @@ public class Apple2Activity extends Activity {
/*mQuitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { /*mQuitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
nativeOnResume(); nativeOnResume(false);
} }
}); });
mQuitDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { mQuitDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
nativeOnResume(); nativeOnResume(false);
} }
});*/ });*/
} }
@ -473,13 +473,13 @@ public class Apple2Activity extends Activity {
/*mRebootDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { /*mRebootDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
nativeOnResume(); nativeOnResume(false);
} }
}); });
mRebootDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { mRebootDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
nativeOnResume(); nativeOnResume(false);
} }
});*/ });*/
} }

View File

@ -138,7 +138,7 @@ public class Apple2DisksMenu {
public void dismiss() { public void dismiss() {
if (isShowing()) { if (isShowing()) {
dismissWithoutResume(); dismissWithoutResume();
mActivity.nativeOnResume(); mActivity.nativeOnResume(/*isSystemResume:*/false);
} }
} }

View File

@ -164,7 +164,7 @@ public class Apple2MainMenu {
public void onDismiss() { public void onDismiss() {
boolean otherMenusShowing = (getSettingsMenu().isShowing() || getDisksMenu().isShowing()); boolean otherMenusShowing = (getSettingsMenu().isShowing() || getDisksMenu().isShowing());
if (!otherMenusShowing) { if (!otherMenusShowing) {
Apple2MainMenu.this.mActivity.nativeOnResume(); Apple2MainMenu.this.mActivity.nativeOnResume(/*isSystemResume:*/false);
} }
} }
}); });

View File

@ -244,7 +244,7 @@ public class Apple2SettingsMenu {
public void dismiss() { public void dismiss() {
if (isShowing()) { if (isShowing()) {
dismissWithoutResume(); dismissWithoutResume();
mActivity.nativeOnResume(); mActivity.nativeOnResume(/*isSystemResume:*/false);
} }
} }

View File

@ -112,13 +112,17 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeGraphicsInitialized(JNIEnv
video_backend->init((void *)0); video_backend->init((void *)0);
} }
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnResume(JNIEnv *env, jobject obj) { void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnResume(JNIEnv *env, jobject obj, jboolean isSystemResume) {
if (!nativePaused) { if (!nativePaused) {
return; return;
} }
nativePaused = false;
LOG("%s", "native onResume..."); LOG("%s", "native onResume...");
pthread_mutex_unlock(&interface_mutex); if (isSystemResume) {
// TODO POSSIBLY : message showing paused state
} else {
nativePaused = false;
pthread_mutex_unlock(&interface_mutex);
}
} }
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnPause(JNIEnv *env, jobject obj) { void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnPause(JNIEnv *env, jobject obj) {
@ -194,6 +198,13 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnKeyUp(JNIEnv *env, jobjec
jboolean Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnTouch(JNIEnv *env, jobject obj, jint action, jint pointerCount, jint pointerIndex, jfloatArray xCoords, jfloatArray yCoords) { jboolean Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnTouch(JNIEnv *env, jobject obj, jint action, jint pointerCount, jint pointerIndex, jfloatArray xCoords, jfloatArray yCoords) {
//LOG("nativeOnTouch : %d/%d/%d :", action, pointerCount, pointerIndex); //LOG("nativeOnTouch : %d/%d/%d :", action, pointerCount, pointerIndex);
if (nativePaused) {
LOG("UNPAUSING NATIVE CPU THREAD");
nativePaused = false;
pthread_mutex_unlock(&interface_mutex);
return true;
}
jfloat *x_coords = (*env)->GetFloatArrayElements(env, xCoords, 0); jfloat *x_coords = (*env)->GetFloatArrayElements(env, xCoords, 0);
jfloat *y_coords = (*env)->GetFloatArrayElements(env, yCoords, 0); jfloat *y_coords = (*env)->GetFloatArrayElements(env, yCoords, 0);