PDA

View Full Version : Turning off TrackIR



WWBrian
9th April 2009, 10:51 PM
Greetings All,

How would I go about using my FighterStick b13 (Hat3 up) to repeatedly decrease POV (zoom in /not fixed view) and shut off TiR at same time?

If decrease POV = " - " key
and TiR on/off = "F12" key

Thanks in advance

Bob Church
9th April 2009, 11:29 PM
Hi WWBrian,

Did you need to autorepeat the zoom on b13 or just click it once?

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

WWBrian
9th April 2009, 11:43 PM
Greetings Bob,

Autorepeat, as long as it is pressed, it continues to zoom in. It is not a fixed "close" view.

Thank you for the assist!

-WWBrian

Bob Church
10th April 2009, 05:43 AM
Hi WWBrian,

Okay. The script below seems to work. You'd need to add the CMS Controls tab to the map, open the script editor in the CM and paste the script in. It will originally have some header info and then just the script and endScript statements. Put the below code between those, make sure there's only on "script" at the to and one "endScript" at the bottom.

I set three "defines" up at the top so that you wouldn't have to dig through the code to modify all the references. The "onTime" is just the minimum width it takes to send the F12 command. The "offTime is the time between the "=" characters and can be adjusted to set the character rate.

So, this seems to work:


script

// Set up the various times.
//
%define onTime 2
%define offTime 2
%define charTime 2

// No need to change these.
//
%define cycling b1
%define stopping b2

// Make sure the flags are setup initially. They should
// bothe be clear anyway, but it's no problem to be sure
// with b1 and the FIRSTSCAN loop has to run to set b2.
//
if( FIRSTSCAN ) then
cycling = FALSE;
stopping = FALSE;
endIf

// Setup the autorepeat timer if the button is clicked and,
// b1 is enabling it, and b2 isn't disabling it.
//
timer( INTERVAL, d1, onTime, offTime ) = js1.b13 AND cycling AND NOT stopping;
cms.b1 = d1;

// This sequence waits until js1.b13 is pressed. It sends the F12
// to disconnect the TIR, then sets cycling TRUE to start the timer.
// The stopping flag holds it off if the other stop sequence is
// running.
//
sequence
wait( js1.b13 AND NOT cycling AND NOT stopping );
cms.b2 = TRUE;
delay( charTime );
cms.b2 = FALSE;
delay( charTime );
cycling = TRUE;
endSequence

// Any js1.b13 release initiates a shutdown. Then it sets
// b1 FALSE to renable for the next press and b2 TRUE to
// inhibit a new press until the TIR gets done.
//
sequence
wait( NOT js1.b13 );
cycling = FALSE;
stopping = TRUE;
delay( onTime + offTime );
cms.b2 = TRUE;
delay( charTime );
cms.b2 = FALSE;
delay( charTime );
stopping = FALSE;
endSequence

endScript

Close the editor and go to the CMS Controls tab. Find Button 1, uncheck the "DX Mode" box and put:

= NULL

in the "Normal Action" "Press" box. Then program button two the same way, but in the "Press" box use:

F12 NULL

That should do it. Save the map and download it to the CM, you can watch it in the KeyTest utility on the Toolbar to see if it's sending what you want. It should always send a pair of F12 press/releases. You need to hold it down longer than that and it will start to send "=" characters until you release it. Then it sends the second F12 press/release. If you play with the "define" values, you need to save and download the map again before they'll be active.

There's always a small possibility that it will get out of sync with the TIR OFF/ON commands. It shouldn't happen often, if at all, but just hit the F12 on the keyboard once and it should line right back up.

Nothing to do but try it. If you have any trouble, let me know!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

WWBrian
10th April 2009, 06:38 AM
Hi Bob,



My fault - I didnt specify that the FighterStick was J3

(Pro Throttle as J1 and Pro Pedals as J2 )

...so I just changed the j1.b13 refrences to j3.b13

When I did the key test, I saw = F12 F12 = = = = = =

...then a Blue Screen! :blink:

I'm running Vista 64bit with CMCC v4.50 & CHCM v4.51 as Admin.

Other than the BSOD...it looks like it worked perfectly!

EDIT: Well actually, I opened up CHCM after reebooting and when I touch my Throttle or pedals, the corresponding tab shows up...but the FighterStick doesnt. No buttons, no axis'...nada'....


The stick still shows up in windows as Device 3, but It does nothing in the test/calibrate of CHCM



// CMS Script File
//
// Game Title:
// Written By:
// Date:
//
script
// Set up the various times.
//
%define onTime 2
%define offTime 2
%define charTime 2
// No need to change these.
//
%define cycling b1
%define stopping b2
// Make sure the flags are setup initially. They should
// bothe be clear anyway, but it's no problem to be sure
// with b1 and the FIRSTSCAN loop has to run to set b2.
//
if( FIRSTSCAN ) then
cycling = FALSE;
stopping = FALSE;
endIf
// Setup the autorepeat timer if the button is clicked and,
// b1 is enabling it, and b2 isn't disabling it.
//
timer( INTERVAL, d1, onTime, offTime ) = js3.b13 AND cycling AND NOT stopping;
cms.b1 = d1;
// This sequence waits until js1.b13 is pressed. It sends the F12
// to disconnect the TIR, then sets cycling TRUE to start the timer.
// The stopping flag holds it off if the other stop sequence is
// running.
//
sequence
wait( js3.b13 AND NOT cycling AND NOT stopping );
cms.b2 = TRUE;
delay( charTime );
cms.b2 = FALSE;
delay( charTime );
cycling = TRUE;
endSequence
// Any js3.b13 release initiates a shutdown. Then it sets
// b1 FALSE to renable for the next press and b2 TRUE to
// inhibit a new press until the TIR gets done.
//
sequence
wait( NOT js3.b13 );
cycling = FALSE;
stopping = TRUE;
delay( onTime + offTime );
cms.b2 = TRUE;
delay( charTime );
cms.b2 = FALSE;
delay( charTime );
stopping = FALSE;
endSequence
endScript


EDIT #2: unplugging and replugging seemed to fig the FighterStick!

*whew!*

- Brian

Bob Church
10th April 2009, 06:50 AM
Hi Brian,

>> ...it looks like it worked perfectly! <<

Well, that's the main thing. :)

I'll have to run it on V64 and see if I can duplicate it. If you run it again and it BSODs, it's helpful if you can get the numbers of the screen about which module crashed, the offsets, etc. Sometimes it shows them, sometimes it doesn't, just whatever it tells you.

I'll set it up, it may be a day or so, I don't have the Vista64 stuff set up so I'll need to install it all first. I'll let you know what turns up.

Thanks!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

WWBrian
10th April 2009, 07:04 AM
Hi Bob,

Yeah, it just BSODs after a few = inputs...

I can't catch the screen fast enough but it was in module chdrvr01.sys

Heres the report to MS stuff --

Problem signature:
Problem Event Name: BlueScreen
OS Version: 6.0.6001.2.1.0.256.1
Locale ID: 1033
Additional information about the problem:
BCCode: d1
BCP1: FFFFFA64034E811C
BCP2: 0000000000000002
BCP3: 0000000000000000
BCP4: FFFFFA60034E39DF
OS Version: 6_0_6001
Service Pack: 1_0
Product: 256_1


Oh well. it was worth a try.

Thanks again for your prompt response!
- Brian

Bob Church
10th April 2009, 11:09 AM
Hi Brian,

I set it up and ran it, and it crashed straight away. Worked okay on Vista 32, but in Vista 64 it went down virtually as soon as I touched that button every time. I took the script and commented things out, then started to put them back in, and it just doesn't like me doing the addition in the argument to the delay statement in the second sequence:


sequence
wait( NOT js1.b13 );
cycling = FALSE;
stopping = TRUE;
delay( onTime + offTime ); // This one crashes it
cms.b2 = TRUE;
delay( charTime );
cms.b2 = FALSE;
delay( charTime );
stopping = FALSE;
endSequence

I thought maybe it was the addition itself inside the sequence, but that didn't seem to matter. It's the fact that it's in the delay statement and it doesn't matter if you just add two numbers or a number and an analog variable. I didn't think to try two analog variables, it probably does it then, too. Anyway, if I change the code to read like this:


sequence
wait( NOT js1.b13 );
cycling = FALSE;
stopping = TRUE;
a1 = onTime + offTime; // Add the two values together in a1
delay( a1 ); // Delay on the result of the addition
cms.b2 = TRUE;
delay( charTime );
cms.b2 = FALSE;
delay( charTime );
stopping = FALSE;
endSequence

then it seems to work fine. If I put any addition operation in the delay statement itself, though, it goes down again. You can also just add them up and put a hard number in there like "delay( 4 );" and it works. Very odd.

I'll have to track it down and get the driver fixed for the next release. In the meantime, if you want to you can try it like the above or with a hard number. Adding them in a1 saves having to remember to change it if you change the other times, but it just needs to be long enough that the interval timer can complete one cycle if it needs to so that it's definitely done before the second F12 gets sent. If you do try it, let me know if it clears it for you, too.

Meanwhile, I'll have to go see if I can figure out why V64 doesn't like the silly add operation. :)

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

WWBrian
10th April 2009, 09:25 PM
Hi Bob,

Sweet!



a1 = onTime + offTime; // Add the two values together in a1
delay( a1 ); // Delay on the result of the addition


This works almost perfectly! You are da' man! :thumbsup:

...but Im getting an unwanted F12 input at the end. Just need the beginning one.

I can't let you spend your time figuring this out and not have me at least try it! But that is very bizarre that 64bit doesn't like a simple addition like that.
Leave it to me to request something that Murphy has his fingers in! :joystick:

Thank you for your additional time and effort Bob,

- Brian

Bob Church
11th April 2009, 06:16 AM
Hi Brian,

>> Sweet!

This works almost perfectly! <<

Great! It can be hard to find those sometimes but this narrows it down to a pretty small area of code. I should be able to find it without much trouble. Thank you for running it again and verifying it!

>> ...but Im getting an unwanted F12 input at the end. Just need the beginning one. <<

Well, there's one there that I thought you needed one to switch the TIR back on. If I misunderstood and you want to leave the TIR in OFF mode, you'd just need to get rid of the four lines that send it. Comment them as below like this:


sequence
wait( NOT js1.b13 );
cycling = FALSE;
stopping = TRUE;
delay( onTime + offTime );
// cms.b2 = TRUE;
// delay( charTime );
// cms.b2 = FALSE;
// delay( charTime );
stopping = FALSE;
endSequence

or just delete them. You need to leave the "stopping" logic in place to cover the shutdown on the other timer, but those four lines are what actually send the trailing F12.

If you're getting two F12s at the end, that shouldn't be happening. I'll need to revisit the logic a little and see if I can figure how it might be happening.

>> I can't let you spend your time figuring this out and not have me at least try it! But that is very bizarre that 64bit doesn't like a simple addition like that. Leave it to me to request something that Murphy has his fingers in! <<

And me to find some way to write it. :) I do appreciate it. I could duplicate this one, but even then it's hard to be sure. It's always nice to get a little verification.

>> Thank you for your additional time and effort Bob, <<

Glad to help, Brian! Thank you for letting me know and for checking the fix!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com