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 @Inject
lateinit var preferenceSettings : PreferenceSettings lateinit var preferenceSettings : PreferenceSettings
lateinit var nativeSettings : NativeSettings
@Inject @Inject
lateinit var inputManager : InputManager lateinit var inputManager : InputManager
@ -196,7 +198,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
GpuDriverHelper.ensureFileRedirectDir(this) GpuDriverHelper.ensureFileRedirectDir(this)
emulationThread = Thread { 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() returnFromEmulation()
} }
@ -208,7 +210,10 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
requestedOrientation = preferenceSettings.orientation requestedOrientation = preferenceSettings.orientation
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
inputHandler = InputHandler(inputManager, preferenceSettings) inputHandler = InputHandler(inputManager, preferenceSettings)
nativeSettings = NativeSettings(this, preferenceSettings)
setContentView(binding.root) setContentView(binding.root)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
@ -250,9 +255,13 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
} }
}, 250) }, 250)
setOnClickListener { setOnClickListener {
preferenceSettings.disableFrameThrottling = !preferenceSettings.disableFrameThrottling val newValue = !preferenceSettings.disableFrameThrottling
var color = if (preferenceSettings.disableFrameThrottling) getColor(R.color.colorPerfStatsSecondary) else getColor(R.color.colorPerfStatsPrimary) preferenceSettings.disableFrameThrottling = newValue
nativeSettings.disableFrameThrottling = newValue
var color = if (newValue) getColor(R.color.colorPerfStatsSecondary) else getColor(R.color.colorPerfStatsPrimary)
binding.perfStats.setTextColor(color) binding.perfStats.setTextColor(color)
nativeSettings.updateNative()
} }
} }
} }