@@ -524,14 +524,29 @@ private void handleKeyboardEvent(SDL_KeyboardEvent evtKey)
524
524
525
525
private void handleKeymapChangedEvent ( ) => KeymapChanged ? . Invoke ( ) ;
526
526
527
+ // pen input events should ultimately have its own input flow with code from InputManager to fall back to mouse input,
528
+ // but as the current structure of InputManager completely disallows that, synthesize touch input on pen events
529
+ // so it still works correctly for our use case (consider OsuTouchInputMapper in osu!).
530
+
527
531
private void handlePenMotionEvent ( SDL_PenMotionEvent evtPenMotion )
528
532
{
529
- PenMove ? . Invoke ( new Vector2 ( evtPenMotion . x , evtPenMotion . y ) * Scale ) ;
533
+ var pos = new Vector2 ( evtPenMotion . x , evtPenMotion . y ) * Scale ;
534
+
535
+ if ( evtPenMotion . pen_state . HasFlagFast ( SDL_PenInputFlags . SDL_PEN_INPUT_DOWN ) )
536
+ TouchDown ? . Invoke ( new Touch ( TouchSource . PenTouch , pos ) ) ;
537
+ else
538
+ PenMove ? . Invoke ( pos ) ;
530
539
}
531
540
532
541
private void handlePenTouchEvent ( SDL_PenTouchEvent evtPenTouch )
533
542
{
534
- PenTouch ? . Invoke ( evtPenTouch . down ) ;
543
+ var pos = new Vector2 ( evtPenTouch . x , evtPenTouch . y ) * Scale ;
544
+ var touch = new Touch ( TouchSource . PenTouch , pos ) ;
545
+
546
+ if ( evtPenTouch . down )
547
+ TouchDown ? . Invoke ( touch ) ;
548
+ else
549
+ TouchUp ? . Invoke ( touch ) ;
535
550
}
536
551
537
552
/// <summary>
@@ -741,11 +756,6 @@ private void updateConfineMode()
741
756
/// </summary>
742
757
public event Action < Vector2 > ? PenMove ;
743
758
744
- /// <summary>
745
- /// Invoked when a pen touches (<c>true</c>) or lifts (<c>false</c>) from the tablet surface.
746
- /// </summary>
747
- public event Action < bool > ? PenTouch ;
748
-
749
759
/// <summary>
750
760
/// Invoked when a <see cref="TabletPenButton">pen button</see> is pressed (<c>true</c>) or released (<c>false</c>).
751
761
/// </summary>
0 commit comments