Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
f5b5f1c
Start work on documenting the API
Perksey Feb 15, 2025
4888320
Finish documenting API & split out files
Perksey Feb 22, 2025
2585ede
Add InputMarshal and InputContextDeviceList, lay out SDL implementation
Perksey Mar 15, 2025
2080e1b
Start on SdlInputBackend
Perksey Apr 5, 2025
f1880f0
Push latest work on SDL backend
Perksey May 25, 2025
1d16317
Remove types I didn't use in the end
Perksey May 25, 2025
e497dde
begin mucking about input event processing
domportera Jun 22, 2025
f129ae9
refine internal device creation abstractions
domportera Jun 24, 2025
fcf49f6
continued - move name back where it belongs
domportera Jun 24, 2025
33cc20d
cont'd
domportera Jun 29, 2025
e72bf55
comments/clarity + enum helper class
domportera Jul 4, 2025
3e4e168
simplify enum assistant and provide guaranteed sorted enum values
domportera Jul 4, 2025
bce7136
simpler indexing
domportera Jul 4, 2025
8f00a4b
add support for enums with multiple names for the same value
domportera Jul 4, 2025
bf382bc
optimize enum performance for larger enums
domportera Jul 5, 2025
555275b
clarifying comment
domportera Jul 5, 2025
fb889c6
documentation/cleanup enum class
domportera Jul 5, 2025
021a8c9
begin constructing gamepads via the joystick API
domportera Jul 6, 2025
8e7eda4
some experimentation/progress re: axis/button indexing
domportera Aug 9, 2025
e637ba7
joystick/gamepad abstraction progress, expand rumble system
domportera Aug 28, 2025
d0f05aa
cont'd
domportera Aug 29, 2025
7942c92
start attempting to guarantee unique ids
domportera Sep 1, 2025
7e84c15
move backendextensions to its own file, begin keyboard
domportera Sep 6, 2025
8c5f3da
start key conversions
domportera Sep 6, 2025
e20d640
tweak device id abstraction
domportera Sep 6, 2025
4387adb
begin keyboard text handling
domportera Sep 7, 2025
35677b0
improve text retrieval functions
domportera Sep 7, 2025
e0abc15
continue text recorder
domportera Sep 7, 2025
c7159ad
begin integration with sdl native text entry
domportera Sep 12, 2025
436aa72
add span utility
domportera Sep 14, 2025
a35120a
text entry continued
domportera Sep 14, 2025
67df00f
additional modifier utility methods
domportera Sep 14, 2025
dd81078
create world's weakest fallback key -> character converter
domportera Sep 14, 2025
0ba7c09
add joystick interface to gamepad, invoke id refresh
domportera Sep 14, 2025
ec0e48b
increase number of characters supported
domportera Sep 14, 2025
7983462
organization
domportera Sep 14, 2025
e263b9b
constrained usage of special enum-as-indexes functionality via attrib…
domportera Sep 14, 2025
4d77d20
mark method static
domportera Sep 14, 2025
116ec2d
begin pointer logic - mouse
domportera Sep 21, 2025
0503cca
Merge remote-tracking branch 'origin/develop/3.0' into feature/input-3.0
domportera Nov 21, 2025
09fa974
reintegrate Input into solution, upgrade dotnet, make input compileab…
domportera Nov 22, 2025
0eacca1
the s....
domportera Nov 22, 2025
f7e2354
namespace cleanup, begin custom cursor support
domportera Nov 23, 2025
f8f1ab1
Merge remote-tracking branch 'origin/develop/3.0' into feature/input-3.0
domportera Nov 30, 2025
19f7c7c
add method to analyzer
domportera Nov 30, 2025
c509002
cursor api "complete" (untested)
domportera Dec 5, 2025
42e8391
pointer & target work
domportera Dec 5, 2025
a1e793c
organization, pointer type consolidation
domportera Dec 5, 2025
20b50cc
generic target creation and updating
domportera Dec 6, 2025
e4ce82b
more pointer implementation logic
domportera Dec 21, 2025
f5dd29f
begin pen and touch
domportera Dec 28, 2025
a82556d
remove redundant switch cases
domportera Dec 28, 2025
e4deb68
continued handling of pointer device creation
domportera Jan 4, 2026
573240f
cleanup stuff
domportera Jan 9, 2026
4a2cc72
Merge remote-tracking branch 'origin/develop/3.0' into feature/input-3.0
domportera Jan 18, 2026
41290bf
remove unnecessary handle extensions
domportera Jan 18, 2026
de26f77
begin event finalization/dispatch
domportera Jan 23, 2026
6fc626f
correct IInputHandler signature for pointers
domportera Jan 25, 2026
bbc9874
continued
domportera Feb 1, 2026
3701591
continue fleshing out pointer events
domportera Feb 8, 2026
7eaf84b
continue iterating on pointers, continue populating events as they occur
domportera Feb 14, 2026
c04161f
flesh out and streamline gamepad axis updates
domportera Feb 23, 2026
7564d23
key event populatioon
domportera Feb 24, 2026
5279e9d
organize input handlers
domportera Mar 1, 2026
8bf18d1
begin test environment
domportera Mar 1, 2026
4d81309
remove unused Initialize method, fix index out of bounds on cursor in…
domportera Mar 1, 2026
2ed3fd2
implement missing events, improve fallback ID implementation, etc
domportera Mar 20, 2026
6c24e1a
begin precision timing
domportera Mar 22, 2026
564d0b1
continued
domportera Mar 23, 2026
9abcba2
fix mouse scrolling
domportera Mar 29, 2026
09a8deb
lots of stuff
domportera Mar 29, 2026
d7027f7
use stable sort for event ordering
domportera Mar 29, 2026
e4d9055
ensure propagation of device creation events, fix enum-based button i…
domportera Apr 17, 2026
60ba38c
move unsafe value conversions to their own experimental public class
domportera Apr 17, 2026
030a583
add new experimental IDs to NoWarn property of input csproj
domportera Apr 17, 2026
a273d3b
begin correcting joystick/gamepad implementation
domportera May 16, 2026
b270577
gamepad fixes continued
domportera May 23, 2026
c199d9d
complete xbone gamepad implementation
domportera Jun 15, 2026
e6eb8c5
forgot to commit this using statement
domportera Jun 20, 2026
f5baa1f
optimize/correct hot indexing paths, remove unnecessary comment warni…
domportera Jun 25, 2026
c01ddc6
micro-optimization
domportera Jun 25, 2026
57c6fe4
updates for pen devices
domportera Jun 28, 2026
499634c
re-commit previously yeeted method that was used in debug builds
domportera Jun 28, 2026
3655ebe
do some to-dos, cleanup code / todos
domportera Jul 10, 2026
1907a7d
formatting and documentation
domportera Jul 13, 2026
336571d
cleanup, usings reduction, begin gamepad-touchpad input
domportera Jul 18, 2026
8f60d7d
naming clarity with simulated pointer targets
domportera Aug 28, 2026
3621ed6
clean up usage of event pointer
domportera Aug 28, 2026
326c671
correctness, performance, clarity in naming
domportera Aug 29, 2026
5bc141b
remove secondary sorted collection for SDL events
domportera Aug 30, 2026
43ca6f2
use enum discriminator for input event dispatch
domportera Aug 30, 2026
95f91f5
properly dispose of native memory for event queues
domportera Aug 30, 2026
ec2a906
tweaked input event loop for correctness
domportera Aug 30, 2026
eb1a53a
lil code hygeine, remove redundant pre-sort checks
domportera Aug 30, 2026
29ae7cd
replace now-redundant event queue class with NativeMemory<T>
domportera Sep 5, 2026
ea3c5b9
cleanup
domportera Sep 5, 2026
ab910fa
further pointer/target work and organization
domportera Sep 22, 2026
2098777
pointer target point mapping, generic event flow refactor
domportera Sep 22, 2026
5106245
fix some oopsies
domportera Sep 23, 2026
da69dc7
remove unused code, micro-optimizations
domportera Sep 23, 2026
b130d29
fix release compilation, further micro-optimizations & enumerator usa…
domportera Sep 23, 2026
4c87bc3
reduce capacity checks & collections marshall calls
domportera Sep 23, 2026
8524c36
gamepad axis correction & logging
domportera Sep 23, 2026
81bc3a5
flip y-axis so +Y is up
domportera Sep 23, 2026
0a5b2b9
front-load timestamp calculations and perform no sorting on inputs
domportera Sep 23, 2026
c472a02
dispose native memory on exit (oops)
domportera Sep 23, 2026
a79d710
improve mouse/cursor spec compliance
domportera Sep 25, 2026
48d64fe
various fixes:
domportera Sep 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
correctness, performance, clarity in naming
  • Loading branch information
domportera committed Aug 29, 2026
commit 326c67197b4b0bbc4fde91bcd6b43f3889c2e40b
45 changes: 32 additions & 13 deletions sources/Input/Input/Handlers/InputContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,35 @@ private void HandleBackendAddition(IInputBackend backend)

void IInputHandler<ConnectionEvent>.Handle(ConnectionEvent e) => HandleDeviceConnectionChanged(e);

private void HandleDeviceConnectionChanged(ConnectionEvent e)
private void HandleDeviceConnectionChanged(ConnectionEvent evt)
{
InputLog.Debug($"Input device connection changed: {e}");
_pointers?.HandleDeviceConnectionChanged(e);
_joysticks?.HandleDeviceConnectionChanged(e);
_gamepads?.HandleDeviceConnectionChanged(e);
_keyboards?.HandleDeviceConnectionChanged(e);
InputLog.Debug($"Input device connection changed: {evt}");
_pointers?.HandleDeviceConnectionChanged(evt);
_joysticks?.HandleDeviceConnectionChanged(evt);
_gamepads?.HandleDeviceConnectionChanged(evt);
_keyboards?.HandleDeviceConnectionChanged(evt);

if (_devices is null)

if (_devices is not null)
{
return;

if (evt.IsConnected)
{
_devices.Add(evt.Device);
}
else
{
_devices.Remove(evt.Device);
}
}

if (e.IsConnected)
try
{
_devices.Add(e.Device);
ConnectionChanged?.Invoke(evt);
}
else
catch (Exception e)
{
_devices.Remove(e.Device);
InputLog.Error(e.ToString());
}
}

Expand Down Expand Up @@ -212,7 +221,15 @@ void IKeyboardInputHandler.HandleKeyChar(KeyCharEvent @event) =>
void IInputHandler.HandleDeviceConnectionChanged(ConnectionEvent @event)
{
HandleDeviceConnectionChanged(@event);
ConnectionChanged?.Invoke(@event);

try
{
ConnectionChanged?.Invoke(@event);
}
catch (Exception e)
{
InputLog.Error(e.ToString());
}
}

IEnumerator<IInputBackend> IEnumerable<IInputBackend>.GetEnumerator() =>
Expand All @@ -232,6 +249,8 @@ void ICollection<IInputBackend>.Clear()
{
HandleBackendRemoval(backend);
}

_backends.Clear();
}

bool ICollection<IInputBackend>.Contains(IInputBackend item) => _backends.Contains(item);
Expand Down
19 changes: 13 additions & 6 deletions sources/Input/Input/Implementations/EnumInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.


using System.Collections.Concurrent;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Silk.NET.Input;
Expand Down Expand Up @@ -44,7 +46,7 @@
public static readonly Type UnderlyingType = typeof(T).GetEnumUnderlyingType();

private static readonly T[] _allValuesOrdered;
private static readonly Dictionary<T, int> _numericallyDistinctIndices;
private static readonly ConcurrentDictionary<T, int> _numericallyDistinctIndices;
private static readonly ulong[] _allEnumValuesDistinctRaw;
private static readonly bool _unnamedAreIndexable;
#pragma warning disable CS0414 // Field is assigned but its value is never used
Expand Down Expand Up @@ -136,14 +138,19 @@
throw new InvalidOperationException("Enum provided uses an unknown numeric base??");
}

var dict = new Dictionary<T, int>(numericallyDistinct.Length);
var dict = new ConcurrentDictionary<T, int>(
concurrencyLevel: -1, // defaults to Environment.ProcessorCount at time of writing
capacity: numericallyDistinct.Length);

for (var index = 0; index < numericallyDistinct.Length; index++)
{
var enumVal = numericallyDistinct[index];
#if DEBUG
Debug.Assert(dict.TryAdd(enumVal, index));
#else
_ = dict.TryAdd(enumVal, index);
#endif

// get attribute and check for ignore

dict.Add(enumVal, index);
}

_allValuesOrdered = all;
Expand Down Expand Up @@ -171,7 +178,7 @@
});
}

#pragma warning disable ST0006 ST0007 ST0008 ST0009

Check warning on line 181 in sources/Input/Input/Implementations/EnumInfo.cs

View workflow job for this annotation

GitHub Actions / Test (linux-x64, ubuntu-22.04, linux-x64)

Single-line comment or end-of-line expected

Check warning on line 181 in sources/Input/Input/Implementations/EnumInfo.cs

View workflow job for this annotation

GitHub Actions / Test (osx-arm64, macos-latest, osx-arm64)

Single-line comment or end-of-line expected

Check warning on line 181 in sources/Input/Input/Implementations/EnumInfo.cs

View workflow job for this annotation

GitHub Actions / Test (win-x64, windows-latest, win-x64)

Single-line comment or end-of-line expected
/// <summary>
/// Gets the ordered index of the unnamed enum value provided. This index is calculated by:
/// (the number of named members in this enum type) + (the raw value of the number if unnamed)
Expand Down Expand Up @@ -207,7 +214,7 @@
if (_numericallyDistinctIndices.Count < _maxCapacity)
{
#if DEBUG
System.Diagnostics.Debug.Assert(_numericallyDistinctIndices.TryAdd(value, idx));
Debug.Assert(_numericallyDistinctIndices.TryAdd(value, idx));
#else
_ = _numericallyDistinctIndices.TryAdd(value, idx);
#endif
Expand All @@ -217,7 +224,7 @@
}


#pragma warning restore ST0006 ST0007 ST0008 ST0009

Check warning on line 227 in sources/Input/Input/Implementations/EnumInfo.cs

View workflow job for this annotation

GitHub Actions / Test (linux-x64, ubuntu-22.04, linux-x64)

Single-line comment or end-of-line expected

Check warning on line 227 in sources/Input/Input/Implementations/EnumInfo.cs

View workflow job for this annotation

GitHub Actions / Test (osx-arm64, macos-latest, osx-arm64)

Single-line comment or end-of-line expected

Check warning on line 227 in sources/Input/Input/Implementations/EnumInfo.cs

View workflow job for this annotation

GitHub Actions / Test (win-x64, windows-latest, win-x64)

Single-line comment or end-of-line expected

public static unsafe T ValueOfIndex(int index)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;

namespace Silk.NET.Input.SDL3.DataStructures;

internal readonly record struct GenericEvent(nint EventPtr, Type Type)
{
public unsafe ref T Value<T>() => ref Unsafe.AsRef<T>((void*)EventPtr);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Buffers;
using System.Runtime.CompilerServices;
using Silk.NET.Input.SDL3.Devices.Pointers;

namespace Silk.NET.Input.SDL3.DataStructures;

internal sealed class GenericEventQueueSdl : SdlInputEventQueue<GenericEvent>
{
private readonly SdlTimestampCalculator.TimeBasis _basis;
public GenericEventQueueSdl(SdlTimestampCalculator.TimeBasis basis) => _basis = basis;

/// <summary>
/// Populates this instance's buffer with events from another <see cref="SdlInputEventQueue{T}"/> <see cref="queueSdl"/>
/// of any kind by calling <see cref="SdlInputEventQueue{T}.ConsumeWithoutClearing"/> on it.<br/><br/>
///
/// It is <b>imperative</b> that you do not allow any writes to the provided <see cref="SdlInputEventQueue{T}"/>
/// until you are done processing the sorted data returned by <see cref="ConsumeAndSortSelf"/>. Changes to the
/// provided <see cref="SdlInputEventQueue{T}"/> will invalidate the data this class stores and can lead to confusing
/// bugs, or even memory access violations.<br/><br/>
/// </summary>
/// <param name="queueSdl">The queue whose data to reference</param>
/// <param name="consume">If true (default), <see cref="queueSdl"/> will be "consumed" -
/// the equivalent of calling <see cref="List{T}.Clear()"/></param>
/// <typeparam name="T"></typeparam>
public unsafe void StoreReferencesTo<T>(in SdlInputEventQueue<T> queueSdl, bool consume = true) where T : struct
{
var q = consume ? queueSdl.ConsumeWithoutClearing() : queueSdl.AsSpanPair();
var values = q.Values;
var timestamps = q.SdlTimestamps;
for (var i = 0; i < q.Length; i++)
{
var genericEvent = new GenericEvent(
EventPtr: values.PointerAt(i),
Type: typeof(T));

Enqueue(genericEvent, timestamps.Ptr[i]);
}
}

/// <summary>
/// This method is the final method that should be called to consume our events in-order.
/// After this is call, our memory will appear unused, so any additional writes will overwrite data in the
/// returned span.<br/><br/>
/// Therefore, it is <b>imperative</b> that you do not allow any writes to this
/// <see cref="GenericEventQueueSdl"/> until you are done processing the sorted data.
/// consuming.<br/><br/>
/// </summary>
/// <returns></returns>
public unsafe NativeMemory<GenericEvent>.UnsafeView ConsumeAndSortSelf()
{
var pair = ConsumeWithoutClearing();
var valuesToSort = pair.Values;
var sdlTimestamps = pair.SdlTimestamps;

var length = valuesToSort.Length;
var heap = length > 512 ? ArrayPool<FractionalTimestamp>.Shared.Rent(length) : null;
var sortKeys = heap ?? stackalloc FractionalTimestamp[length];
for (var i = 0; i < length; i++)
{
sortKeys[i] = SdlTimestampCalculator.ToTimestamp(sdlTimestamps.Ptr[i], _basis);
}

sortKeys.StableSortWith(valuesToSort, _timestampComparer);

if (heap is not null)
{
ArrayPool<FractionalTimestamp>.Shared.Return(heap);
}

return valuesToSort;
}

private static readonly Comparison<FractionalTimestamp> _timestampComparer = (timeA, timeB) => timeA.CompareTo(timeB);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Silk.NET.Input.SDL3.DataStructures;

internal interface ISdlInputEventQueue<T> where T : struct
{
public void Enqueue(in T item, ulong sdlTimestamp);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Silk.NET.SDL;

namespace Silk.NET.Input.SDL3;
namespace Silk.NET.Input.SDL3.DataStructures;

// note - this probably doesn't need to be a ref struct, but is bc that's the extents
// note - this probably doesn't need to be a ref struct, but is bc that's the extent
// of the struct's current use cases
// LONG-TERM DOM-SPECIFIC TO-DO - can this struct be represented as a NativeArray<T, TBackend> where TBackend has a
// Free(void*) or Free(void*, int) method?
internal readonly unsafe ref struct SdlArray<T> : IDisposable, IEquatable<SdlArray<T>>, IReadOnlyList<T> where T : unmanaged
/// <summary>
/// Represents an array of values produced by SDL. For .NET-allocated native memory, see
/// <seealso cref="NativeMemory{T}"/>.
/// </summary>
/// <typeparam name="T">The type of values in the array - usually SDL struct types.</typeparam>
internal readonly unsafe ref struct SdlArray<T> : IDisposable, IEquatable<SdlArray<T>> where T : unmanaged
{
private readonly Ptr<T> _ptr;
public int Count { get; }
Expand Down Expand Up @@ -76,8 +80,6 @@ public void Dispose()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan<T> AsReadOnlySpan() => _ptr.Native == null ? default : new ReadOnlySpan<T>(_ptr.Native, Count);

T IReadOnlyList<T>.this[int index] => this[index];

public ref T this[int index]
{
get
Expand Down Expand Up @@ -106,17 +108,6 @@ public ref T this[uint index]

public bool Equals(SdlArray<T> other) => this == other;

public IEnumerator<T> GetEnumerator()
{
if (_ptr == nullptr)
{
throw new NullReferenceException();
}

return (IEnumerator<T>)AsReadOnlySpan().ToArray().GetEnumerator();
}

public override bool Equals(object? obj) => obj == null && _ptr.Native == null;
public override int GetHashCode() => HashCode.Combine(_ptr, Count, _sdl);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Silk.NET.Input.SDL3.DataStructures;

internal class SdlInputEventQueue<T> : ISdlInputEventQueue<T>, IDisposable where T : struct
{
// Currently unused, so just commenting this out
/*public int Count
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
Debug.Assert(_sdlTimestamps.Count == _events.Count);
return _sdlTimestamps.Count;
}
}*/


public void Enqueue(in T item, ulong sdlTimestamp)
{
if (_disposed)
{
GC.ReRegisterForFinalize(this);
_disposed = false;
}

_events.Add(item);
_sdlTimestamps.Add(sdlTimestamp);
}


internal readonly ref struct SdlTimestampedValues<TValue>(NativeMemory<TValue>.UnsafeView values, NativeMemory<ulong>.UnsafeView sdlTimestamps) where TValue : struct
{
public readonly NativeMemory<TValue>.UnsafeView Values = values;
public readonly NativeMemory<ulong>.UnsafeView SdlTimestamps = sdlTimestamps;

public int Length
{
get
{
Debug.Assert(Values.Length == SdlTimestamps.Length);
return Values.Length;
}
}
}

/// <Summary>
/// Returns a reference to our data as two spans and clears the inner count of our buffers
/// (the functional equivalent of calling <see cref="List{T}.Clear()"/>)
/// </summary>

Check warning on line 54 in sources/Input/Input/Implementations/SDL3/DataStructures/SdlInputEventQueue.cs

View workflow job for this annotation

GitHub Actions / Test (linux-x64, ubuntu-22.04, linux-x64)

XML comment has badly formed XML -- 'End tag 'summary' does not match the start tag 'Summary'.'

Check warning on line 54 in sources/Input/Input/Implementations/SDL3/DataStructures/SdlInputEventQueue.cs

View workflow job for this annotation

GitHub Actions / Test (osx-arm64, macos-latest, osx-arm64)

XML comment has badly formed XML -- 'End tag 'summary' does not match the start tag 'Summary'.'

Check warning on line 54 in sources/Input/Input/Implementations/SDL3/DataStructures/SdlInputEventQueue.cs

View workflow job for this annotation

GitHub Actions / Test (win-x64, windows-latest, win-x64)

XML comment has badly formed XML -- 'End tag 'summary' does not match the start tag 'Summary'.'
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal SdlTimestampedValues<T> ConsumeWithoutClearing() => new(_events.ConsumeWithoutClearing(), _sdlTimestamps.ConsumeWithoutClearing());

public void Clear(bool entireCapacity, int startIndex = 0)
{
_events.ClearValues(entireCapacity, (uint)startIndex);
_sdlTimestamps.ClearValues(entireCapacity, (uint)startIndex);
}

public void Dispose()
{
if(_disposed)
{
throw new ObjectDisposedException(nameof(SdlInputEventQueue<>));
}

_disposed = true;
_sdlTimestamps.Dispose();
_events.Dispose();
GC.SuppressFinalize(this);
}

~SdlInputEventQueue()
{
if (_disposed)
return;

_sdlTimestamps.Dispose();
_events.Dispose();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public SdlTimestampedValues<T> AsSpanPair() => new(_events.AsSpan(), _sdlTimestamps.AsSpan());

private bool _disposed;
private NativeMemory<T> _events;
private NativeMemory<ulong> _sdlTimestamps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Silk.NET.Input.SDL3;
/// <typeparam name="T"></typeparam>
internal interface ISdlDevice<out T> : IInputDevice where T : SdlDevice
{
public static abstract T? CreateDevice(ulong sdlDeviceId, long timestamp, ulong sdlTimestamp, bool isSimulated, SdlInputBackend backend, SilkEventContext context);
public static abstract T? CreateDevice(ulong sdlDeviceId, long timestamp, ulong sdlTimestamp, bool isSimulated, SdlInputBackend backend, SdlInputEventContext context);
}

internal interface INeedFinalizationEachFrame
Expand Down
Loading
Loading