|
1 | 1 | using SDL; |
2 | 2 | using System; |
3 | 3 | using System.Collections.Generic; |
| 4 | +using System.Numerics; |
4 | 5 | using System.Runtime.InteropServices; |
5 | 6 | using System.Text; |
6 | 7 |
|
@@ -448,36 +449,72 @@ public void PollEvents() |
448 | 449 | case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN: |
449 | 450 | case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP: |
450 | 451 |
|
451 | | - AppEventQueue.instance.Add(AppEvent.Mouse(_event.button.button switch |
| 452 | + if (Platform.IsDesktopPlatform) |
452 | 453 | { |
453 | | - 1 => AppEventMouseButton.Left, |
454 | | - 2 => AppEventMouseButton.Middle, |
455 | | - 3 => AppEventMouseButton.Right, |
456 | | - 4 => AppEventMouseButton.Button1, |
457 | | - 5 => AppEventMouseButton.Button2, |
458 | | - _ => 0, |
459 | | - }, |
| 454 | + AppEventQueue.instance.Add(AppEvent.Mouse(_event.button.button switch |
| 455 | + { |
| 456 | + 1 => AppEventMouseButton.Left, |
| 457 | + 2 => AppEventMouseButton.Middle, |
| 458 | + 3 => AppEventMouseButton.Right, |
| 459 | + 4 => AppEventMouseButton.Button1, |
| 460 | + 5 => AppEventMouseButton.Button2, |
| 461 | + _ => 0, |
| 462 | + }, |
460 | 463 | _event.button.down ? AppEventInputState.Press : AppEventInputState.Release, |
461 | 464 | GetModifiers(SDL3.SDL_GetModState()))); |
| 465 | + } |
462 | 466 |
|
463 | 467 | break; |
464 | 468 |
|
465 | 469 | case SDL_EventType.SDL_EVENT_MOUSE_MOTION: |
466 | 470 |
|
467 | | - if (SDL3.SDL_GetWindowRelativeMouseMode(window)) |
| 471 | + if(Platform.IsDesktopPlatform) |
| 472 | + { |
| 473 | + if (SDL3.SDL_GetWindowRelativeMouseMode(window)) |
| 474 | + { |
| 475 | + Input.CursorPosCallback(_event.motion.xrel, _event.motion.yrel); |
| 476 | + } |
| 477 | + else |
| 478 | + { |
| 479 | + Input.CursorPosCallback(_event.motion.x, _event.motion.y); |
| 480 | + } |
| 481 | + } |
| 482 | + |
| 483 | + break; |
| 484 | + |
| 485 | + case SDL_EventType.SDL_EVENT_MOUSE_WHEEL: |
| 486 | + |
| 487 | + if (Platform.IsDesktopPlatform) |
468 | 488 | { |
469 | | - Input.CursorPosCallback(_event.motion.xrel, _event.motion.yrel); |
| 489 | + Input.MouseScrollCallback(_event.wheel.x, _event.wheel.y); |
470 | 490 | } |
471 | | - else |
| 491 | + |
| 492 | + break; |
| 493 | + |
| 494 | + case SDL_EventType.SDL_EVENT_FINGER_CANCELED: |
| 495 | + case SDL_EventType.SDL_EVENT_FINGER_DOWN: |
| 496 | + case SDL_EventType.SDL_EVENT_FINGER_UP: |
| 497 | + |
472 | 498 | { |
473 | | - Input.CursorPosCallback(_event.motion.x, _event.motion.y); |
| 499 | + var size = Size; |
| 500 | + |
| 501 | + AppEventQueue.instance.Add(AppEvent.Touch((int)_event.tfinger.fingerID, |
| 502 | + new Vector2((int)(_event.tfinger.x * size.X), (int)(_event.tfinger.y * size.Y)), |
| 503 | + (SDL_EventType)_event.type == SDL_EventType.SDL_EVENT_FINGER_DOWN ? |
| 504 | + AppEventInputState.Press : AppEventInputState.Release)); |
474 | 505 | } |
475 | 506 |
|
476 | 507 | break; |
477 | 508 |
|
478 | | - case SDL_EventType.SDL_EVENT_MOUSE_WHEEL: |
| 509 | + case SDL_EventType.SDL_EVENT_FINGER_MOTION: |
479 | 510 |
|
480 | | - Input.MouseScrollCallback(_event.wheel.x, _event.wheel.y); |
| 511 | + { |
| 512 | + var size = Size; |
| 513 | + |
| 514 | + AppEventQueue.instance.Add(AppEvent.Touch((int)_event.tfinger.fingerID, |
| 515 | + new Vector2((int)(_event.tfinger.x * size.X), (int)(_event.tfinger.y * size.Y)), |
| 516 | + AppEventInputState.Repeat)); |
| 517 | + } |
481 | 518 |
|
482 | 519 | break; |
483 | 520 |
|
|
0 commit comments