PDA

View Full Version : CMS Axis starting value


Torpedovisk
10-02-2005, 07:47 PM
I use the PT microstick as a virtual slider in most of my games, via CMS scripting.

Both axes (x-Prop/y-Trim) start at zero. How can i make them start at (255/128) instead of zero? My attempts ended with a permanent 255/128 value added to the axis.

Right now i'm using a button to reset the axis to 255/128, but if it could start at 255/128 it would be nice.

Thanks!



EDIT: Ops wrong numbers! :rolleyes:

Bob Church
11-02-2005, 02:04 AM
Hi Torpedovisk,

I'm not sure I understand what you're asking. Do you want to invert them? You should be able to just check the "Reverse" box for the CMS axis that they end up on to do that. If you're trying to offset them, you can just add to the value, but remember that it will only allow 0 to 255 when it goes to the output. Some combination of the two ought to get you where you want to go. Could you state it like "I want 128 at one end, 192 at center, 255 at the other end." or something like that? I'm just not clear what you mean by "..start at (255/128)...".

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Torpedovisk
11-02-2005, 01:20 PM
Sorry if i made a confusion :blush: , here is what i'm trying to do:

I made a script so the Pro throttle microstick acts as a slider. For example, if i keep the microstick deflected up with a value more than 175, the scripts keeps adding 1 to CMS.A8.

CMS.A8 is my Trim axis, so by moving the microstick i can change the absolute location of the trim wheel in flight simulator.

CMS.A8 starts at a value of 0, but it would be much better if it could start at 128 instead, so the trim wheel would be centered.

I use the same for my Prop lever, using the Y value of the microstick instead. Again, the axis starts at 0, but 255 would be nicer.

Here is the script:

// Microstick ***
Â*
//// Â*Axes

Â*CMS.A7 = A50;
Â*CMS.A8 = A51;
Â*
// Axes Limits

Â*IF ( [ A50 > 255 ] ) THEN
Â* Â*A50 = 255;
Â* Â* Â*ENDIF
Â*
Â*IF ( [ A50 < 0 ] ) THEN
Â* Â*A50 = 0;
Â* Â* Â*ENDIF
Â*
Â*IF ( [ A51 > 255 ] ) THEN
Â* Â*A51 = 255;
Â* Â* Â*ENDIF
Â*
Â*IF ( [ A51 < 0 ] ) THEN
Â* Â*A51 = 0;
Â* Â* Â*ENDIF

/// Reset Axes

Â*SEQUENCE
Â* Â*WAIT ( JS2.B3 AND JS1.B4 );
Â* Â*A50 = 255;
Â* Â*A51 = 128;
Â*ENDSEQUENCE

///// X Axis - Prop

////// X Slow

Â*SEQUENCE
Â* Â* Â*IF ( [ JS2.A1 >= 175 ] AND [ JS2.A1 <= 219 ] AND NOT [ A50 >= 255 ] ) THEN
Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â*A50 = A50 + 1;
Â* Â* Â* Â* Â*DELAY ( 5 );
Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ELSE
Â* Â* Â* Â*IF ( [ JS2.A1 <= 70 ] AND [ JS2.A1 >= 29 ] AND NOT [ A50 <= 0 ] ) THEN
Â* Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â* Â*A50 = A50 - 1;
Â* Â* Â* Â* Â* Â*DELAY ( 5 );
Â* Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ENDIF
Â* Â* Â* Â*ENDIF Â* Â* Â*
Â*ENDSEQUENCE

////// X Normal
Â*
Â*SEQUENCE
Â* Â* Â*IF ( [ JS2.A1 >= 220 ] AND NOT [ A50 >= 255 ] AND NOT JS1.B4 ) THEN
Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â*A50 = A50 + 2;
Â* Â* Â* Â* Â*DELAY ( 1 );
Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ELSE
Â* Â* Â* Â*IF ( [ JS2.A1 <= 28 ] AND NOT [ A50 <= 0 ] AND NOT JS1.B4 ) THEN
Â* Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â* Â*A50 = A50 - 2;
Â* Â* Â* Â* Â* Â*DELAY ( 1 );
Â* Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ELSE
Â* Â* Â* Â*IF ( [ JS2.A1 >= 220 ] AND NOT [ A50 >= 255 ] AND JS1.B4 ) THEN
Â* Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â* Â*A50 = A50 + 10;
Â* Â* Â* Â* Â* Â*DELAY ( 1 );
Â* Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ELSE
Â* Â* Â* Â*IF ( [ JS2.A1 <= 28 ] AND NOT [ A50 <= 0 ] AND JS1.B4 ) THEN
Â* Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â* Â*A50 = A50 - 10;
Â* Â* Â* Â* Â* Â*DELAY ( 1 );
Â* Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ENDIF
Â* Â* Â* Â*ENDIF
Â* Â* Â* Â* Â*ENDIF
Â* Â* Â* Â* Â* Â*ENDIF
Â*ENDSEQUENCE
Â*
///// Y Axis - Trim

////// Y Slow

Â*SEQUENCE
Â* Â* Â*IF ( [ JS2.A2 >= 175 ] AND [ JS2.A2 <= 219 ] AND NOT [ A51 >= 255 ] ) THEN
Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â*A51 = A51 + 1;
Â* Â* Â* Â* Â*DELAY ( 5 );
Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ELSE
Â* Â* Â* Â*IF ( [ JS2.A2 <= 70 ] AND [ JS2.A2 >= 29 ] AND NOT [ A51 <= 0 ] ) THEN
Â* Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â* Â*A51 = A51 - 1;
Â* Â* Â* Â* Â* Â*DELAY ( 5 );
Â* Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ENDIF
Â* Â* Â* Â*ENDIF Â* Â* Â*
Â*ENDSEQUENCE

////// Y Normal
Â*
Â*SEQUENCE
Â* Â* Â*IF ( [ JS2.A2 >= 220 ] AND NOT [ A51 >= 255 ] ) THEN
Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â*A51 = A51 + 2;
Â* Â* Â* Â* Â*DELAY ( 1 );
Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ELSE
Â* Â* Â* Â*IF ( [ JS2.A2 <= 28 ] AND NOT [ A51 <= 0 ] ) THEN
Â* Â* Â* Â* Â*SEQUENCE
Â* Â* Â* Â* Â* Â*A51 = A51 - 2;
Â* Â* Â* Â* Â* Â*DELAY ( 1 );
Â* Â* Â* Â* Â*ENDSEQUENCE
Â* Â* Â*ENDIF
Â* Â* Â* Â*ENDIF Â* Â* Â*
Â*ENDSEQUENCE

Thanks!

Bob Church
11-02-2005, 02:01 PM
Hi Torpedovisk,

Okay. Well, you can just use the "FIRSTSCAN" flag which is TRUE the first pass through the script after you switch to Mapped Mode and FALSE thereafter:

if( FIRSTSCAN ) then
cms.a7 = 255;
cms.a8 = 128;
endIf

That should do the trick for you.

Watch out using the SEQUENCE commands inside IF/THEN blocks. If the "IF" sees FALSE, the sequence will stall wherever it is until the IF sees TRUE again, then it will pick up where it left off. If there's an "ELSE" in there it will stall on the opposite state, e.g. when the IF sees TRUE.

Hope this helps!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Torpedovisk
11-02-2005, 11:02 PM
Thanks for the quick reply! Sorry but i couldn't test it earlier, but i just did.

I tried placing the script both before and after mine, restarted, switched from off mode to direct mode, mapped mode, etc, but i couldn't get it to work.

The axis would stay at 0/0.

Thanks for the tip about the sequence command!

Bob Church
12-02-2005, 05:57 AM
Hi Torpedovisk,

Well, I went over it again and it looks to me like it should do the preset okay. What I think might be happening is this. The DirectX values aren't updated unless a value changes. Now, when you download the map, FIRSTSCAN sets the values to 128/255, but at that point they are stable until the axis moves them. You start the sim and it's got zeroes in the values. The problem is that there's no reason for DX to update. CMS says 128/255, but DX doesn't tell the sim until.

When you had the FIRSTSCAN logic running, did you happen to notice whether or not moving the axis caused the values to jump to 128/255 or you still needed to hold the axis off-center and let it increment it's way there? If it were working, I'd expect the first increment or decrement on the axis to cause the 128/255 values to get sent to the sim.

If that's what's happening, I don't know any good way to get around it except to bounce the axis once after you start the sim, and that may not really be any better than the "reset" you've got running now. You push the axis or you push the buttons. You could write a script to bounce the axis easily enough, but you couldn't determine whether or not the sim has been started to when the bounce should happen.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Torpedovisk
13-02-2005, 01:52 PM
Hi Bob,


The values never jumped to 255/128, both in the CM and in-game.

Switching from off-mode to mapped-mode reset the values to 0.


I wonder if my script is messing the the command?

This is the only other part of my script(Found here in CH Hangar and modified a bit for me):


Thanks a lot for the help!


// Trim

Â*IF ( NOT JS1.B3 ) THEN

Â* Â*IF ( [ A1 == 0 ] ) THEN
Â* Â* Â*CMS.A1 = JS1.A1;
Â* Â*ELSE
Â* Â* Â*CMS.A1 = JS1.A1 + A1;
Â* Â*ENDIF
Â*
Â* Â*IF ( [ A2 == 0 ] ) THEN
Â* Â* Â*CMS.A2 = JS1.A2;
Â* Â*ELSE
Â* Â* Â*CMS.A2 = JS1.A2 + A2;
Â* Â*ENDIF
Â* Â* Â* Â*
Â* Â*IF ( [ A3 == 0 ] ) THEN
Â* Â* Â*CMS.A3 = JS3.A3;
Â* Â*ELSE
Â* Â* Â*CMS.A3 = JS3.A3 + A3;
Â* Â*ENDIF
Â* Â* Â*
Â*ENDIF
Â*
Â*SEQUENCE
Â* Â*WHILE ( JS1.B11 AND JS1.B4 );
Â* Â* Â*IF ( [ A2 < 127 ] ) THEN
Â* Â* Â* Â*A2 = A2 + 1;
Â* Â* Â*ENDIF;
Â* Â* Â*DELAY (1);
Â*ENDSEQUENCE

Â*SEQUENCE
Â* Â*WHILE ( JS1.B9 AND JS1.B4 );
Â* Â* Â*IF ( [ (A2 + 128) != 0 ] ) THEN
Â* Â* Â* Â*A2 = A2 - 1;
Â* Â* Â*ENDIF;
Â* Â* Â*DELAY (1);
Â*ENDSEQUENCE

Â*SEQUENCE
Â* Â*WHILE ( JS1.B10 AND JS1.B4 );
Â* Â* Â*IF ( [ A1 < 127 ] ) THEN
Â* Â* Â* Â*A1 = A1 + 1;
Â* Â* Â*ENDIF;
Â* Â* Â*DELAY (1);
Â*ENDSEQUENCE

Â*SEQUENCE
Â* Â*WHILE ( JS1.B12 AND JS1.B4 );
Â* Â* Â*IF ( [ (A1 + 128) != 0 ] ) THEN
Â* Â* Â* Â*A1 = A1 - 1;
Â* Â* Â*ENDIF;
Â* Â* Â*DELAY (1);
Â*ENDSEQUENCE
Â*
Â*SEQUENCE
Â* Â*WAIT( JS1.B3 AND NOT JS1.B4 );
Â* Â*A1 = JS1.A1 - 128;
Â* Â*A2 = JS1.A2 - 128;
Â* Â*A3 = JS3.A3 - 128;
Â*ENDSEQUENCE
Â*
Â*SEQUENCE
Â* Â*WAIT( JS1.B3 AND JS1.B4 );
Â* Â*A1 = 0;
Â* Â*A2 = 0;
Â* Â*A3 = 0;
Â*ENDSEQUENCE

JNOV
16-02-2005, 01:04 AM
Could the problem be here, right at the top of the script you posted?

//// Axes

CMS.A7 = A50;
CMS.A8 = A51;

It looks like you've got an unqualified assignment of a50 to cms.a7 and a51 to cms.a8, which might override your attempt to set the values of cms.a7 and cms.a8 during the first scan. In any case, if you don't set a50 and a51 equal to cms.a7 and cms.a8, respectively, during the first scan, their values will change the first-scan values of cms.a7 and cms.a8 during the second scan.

Just a thought,

JNOV

Bob Church
16-02-2005, 01:24 PM
Hi JNOV,

You're right of course. Probably just setting the A50 and A51 values at initialization would fix it. If the initialization was at the top of the program, those two assignments would set up the CMS axes on the first pass automatically.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Torpedovisk
17-02-2005, 02:39 AM
That did it! :thumbsup:

Thank you both! :cheers: