Skip to content

Commit dca8e21

Browse files
committed
WIP timestamp events
1 parent 195116b commit dca8e21

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

osu.Framework/Platform/SDL3/SDL3Window_Input.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ private void handleTextEditingEvent(SDL_TextEditingEvent evtEdit)
508508

509509
private void handleKeyboardEvent(SDL_KeyboardEvent evtKey)
510510
{
511+
// GlobalEventTimestamps.LastTimestamp = (long)evtKey.timestamp;
512+
GlobalEventTimestamps.LastTimestamp = GlobalEventTimestamps.GetTimestamp();
513+
511514
Key key = evtKey.ToKey();
512515

513516
if (key == Key.Unknown)
@@ -760,4 +763,15 @@ private void updateConfineMode()
760763

761764
#endregion
762765
}
766+
767+
public static class GlobalEventTimestamps
768+
{
769+
public static long LastTimestamp;
770+
771+
public static long GetTimestamp() => Stopwatch.GetTimestamp();
772+
public static double GetDelta(long t1, long t2) => (double)(t2 - t1) / Stopwatch.Frequency * 1000;
773+
774+
public static ulong GetTimestamp_SDL() => SDL_GetTicksNS();
775+
public static double GetDelta_SDL(ulong t1, ulong t2) => (t2 - t1) / 1e6;
776+
}
763777
}

0 commit comments

Comments
 (0)