PDA

View Full Version : limiting output to deflection AWAY from center



luap
9th February 2008, 11:16 PM
Greetings,

I would like to use the mini stick on the PT as a TDC slew but the problem is it returns the cursor to (toward) center immediately upon release (or relaxation of pressure).

So I propose to limit output from the ministick only as values move away from center. E.g.: Move the ministick right of center, TDC moves right, release ministick and it returns to center but the TDC does not. TDC does not move back other way until ministick is moved left of center.

No spoon feeding, please. Somebody please just nudge me in the right direction. Searching teh documentation is not turning anything up so far.... but then I do not exactly know what it is that I am searching for.

Bob Church
9th February 2008, 11:46 PM
Hi luap,

>> I would like to use the mini stick on the PT as a TDC slew but the problem is it returns the cursor to (toward) center immediately upon release (or relaxation of pressure).

So I propose to limit output from the ministick only as values move away from center. E.g.: Move the ministick right of center, TDC moves right, release ministick and it returns to center but the TDC does not. TDC does not move back other way until ministick is moved left of center.

No spoon feeding, please. Somebody please just nudge me in the right direction. Searching teh documentation is not turning anything up so far.... but then I do not exactly know what it is that I am searching for. <<

If I understand it correctly, it would be a matter of checking the axis value to see which side of center it was on and then making the decision as to whether it could move. It could always move from center, of course. So maybe a couple of conditionals to determine if the axis was left of center, at center, or right of center, then use those to enable it's output to move the mouse if the current position was suitable, e.g.:

If it's left of center and the movement is left, move it left. If not do nothing.

If it's right of center and the movement is right, move it right. If not, do nothing.

If the output is centerec and the axis isn't, move it in any case.

Is that what you want to happen?

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

luap
9th February 2008, 11:47 PM
Follow up...

What I am looking for is axis response same as what you get when you program the ministick to be a mouse. THe mouse does not snap back to center screen when you release the ministick, it stays in its position untill some input is given away from the ministicks spring center position

luap
9th February 2008, 11:48 PM
Gee, Bob... I hope you are here lurking... because you posted just as I was following up.

The output needs to be an axis output, mouse has no effect on the program command, it needs to be axis.

Bob Church
9th February 2008, 11:53 PM
Hi luap,

Twice actually. :) I hadn't thought it through, but the conditionals sound like they would work. The ministick will put out 128 at center, you'd need to use a CMS axis for the actual output, it will put out 128 at center, too. So you'd need to base the conditional on the CMS output and the need for movement on the ministick axis.

Wouldn't be too hard to set up, really. Does it sound to you like it would do the trick?

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

luap
10th February 2008, 12:12 AM
Hi Bob,

If the axis behaviour would treat a TDC the same as it treats the mouse cousor, yes.

if x is > previous x and x is > 128 then move
if x is < previous x and x is < 128 then move

... or maybe the check would have to be

if x > 128 and next x > previous x then move
if x < 128 and next x < previous x then move

same for y

Bob Church
10th February 2008, 05:12 AM
Hi luap,

Well, I played around with it some but it's just sort of ambiguous. I came up with this:


script

// Have cms.a1 track js2.a1 so long as it's on the same side that it
// was last time.
//
if([ a1 >= 128 ] AND [ js1.a1 < 128 ]) then
cms.a1 = js1.a1;
else
if([ a1 <= 128 ] AND [ js1.a1 > 128 ]) then
cms.a1 = js1.a1;
else
if([ js1.a1 < a1 ] AND [ a1 < 128 ]) then
cms.a1 = cms.a1 - ( a1 - js1.a1 );
else
if([ js1.a1 > a1 ] AND [ a1 > 128 ]) then
cms.a1 = a1 + ( js1.a1 - a1 );
endIf
endIf
endIf
endIf

// Make sure CMS.A1 doesn't get out of range.
//
if([ cms.a1 < 0 ]) then
cms.a1 = 0;
else
if([ cms.a1 > 255 ]) then
cms.a1 = 255;
endIf
endIf
a1 = cms.a1;

endScript

Which doesn't move until you hit the last peak value and then it tracks the difference. The problem is that if it's supposed to act like a mouse, the mouse is going to keep on moving because the values are still in the mouse registers (cms.a1 and cms.a2) and aren't 128s.

My next shot was to add some code so if the mouse wasn't moved, it went back to center, which would stop the mouse. Then the problem is that the next mouse move would have to exceed all previous mouse moves to be recognized. That would mean. presumably, that as you got closer to your final position, the point where you'd want precision control, the mouse is giving its least precision. You'd be getting large moves when what you really probably wanted was small moves.

I don't know. What exactly are you trying to accomplish? Any ideas on what to do with the mouse?

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

luap
10th February 2008, 05:36 AM
Hi Bob,

If you are familiar with LOMAC, you will know that you can assign an axis to the TDC slew. The problem with doing this arises with the behaviour of the ministick in that it naturally returns to center as soon as you let it go. This makes aiming with it very difficult and results in the TDC returning to center.

I could just as easily program another hat to send the ASCII characters, but what fun would that be? Then I am just taking the easy route to play a game. Frivolous as it may seem learning programming techniques that will allow me to while away time in a flight simulation do add to the body of knowledge in my head. Programming is programming, right? Maybe someday I'll put the tools I learn to legitimate use. For now, i just want to use it to blow up Rooskies.

PSB

Bob Church
10th February 2008, 06:14 AM
Hi Bob,

>> If you are familiar with LOMAC, you will know that you can assign an axis to the TDC slew. The problem with doing this arises with the behaviour of the ministick in that it naturally returns to center as soon as you let it go. This makes aiming with it very difficult and results in the TDC returning to center. <<

So what you'd really like is a ministick with no springs? :) Not being a mouse axis makes it easier. The problem would be that if you overshot, there'd be no way back without going through center first. But if that's okay, then something like this should work. I did it on the FighterStick X Axis, you'll have to make so adjustments. Basically it's just a "peak detector that won't come off the last peak until it crosses 128 again. Also, the output is from CMS Axis 1, the stick itself should go nowhere. Anyway:


script
if(([ js1.a1 < 128 ] AND [ js1.a1 < cms.a1 ]) OR ([ js1.a1 > 128 ] AND [js1.a1 > cms.a1 ])) then
cms.a1 = js1.a1;
endIf
endScript

You might want to put a centering buttons on it somewhere to force it back to the middle, as it is you have to hit like 127 or 129, just cross center, to get the cursor to return to the middle.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Bob Church
10th February 2008, 06:49 AM
Hi Luap

Another option might be to use the stick to change the value in a register:


script

// Center the TDC axis initially
//
if( FIRSTSCAN ) then
cms.a1 = 128;
endIf

// if( CLOCKTICK ) then

// Just check which side of center the stick is on and move cms.a1
// in that direction by a count.
//
if([ js1.a1 > 144 ] AND [ cms.a1 < 255 ]) then
cms.a1 = cms.a1 + 1;
else
if([ js1.a1 < 112 ] AND [ cms.a1 > 0 ]) then
cms.a1 = cms.a1 - 1;
endIf
endIf

// endIf

endScript

It just moves the value one way or the other, but I suspect this is much the same as using the characters. The timing is a little unpredictable, too. You could lock it to the "CLOCKTICK" variable, but then it's it's pretty slow. I've included the lines to do it but commented them out. Anyway, with CLOCKTICK, it takes several seconds for it to move through the range. Unless moving by more than 1 count at a time were acceptable, it's probably too slow.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Capt_Crunch
10th February 2008, 12:17 PM
Another simple option would be to just set the mini-stick as a mouse, (use deadzone) and in Lomac assign the mouse as the horizontal and vertical TDC slew assignments. You can also tweak the axis' response curve in CM. I have Lomac setup this way and get great control for the TDC.

luap
10th February 2008, 05:04 PM
I must be missing it Capt'n... because I didn;t see an option to do that. I'll look a little closer. But as I said... why do things the easy way just to play a game. Make some intersting scripts that do neat and totally unnecessary things simply for the sake of doing it.

luap
11th February 2008, 05:34 AM
I settled on using a solution along these lines...

CMS.B26 = [JS2.A1 < 88];
CMS.B27 = [JS2.A1 > 168]

... and then assigned a key press to the CMS.B's as appropriate

I get a nice dead zone and the behavior I am looking for.

I do appreciate the elegance of your approaches though, Bob. They give me ideas for other things. Thanks, again.

Bob Church
11th February 2008, 05:47 AM
Hi luap,

Glad you got it to work one way or the other, that's the main thing. :)

WRT Capt_Crunch's post, I don't know about the assignment process in the sim or which assignment you didn't understand, but if you need to make the ministick act as a mouse, it's just a matter of doing a DX Mode assignment, but rather than going to a "CM Device", they need to go to "Mouse". It's in the drop-down list with the CM Devices on the right side of the screen, down below CM Device 16. The X and Y are mouse movement, Z is like a scroll wheel, and buttons 1, 2, and 3 are "Left", "Right", and "Middle" respectively.

Anyway, I'm glad you got things operating! Have fun!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

luap
12th February 2008, 03:51 AM
The issue was I simply did not know the game had a mouse option for TDC. There is not alot of good a box of nails will do you if you don't realize you have a hammer to drive them with.

JNOV
11th March 2008, 04:32 PM
When I'm using the ministick to drive an analog axis, what I typically do is what Bob suggests: use the ministick deflection to control the "velocity" of the axis, rather than its absolute value. The simplest approach is simply to check which way the minstick is deflected and to increment or decrement the axis value, as appropriate.

That works, but, in addition to potentially updating the axis too slowly or too quickly, it also throws away a bunch of information provided by the ministick. It might be nice, for example, to have the rate of change for the axis be proportional to stick deflection (i.e., the axis value changes more raplidly the farther from the center the stick is deflected). The problem with trying to do that is that we only have 255 counts, so something like

%define miniX js1.a1
%define axis cms.a1
%define deadband 20

if ([miniX > (128+deadband)]) then
axis = axis + (miniX - (128+deadband));
if ([axis > 255]) then
axis = 255;
endif
endif

tends to result in very quick, very coarse movement when the stick is deflected much from center.

One way to deal with this problem is to use an analog variable (which is not limited to 255 counts) as a scaled version of your axis, along with a scaling factor that defines the span of the scaled axis (I've picked a1 and 20 arbitrarily). Thus, where an ordinary axis runs from 0 to 255, a scaled axis runs from 0 to 255 times the scaling factor:

%define scaledAxis a1
%define scaleFactor 20
%define miniX js1.a1
%define axis cms.a1
%define deadband 20

if ([miniX > (128 + deadband)]) then
// ministick axis is used to update scaled axis, rather than the actual axis
scaledAxis = scaledAxis + (miniX - (128 + deadband));
if ([scaledAxis > (255 * scaleFactor)]) then
scaledAxis = 255 * scaleFactor;
endif
// actual axis value is computed by "de-scaling" scaled axis
axis = scaledAxis / scaleFactor;
endif

(This is the update code for stick deflection to the right; you need complementary code to handle left stick deflection.)

Updating scaledAxis, rather than axis, allows for much less coarse control. You can tune the sensitivity of the stick by adjusting scaleFactor. Increasing scaleFactor increases the span of the scaled axis and therefore decreases update speed (i.e., lowers sensitivity and coarseness); decreasing scaleFactor has the opposite effect.

I've used this a number of times in games (including using the minstick to control radar/eos cursors) and it seems to work pretty well. I hope this is helpful.

Best regards,

JNOV

DonULFonso
11th March 2008, 08:00 PM
What about storing the current input value in variable 1 now and a bit later check for the current value and store it in var. 2 and the see whether both are the same or the new one's changed, then move the mouse (if not, then not)? Repeat/loop...

(Sorry, off for a drink (or two)...)