Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public GlfwButtonCollection(byte* bytes, int count)
public int Count => _count;

public Button this[int index] => index < _count
? new Button ((ButtonName)index, index, Get(_bytes, index) != 0)
? new Button ((ButtonName)index, index, _bytes[index] != 0)
: throw new ArgumentOutOfRangeException();

public IEnumerator<Button> GetEnumerator()
Expand All @@ -34,10 +34,6 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}

public static byte Get(byte* bytes, int index)
{
return Marshal.ReadByte((IntPtr) bytes, index);
}
private struct Enumerator : IEnumerator<Button>
{
private GlfwButtonCollection _col;
Expand All @@ -58,7 +54,7 @@ public bool MoveNext()
return false;
}

Current = new Button((ButtonName)_current, _current, Get(_col._bytes, _current) != 0);
Current = new Button((ButtonName)_current, _current, _col._bytes[_current] != 0);
_current++;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Silk.NET.Input.Common;
using Silk.NET.Input.Common;
using System;
using System.Collections;
using System.Collections.Generic;
Expand All @@ -19,7 +19,7 @@ public GlfwHatCollection(Position2D* positions, int count)
}

public Hat this[int index] => index < _count
? new Hat(index, Get(_positions, index))
? new Hat(index, _positions[index])
: throw new ArgumentOutOfRangeException();

public int Count => _count;
Expand All @@ -33,10 +33,6 @@ IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public static Position2D Get(Position2D* positions, int index)
{
return (Position2D) Marshal.ReadInt32((IntPtr) positions, index * IntPtr.Size);
}

private struct Enumerator : IEnumerator<Hat>
{
Expand All @@ -58,7 +54,7 @@ public bool MoveNext()
return false;
}

Current = new Hat(_current, Get(_col._positions, _current));
Current = new Hat(_current, _col._positions[_current]);
_current++;
return true;
}
Expand Down