Skip to content

Glfw.GetKeyName(Keys key, int scanCode) throws internal exception when used with non-printable key #28

@SuperS1405

Description

@SuperS1405

Glfw.GetKeyName(Keys key, int scanCode) throws an internal NullReferenceException when specifying a key that is non-printable (eg. Keys.LeftControl). Description states the method returnes null instead. To fix this, changing

public static string GetKeyName(Keys key, int scanCode)
{
    return Util.PtrToStringUTF8(GetKeyNameInternal(key, scanCode));
}

to

public static string GetKeyName(Keys key, int scanCode)
{
    IntPtr ptr = GetKeyNameInternal(key, scanCode);
    return ptr == IntPtr.Zero? null : Util.PtrToStringUTF8(ptr);
 }

should probably do the trick.

Side note: what are the plans on releasing the current/corrected version to nuget?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions