33
44using System . Numerics ;
55using System . Runtime . CompilerServices ;
6+ using Silk . NET . Input . SDL3 . Extensions ;
67using Silk . NET . SDL ;
78
89namespace Silk . NET . Input . SDL3 . Devices . Pointers ;
@@ -32,24 +33,10 @@ protected internal override void Initialize(long timestamp, ulong sdlTimestamp)
3233 ApplyMouseButtonState ( mouseInputFlags , sdlTimestamp , timestamp ) ;
3334
3435 var window = NativeBackend . GetMouseFocus ( ) ;
35- uint windowId ;
36- if ( window == nullptr )
36+ if ( Backend . TryGetOrCreatePointerTargetForWindow ( window , out var target ) )
3737 {
38- windowId = 0 ;
38+ AddOrUpdatePoint ( null , target , new Vector3 ( x , y , 0 ) , null , DownState , null , true , sdlTimestamp , timestamp ) ;
3939 }
40- else
41- {
42- windowId = NativeBackend . GetWindowID ( window ) ;
43- if ( windowId == 0 )
44- {
45- SdlLog . Error ( "Mouse has no window" ) ;
46- }
47- }
48-
49-
50- // var pressure = _state.Buttons[PointerButton.Primary].Pressure;
51- Backend . TryGetPointerTargetForWindow ( windowId , out var target ) ;
52- AddOrUpdatePoint ( null , target , new Vector3 ( x , y , 0 ) , null , DownState , null , true , sdlTimestamp , timestamp ) ;
5340 // var point = _unboundedPointerTarget.GetPoint(this, 0);
5441 }
5542
@@ -184,13 +171,8 @@ public bool TrySetPosition(Vector2 position)
184171 /// </summary>
185172 public bool NeedsPump { get ; private set ; }
186173
187- public void AddMotion ( in MouseMotionEvent evtMotion , long timestamp )
174+ public void AddMotion ( in MouseMotionEvent evtMotion , IPointerTarget target , long timestamp )
188175 {
189- if ( ! Backend . TryGetPointerTargetForWindow ( evtMotion . WindowID , out var target ) )
190- {
191- throw new InvalidOperationException ( "Failed to get pointer target for window" ) ;
192- }
193-
194176 AddOrUpdatePoint ( null , target , new Vector3 ( evtMotion . X , evtMotion . Y , 0 ) , 1 , null , null ,
195177 evtMotion . WindowID != 0 , evtMotion . Timestamp , timestamp ) ;
196178 }
@@ -211,7 +193,7 @@ public void AddButtonEvent(in MouseButtonEvent evtButton, long timestamp)
211193 AddButtonEvent ( button , timestamp , evtButton . Timestamp , evtButton . Down > 0 , evtButton . Down * mult ) ;
212194 }
213195
214- public void AddWheelEvent ( in MouseWheelEvent evtWheel , long timestamp )
196+ public void AddWheelEvent ( in MouseWheelEvent evtWheel , IPointerTarget target , long timestamp )
215197 {
216198 var pWheelPosition = _state . WheelPosition ;
217199 const float max = 100f ;
@@ -230,7 +212,7 @@ public void AddWheelEvent(in MouseWheelEvent evtWheel, long timestamp)
230212 AddMouseScrollEvent (
231213 scrollWheelPosition : _state . WheelPosition = pWheelPosition + delta ,
232214 scrollWheelDelta : delta ,
233- windowId : evtWheel . WindowID ,
215+ target : target ,
234216 sdlTimestamp : evtWheel . Timestamp ,
235217 mousePos : new Vector3 ( evtWheel . X , evtWheel . Y , 0 ) ,
236218 timestamp : timestamp ) ;
0 commit comments