Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
Page 1 of 2 1 2
#3123491 - 10/25/10 07:16 PM T.A.R.G.E.T. mouse programming  
Joined: Apr 2002
Posts: 17,733
Joe Offline
Veteran
Joe  Offline
Veteran

Joined: Apr 2002
Posts: 17,733
Bridgewater, NJ
The Script Editor manual currently seems devoid of information on mouse programming. How do you program the mouse pointer to move to a certain screen position? For example, Foxy code would be:
Code:
BTN S4 MOUSEXY (UL, 512, 190)

Inline advert (2nd and 3rd post)

#3123952 - 10/26/10 11:40 AM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 104
Dimebug Offline
Member
Dimebug  Offline
Member

Joined: Sep 2010
Posts: 104
France
well, the behavior of the mouse is different with TARGET, the mouse has X and Y axis, each axis have a range of -32767 to 32767 (65534 values)

this command will send the cursor to the X 0 and Y 0 (center of the screen)

MapKey(&Joystick, S4, EXEC(
"DXAxis(MOUSE_X_AXIS, 0);"
"DXAxis(MOUSE_Y_AXIS, 0);"
));


So to reach exact pixel position, we need to create a ratio Axis rang/Resolution and offset the wished value.

Example for a monitor using 1680 x 1050 resolution and reach 512 & 190

MapKey(&Joystick, S4, EXEC(
"DXAxis(MOUSE_X_AXIS, 512*2*32767/1680 - 32767);"
"DXAxis(MOUSE_Y_AXIS, 190*2*32767/1050 - 32767);"
));


It could be interesting to define a function that contain all the math for the Ratio, especially if we use this kind of feature several times in the file. It will make writing more simple.

complete file:

include "target.tmh" //here we link this file to the file that contains the default Thrustmaster function code

define SCREEN_DX_Index 2*32767/1680 - 32767
define SCREEN_DY_Index 2*32767/1050 - 32767

int main() //usual line, don't care
{
if(Init(&EventHandle)) return 1; //usual line, don't care

MapKey(&Joystick, S4, EXEC(
"DXAxis(MOUSE_X_AXIS, 512*SCREEN_DX_Index);"
"DXAxis(MOUSE_Y_AXIS, 190*SCREEN_DY_Index);"
));
}

int EventHandle(int type, alias o, int x) //usual line, don't care
{
DefaultMapping(&o, x); //usual line, don't care
}



Last edited by Dimebug; 10/26/10 11:46 AM.

Guillaume "Dimebug" Leleve
#3124073 - 10/26/10 03:13 PM Re: T.A.R.G.E.T. mouse programming [Re: Dimebug]  
Joined: Apr 2002
Posts: 17,733
Joe Offline
Veteran
Joe  Offline
Veteran

Joined: Apr 2002
Posts: 17,733
Bridgewater, NJ
Thinking about this...

Originally Posted By: Dimebug
well, the behavior of the mouse is different with TARGET, the mouse has X and Y axis, each axis have a range of -32767 to 32767 (65534 values)


Aren't the Warthog radar slew axes 10-bit, not 16-bit? Wouldn't the math be based on 1024 possible values, not 65536?

#3124109 - 10/26/10 04:00 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 104
Dimebug Offline
Member
Dimebug  Offline
Member

Joined: Sep 2010
Posts: 104
France
we're not talking of the slew, just of the mouse axes here, managed by a button. If you want to use the mouse on the slew

you simply have to map mouse axis over the slew ones use MapAxis and fine tune the respons with SetSCurve

MapAxis(&Throttle, SCX, MOUSE_X_AXIS, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Throttle, SCY, MOUSE_Y_AXIS, AXIS_NORMAL, MAP_RELATIVE);

SetSCurve(&Throttle, SCX, 0, 25, 0, -1, -5);
SetSCurve(&Throttle, SCY, 0, 25, 0, -1, -5);


Guillaume "Dimebug" Leleve
#3124125 - 10/26/10 04:31 PM Re: T.A.R.G.E.T. mouse programming [Re: Dimebug]  
Joined: Apr 2002
Posts: 17,733
Joe Offline
Veteran
Joe  Offline
Veteran

Joined: Apr 2002
Posts: 17,733
Bridgewater, NJ
Originally Posted By: Dimebug
we're not talking of the slew, just of the mouse axes here, managed by a button.



Right, of course. So the rule for T.A.R.G.E.T. is that all of the axes inside the software have 65535 possible values?

#3124131 - 10/26/10 04:45 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 104
Dimebug Offline
Member
Dimebug  Offline
Member

Joined: Sep 2010
Posts: 104
France
yes, all TARGET axes works on a 65536 possible values. This way you don't have to care about the digital resolution of your axes.


Guillaume "Dimebug" Leleve
#3124196 - 10/26/10 06:08 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Apr 2002
Posts: 17,733
Joe Offline
Veteran
Joe  Offline
Veteran

Joined: Apr 2002
Posts: 17,733
Bridgewater, NJ
Thanks; that makes sense.

Ok, thinking about all of this, here's what I've come up with. The mouse coordinate (512,190) is designed for a screen resolution of 1024x768. To make this more flexible it really should be programmed as a percentage. In this case a different user with a different resolution, or even the same user that changes resolutions, does not have to make any modifications to this code. 512 is the center of the X axis. 190 is roughly 25% of the way down from the top of the Y axis. So here's what I've come up with.

Code:
MapKeyIO(&Joystick, S4, 
	EXEC(
		"DXAxis(MOUSE_X_AXIS, 65536*.5-32768);" // moves mouse cursor to point that is 50% (0.5) of the screen resolution
		"DXAxis(MOUSE_Y_AXIS, 65536*.25-32768);" // moves mouse cursor to point that is 25% (0.25) of the screen resolution
		), // moves mouse cursor to padlock visual centerpoint 
	Voice_Comms_PTT);



The only question I've got is which sides of the axes are negative and which are positive, so I might be missing a negative sign here or there.

Don't have the hardware to test it on right now, but does this look appropriate? I'm trying to put the mouse cursor at a point that is in the horizontal center of the screen and at a point 25% of the way down from the top of the screen.

#3124323 - 10/26/10 08:13 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 104
Dimebug Offline
Member
Dimebug  Offline
Member

Joined: Sep 2010
Posts: 104
France
well, for this, i would have avoid to use math,

0.5 of the screen = the middle of the screen where the axe value is simply zero.

For the other one, using math is welcome and your code is right. Calculate the coordinate was also simple:

25% of the total height = 50% of the middle of the screen to the top = 32768*0.5 = 16384

As you want it to be from the top, you're in the negative range.
This save ressources (useless but a good reflex).


EXEC(
"DXAxis(MOUSE_X_AXIS, 0);" // moves mouse cursor to screen center
"DXAxis(MOUSE_Y_AXIS, -16384);" // moves mouse cursor to point that is 25% of the screen resolution, from the top
)


Guillaume "Dimebug" Leleve
#3124354 - 10/26/10 08:58 PM Re: T.A.R.G.E.T. mouse programming [Re: Dimebug]  
Joined: Apr 2002
Posts: 17,733
Joe Offline
Veteran
Joe  Offline
Veteran

Joined: Apr 2002
Posts: 17,733
Bridgewater, NJ
Originally Posted By: Dimebug
well, for this, i would have avoid to use math,

0.5 of the screen = the middle of the screen where the axe value is simply zero.
Yes, it's definitely simpler to just put a "0" in the case of the middle of the screen, but I wanted to have some code that could be copied elsewhere for coordinates to be changed.


Quote:
As you want it to be from the top, you're in the negative range.
So the left/right mouse axis has its negative value on the left and its positive value on the right, while the up/down mouse axis has its negative value on the top and its positive value on the bottom?

#3169951 - 01/02/11 07:49 AM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Mar 2007
Posts: 14
stinger Offline
Junior Member
stinger  Offline
Junior Member

Joined: Mar 2007
Posts: 14
San Antonio, Texas USA
Boy, I feel stupid. I didn't understand a single word, phrase, or number that I just read. I will be very simple, so please lower the level and join me. This is the only post I have found that is even close to what I am looking for. I am not trying to hijack a post. I am just hoping for more clarity for all of us.
I still am using Falcon 4 AF. In the left MFD, I have my radar screen and if I use the up,down,right, and left arrows on my keyboard, then I can move the cursor on the MFD. With my old Foxy Program it looked like this.

rem microstick is mouse with /O and radar cursor with /I
MIX /I 6 23 (2 4 6 8 11 14 17 21 25 30 36 43 58 65 71 76 80 84 87 90 93 95 97 98) MSX(3+) MSX(3-) MSX(0)
/O 3 LARROW ^ RARROW
MIY /I 6 23 (2 4 6 8 11 14 17 21 25 30 36 43 58 65 71 76 80 84 87 90 93 95 97 98) MSY(3-) MSY(3+) MSY(0)
/O 3 DARROW ^ UARROW
It worked perfect.
I have tried to assign the RARROW and LARROW to the RDR_X parameter. I used the little arrow slider and split both with some dead space in the middle for centering. Not only did this not work, but the micromouse stick shows no movement at all. I know it works because when I run the CCP from Cougar and calibrate the system the mouse is recognized. what the heck am I doing wrong?

#3170090 - 01/02/11 04:40 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 104
Dimebug Offline
Member
Dimebug  Offline
Member

Joined: Sep 2010
Posts: 104
France
there's several way to do this,
you can control your radar cursor with analog axis (this is what's done in the Target provided F4 profile).

In you foxy code you where controlling mouse and arrows depending of the /I / O button.

if you just want to control the arrows, here is the script code:

KeyAxis(&Throttle, SCX, 0, AXMAP2( LIST( 0, 35, 65 ), LARROW, 0, RARROW ));
KeyAxis(&Throttle, SCY, 0, AXMAP2( LIST( 0, 35, 65 ), UARROW, 0, DARROW ));


with the mouse, you can write it like this (you can fine tune the mouse speed):

KeyAxis(&Throttle, SCX, 'iumd', AXMAP2( LIST( 0, 35, 65 ), AXIS(MOUSE_X_AXIS, -100, 30), 0, AXIS(MOUSE_X_AXIS, 100, 30) ));
KeyAxis(&Throttle, SCX, 'oumd', AXMAP2( LIST( 0, 35, 65 ), LARROW, 0, RARROW ));
KeyAxis(&Throttle, SCY, 'iumd', AXMAP2( LIST( 0, 35, 65 ), AXIS(MOUSE_Y_AXIS, -100, 30), 0, AXIS(MOUSE_Y_AXIS, 100, 30) ));
KeyAxis(&Throttle, SCY, 'oumd', AXMAP2( LIST( 0, 35, 65 ), UARROW, 0, DARROW ));

if you want more mouse fine tuning

you can define SCX and SCY like axes, lock them when the shift / button is out and unlock them when the shift button is pressed, example, with S4 as shift button:

SetShiftButton(&Joystick, S4, &Throttle, BSF, BSB);

MapAxis(&Throttle, SCX, MOUSE_X_AXIS, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Throttle, SCY, MOUSE_Y_AXIS, AXIS_NORMAL, MAP_RELATIVE);

SetSCurve(&Throttle, SCX, 0, 25, 0, -2, -6);
SetSCurve(&Throttle, SCY, 0, 25, 0, -2, -6);

LockAxis(&Throttle, SCX, 1);
LockAxis(&Throttle, SCY, 1);


MapKey(&Joystick, S4, EXEC("LockAxis(&Throttle, SCX, 0); LockAxis(&Throttle, SCY, 0);"));
MapKeyR(&Joystick, S4, EXEC("LockAxis(&Throttle, SCX, 1); LockAxis(&Throttle, SCY, 1);"));

KeyAxis(&Throttle, SCX, 'oumd', AXMAP2( LIST( 0, 35, 65 ), LARROW, 0, RARROW ));
KeyAxis(&Throttle, SCY, 'oumd', AXMAP2( LIST( 0, 35, 65 ), UARROW, 0, DARROW ));





Last edited by Dimebug; 01/02/11 05:14 PM.

Guillaume "Dimebug" Leleve
#3170158 - 01/02/11 06:53 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Mar 2007
Posts: 14
stinger Offline
Junior Member
stinger  Offline
Junior Member

Joined: Mar 2007
Posts: 14
San Antonio, Texas USA
Thank you for the help. I will try this and see how it works. Can I just open up the script and copy and paste from here to there?

#3170168 - 01/02/11 07:10 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Mar 2007
Posts: 14
stinger Offline
Junior Member
stinger  Offline
Junior Member

Joined: Mar 2007
Posts: 14
San Antonio, Texas USA
Ok....I spent all F*****G day yesterday assigning these damn commands to the F#$%^%@g controller and I made sure they were all saved. I go in now and the file is there but when I open GUI, and go to edit, it shows nothing. I start the game and all of my saved controls are gone. What the F*&^ is going on? This Target crap is pissing me off. I had no problems with Foxy. I was really hoping this new program would work better since it looks easier but it is turning out to be crap so far. When I click on finish my file comes up and it says "basic". I spent all day setting up an advanced file and its not there?

Last edited by stinger; 01/02/11 07:21 PM.
#3170221 - 01/02/11 08:47 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Mar 2007
Posts: 14
stinger Offline
Junior Member
stinger  Offline
Junior Member

Joined: Mar 2007
Posts: 14
San Antonio, Texas USA
Guess it's time to start a new file and waste another day. I am also going to have to read the pdf on the script editor to learn how to write the script and where to put it.

Last edited by stinger; 01/02/11 09:18 PM.
#3173019 - 01/06/11 03:55 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Apr 2002
Posts: 17,733
Joe Offline
Veteran
Joe  Offline
Veteran

Joined: Apr 2002
Posts: 17,733
Bridgewater, NJ
stinger,

I don't mind you jumping in one this thread and adding more mouse programming questions. That's what the thread is for.

Let's just keep things constructive and useful, OK?

#3228987 - 03/09/11 09:04 AM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 56
tintifaxl Offline
Junior Member
tintifaxl  Offline
Junior Member

Joined: Sep 2010
Posts: 56
Austria
I'd like to assign mouse buttons 4 and 5 to the joystick for Teamspeak and VAC activation. But I don't manage to find the correct names for these buttons. If someone could post them, I'd be very happy cheers

#3229488 - 03/09/11 06:26 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 104
Dimebug Offline
Member
Dimebug  Offline
Member

Joined: Sep 2010
Posts: 104
France
It may be a bug as
MOUSE_BTN4
MOUSE_BTN5

are defined.


Guillaume "Dimebug" Leleve
#3229659 - 03/09/11 08:53 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 56
tintifaxl Offline
Junior Member
tintifaxl  Offline
Junior Member

Joined: Sep 2010
Posts: 56
Austria
Thank you for the symbols, they compile but don't generate any output if mapped to joystick button, MOUSE_LEFT, MOUSE_RIGHT do work. I submitted a report at the bug tracking site.

#3230052 - 03/10/11 04:17 AM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Mar 2011
Posts: 14
Thermal Offline
Junior Member
Thermal  Offline
Junior Member

Joined: Mar 2011
Posts: 14
Look in the define.tmh file for the button descriptions. Not the manual *sigh*.

#3253356 - 03/31/11 01:28 PM Re: T.A.R.G.E.T. mouse programming [Re: Joe]  
Joined: Sep 2010
Posts: 56
tintifaxl Offline
Junior Member
tintifaxl  Offline
Junior Member

Joined: Sep 2010
Posts: 56
Austria
Just got the response from Thrustmaster after 3 weeks:


We begin by thanking you for your interest in Thrustmaster products.

We can confirm that the virtual mouse used by TARGET only has 3 buttons.

MOUSE_BTN4 and MOUSE_BTN5 were declared in defines.tmh, but they are in fact not supported.

They will be removed from defines.tmh in the next release of TARGET.

We thank you for your understanding.

Bugger, as these buttons would have been great for Teamspeak. sigh

Page 1 of 2 1 2

Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
10 Years ago MV Sewol
by wormfood. 04/15/24 08:25 PM
Pride Of Jenni race win
by NoFlyBoy. 04/15/24 12:22 AM
It's Friday: grown up humor for the weekend.
by NoFlyBoy. 04/12/24 01:41 PM
OJ Simpson Dead at 76
by bones. 04/11/24 03:02 PM
They wokefied tomb raider !!
by Blade_RJ. 04/10/24 03:09 PM
Good F-35 Podcast
by RossUK. 04/08/24 09:02 AM
Gleda Estes
by Tarnsman. 04/06/24 06:22 PM
Food Safety and Bad Roommates
by KRT_Bong. 04/04/24 02:16 AM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0