Modifier keys

nobody wrote on Sunday, February 05, 2006:

On Mac OS X, the command key doesn’t trigger an event. Thankfully, I was able to fix this by adding a only few lines to GLFW’s source. My problem now is that both the left-side and right-side modifier keys cause GLFW to trigger events for left-side modifiers.

My game really needs to be able to differentiate between the modifiers on each side of the keyboard, but GLFW doesn’t seem to support that on Mac OS X.

Would it be possible to add support for this in a future release?

elmindreda wrote on Sunday, February 05, 2006:

Well, there are no constants for command keys in GLFW. They could be added, of course, or the keys could be mapped to existing constants. Sounds like a useful addition. I’ll see if it can be added (I’m only the OS X developer).

It would be great if you could email me a patch with your changes, as a reference.

nobody wrote on Monday, February 06, 2006:

[I’m the same person who started the thread]

Simply add this line to the _glfwHandleMacModifierChange function:
_glfwTestModifier( cmdKey, GLFW_KEY_LCMD );
and add a GLFW_KEY_LCMD constant to glfw.h

Carbon provides only a "cmdKey" constant, no constant for the right-side version like it has for the other mods.

This little utility may help (somehow) - it can show codes for any modifier key:
http://www.petermaurer.de/nasi.php?section=keycodes

The problem with right mod keys registering as left mod keys (both left and right shift keys trigger LSHIFT, for example) might just be a problem with Carbon or my OS, because it is clear that your code is written properly in _glfwHandleMacModifierChange.

nobody wrote on Monday, February 06, 2006:

[I’m the same person who started the thread]

I’ve modified the GLFW code to use Apple’s HID Utilities library to get individual modifier key states.

With the modifications, user must now link against IOKit,
CoreFoundation, and HIDUtilities to compile their GLFW programs.

HID Utilities must be downloaded separately from Apple:
http://developer.apple.com/samplecode/HID_Utilities_Source/HID_Utilities_Source.html

You may decide not to use my additions, but I’m sure you’d be interested in seeing them. Unfortunately, I haven’t a clue how to do a patch thingy, so what do you suggest?

elmindreda wrote on Monday, February 06, 2006:

I’m going to add a dependency to the HID Manager for joystick support, but I’d really rather not depend on code outside the regular OS and Developer Tools. I’d still be interested in your code, since I’ll have to duplicate parts of the HID Utilities functionality anyway.

If your copy of GLFW comes from CVS, then you can produce a suitable diff with `cvs duff -u`. Otherwise, download a fresh copy of the sources and do `diff -ru clean-glfw-dir your-glfw-dir`.

Thank you for working on this. It may be the thing to finally get me to add HID support to GLFW. Please don’t hesitate to bug me via email :slight_smile:

nobody wrote on Tuesday, February 07, 2006:

I uploaded the diff file to my site:
http://rodatus.info/family/josh/files/glfw-2.5-mod.diff

elmindreda wrote on Tuesday, February 07, 2006:

That’s great! Thank you very much :slight_smile: