Game Development Community

Strange key issues

by Philip Bloom · in Torque Game Engine · 04/07/2005 (4:02 pm) · 5 replies

I'm currently trying to debug a strange issue with keyboard input. I'm working with a game with two mouse modes: with cursor and without. Without cursor, it reads what is in config.cs just like it should. With cursor, it almost does, and I'm not quite sure why. Everything works except for 'tab', which 'works' but finds it's definition rebound while the mouse cursor is showing to 'ctrl+tab'.

Since this used to be where the orc view mode change was, I'm wondering if perhaps it's some specialized handling for tab?

#1
04/09/2005 (4:36 am)
Anyone? Checking shows this is a holdover issue from the FPS module I built off of. I'll likely dive into the sourcecode this evening, but this seems pretty odd that tab would be getting mysteriously rebound when nocursor="";

Basically, in simple: (playgui is a gameTSctrl)
if playgui.nocursor="1";
then tab functions normally, mapping onto the config.cs bind movemap.
if playgui.nocursor="";
then tab does not function unless pressed in conjugation with ctrl, in which case it then maps to the config.cs.

What would nocursor being doing that breaks up how the keyboard mapping is working?
#2
04/09/2005 (7:31 am)
Tab is used as field selector key to move across fields in a gui (normally text input gui's, but probably other ones as well). It may be that this is hard coded to the nocursor value of a particular gui, as well as the first responder value.
#3
04/09/2005 (7:56 am)
Fiddling more:

It's something that switches wrong when GuiCanvas.cursorOn() is called. Which itself maps directly down to the C++ code through consoleMethod

Checking it though, it shouldn't even do anything o_O
ConsoleMethod(GuiCanvas, cursorOn, void, 2, 2, "")
{
object;
argc;
argv;
Canvas->setCursorON(true);
}

This would just pass true to the below function:

void GuiCanvas::setCursorON(bool onOff)
{
cursorON = onOff;
if(!cursorON)
mMouseControl = NULL;
}

if that's passed true, as far as I can tell, it shouldn't be doing anything. I can't understand how it'd be switching back. No...wait, I'm wrong. it sets a bool, cursorOn that's not local.

There it is:

if ( isCursorON() && ( event->objInst == KEY_TAB ) )
{
if (size() > 0)
{
if (event->modifier & SI_SHIFT)
{
tabPrev();
return true;
}
else if (event->modifier == 0)
{
tabNext();
return true;
}
}
}


Tab and tab alone has some special hard coded engine handling that only results when the cursor is on. This is catching the tab event and not passing it along to the normal event handling. I'm going to try commenting it out for a fix.

And that fixes it. I don't know what that code chunk is intended to do, but it definitely breaks what I'd think is normal usage of the keybinds. Might do for a slight rewrite there to handle tab usage being overwritten in script.
#4
04/09/2005 (2:56 pm)
It implements tabbing from one control to another. Actionmaps should be being applied BEFORE the GUI gets it - the GlobalActionMap, for instance.
#5
04/30/2005 (9:25 pm)
Man! I've been trying for a while to find this thread again, lol.

Philip - if you disable that code you'll disable the ability of tabbed windows to loop through their ranks. I would persue a different fix for your troubles.