mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Hide touch controls if gamepad is detected
This commit is contained in:
@ -376,6 +376,8 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
setOnClickListener { binding.onScreenControllerView.isInvisible = !binding.onScreenControllerView.isInvisible }
|
setOnClickListener { binding.onScreenControllerView.isInvisible = !binding.onScreenControllerView.isInvisible }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.onScreenControllerView.isInvisible = isControllerConnected()
|
||||||
|
|
||||||
binding.onScreenPauseToggle.apply {
|
binding.onScreenPauseToggle.apply {
|
||||||
isGone = !emulationSettings.showPauseButton
|
isGone = !emulationSettings.showPauseButton
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
@ -641,6 +643,23 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isControllerConnected() : Boolean {
|
||||||
|
val deviceIds = InputDevice.getDeviceIds()
|
||||||
|
|
||||||
|
deviceIds.forEach { deviceId ->
|
||||||
|
InputDevice.getDevice(deviceId).apply {
|
||||||
|
// Verify that the device has gamepad buttons, control sticks, or both.
|
||||||
|
if (sources and InputDevice.SOURCE_GAMEPAD == InputDevice.SOURCE_GAMEPAD
|
||||||
|
|| sources and InputDevice.SOURCE_JOYSTICK == InputDevice.SOURCE_JOYSTICK) {
|
||||||
|
// This device is a game controller.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun dispatchKeyEvent(event : KeyEvent) : Boolean {
|
override fun dispatchKeyEvent(event : KeyEvent) : Boolean {
|
||||||
return if (inputHandler.handleKeyEvent(event)) true else super.dispatchKeyEvent(event)
|
return if (inputHandler.handleKeyEvent(event)) true else super.dispatchKeyEvent(event)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user