11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4- using System . Diagnostics ;
54using System . Diagnostics . CodeAnalysis ;
65using System . Numerics ;
76using System . Runtime . CompilerServices ;
@@ -28,8 +27,8 @@ protected SdlPointerDevice(SdlInputBackend backend, nint silkId,
2827 }
2928 }
3029
31-
32- protected void AddButtonEvent ( PointerButton button , long timestamp , ulong sdlTimestamp , bool isDown , float ? pressure = null )
30+ protected void AddButtonEvent ( PointerButton button , long timestamp , ulong sdlTimestamp , bool isDown ,
31+ float ? pressure = null )
3332 {
3433 pressure ??= isDown ? 1.0f : 0.0f ;
3534 var idx = EnumInfo < PointerButton > . ValueIndexOfUnnamed ( button ) ;
@@ -46,7 +45,8 @@ protected void AddButtonEvent(PointerButton button, long timestamp, ulong sdlTim
4645
4746 if ( myButton != original )
4847 {
49- ButtonEvents . Enqueue ( new ButtonChangedEvent < PointerButton > ( this , timestamp , myButton , original ) , sdlTimestamp ) ;
48+ ButtonEvents . Enqueue ( new ButtonChangedEvent < PointerButton > ( this , timestamp , myButton , original ) ,
49+ sdlTimestamp ) ;
5050 }
5151 }
5252
@@ -79,6 +79,7 @@ private ref Button<PointerButton> GetButtonRef(PointerButton button)
7979 public void FinalizeUpdate ( )
8080 {
8181 RepopulateActiveTargets ( ) ;
82+
8283 return ;
8384
8485 void RepopulateActiveTargets ( )
@@ -163,7 +164,6 @@ private unsafe ref TargetPoint CreateOrUpdateTargetPoint(IPointerTarget? target,
163164 }
164165
165166
166-
167167 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
168168 private static Ray3D < float > ConstructRay ( in Vector3D < float > origin , Vector3D < float > ? direction = null ) =>
169169 new ( origin , direction ?? Vector3D < float > . UnitZ ) ;
@@ -300,8 +300,7 @@ private TargetPoint ToTargetPoint(in Vector3 posOnTarget, float pressure, IPoint
300300 ) ;
301301 }
302302
303- protected void AddMouseScrollEvent ( Vector2 scrollWheelPosition , uint ? windowId , Vector3 ? position ,
304- bool isMouseRelative , ulong sdlTimestamp , long timestamp )
303+ protected void AddMouseScrollEvent ( Vector2 scrollWheelPosition , Vector2 scrollWheelDelta , Vector3 mousePos , uint ? windowId , ulong sdlTimestamp , long timestamp )
305304 {
306305 if ( this is not IMouse mouse )
307306 {
@@ -311,23 +310,19 @@ protected void AddMouseScrollEvent(Vector2 scrollWheelPosition, uint? windowId,
311310 uint ? touchId = null ;
312311 GetPointIdentifiers ( ref touchId , windowId ?? _previousWindowId , out var windowTarget ) ;
313312
314- ref var point = ref CreateOrUpdateTargetPoint ( windowTarget , touchId . Value , null , null , null , out _ ) ;
315-
316- var previousScroll = _previousScrollWheelPosition ?? Vector2 . Zero ;
313+ ref var point = ref CreateOrUpdateTargetPoint ( windowTarget , touchId . Value , mousePos , null , null , out _ ) ;
317314
318315 ScrollEvents . Enqueue ( new MouseScrollEvent (
319316 Mouse : mouse ,
320317 Timestamp : timestamp ,
321318 Point : point ,
322319 WheelPosition : scrollWheelPosition ,
323- Delta : scrollWheelPosition - previousScroll ) , sdlTimestamp ) ;
320+ Delta : scrollWheelDelta ) , sdlTimestamp ) ;
324321
325- _previousScrollWheelPosition = scrollWheelPosition ;
326322 }
327323
328- private Vector2 ? _previousScrollWheelPosition ;
329-
330- protected void UpdatePointRay ( uint ? touchId , float ? xTilt , float ? yTilt , float ? zTwist , float ? distance , ulong sdlTimestamp , long timestamp )
324+ protected void UpdatePointRay ( uint ? touchId , float ? xTilt , float ? yTilt , float ? zTwist , float ? distance ,
325+ ulong sdlTimestamp , long timestamp )
331326 {
332327 if ( xTilt == null && yTilt == null && zTwist == null && distance == null )
333328 {
@@ -358,7 +353,8 @@ protected void SetGripPressure(float pressure, ulong sdlTimestamp, long timestam
358353 {
359354 // todo - use only the given events to update the state? is that possible? keyboard character input would probably be a problem..
360355 State . GripPressure = pressure ;
361- GripEvents . Enqueue ( new PointerGripChangedEvent ( this , timestamp , pressure , pressure - State . GripPressure ) , sdlTimestamp ) ;
356+ GripEvents . Enqueue ( new PointerGripChangedEvent ( this , timestamp , pressure , pressure - State . GripPressure ) ,
357+ sdlTimestamp ) ;
362358 }
363359
364360
0 commit comments