mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 03:18:55 +02:00
[android] Adjusted in-built controller handling to disable auto touchscreen control.
This commit is contained in:
parent
89b8932f36
commit
88124a4cd7
2 changed files with 41 additions and 19 deletions
|
|
@ -246,6 +246,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener, InputManager
|
||||||
nfcReader.startScanning()
|
nfcReader.startScanning()
|
||||||
startMotionSensorListener()
|
startMotionSensorListener()
|
||||||
InputHandler.updateControllerData()
|
InputHandler.updateControllerData()
|
||||||
|
notifyPhysicalControllerState()
|
||||||
|
|
||||||
buildPictureInPictureParams()
|
buildPictureInPictureParams()
|
||||||
}
|
}
|
||||||
|
|
@ -469,29 +470,30 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener, InputManager
|
||||||
override fun onInputDeviceAdded(deviceId: Int) {
|
override fun onInputDeviceAdded(deviceId: Int) {
|
||||||
if (isGameController(deviceId)) {
|
if (isGameController(deviceId)) {
|
||||||
InputHandler.updateControllerData()
|
InputHandler.updateControllerData()
|
||||||
val navHostFragment =
|
notifyPhysicalControllerState()
|
||||||
supportFragmentManager.findFragmentById(R.id.fragment_container) as? NavHostFragment
|
|
||||||
val emulationFragment =
|
|
||||||
navHostFragment?.childFragmentManager?.fragments?.firstOrNull() as? org.yuzu.yuzu_emu.fragments.EmulationFragment
|
|
||||||
emulationFragment?.onControllerConnected()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onInputDeviceRemoved(deviceId: Int) {
|
override fun onInputDeviceRemoved(deviceId: Int) {
|
||||||
InputHandler.updateControllerData()
|
InputHandler.updateControllerData()
|
||||||
val navHostFragment =
|
notifyPhysicalControllerState()
|
||||||
supportFragmentManager.findFragmentById(R.id.fragment_container) as? NavHostFragment
|
|
||||||
val emulationFragment =
|
|
||||||
navHostFragment?.childFragmentManager?.fragments?.firstOrNull() as? org.yuzu.yuzu_emu.fragments.EmulationFragment
|
|
||||||
emulationFragment?.onControllerDisconnected()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onInputDeviceChanged(deviceId: Int) {
|
override fun onInputDeviceChanged(deviceId: Int) {
|
||||||
if (isGameController(deviceId)) {
|
if (isGameController(deviceId)) {
|
||||||
InputHandler.updateControllerData()
|
InputHandler.updateControllerData()
|
||||||
|
notifyPhysicalControllerState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun notifyPhysicalControllerState() {
|
||||||
|
val navHostFragment =
|
||||||
|
supportFragmentManager.findFragmentById(R.id.fragment_container) as? NavHostFragment
|
||||||
|
val emulationFragment =
|
||||||
|
navHostFragment?.childFragmentManager?.fragments?.firstOrNull() as? org.yuzu.yuzu_emu.fragments.EmulationFragment
|
||||||
|
emulationFragment?.onPhysicalControllerStateChanged(InputHandler.androidControllers.isNotEmpty())
|
||||||
|
}
|
||||||
|
|
||||||
override fun onSensorChanged(event: SensorEvent) {
|
override fun onSensorChanged(event: SensorEvent) {
|
||||||
if (!NativeLibrary.isRunning() || NativeLibrary.isPaused()) {
|
if (!NativeLibrary.isRunning() || NativeLibrary.isPaused()) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ import org.yuzu.yuzu_emu.utils.FileUtil
|
||||||
import org.yuzu.yuzu_emu.utils.GameHelper
|
import org.yuzu.yuzu_emu.utils.GameHelper
|
||||||
import org.yuzu.yuzu_emu.utils.GameIconUtils
|
import org.yuzu.yuzu_emu.utils.GameIconUtils
|
||||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||||
|
import org.yuzu.yuzu_emu.utils.InputHandler
|
||||||
import org.yuzu.yuzu_emu.utils.Log
|
import org.yuzu.yuzu_emu.utils.Log
|
||||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||||
import org.yuzu.yuzu_emu.utils.NativeFreedrenoConfig
|
import org.yuzu.yuzu_emu.utils.NativeFreedrenoConfig
|
||||||
|
|
@ -114,6 +115,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
private var controllerInputReceived = false
|
private var controllerInputReceived = false
|
||||||
|
private var hasPhysicalControllerConnected = false
|
||||||
|
private var overlayHiddenByPhysicalController = false
|
||||||
|
|
||||||
private var _binding: FragmentEmulationBinding? = null
|
private var _binding: FragmentEmulationBinding? = null
|
||||||
|
|
||||||
|
|
@ -666,6 +669,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
driverInUse = driverViewModel.selectedDriverVersion.value
|
driverInUse = driverViewModel.selectedDriverVersion.value
|
||||||
|
|
||||||
updateQuickOverlayMenuEntry(BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean())
|
updateQuickOverlayMenuEntry(BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean())
|
||||||
|
onPhysicalControllerStateChanged(InputHandler.androidControllers.isNotEmpty())
|
||||||
|
|
||||||
binding.surfaceEmulation.holder.addCallback(this)
|
binding.surfaceEmulation.holder.addCallback(this)
|
||||||
binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
|
binding.doneControlConfig.setOnClickListener { stopConfiguringControls() }
|
||||||
|
|
@ -760,11 +764,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
|
|
||||||
R.id.menu_quick_overlay -> {
|
R.id.menu_quick_overlay -> {
|
||||||
val newState = !BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()
|
val newState = !BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()
|
||||||
BooleanSetting.SHOW_INPUT_OVERLAY.setBoolean(newState)
|
|
||||||
updateQuickOverlayMenuEntry(newState)
|
|
||||||
binding.surfaceInputOverlay.refreshControls()
|
|
||||||
// Sync view visibility with the setting
|
|
||||||
toggleOverlay(newState)
|
toggleOverlay(newState)
|
||||||
|
updateQuickOverlayMenuEntry(BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean())
|
||||||
NativeConfig.saveGlobalConfig()
|
NativeConfig.saveGlobalConfig()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
@ -1053,7 +1054,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
val shouldShowOverlay = if (args.overlayGamelessEditMode) {
|
val shouldShowOverlay = if (args.overlayGamelessEditMode) {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
showInputOverlay && emulationViewModel.emulationStarted.value
|
showInputOverlay && emulationViewModel.emulationStarted.value &&
|
||||||
|
!hasPhysicalControllerConnected
|
||||||
}
|
}
|
||||||
b.surfaceInputOverlay.setVisible(shouldShowOverlay)
|
b.surfaceInputOverlay.setVisible(shouldShowOverlay)
|
||||||
if (!isInFoldableLayout) {
|
if (!isInFoldableLayout) {
|
||||||
|
|
@ -2497,6 +2499,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
|
|
||||||
fun toggleOverlay(enable: Boolean) {
|
fun toggleOverlay(enable: Boolean) {
|
||||||
if (!isAdded || _binding == null) return
|
if (!isAdded || _binding == null) return
|
||||||
|
if (enable && hasPhysicalControllerConnected && !args.overlayGamelessEditMode) return
|
||||||
if (enable == !BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()) {
|
if (enable == !BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()) {
|
||||||
// Reset controller input flag so controller can hide overlay again
|
// Reset controller input flag so controller can hide overlay again
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
|
|
@ -2520,13 +2523,30 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onControllerConnected() {
|
fun onControllerConnected() {
|
||||||
controllerInputReceived = false
|
onPhysicalControllerStateChanged(InputHandler.androidControllers.isNotEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onControllerDisconnected() {
|
fun onControllerDisconnected() {
|
||||||
if (!BooleanSetting.HIDE_OVERLAY_ON_CONTROLLER_INPUT.getBoolean()) return
|
onPhysicalControllerStateChanged(InputHandler.androidControllers.isNotEmpty())
|
||||||
if (!BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()) return
|
}
|
||||||
|
|
||||||
|
fun onPhysicalControllerStateChanged(hasConnectedControllers: Boolean) {
|
||||||
|
hasPhysicalControllerConnected = hasConnectedControllers
|
||||||
controllerInputReceived = false
|
controllerInputReceived = false
|
||||||
toggleOverlay(true)
|
if (!isAdded || _binding == null) return
|
||||||
|
if (binding.surfaceInputOverlay.isGamelessMode()) return
|
||||||
|
|
||||||
|
if (hasConnectedControllers) {
|
||||||
|
if (BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()) {
|
||||||
|
overlayHiddenByPhysicalController = true
|
||||||
|
toggleOverlay(false)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overlayHiddenByPhysicalController) {
|
||||||
|
overlayHiddenByPhysicalController = false
|
||||||
|
toggleOverlay(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue