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

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

Open
SuperS1405 opened this issue May 27, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@SuperS1405
Copy link

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?

@ForeverZer0
Copy link
Owner

Thanks, will fix that too,

Am finally working on this again right now (literally).

@ForeverZer0 ForeverZer0 self-assigned this May 27, 2020
@ForeverZer0 ForeverZer0 added the bug Something isn't working label May 27, 2020
@SuperS1405
Copy link
Author

Awesome! Allow me to thank you for all the time you put into this - making bindings is a pain (I am one to talk, you would know xD), so this makes a lot of peoples life significantly easier. We appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants