Translating Key Tokens to text

dougbinks wrote on Wednesday, August 07, 2013:

I need to be able to prompt users with the correct key names to press for actions, and also to allow them to configure their key bindings and display the correct key name rather than the Key Token.

I can’t see this functionality present in GLFW 3, and it would be very useful. I’d be willing to help program and test this if it was thought an appropriate addition to GLFW.

elmindreda wrote on Wednesday, August 07, 2013:

This is a planned feature for 3.x. I’d welcome a pull request for this. Here’s an initial design:

GLFWAPI const char* glfwGetKeyName(int key);

dougbinks wrote on Wednesday, August 07, 2013:

Great, thanks - I’ll look into this next week (busy this week), starting with Windows which I’m more familiar with for this. Anyone with any hints on links to documentation on Linux/OS X feel free to post on this thread.

elmindreda wrote on Wednesday, August 07, 2013:

XKB for X.

dougbinks wrote on Wednesday, August 14, 2013:

I have a working Windows version here: https://github.com/dougbinks/glfw/commit/f4ed02f6c87d2689cb313c1911d846c0f6f1f7cc

Note that I’ve not yet put stub functions in for the other OSs, but will move on to this and then the OS X and Linux implementations.

The Windows function may need to be changed if this issue is resolved: https://github.com/glfw/glfw/issues/114

dougbinks wrote on Wednesday, August 14, 2013:

Stub methods for OS X and Linux now in: https://github.com/dougbinks/glfw/commit/6edcc75a6bbe6f358a2ba5d5101c6872472cc211

dougbinks wrote on Wednesday, August 14, 2013:

OS X / Cocoa version now working: https://github.com/dougbinks/glfw/commit/9c68e11f2fee44b867bf4d2291399a1915bfd08d

Note this adds a dependency to Carbon framework, so have added this to CMakelists.txt.

dougbinks wrote on Thursday, August 15, 2013:

I’ve now completed this on X11 and also updated the Windows and Cocoa versions to be more consistent.