Game Development Community

Mouse Functions

by Greyfort · in Torque 3D Beginner · 11/16/2011 (12:05 pm) · 6 replies

I'm trying to figure the best place to insure mouse function across the server and client.

I see the bulk of the work is done in


//-----------------------------------------------------------------------------
// defaults.bind.cs file

I would like player to be able to click single,double on objects, or hold down one button or both and wheel button click roll, hold, etc.

functions would be:

1 click button0
2 click button0

1 click button1
2 click button1

hold button 0
hold button 1
hold both 0,1

click wheel button roll up,down
hold wheel button (move mouse)
hold wheel 1click button0
hold wheel 2click button0
hold wheel hold button0
hold wheel 1click button1
hold wheel 2click button1
hold wheel hold button1
hold wheel hold button0 button 1

I may have missed a few mouse actions I'm sure you get my point. torque 3D documentation does give much info on this some gui::onMouseclick etc...ware might I find documentation on this, or does some one have some sample code. Any help would be kind.

Also I wanted as seen above alot more mouse events, will #include Windows.h from C work withing torque?

About the author

Computer programming/repair,3D Modeling,anim,Game Dev.


#1
11/17/2011 (1:21 pm)
So far I have found much information on mouse functions other then
GuiMouse?Ctrl::onMouse? and although these accomplish a bit. I want a more comprehensive mouse_event controls. So my question is can I using the headers make a more detailed GuiMouse?Ctrl::onMouse? or is this file that sets the engine GuiMouse closed you know hard coded no adjustable. If so would a Torque script that calls the windows headers,lib,dll work?
#2
11/18/2011 (7:13 pm)
hi there, and welcomee.

the main/starting file for mouse handling is windowInputGenerator.cpp
I don't think that torque script can can external dlls so windows headers etc not viable in that way. also portability would be negatively effected.

hope this helps. perhaps some more knowledgable bods could help you.
#3
11/18/2011 (11:27 pm)
Thank you Edward, all ideas are welcome after all since we are all garage indie designers we can come up with wonderful things the more we help each other.

The reason I asked about mouse functions is because what I'm trying to emulate.
keyboard controls
w=run
s=walk
a=turn left
d=turn right
q=strafe left
e=strafe right
x=backwards
space=jump

mouse controls (note much more detail in each action)
mouse point center screen spawn point
left click=select object, terrain move player there
double left click=(special function action based on object double clicked on)
right click=examine object mouse over or some thing
double right click=speak with object mouse over or something
wheel mouse button single click toggle mouse camera on off
wheel mouse button hold down use missile weapon like fps
wheel mouse button held right button click...

and so on thats why its important I find ware the engine handles mouse command and use what I can of the engine and make what ever else I have to.

Than kyou Again
#4
11/25/2011 (12:51 pm)
I have found the onMouseDown , yet all i can manage to get out of it is 1 click or a hold option cant get it to dubble click the U8 mouseClickCount to actualu count well it counts one. here is code :

function PlayGui::onMouseDown(%this, %pos, %start, %ray,%mouseClick)
{
%ray = VectorScale(%ray, 100);
%end = VectorAdd(%start, %ray);

// Only care about players this time
%searchMasks = $TypeMasks::PlayerObjectType;

//%searchMasks = GetIsPlayer();//GetObjectType(%this);

// Search!
%scanTarg = ContainerRayCast( %start, %end, %searchMasks );

// DOUBBLE LEFT MOUSE CLICK
if ( %mouseClick >=2 )
{
// greyfort add
echo("LEFT mouse [2] click works");
if (%scanTarg){
//----------[custom scripts]------------
// custom scripts, with custom functions
exec("scripts/gui/vis_player.cs");
}
}// SINGLE LEFT MOUSE CLICK
else if( %mouseClick <=1 )
{
// greyfort add
echo("LEFT mouse [1] click works");
if (%scanTarg){
//----------[custom scripts]------------
// custom scripts, with custom functions
exec("scripts/gui/vis_player.cs");
}
}
}

this function will only fire the one click, any help or Ideas would be great.
#5
11/27/2013 (10:46 am)
if u really wanna get your hands dirty with source code i dealt with this before for a function i needed double click for, go to windowManager/win32/win32Window.cpp

add a case for WM_LBUTTONDBLCLK that can then be passed to the event.h files enum block for the event

#6
12/01/2013 (8:32 pm)
Ew, don't do that...

You can easily accomplish that by modifying the GuiTSCtrl to provide additional mouse callbacks. Then do some l33t raycasting majik and voila.

To handle single vs double clicks use a schedule timer with a say 100ms - 250ms trip delay.