Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AccessViolationException on KeyPress #254

Merged
merged 1 commit into from
Jun 3, 2024
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
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