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

API - Implement 'glfwGetKeyName' #102

Open
bryphe opened this issue Mar 7, 2019 · 0 comments
Open

API - Implement 'glfwGetKeyName' #102

bryphe opened this issue Mar 7, 2019 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bryphe
Copy link
Member

bryphe commented Mar 7, 2019

The glfwGetKeyName API would be useful to have: https://www.glfw.org/docs/latest/group__input.html#ga237a182e5ec0b21ce64543f3b5e7e2be

I'm not sure what the JS equivalent would be, so for now, we could just implement this on the native side (and a stub with a warning in the JS code).

The one change I would consider with this API is returning the integer equivalent of the returned string (for example, GLFW_KEY_A should return 65: https://github.com/bryphe/reason-glfw/blob/d128062ef93afd54f0d42cf128c54e79d46be231/src/glfw_key.re#L126).

So our signature for glfwGetKeyName could look like (key: int, scancode: int) =>Glfw_Key.t

This is primarily for performance consideration - if we return the string to the OCaml side, we'd have to copy the string into GC-managed memory, whereas passing the integer does not require copying.

@bryphe bryphe added help wanted Extra attention is needed good first issue Good for newcomers labels Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant