android - add hack to fix orientation issue

This commit is contained in:
Emmanuel Hansen 2023-12-19 13:45:13 +00:00
parent cc8d44139a
commit 64b21a4578
3 changed files with 14 additions and 2 deletions

View File

@ -185,6 +185,8 @@ void setProgressInfo(char* info, float progressValue) {
progress = progressValue;
}
bool isInitialOrientationFlipped = true;
extern "C"
void setCurrentTransform(long native_window, int transform){
if(native_window == 0 || native_window == -1)
@ -201,10 +203,10 @@ void setCurrentTransform(long native_window, int transform){
nativeTransform = ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_IDENTITY;
break;
case 0x2:
nativeTransform = ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_ROTATE_90;
nativeTransform = ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_ROTATE_90;
break;
case 0x4:
nativeTransform = ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_ROTATE_180;
nativeTransform = isInitialOrientationFlipped ? ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_IDENTITY : ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_ROTATE_180;
break;
case 0x8:
nativeTransform = ANativeWindowTransform::ANATIVEWINDOW_TRANSFORM_ROTATE_270;
@ -337,3 +339,10 @@ JNIEXPORT jstring JNICALL
Java_org_ryujinx_android_NativeHelpers_getStringJava(JNIEnv *env, jobject thiz, jlong id) {
return createStringFromStdString(env, str_helper.get_stored(id));
}
extern "C"
JNIEXPORT void JNICALL
Java_org_ryujinx_android_NativeHelpers_setIsInitialOrientationFlipped(JNIEnv *env, jobject thiz,
jboolean is_flipped) {
isInitialOrientationFlipped = is_flipped;
}

View File

@ -95,6 +95,8 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
surfaceHolder.surfaceFrame.height()
)
NativeHelpers.instance.setIsInitialOrientationFlipped(mainViewModel.activity.display?.rotation == 3)
_guestThread = thread(start = true) {
runGame()
}

View File

@ -31,4 +31,5 @@ class NativeHelpers {
external fun getProgressValue() : Float
external fun storeStringJava(string: String) : Long
external fun getStringJava(id: Long) : String
external fun setIsInitialOrientationFlipped(isFlipped: Boolean)
}