mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 15:09:58 +01:00
Revert "android: Gross disgusting awful workaround for #1267"
This reverts commit 106e994dbf31bfae503551326a1a4b0c48647fab.
This commit is contained in:
parent
2087f96e90
commit
a964e63722
@ -97,82 +97,42 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
return onTouchWhileEditing(event)
|
||||
}
|
||||
|
||||
var hasActiveButtons = false
|
||||
val pointerIndex = event.actionIndex
|
||||
val pointerId = event.getPointerId(pointerIndex)
|
||||
|
||||
val xPosition = event.getX(pointerIndex).toInt()
|
||||
val yPosition = event.getY(pointerIndex).toInt()
|
||||
val motionEvent = event.action and MotionEvent.ACTION_MASK
|
||||
val isActionDown =
|
||||
motionEvent == MotionEvent.ACTION_DOWN || motionEvent == MotionEvent.ACTION_POINTER_DOWN
|
||||
val isActionMove = motionEvent == MotionEvent.ACTION_MOVE
|
||||
val isActionUp =
|
||||
motionEvent == MotionEvent.ACTION_UP || motionEvent == MotionEvent.ACTION_POINTER_UP
|
||||
|
||||
var hasActiveButtons = false
|
||||
var isAnyButtonSliding = false
|
||||
for (button in overlayButtons) {
|
||||
if (button.trackId == pointerId) {
|
||||
hasActiveButtons = true
|
||||
}
|
||||
if (button.isButtonSliding) {
|
||||
if (isActionUp) {
|
||||
// A touch event ended, so tell any buttons tracking sliding to stop
|
||||
button.isButtonSliding = false
|
||||
} else {
|
||||
isAnyButtonSliding = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
var hasActiveDpad = false
|
||||
if (!hasActiveButtons) {
|
||||
for (dpad in overlayDpads) {
|
||||
if (dpad.trackId == pointerId) {
|
||||
hasActiveDpad = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hasActiveJoystick = false
|
||||
if(!hasActiveButtons && !hasActiveDpad){
|
||||
for (joystick in overlayJoysticks) {
|
||||
if (joystick.trackId == pointerId) {
|
||||
hasActiveJoystick = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var shouldUpdateView = false
|
||||
|
||||
if (!preferences.getBoolean("isTouchEnabled", true)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (isActionMove) {
|
||||
var noneConsumed = true
|
||||
for (i in 0 until event.pointerCount) {
|
||||
val fingerId = event.getPointerId(i)
|
||||
if (isTouchInputConsumed(fingerId)) {
|
||||
noneConsumed = false
|
||||
continue
|
||||
}
|
||||
NativeLibrary.onTouchMoved(xPosition.toFloat(), yPosition.toFloat())
|
||||
}
|
||||
|
||||
if (noneConsumed && !isAnyButtonSliding) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (isActionUp && !isTouchInputConsumed(pointerId)) {
|
||||
NativeLibrary.onTouchEvent(0f, 0f, false)
|
||||
}
|
||||
|
||||
var anyStateChanged = false
|
||||
if(!hasActiveDpad && !hasActiveJoystick) {
|
||||
for (button in overlayButtons) {
|
||||
val stateChanged = button.updateStatus(event, hasActiveButtons, this)
|
||||
if (!stateChanged) {
|
||||
continue
|
||||
}
|
||||
anyStateChanged = true
|
||||
|
||||
if (button.id == NativeLibrary.ButtonType.BUTTON_SWAP && button.status == NativeLibrary.ButtonState.PRESSED) {
|
||||
swapScreen()
|
||||
@ -202,7 +162,6 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
if (!stateChanged) {
|
||||
continue
|
||||
}
|
||||
anyStateChanged = true
|
||||
|
||||
NativeLibrary.onGamePadEvent(
|
||||
NativeLibrary.TouchScreenDevice,
|
||||
@ -229,12 +188,12 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasActiveDpad && !hasActiveButtons) {
|
||||
for (joystick in overlayJoysticks) {
|
||||
val stateChanged = joystick.updateStatus(event, true, this)
|
||||
val stateChanged = joystick.updateStatus(event, hasActiveJoystick, this)
|
||||
if (!stateChanged) {
|
||||
continue
|
||||
}
|
||||
anyStateChanged = true
|
||||
|
||||
val axisID = joystick.joystickId
|
||||
NativeLibrary.onGamePadMoveEvent(
|
||||
@ -246,15 +205,39 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
|
||||
shouldUpdateView = true
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldUpdateView) {
|
||||
invalidate()
|
||||
}
|
||||
|
||||
if (!anyStateChanged && isActionDown && !isTouchInputConsumed(pointerId)) {
|
||||
NativeLibrary.onTouchEvent(xPosition.toFloat(), yPosition.toFloat(), true)
|
||||
if (!preferences.getBoolean("isTouchEnabled", true)) {
|
||||
return true
|
||||
}
|
||||
|
||||
val xPosition = event.getX(pointerIndex).toInt()
|
||||
val yPosition = event.getY(pointerIndex).toInt()
|
||||
val motionEvent = event.action and MotionEvent.ACTION_MASK
|
||||
val isActionDown =
|
||||
motionEvent == MotionEvent.ACTION_DOWN || motionEvent == MotionEvent.ACTION_POINTER_DOWN
|
||||
val isActionMove = motionEvent == MotionEvent.ACTION_MOVE
|
||||
val isActionUp =
|
||||
motionEvent == MotionEvent.ACTION_UP || motionEvent == MotionEvent.ACTION_POINTER_UP
|
||||
if (isActionDown && !isTouchInputConsumed(pointerId)) {
|
||||
NativeLibrary.onTouchEvent(xPosition.toFloat(), yPosition.toFloat(), true)
|
||||
}
|
||||
if (isActionMove) {
|
||||
for (i in 0 until event.pointerCount) {
|
||||
val fingerId = event.getPointerId(i)
|
||||
if (isTouchInputConsumed(fingerId)) {
|
||||
continue
|
||||
}
|
||||
NativeLibrary.onTouchMoved(xPosition.toFloat(), yPosition.toFloat())
|
||||
}
|
||||
}
|
||||
if (isActionUp && !isTouchInputConsumed(pointerId)) {
|
||||
NativeLibrary.onTouchEvent(0f, 0f, false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,6 @@ class InputOverlayDrawableButton(
|
||||
val opacity: Int
|
||||
) {
|
||||
var trackId: Int
|
||||
var isButtonSliding: Boolean
|
||||
|
||||
private var isMotionFirstButton = false // mark the first activated button with the current motion
|
||||
|
||||
@ -62,7 +61,6 @@ class InputOverlayDrawableButton(
|
||||
this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap)
|
||||
this.pressedStateBitmap = BitmapDrawable(res, pressedStateBitmap)
|
||||
trackId = -1
|
||||
isButtonSliding = false
|
||||
width = this.defaultStateBitmap.intrinsicWidth
|
||||
height = this.defaultStateBitmap.intrinsicHeight
|
||||
}
|
||||
@ -94,7 +92,7 @@ class InputOverlayDrawableButton(
|
||||
if (trackId != pointerId) {
|
||||
return false
|
||||
}
|
||||
buttonUp(overlay, false)
|
||||
buttonUp(overlay)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -111,7 +109,7 @@ class InputOverlayDrawableButton(
|
||||
if (buttonSliding == ButtonSlidingMode.Alternative.int && isMotionFirstButton) {
|
||||
return false
|
||||
}
|
||||
buttonUp(overlay, true)
|
||||
buttonUp(overlay)
|
||||
return true
|
||||
} else {
|
||||
// button was not yet pressed
|
||||
@ -134,11 +132,10 @@ class InputOverlayDrawableButton(
|
||||
overlay.hapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
|
||||
}
|
||||
|
||||
private fun buttonUp(overlay: InputOverlay, _isButtonSliding: Boolean) {
|
||||
private fun buttonUp(overlay: InputOverlay) {
|
||||
pressedState = false
|
||||
isMotionFirstButton = false
|
||||
trackId = -1
|
||||
isButtonSliding = _isButtonSliding
|
||||
overlay.hapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY_RELEASE)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user