View Full Version : Loop processing without device movement
Chris
27th May 2004, 09:20 AM
Is there any way to ensure that the loop is processed even if no button is pressed and the controls are not moved? I only have CH Pro Pedals and what I want is to make them send key strokes for old flight sims that only accept one stick (which in my case is a Logitech WingMan Force, so not supported by CHCM).
My idea is that e.g. for half pressed right rudder, the device sends alternatively key press and key release for some rudder in the sim.
Something like:
SEQUENCE
A1 = JS1.A1;
B1 = [ A1 > 127 ]; // right or left rudder?
IF( B1 ) THEN
A1 = A1 - 127 - DEADZONE; // how much right rudder?
ELSE
A1 = 128 - A1 - DEADZONE; // how much left rudder?
ENDIF
CMS.B1 = ( NOT B1 ) AND [ A1 > 0 ]; // press left rudder key
CMS.B2 = B1 AND [ A1 > 0 ]; // press right rudder key
DELAY ( A1 ); // longer if more rudder is applied
CMS.B1 = FALSE; // release rudder key
CMS.B2 = FALSE;
DELAY ( 128 - A1 ); // keep released for a while
ENDSEQUENCE
The problem is that this code has to be executed even if the controls values remain the same.
Thanks in advance for your help,
Chris
Bob Church
27th May 2004, 03:18 PM
It's easier to do it with a timer than a sequence, really. Also, using A1 directly is probably going to be too slow, and it works the wrong way in any case. Bigger values are going to give longer delays. You probably can't use too many counts before it slows down too far to be useful, each one is worth at least 25 ms, it slows down pretty quickly. You need to scale A1 down and then sort of "invert" it so that the farther off center you get, the faster the characters show up.
The following seems to do basically what you want (you'll have to play with the axis ID). It scales A1 down by a factor of 15 and then turns the value around by subtracting from 9. I haven't tested the math 100%, but the idea is to come up with a value ranging from 1 to 8. You'll probably have to play with the values to get it to line up with what you're trying to do. Anyway:
script
// Process here if we're left of center
//
if( [ js1.a1 < 128 ] ) then
cms.b1 = d1;
a1 = 9 - (( 128 - js1.a1 ) / 15 );
endif
// Process here if we're right of center
//
if( [ js1.a1 > 128 ] ) then
cms.b2 = d1;
a1 = 9 - (( js1.a1 - 128 ) / 15);
endif
// Set B1 if we're off-center to run the timer
//
b1 = [ js1.a1 != 128 ];
timer( interval, d1, 1, a1 ) = b1;
endScript
In the GUI set CMS.B1 to send rudder left and CMS.B2 to send rudder right. You'll need a NULL to keep it from repeating, I had them set to "l NULL" and "r NULL" using the X axis on the stick just for a test and it seems to basically work. Watch it in NotePad, though, you can see the speed change more easily there. You might also want to pass b1 up to cms.b3 and have it send a "center rudder" character if there is one. That way when you center the pedals the character will force the rudders back to center.
- Bob
The StickWorks
http://www.stickworks.com
Chris
28th May 2004, 08:45 AM
Hi Bob,
thanks for your answer, but I still encounter problems with this script. Maybe it's some setting in CM, but I have the impression that the timer's on/off state is only checked when an axis value changes.
Here's what I see: when I apply left rudder, I do see some 'l's pop up in notepad. But as soon as I keep steady rudder (e.g., half deflected) no more of them appear. Now, if I still keep steady half deflected left rudder and use the right toe-brake, the 'l's appear again.
I don't know if this makes sense, but I have the impression that I need to 'wobble' on the device for the script to be executed.
One more thing: to be honest, I didn't understand the NULL thing. I tried to type in 'l NULL' as key command, but then no 'l's showed up at all. Maybe that's the mistake.
Cheers,
Chris
Bob Church
29th May 2004, 12:33 AM
Well, they should keep coming. Can you send me th MAP/CMS/CMC file so I can take a look? Either post them here or you can email directly if you like. My addy is sticky (at) stickworks (dot) com. Maybe I can see where it's gone astray.
- Bob
The StickWorks
http://www.stickworks.com
MichaelCHProd
29th May 2004, 02:36 AM
Get'um Bob B)
Chris
2nd June 2004, 07:45 AM
Hi Bob,
thanks for looking into it. I'll attach the map and cms files. So far, I don't have a cmc.
As a side note, I tried to find out how the scripts are executed and tried something like:
a1 = a1 + 1;
cms.a1 = a1;
The outcome was, that the axis a1 only moved when I moved the pedal. I know that the speed of movement has to be controleld using CLOCKTICK, but it should move up in any case, shouldn't it?
Cheers,
Chris
Bob Church
2nd June 2004, 09:05 AM
It should move up. I'm not sure where you're getting the pedal value into the loop, though. Just the "A1 + 1" part without the CLOCKTICK would hit 255+ in maybe 1 or 2 seconds and the CMS.Ax values can only accept 0..255 so The CMS.A1 value would have stopped. A1 would have kept going but I'm not sure how you'd get a look at it to know. Anyway, if you were watching CMS.A1, it would go to 255 and stop the way that it's written. Maybe that would explain it?
Got the script. I'll take a look and see what I can find.
- Bob
The StickWorks
http://www.stickworks.com
Bob Church
2nd June 2004, 09:54 AM
Okay, I think I see the problem. It was my error. In the two blocks:
if( [ js1.a1 < 128 ] ) then
cms.b1 = d1;
a1 = 9 - (( 128 - js1.a1 ) / 15 );
endif
there needs to be an "else" that resets cms.b1 (in the above) and cms.b2 (in the other block). Otherwise they can get left ON when js1.a1 swings back into 128. It needs to be something like:
if( [ js1.a1 < 128 ] ) then
cms.b1 = d1;
a1 = 9 - (( 128 - js1.a1) / 15 );
else
cms.b1 = FALSE;
endIf
That would explain the observation that it needs to move. Moving it would tend to unstick it. Chances are, your pedals were just in a stable position and my stick was in position to "bobble" and that left it unstuck.
The second thing I see is in a mod you made at the end:
timer( interval, d1, 8-a1, a1 )....
That's not going to change timing. The overal time is always the sum of the two times and in the above that works out to be ((8 - a1) + a1) = 8, with only one transitions. You'll change the on-time vs. off-time, but you'll still only send one character unless you're working with large enough values of a1 to actually let the characters autorepeat during the ON time. You can fix the time for the firstl delay, it only needs to be 1 frame-time, long enough for the character to register, and then the second one will vary the character rate.
I've still go to set it up and try it, but I probably won't be able to do that until tomorrow.
- Bob
The StickWorks
http://www.stickworks.com
Bob Church
3rd June 2004, 02:56 AM
Okay, I set it up and tried it and it does need the "Else" clauses. I still don't see that it needs to be moving with my setup, but it does tend to leave the characters stuck when you recenter the stick and I suspect it's just another manifestation of the same problem.
I also played with the using "8-a1" for the parameter in the timer instruction and what happens is that you get a longer or shorter burst of autorepeat characters with shorter or longer gaps between them. If you change it to just "1", then the axis varies the rate and the characters are about evenly spaced.
- Bob
The StickWorks
http://www.stickworks.com
Chris
4th June 2004, 07:19 AM
Hi Bob,
I will try the else and modify the timer back to the original setting over the week-end. I'll let you know on Monday how it worked.
The idea on changing the timer was to have an equal timing (say 8 ticks) and with few pedal, press the key for 1 tick, then release it for 7 ticks, then press it again for 1 tick. Half rudder should keep the key pressed for 4 ticks (half the interval) then release the key for 4 ticks. Full rudder then should keep the key pressed. This is what I'm doing manually when flying old sims like Crimson Skies, but I'd need the hand on the throttle of course. ;)
I did of course use an if statement to reset cms.a1 when it was >255. As long as I moved something on the pedals, the value kept moving. This sample was just to figure out how often the script was executed. It was (should have been) completely independant of the device itself.
Same with your suggested 'else': I had half left rudder applyed (js1.a3 around 64, well below 128). What I did was to apply right toe brake (js1.a2) to 'unstick' the timer. I'm on Windows XP professional with pedals connected via USB.
Anyway, I'll experiment over the week-end and let you know.
Chris
Bob Church
4th June 2004, 08:05 AM
Yeah, I could see the logic. I'm not sure which would work the best, really. Using "1" is smoother, the equal time thing would tend to be kind of off-on-off-on..., but it probably gives more characters and so would have a greater effect. What you might do, too, would be to use the "1" method but set it up so that if the axis got out to the ends, say less then 10 or greater than 245, it would just hold the keys down continously. Anyway, nothing much to do but try it and see. Let us know how it works out!
- Bob
The StickWorks
http:/www.stickworks.com
Chris
7th June 2004, 10:37 AM
Hi Bob,
I think that I'll find out about the timers by experimenting. The problem seems to be more basic in nature. Let's get back to the axis moving from 0 to 255.
a1 = a1 + 1;
if ( [ a1 > 255 ] ) then
a1 = 0;
endif;
cms.a1 = a1;
I tried this with and without the CLOCKTICK (see attached files). The point is, that cms.a1 only moves, when I move any of the other axis. Any explanation for this?
I made a movie of this, unfortunately it's 3.8MB in size. As I didn't have a screen capturing tool for movies at hand, I used my digicam -- sorry for the poor quality -- but there you can see that cms.a1 (4th axis) and cms.a2 (5th axis) only move when I use the rudder pedal (3rd axis). I can send it by e-mail if you want.
Cheers,
Chris
MichaelCHProd
7th June 2004, 10:54 PM
My attachment button here in the Hangar is 5MB. Sure you can't post the movie? Howe about sending it to my account...
Michael@chproductsDOTcom
MichaelCHProd
7th June 2004, 11:03 PM
I just downloaded your map and it is running like you want without me having to move the pedals the R and U axis are coutning from 0 to 255 all by themselves. Maybe it is something wrong with your pedals. Would you like to send them in for inspection/repair?
LittleFlower
13th June 2004, 02:09 PM
Michael. No disrespect, but I am seeing something similar in my setup. Sometimes the loops don't seem to execute, unless you move the axis. I've done a lot of testing, and ended up writing a simplified test script. Whatever I try, I can't get it to do what I want reliably. I will open a separate thread about it.
MichaelCHProd
13th June 2004, 05:27 PM
None taken brother. I will look for your new thread.
Powered by vBulletin® Version 4.1.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.