|
|
|
#3123491 - 10/25/10 03:16 PM
T.A.R.G.E.T. mouse programming
|
Veteran
Registered: 04/05/02
Posts: 17733
Loc: 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: BTN S4 MOUSEXY (UL, 512, 190)
|
|
Top
|
|
|
|
#3123952 - 10/26/10 07:40 AM
Re: T.A.R.G.E.T. mouse programming
[Re: Joe]
|
Member
Registered: 09/18/10
Posts: 103
Loc: 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 }
Edited by Dimebug (10/26/10 07:46 AM)
_________________________
Guillaume "Dimebug" Leleve
|
|
Top
|
|
|
|
#3124073 - 10/26/10 11:13 AM
Re: T.A.R.G.E.T. mouse programming
[Re: Dimebug]
|
Veteran
Registered: 04/05/02
Posts: 17733
Loc: Bridgewater, NJ
|
Thinking about this... 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?
|
|
Top
|
|
|
|
#3124109 - 10/26/10 12:00 PM
Re: T.A.R.G.E.T. mouse programming
[Re: Joe]
|
Member
Registered: 09/18/10
Posts: 103
Loc: 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
|
|
Top
|
|
|
|
#3124125 - 10/26/10 12:31 PM
Re: T.A.R.G.E.T. mouse programming
[Re: Dimebug]
|
Veteran
Registered: 04/05/02
Posts: 17733
Loc: Bridgewater, NJ
|
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?
|
|
Top
|
|
|
|
#3124131 - 10/26/10 12:45 PM
Re: T.A.R.G.E.T. mouse programming
[Re: Joe]
|
Member
Registered: 09/18/10
Posts: 103
Loc: 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
|
|
Top
|
|
|
|
#3124196 - 10/26/10 02:08 PM
Re: T.A.R.G.E.T. mouse programming
[Re: Joe]
|
Veteran
Registered: 04/05/02
Posts: 17733
Loc: 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. 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.
|
|
Top
|
|
|
|
#3124323 - 10/26/10 04:13 PM
Re: T.A.R.G.E.T. mouse programming
[Re: Joe]
|
Member
Registered: 09/18/10
Posts: 103
Loc: 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
|
|
Top
|
|
|
|
#3124354 - 10/26/10 04:58 PM
Re: T.A.R.G.E.T. mouse programming
[Re: Dimebug]
|
Veteran
Registered: 04/05/02
Posts: 17733
Loc: Bridgewater, NJ
|
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. 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?
|
|
Top
|
|
|
|
#3169951 - 01/02/11 02:49 AM
Re: T.A.R.G.E.T. mouse programming
[Re: Joe]
|
Junior Member
Registered: 03/07/07
Posts: 14
Loc: 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?
|
|
Top
|
|
|
|
|
|
| |