|
|
@ -810,28 +810,26 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
|
|
|
|
|
|
override fun onConfigurationChanged(newConfig: Configuration) { |
|
|
override fun onConfigurationChanged(newConfig: Configuration) { |
|
|
super.onConfigurationChanged(newConfig) |
|
|
super.onConfigurationChanged(newConfig) |
|
|
if (_binding == null) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
val b = _binding ?: return |
|
|
|
|
|
|
|
|
updateScreenLayout() |
|
|
updateScreenLayout() |
|
|
val showInputOverlay = BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean() |
|
|
val showInputOverlay = BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean() |
|
|
if (emulationActivity?.isInPictureInPictureMode == true) { |
|
|
if (emulationActivity?.isInPictureInPictureMode == true) { |
|
|
if (binding.drawerLayout.isOpen) { |
|
|
|
|
|
binding.drawerLayout.close() |
|
|
|
|
|
|
|
|
if (b.drawerLayout.isOpen) { |
|
|
|
|
|
b.drawerLayout.close() |
|
|
} |
|
|
} |
|
|
if (showInputOverlay) { |
|
|
if (showInputOverlay) { |
|
|
binding.surfaceInputOverlay.setVisible(visible = false, gone = false) |
|
|
|
|
|
|
|
|
b.surfaceInputOverlay.setVisible(visible = false, gone = false) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
binding.surfaceInputOverlay.setVisible( |
|
|
|
|
|
|
|
|
b.surfaceInputOverlay.setVisible( |
|
|
showInputOverlay && emulationViewModel.emulationStarted.value |
|
|
showInputOverlay && emulationViewModel.emulationStarted.value |
|
|
) |
|
|
) |
|
|
if (!isInFoldableLayout) { |
|
|
if (!isInFoldableLayout) { |
|
|
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { |
|
|
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { |
|
|
binding.surfaceInputOverlay.layout = OverlayLayout.Portrait |
|
|
|
|
|
|
|
|
b.surfaceInputOverlay.layout = OverlayLayout.Portrait |
|
|
} else { |
|
|
} else { |
|
|
binding.surfaceInputOverlay.layout = OverlayLayout.Landscape |
|
|
|
|
|
|
|
|
b.surfaceInputOverlay.layout = OverlayLayout.Landscape |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -847,8 +845,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun updateQuickOverlayMenuEntry(isVisible: Boolean) { |
|
|
private fun updateQuickOverlayMenuEntry(isVisible: Boolean) { |
|
|
val menu = binding.inGameMenu.menu |
|
|
|
|
|
val item = menu.findItem(R.id.menu_quick_overlay) |
|
|
|
|
|
|
|
|
val b = _binding ?: return |
|
|
|
|
|
val item = b.inGameMenu.menu.findItem(R.id.menu_quick_overlay) ?: return |
|
|
|
|
|
|
|
|
if (isVisible) { |
|
|
if (isVisible) { |
|
|
item.title = getString(R.string.emulation_hide_overlay) |
|
|
item.title = getString(R.string.emulation_hide_overlay) |
|
|
item.icon = ResourcesCompat.getDrawable( |
|
|
item.icon = ResourcesCompat.getDrawable( |
|
|
@ -867,8 +866,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun updatePauseMenuEntry(isPaused: Boolean) { |
|
|
private fun updatePauseMenuEntry(isPaused: Boolean) { |
|
|
val menu = binding.inGameMenu.menu |
|
|
|
|
|
val pauseItem = menu.findItem(R.id.menu_pause_emulation) |
|
|
|
|
|
|
|
|
val b = _binding ?: return |
|
|
|
|
|
val pauseItem = b.inGameMenu.menu.findItem(R.id.menu_pause_emulation) ?: return |
|
|
if (isPaused) { |
|
|
if (isPaused) { |
|
|
pauseItem.title = getString(R.string.emulation_unpause) |
|
|
pauseItem.title = getString(R.string.emulation_unpause) |
|
|
pauseItem.icon = ResourcesCompat.getDrawable( |
|
|
pauseItem.icon = ResourcesCompat.getDrawable( |
|
|
@ -887,9 +886,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
override fun onPause() { |
|
|
override fun onPause() { |
|
|
if (emulationState.isRunning && emulationActivity?.isInPictureInPictureMode != true) { |
|
|
|
|
|
emulationState.pause() |
|
|
|
|
|
updatePauseMenuEntry(true) |
|
|
|
|
|
|
|
|
if (this::emulationState.isInitialized) { |
|
|
|
|
|
if (emulationState.isRunning && emulationActivity?.isInPictureInPictureMode != true) { |
|
|
|
|
|
emulationState.pause() |
|
|
|
|
|
updatePauseMenuEntry(true) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
super.onPause() |
|
|
super.onPause() |
|
|
} |
|
|
} |
|
|
@ -906,15 +907,15 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
override fun onResume() { |
|
|
super.onResume() |
|
|
super.onResume() |
|
|
// If the overlay is enabled, we need to update the position if changed |
|
|
|
|
|
val position = IntSetting.PERF_OVERLAY_POSITION.getInt() |
|
|
|
|
|
updateStatsPosition(position) |
|
|
|
|
|
|
|
|
|
|
|
val socPosition = IntSetting.SOC_OVERLAY_POSITION.getInt() |
|
|
|
|
|
updateSocPosition(socPosition) |
|
|
|
|
|
|
|
|
|
|
|
binding.inGameMenu.post { |
|
|
|
|
|
emulationState?.isPaused?.let { updatePauseMenuEntry(it) } |
|
|
|
|
|
|
|
|
val b = _binding ?: return |
|
|
|
|
|
updateStatsPosition(IntSetting.PERF_OVERLAY_POSITION.getInt()) |
|
|
|
|
|
updateSocPosition(IntSetting.SOC_OVERLAY_POSITION.getInt()) |
|
|
|
|
|
|
|
|
|
|
|
if (this::emulationState.isInitialized) { |
|
|
|
|
|
b.inGameMenu.post { |
|
|
|
|
|
if (!this::emulationState.isInitialized || _binding == null) return@post |
|
|
|
|
|
updatePauseMenuEntry(emulationState.isPaused) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1229,6 +1230,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun updateScreenLayout() { |
|
|
private fun updateScreenLayout() { |
|
|
|
|
|
val b = _binding ?: return |
|
|
val verticalAlignment = |
|
|
val verticalAlignment = |
|
|
EmulationVerticalAlignment.from(IntSetting.VERTICAL_ALIGNMENT.getInt()) |
|
|
EmulationVerticalAlignment.from(IntSetting.VERTICAL_ALIGNMENT.getInt()) |
|
|
val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.getInt()) { |
|
|
val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.getInt()) { |
|
|
@ -1240,35 +1242,37 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
} |
|
|
} |
|
|
when (verticalAlignment) { |
|
|
when (verticalAlignment) { |
|
|
EmulationVerticalAlignment.Top -> { |
|
|
EmulationVerticalAlignment.Top -> { |
|
|
binding.surfaceEmulation.setAspectRatio(aspectRatio) |
|
|
|
|
|
|
|
|
b.surfaceEmulation.setAspectRatio(aspectRatio) |
|
|
val params = FrameLayout.LayoutParams( |
|
|
val params = FrameLayout.LayoutParams( |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
ViewGroup.LayoutParams.WRAP_CONTENT |
|
|
ViewGroup.LayoutParams.WRAP_CONTENT |
|
|
) |
|
|
) |
|
|
params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL |
|
|
params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL |
|
|
binding.surfaceEmulation.layoutParams = params |
|
|
|
|
|
|
|
|
b.surfaceEmulation.layoutParams = params |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
EmulationVerticalAlignment.Center -> { |
|
|
EmulationVerticalAlignment.Center -> { |
|
|
binding.surfaceEmulation.setAspectRatio(null) |
|
|
|
|
|
binding.surfaceEmulation.updateLayoutParams { |
|
|
|
|
|
|
|
|
b.surfaceEmulation.setAspectRatio(null) |
|
|
|
|
|
b.surfaceEmulation.updateLayoutParams { |
|
|
width = ViewGroup.LayoutParams.MATCH_PARENT |
|
|
width = ViewGroup.LayoutParams.MATCH_PARENT |
|
|
height = ViewGroup.LayoutParams.MATCH_PARENT |
|
|
height = ViewGroup.LayoutParams.MATCH_PARENT |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
EmulationVerticalAlignment.Bottom -> { |
|
|
EmulationVerticalAlignment.Bottom -> { |
|
|
binding.surfaceEmulation.setAspectRatio(aspectRatio) |
|
|
|
|
|
|
|
|
b.surfaceEmulation.setAspectRatio(aspectRatio) |
|
|
val params = |
|
|
val params = |
|
|
FrameLayout.LayoutParams( |
|
|
FrameLayout.LayoutParams( |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
ViewGroup.LayoutParams.WRAP_CONTENT |
|
|
ViewGroup.LayoutParams.WRAP_CONTENT |
|
|
) |
|
|
) |
|
|
params.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL |
|
|
params.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL |
|
|
binding.surfaceEmulation.layoutParams = params |
|
|
|
|
|
|
|
|
b.surfaceEmulation.layoutParams = params |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
emulationState.updateSurface() |
|
|
|
|
|
|
|
|
if (this::emulationState.isInitialized) { |
|
|
|
|
|
emulationState.updateSurface() |
|
|
|
|
|
} |
|
|
emulationActivity?.buildPictureInPictureParams() |
|
|
emulationActivity?.buildPictureInPictureParams() |
|
|
updateOrientation() |
|
|
updateOrientation() |
|
|
} |
|
|
} |
|
|
@ -1722,4 +1726,4 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { |
|
|
private val perfStatsUpdateHandler = Handler(Looper.myLooper()!!) |
|
|
private val perfStatsUpdateHandler = Handler(Looper.myLooper()!!) |
|
|
private val socUpdateHandler = Handler(Looper.myLooper()!!) |
|
|
private val socUpdateHandler = Handler(Looper.myLooper()!!) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |