diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.java | 78 |
1 files changed, 50 insertions, 28 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.java index 6b51a596f..50c95d1de 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.java +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.java | |||
| @@ -341,34 +341,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener { | |||
| 341 | return onTouchWhileEditing(event); | 341 | return onTouchWhileEditing(event); |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | int pointerIndex = event.getActionIndex(); | ||
| 345 | |||
| 346 | if (mPreferences.getBoolean("isTouchEnabled", true)) { | ||
| 347 | switch (event.getAction() & MotionEvent.ACTION_MASK) { | ||
| 348 | case MotionEvent.ACTION_DOWN: | ||
| 349 | case MotionEvent.ACTION_POINTER_DOWN: | ||
| 350 | if (NativeLibrary.onTouchEvent(event.getX(pointerIndex), event.getY(pointerIndex), true)) { | ||
| 351 | mTouchscreenPointerId = event.getPointerId(pointerIndex); | ||
| 352 | } | ||
| 353 | break; | ||
| 354 | case MotionEvent.ACTION_UP: | ||
| 355 | case MotionEvent.ACTION_POINTER_UP: | ||
| 356 | if (mTouchscreenPointerId == event.getPointerId(pointerIndex)) { | ||
| 357 | // We don't really care where the touch has been released. We only care whether it has been | ||
| 358 | // released or not. | ||
| 359 | NativeLibrary.onTouchEvent(0, 0, false); | ||
| 360 | mTouchscreenPointerId = -1; | ||
| 361 | } | ||
| 362 | break; | ||
| 363 | } | ||
| 364 | |||
| 365 | for (int i = 0; i < event.getPointerCount(); i++) { | ||
| 366 | if (mTouchscreenPointerId == event.getPointerId(i)) { | ||
| 367 | NativeLibrary.onTouchMoved(event.getX(i), event.getY(i)); | ||
| 368 | } | ||
| 369 | } | ||
| 370 | } | ||
| 371 | |||
| 372 | for (InputOverlayDrawableButton button : overlayButtons) { | 344 | for (InputOverlayDrawableButton button : overlayButtons) { |
| 373 | if (!button.updateStatus(event)) { | 345 | if (!button.updateStatus(event)) { |
| 374 | continue; | 346 | continue; |
| @@ -395,11 +367,61 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener { | |||
| 395 | NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, joystick.getButtonId(), joystick.getButtonStatus()); | 367 | NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, joystick.getButtonId(), joystick.getButtonStatus()); |
| 396 | } | 368 | } |
| 397 | 369 | ||
| 370 | if (!mPreferences.getBoolean("isTouchEnabled", true)) { | ||
| 371 | return true; | ||
| 372 | } | ||
| 373 | |||
| 374 | int pointerIndex = event.getActionIndex(); | ||
| 375 | int xPosition = (int) event.getX(pointerIndex); | ||
| 376 | int yPosition = (int) event.getY(pointerIndex); | ||
| 377 | int pointerId = event.getPointerId(pointerIndex); | ||
| 378 | int motion_event = event.getAction() & MotionEvent.ACTION_MASK; | ||
| 379 | boolean isActionDown = motion_event == MotionEvent.ACTION_DOWN || motion_event == MotionEvent.ACTION_POINTER_DOWN; | ||
| 380 | boolean isActionMove = motion_event == MotionEvent.ACTION_MOVE; | ||
| 381 | boolean isActionUp = motion_event == MotionEvent.ACTION_UP || motion_event == MotionEvent.ACTION_POINTER_UP; | ||
| 382 | |||
| 383 | if (isActionDown && !isTouchInputConsumed(pointerId)) { | ||
| 384 | NativeLibrary.onTouchEvent(xPosition, yPosition, true); | ||
| 385 | } | ||
| 386 | |||
| 387 | if (isActionMove) { | ||
| 388 | for (int i = 0; i < event.getPointerCount(); i++) { | ||
| 389 | int fingerId = event.getPointerId(i); | ||
| 390 | if (isTouchInputConsumed(fingerId)) { | ||
| 391 | continue; | ||
| 392 | } | ||
| 393 | NativeLibrary.onTouchMoved(event.getX(i), event.getY(i)); | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 397 | if (isActionUp && !isTouchInputConsumed(pointerId)) { | ||
| 398 | NativeLibrary.onTouchEvent(xPosition, yPosition, false); | ||
| 399 | } | ||
| 400 | |||
| 398 | invalidate(); | 401 | invalidate(); |
| 399 | 402 | ||
| 400 | return true; | 403 | return true; |
| 401 | } | 404 | } |
| 402 | 405 | ||
| 406 | private boolean isTouchInputConsumed(int track_id) { | ||
| 407 | for (InputOverlayDrawableButton button : overlayButtons) { | ||
| 408 | if (button.getTrackId() == track_id) { | ||
| 409 | return true; | ||
| 410 | } | ||
| 411 | } | ||
| 412 | for (InputOverlayDrawableDpad dpad : overlayDpads) { | ||
| 413 | if (dpad.getTrackId() == track_id) { | ||
| 414 | return true; | ||
| 415 | } | ||
| 416 | } | ||
| 417 | for (InputOverlayDrawableJoystick joystick : overlayJoysticks) { | ||
| 418 | if (joystick.getTrackId() == track_id) { | ||
| 419 | return true; | ||
| 420 | } | ||
| 421 | } | ||
| 422 | return false; | ||
| 423 | } | ||
| 424 | |||
| 403 | public boolean onTouchWhileEditing(MotionEvent event) { | 425 | public boolean onTouchWhileEditing(MotionEvent event) { |
| 404 | // TODO: Reimplement this | 426 | // TODO: Reimplement this |
| 405 | return true; | 427 | return true; |