Update native settings after toggling frame throttling

This commit is contained in:
lynxnb 2023-02-06 18:58:07 +01:00 committed by Billy Laws
parent f850271e2d
commit 5b0a397165

View File

@ -77,6 +77,8 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
@Inject
lateinit var preferenceSettings : PreferenceSettings
lateinit var nativeSettings : NativeSettings
@Inject
lateinit var inputManager : InputManager
@ -196,7 +198,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
GpuDriverHelper.ensureFileRedirectDir(this)
emulationThread = Thread {
executeApplication(rom.toString(), romType, romFd.detachFd(), NativeSettings(this, preferenceSettings), applicationContext.getPublicFilesDir().canonicalPath + "/", applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets)
executeApplication(rom.toString(), romType, romFd.detachFd(), nativeSettings, applicationContext.getPublicFilesDir().canonicalPath + "/", applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets)
returnFromEmulation()
}
@ -208,7 +210,10 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
super.onCreate(savedInstanceState)
requestedOrientation = preferenceSettings.orientation
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
inputHandler = InputHandler(inputManager, preferenceSettings)
nativeSettings = NativeSettings(this, preferenceSettings)
setContentView(binding.root)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
@ -250,9 +255,13 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
}
}, 250)
setOnClickListener {
preferenceSettings.disableFrameThrottling = !preferenceSettings.disableFrameThrottling
var color = if (preferenceSettings.disableFrameThrottling) getColor(R.color.colorPerfStatsSecondary) else getColor(R.color.colorPerfStatsPrimary)
val newValue = !preferenceSettings.disableFrameThrottling
preferenceSettings.disableFrameThrottling = newValue
nativeSettings.disableFrameThrottling = newValue
var color = if (newValue) getColor(R.color.colorPerfStatsSecondary) else getColor(R.color.colorPerfStatsPrimary)
binding.perfStats.setTextColor(color)
nativeSettings.updateNative()
}
}
}