It looks uglier than a remap in CIrrDeviceMacOSX.mm as it appears to be an intentional design thing in irrlicht. If I had to guess, it looks like to get Command into Irrlicht, the KEY_CONTROL is used but only for a few character combinations?
In CIrrDeviceMacOSX::postKeyEvent, the control appears to intentionally be intertwined with command. Since command handles system keys (e.g., cut, paste etc), they are specifically skipped in most cases excepting keys C, V, and X and thus won't handle all keys modified this way. I added 'W' to that list in a test hack, because we are using a scheme where W is run, Shift W is sprint, and Control W is walk. Then I could use command in place of control and we have our "walk" key. Not a solution, just trying to get the bool skipCommand set on for later references to NSControlKeyMask (that part didn't work). To test, I hacked this section of postKeyEvent:
Code: Select all
if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
{
if (mkey == 'C' || mkey == 'V' || mkey == 'X' || mkey == 'W')
{
mchar = 0;
skipCommand = true;
}
}
I added the "W" conditional. This lets skipCommand be set to true which I think is necessary for Control to be recognized too, but it really only lets command work, presumably because Irrlicht doesn't have a "command" in SKeyInput and it is needed for the GUI? I would guess another block is necessary similar to this (only not key specific) that lets that bool be set true on NSControlKeyMask. Control will be set later if skipCommand is true, but sadly, skipCommand appears to be only currently related to NSCommandKeyMask. That implies that one add in a modifier for Command if that proprietary key were desirable, i.e., the SKeyInput would need changing too.
I will mess with that a bit and see if we can get a hack to support control and abandon command, but I'm guessing that supporting both would be the elegant approach. We don't really want any mac specific keys in our game but I could see where the GUI might want that.
Do you think this is an intentional design to get around the fact that Irrlicht doesn't support a Command key modifier in SKeyInput?
I could be in left field with this analysis. I don't have a lot of time to go deeper right now.
Edit: SKeyInput should have been IEventReceiver.h SEvent.SKeyInput which I think is where the bool is referenced for Control. Appears a Command would be necessary there and the GUI routines that reference Cut, Copy, and Paste would require an OR when checking for "Control" such that it's ||event.KeyInput.Control. An example would be to change CGUIEditBox.cpp
to
Code: Select all
if (event.KeyInput.Control||event.KeyInput.Command)
There are a few more references to this in the GUI functions. Are you interested in a formal patch like that? It's probably what I will try.