Skip to content

Commit

Permalink
Fix AccessViolationException on KeyPress
Browse files Browse the repository at this point in the history
  • Loading branch information
nulldg authored and eXpl0it3r committed Jun 3, 2024
1 parent 857906a commit db96416
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/SFML.Window/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public struct KeyEvent
/// <summary>Code of the key. See <see cref="Keyboard.Key"/></summary>
public Keyboard.Key Code;

/// <summary>Physical code of the key. See <see cref="Keyboard.Scancode"/></summary>
public Keyboard.Scancode Scancode;

/// <summary>Is the Alt modifier pressed?</summary>
public int Alt;

Expand Down Expand Up @@ -294,7 +297,7 @@ public struct SensorEvent
/// Event defines a system event and its parameters
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Explicit, Size = 20)]
[StructLayout(LayoutKind.Explicit, Size = 28)]
public struct Event
{
/// <summary>Type of event (see EventType enum)</summary>
Expand Down
7 changes: 6 additions & 1 deletion src/SFML.Window/EventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class KeyEventArgs : EventArgs
public KeyEventArgs(KeyEvent e)
{
Code = e.Code;
Scancode = e.Scancode;
Alt = e.Alt != 0;
Control = e.Control != 0;
Shift = e.Shift != 0;
Expand All @@ -34,15 +35,19 @@ public override string ToString()
{
return "[KeyEventArgs]" +
" Code(" + Code + ")" +
" Scancode(" + Scancode + ")" +
" Alt(" + Alt + ")" +
" Control(" + Control + ")" +
" Shift(" + Shift + ")" +
" System(" + System + ")";
}

/// <summary>Code of the key (see KeyCode enum)</summary>
/// <summary>Code of the key (see <see cref="Keyboard.Key"/>)</summary>
public Keyboard.Key Code;

/// <summary>Physical code of the key (see <see cref="Keyboard.Scancode"/>)</summary>
public Keyboard.Scancode Scancode;

/// <summary>Is the Alt modifier pressed?</summary>
public bool Alt;

Expand Down

0 comments on commit db96416

Please sign in to comment.