Game Development Community

Mouse keybinding on 1.7.2

by Eyal Erez · in Torque Game Builder · 05/05/2008 (8:50 am) · 4 replies

Hi,
I'm having an issue that's been driving me crazy.
While trying to debug it, I managed to narrow it down to that:
I start a new project on tgb 1.7.2
Adding these two lines to game.cs startGame function:

moveMap.bind( mouse, button0, mouseFire );
moveMap.bind( keyboard , "f", mouseFire );

I also added this function:

function mouseFire(%val)
{
echo("########## mouseFIRE ################");
}

When I press the "f" button the function works. However, when I click the mouse nothing happens.
Other than that , my mouse works great when I use onMouseDown() or any other mouse callbacks.
Can somebody please show me that I'm not crazy, just stupid?
I must be doing something wrong since the forum is full of examples that looks exactly like that.
Thanks,
Eyal.

#1
05/05/2008 (9:01 am)
You cannot actually bind two different events to the same function, which is why one works, but the second does not.
#2
05/05/2008 (9:35 am)
Stephen,
Even when comment the keyboard bind and just keep the mouse bind it still doesn't work.
I only used the keyboard bind to test that my mouseFire function works.
Any ideas why it wouldn't?
#3
05/05/2008 (2:12 pm)
@Stephen
I am pretty sure that the same function can be bound to different keys. I thought that limitation was removed not to long ago?

@Eyal
Does your in-game GUI have noCursor = true ?

If you have a visible cursor in your gui, the gui will receive and consume all mouse events, meaning, they will never reach your bound function.

So, if you need to have your cursor visible for this game, you will want to use the onMouse callbacks on your gui rather than a bound function.
#4
05/05/2008 (2:56 pm)
You hit it right on the head! thank you!
When I added the noCursor = true to my mainScreenGui it worked.
Now I can track back to my original problem :)
I'm trying to get two analog inputs to contol my game. so either 2 mice or 1 mouse and 1 joystick.
I got the wiimote working for my game using a sensor bar/glovePIE and TGB mouse callback. Now I'd like to get another wiimote for the second player.
Since I can't get 2 mice inputs through the callbacks I resorted to bind, hoping TGB does support 2 mice as mention in a few places. if not I'll try joystick input.