Joysticks throttles and remapping an axis

Just downloaded Vega Strike and need help? Have a question but don't know where to start? Ask here.
Post Reply
DirtyMagic
Bounty Hunter
Bounty Hunter
Posts: 155
Joined: Fri Oct 24, 2003 5:07 am
Location: Canada (but still south of Wisconsin)
Contact:

Joysticks throttles and remapping an axis

Post by DirtyMagic »

REMAPPING A JOYSTICK AXIS

Joysticks and throttles have been kinda bugging me in the back of my little brain for a while now, so last night I took a little <*cough*> time to try and figure out what's what.

Here's the jist of what I discovered regarding remapping a joystick axis to keys in vegastrike.config...

Forget the "throttle" bit... she's broke. Anthing that has an axis, though, can be assigned to key commands with a bit of work using the analogue hatswitch setup. This is right from the config file...

Code: Select all

<!-- if you have a joystick with an analogue hatswitch
		<axis name="hatswitch" nr="0" margin="0.15" joystick="1" axis="2">
			<hatswitch value="-1.0"/>
			<hatswitch value="-0.6"/>
			<hatswitch value="-0.19"/>
			<hatswitch value="0.1"/>
		</axis>
-->

<!--
		<bind joystick="1" digital-hatswitch="0" direction="up" command="ABKey"/>
		<bind joystick="1" digital-hatswitch="0" direction="left" command="TargetKey"/>
	<bind joystick="1" digital-hatswitch="0" direction="center" command="ABKey"/>

		<bind joystick="1" digital-hatswitch="0" direction="right" command="ABKey"/>
-->
This little ditty assigns positions on the axis to buttons. Keep the name="hatswitch", it seems to define a remapped axis. "nr" is the number assigned to a particular hatswitch. Your first remapped axis will be nr="0", your second nr="1" and so on. You reference this in the 'bind joystick' line, so when you assign buttons to nr="0" you use bind hatswitch="0", nr="1" use bind hatswitch="1". The hatswitch value lines assign buttons to positions on the axis from 0 (centered) to 1 and -1 on each side (more or less, you'll need to tweak it a bit for each joystick). The margin, I believe, is the "active area" around the hatswitch values you set, so if your margin is 0.15 and you set a button at an axis value of 0, it should activate while you hold your joystick anywhere from -0.15 to 0.15. The hatswitch value lines set buttons 0, 1, 2 etc in that order... the first line is button 0, the second is button 1 etc.

You can also double assign an axis so, for example, you can assign it as the y-axis in the joystick part of the config then remap it to the afterburner key in the analogue part of the config and have a "powerdive" effect.

That's the basics of remapping. I'm going to do this in three parts so it's (hopefully) easier to understand. :roll:
Last edited by DirtyMagic on Fri Feb 13, 2004 6:34 pm, edited 1 time in total.
DirtyMagic
Bounty Hunter
Bounty Hunter
Posts: 155
Joined: Fri Oct 24, 2003 5:07 am
Location: Canada (but still south of Wisconsin)
Contact:

Post by DirtyMagic »

EXAMPLE CONFIGURATION

My own configuration is a Nostromo N50 gamepad (which has a hatswitch-like thumbpad and a throttle-like thumbwheel) and a Logitech Extreme Digtial 3D joystick (with a z-axis when you twist the handle). All these controls act like an axis as far as the joystick driver is concerned... the thumbpad puts out basically one value for up, down, left, right. The thumbwheel and handle-twist put out a continuous range of values as they are moved.

The nostromo is /dev/js0. The thumbwheel is joystick 0, axis 2. The thumbpad is joystick 0, axis 1.
The joystick is /dev/js1. The handle-twist is joystick 1, axis 2.
For the sake of example, I've configured them all as "Go Faster/ Go Slowe"r keys.

Code: Select all

<!-- NOSTROMO thumbwheel as speed control -->
		<axis name="hatswitch" nr="0" margin="0.15" joystick="0" axis="2">
			<hatswitch value="-1.0"/>
			<hatswitch value=".9"/>
		</axis>
		<bind hatswitch="0" button="0" modifier="none" command="AccelKey" />
		<bind hatswitch="0" button="1" modifier="none" command="DecelKey" />


<!-- NOSTROMO pad as speed control -->
		<axis name="hatswitch" nr="1" margin="0.15" joystick="0" axis="1">
			<hatswitch value="-1.0"/>
			<hatswitch value=".9"/>
		</axis>
		<bind hatswitch="1" button="0" modifier="none" command="AccelKey" />
		<bind hatswitch="1" button="1" modifier="none" command="DecelKey" />

<!-- LOGITECH handle-twist as speed contrl -->
		<axis name="hatswitch" nr="2" margin="0.15" joystick="1" axis="2">
			<hatswitch value="0.9"/>
			<hatswitch value="-0.4"/> <!-- Low value... calibration off-center? -->
		</axis>
		<bind hatswitch="2" button="0" modifier="none" command="AccelKey" />
		<bind hatswitch="2" button="1" modifier="none" command="DecelKey" />
If your axis is putting out a range of values, you can configure "intermediate" buttons. You can, for example, configure the thumbwheel to speed up and slow down if you move it forward or backward a bit and to fire the afterburners or come to a stop if you jam it all the way to the front.

Code: Select all

<!-- NOSTROMO thumbwheel as speed control -->
		<axis name="hatswitch" nr="0" margin="0.15" joystick="0" axis="2">
			<hatswitch value="-1.0"/>
                        <hatswitch value="-0.4"/>
                        <hatswitch value="0.4"/>
			<hatswitch value=".9"/>
		</axis>
		<bind hatswitch="0" button="0" modifier="none" command="ABKey" />
                <bind hatswitch="0" button="1" modifier="none" command="AccelKey" />
		<bind hatswitch="0" button="2" modifier="none" command="DecelKey" />
                <bind hatswitch="0" button="3" modifier="none" command="StopKey" />

Clear as mud?
Last edited by DirtyMagic on Fri Feb 13, 2004 6:39 pm, edited 1 time in total.
pontiac
Elite
Elite
Posts: 1454
Joined: Sun Jan 12, 2003 6:24 pm
Location: Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy
Contact:

Post by pontiac »

DirtyMagic wrote:

Code: Select all

<!-- NOSTROMO thumbwheel as speed control -->
		<axis name="hatswitch" nr="0" margin="0.15" joystick="0" axis="2">
			<hatswitch value="-1.0"/>
                        <hatswitch value="-0.4"/>
                        <hatswitch value="0.4"/>
			<hatswitch value=".9"/>
		</axis>
		<bind hatswitch="0" button="0" modifier="none" command="ABKey" />
                <bind hatswitch="0" button="1" modifier="none" command="AccelKey" />
		<bind hatswitch="0" button="2" modifier="none" command="DecelKey" />
                <bind hatswitch="0" button="3" modifier="none" command="StopKey" />

Clear as mud?
Whoa, DirtyMagic, you're da man 8)
That is exactly what i was looking for since the throttle (even the working one in 0.3) doesn't fit my steering behaviour ;-)


Pontiac

PS: I put a link to this thread in the wiki. When i have some time i will include it there.
DirtyMagic
Bounty Hunter
Bounty Hunter
Posts: 155
Joined: Fri Oct 24, 2003 5:07 am
Location: Canada (but still south of Wisconsin)
Contact:

Post by DirtyMagic »

HOW TO FIGURE OUT YOUR JOYSTICK OUTPUT
For the newbies (like me :D )

I'm assuming you've got joystick drivers installed and working. If not, google is your friend.

You'll find joystick-like devices in /dev as /dev/js0, /dev/js1 etc.

You can see what each button/axis generates if you type in the console:
jstest /dev/js0
If it starts outputting multiple lines, try making your console wider. It's easier if there isn't crap scrolling everywhere. You can hit ctrl-c to get out of jstest.

You'll get a line showing every axis and button that your joystick has. To figure out what's what just fiddle with your stick... if you twist the stick and the axis 3 numbers change, you've just found joystick 0, axis 3. Too easy, huh?

I found that some sticks are pretty finicky about the "hatswitch values" you assign them. You can do the multiple-button config from above to see what stick position corresponds to what config-file value. Something like this:

Code: Select all

<!-- NOSTROMO thumbwheel as speed control -->
		<axis name="hatswitch" nr="0" margin="0.15" joystick="0" axis="2">
			<hatswitch value="-1.0"/>
                       <hatswitch value="-0.6"/>
                       <hatswitch value="-0.2"/>
                       <hatswitch value="0.2"/>
                       <hatswitch value="0.6"/>
			<hatswitch value=".9"/>
		</axis>
		<bind hatswitch="0" button="0" modifier="none" command="AccelKey" />
		<bind hatswitch="0" button="1" modifier="none" command="DecelKey" />
                <bind hatswitch="0" button="0" modifier="none" command="AccelKey" />
		<bind hatswitch="0" button="1" modifier="none" command="TargetKey" />
                <bind hatswitch="0" button="0" modifier="none" command="ReverseTargetKey" />
		<bind hatswitch="0" button="1" modifier="none" command="TargetKey" />

If you twist your joystick slowly, you can figure out which directions are positive and negative based on whether your speed or target change. You can figure out roughly what values your stick "likes" based on your stick position when things change.

This is probably all confusing (I'm sure it has nothing to do with the ungodly hour I figured all this out at...) but it's not bad once you start playing with it.
Last edited by DirtyMagic on Fri Feb 13, 2004 6:45 pm, edited 1 time in total.
DirtyMagic
Bounty Hunter
Bounty Hunter
Posts: 155
Joined: Fri Oct 24, 2003 5:07 am
Location: Canada (but still south of Wisconsin)
Contact:

Post by DirtyMagic »

Holy crap that was a fast reply! Didn't even get part 3 done and it's already linked in the WIKI?? YOU da man. :D

It's just been bugging me that half the controls on both my controller are an axis (again deftly avoiding the plural of axis) and therefore useless. Don't try to hold back my VS, baby.... must have more buttons!
pontiac
Elite
Elite
Posts: 1454
Joined: Sun Jan 12, 2003 6:24 pm
Location: Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy
Contact:

Post by pontiac »

DirtyMagic wrote:Holy crap that was a fast reply! Didn't even get part 3 done and it's already linked in the WIKI?? YOU da man. :D
Hey it's just a link ;-) the actually content you have collected is much more work.
It's just been bugging me that half the controls on both my controller are an axis (again deftly avoiding the plural of axis) and therefore useless. Don't try to hold back my VS, baby.... must have more buttons!
:lol:

i'm trying to make the config for my sidewinder, but the single margin isn't so good for that :?
Do you know if it is possible to set a margin for each bottom extra ?
So instead of this config

Code: Select all

<axis name="hatswitch" nr="0" margin="0.2" joystick="0" axis="2" inverse="false">
  <hatswitch value="-1.0"/>
  <hatswitch value="-0.4"/>
  <hatswitch value="0.4"/>
  <hatswitch value="1.0"/>
</axis>
using something like this:

Code: Select all

<axis name="hatswitch" nr="0"  joystick="0" axis="2" inverse="false">
  <hatswitch value="-1.0" margin="0.1" />
  <hatswitch value="-0.4" margin="0.35"/>
  <hatswitch value="0.4"  margin="0.35"/>
  <hatswitch value="1.0"  margin="0.1"/>
</axis>


Pontiac
DirtyMagic
Bounty Hunter
Bounty Hunter
Posts: 155
Joined: Fri Oct 24, 2003 5:07 am
Location: Canada (but still south of Wisconsin)
Contact:

Post by DirtyMagic »

Ya know... I dunno. :D I would guess that when the code parses the margin it would need it to be in the header line. For something like that you might try making the margin bigger and actually setting your highest range outside the max values to kinda "clip" the active spot.

Code: Select all

<axis name="hatswitch" nr="0" margin="0.35" joystick="0" axis="2" inverse="false">
  <hatswitch value="-1.1"/>
  <hatswitch value="-0.4"/>
  <hatswitch value="0.4"/>
  <hatswitch value="1.1"/>
</axis>
your actual hotspots should now be (sigh, math)
-1.45 to -.75
-.75 to -.15
.15 to .75
.75 to 1.45

I'm no expert... just figgered it all out last night but you might want to play with something like that. I actually just left dead spots when I was setting it all up, they don't really hurt anything and they prevent math from intruding into my life. :D

Incidentally, this is alot like a chat room all of a sudden. :D
pontiac
Elite
Elite
Posts: 1454
Joined: Sun Jan 12, 2003 6:24 pm
Location: Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy
Contact:

Post by pontiac »

DirtyMagic wrote:Ya know... I dunno. :D I would guess that when the code parses the margin it would need it to be in the header line. For something like that you might try making the margin bigger and actually setting your highest range outside the max values to kinda "clip" the active spot.

Code: Select all

<axis name="hatswitch" nr="0" margin="0.35" joystick="0" axis="2" inverse="false">
  <hatswitch value="-1.1"/>
  <hatswitch value="-0.4"/>
  <hatswitch value="0.4"/>
  <hatswitch value="1.1"/>
</axis>
your actual hotspots should now be (sigh, math)
-1.45 to -.75
-.75 to -.15
.15 to .75
.75 to 1.45
That's a good idea. Will try if it works.
....
Incidentally, this is alot like a chat room all of a sudden. :D
It all depends on the topic and the number of ppl online ;-)

Pontiac
Guest

Post by Guest »

Is this still supposed to work? I can't seem to use it to bind the fourth axis on my gamepad (which is definitely recognized -- jstest shows it working).

I tried this:

Code: Select all

                <axis name="hatswitch" nr="0" margin="0.25" joystick="0" axis="3">
                    <hatswitch value="-0.75"/>
                    <hatswitch value="0.75"/>
                </axis>

                <bind hatswitch="0" button="0" modifier="none" command="AccelKey"/> 
                <bind hatswitch="0" button="1" modifier="none" command="DecelKey"/>
ShaggyMoose
Insys Pilot
Insys Pilot
Posts: 2
Joined: Sat Mar 12, 2005 5:23 am
Location: Sydney, Australia

Post by ShaggyMoose »

I have a Logitech Wingman Interceptor. This is a digital stick with a throttle and three digital hatswitches. I have tried a few different ways to get the hatswitches working, but all have failed. There is absolutely no input from any of the hatswitches. The normal button assignments and the throttle axis work fine. All three hatswitches also work fine in other games. Can anyone see what I am doing wrong? Thanks.

EDIT: Forgot to ask; is it possible to set a deadzone for a digital stick? Thanks.

<!-- Logitech Wingman Interceptor:BEGIN -->
<!-- Buttons:BEGIN -->
<bind joystick="0" player="0" button="0" modifier="none" command="FireKey" />
<bind joystick="0" button="1" modifier="none" command="MissileKey" />
<bind joystick="0" button="2" modifier="none" command="PickTargetKey" />
<bind joystick="0" button="3" modifier="none" command="SheltonKey" />
<bind joystick="0" button="4" modifier="none" command="ABKey" />
<bind joystick="0" button="5" modifier="none" command="MisSelKey" />
<bind joystick="0" button="6" modifier="none" command="WeapSelKey" />
<bind joystick="0" button="7" modifier="none" command="RollLeftKey" />
<bind joystick="0" button="8" modifier="none" command="RollRightKey" />
<!-- Buttons:END -->

<!-- Axes:BEGIN -->
<axis name="x" joystick="0" axis="0" inverse="false" />
<axis name="y" joystick="0" axis="1" inverse="false" />
<axis name="throttle" joystick="0" axis="2" inverse="false" />
<!-- Axes:END -->

<!-- Hatswitches:BEGIN -->
<bind joystick="0" digital-hatswitch="0" direction="up" command="NearestTargetKey"/>
<bind joystick="0" digital-hatswitch="0" direction="down" command="SubUnitTargetKey"/>
<bind joystick="0" digital-hatswitch="0" direction="left" command="TargetKey"/>
<bind joystick="0" digital-hatswitch="0" direction="right" command="ReverseTargetKey"/>

<bind joystick="0" digital-hatswitch="1" direction="up" command="Cockpit::Inside"/>
<bind joystick="0" digital-hatswitch="1" direction="down" command="Cockpit::Behind"/>
<bind joystick="0" digital-hatswitch="1" direction="left" command="Cockpit::InsideLeft"/>
<bind joystick="0" digital-hatswitch="1" direction="right" command="Cockpit::InsideRight"/>

<bind joystick="0" digital-hatswitch="2" direction="left" command="Cockpit::SwitchLVDU"/>
<bind joystick="0" digital-hatswitch="2" direction="right" command="Cockpit::SwitchRVDU"/>
<!-- Hatswitches:END -->
<!-- Logitech Wingman Interceptor:END -->
pontiac
Elite
Elite
Posts: 1454
Joined: Sun Jan 12, 2003 6:24 pm
Location: Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy
Contact:

Post by pontiac »

Ok, small update on this topic.

I recently tried to undust my joystick and was buffled why my config doesn't work anymore.
The config-setting for the analog hatswitches doesn't seem to work anymore (worked under windows back in those dark times).

When i define the buttons for the hatswitch they overwrite the normal buttons (0,1,2,etc..)
http://vegastrike.sourceforge.net/wiki/ ... FHATSWITCH
Is this my fault, or has something changed over time ?

Here's the config i currently use (just ignore the "<hatswitch value="xxx"/>" entries, they do not reflect reality yet)

Code: Select all

<!-- #joy_ffp -->
<bind joystick="0" button="0" player="0" modifier="none" command="FireKey" /> 
<bind joystick="0" button="1" modifier="none" command="MissileKey" />
<bind joystick="0" button="2" modifier="none" command="TargetKey" /> 
<bind joystick="0" button="3" modifier="none" command="PickTargetKey" /> 
<bind joystick="0" button="4" modifier="none" command="ABKey" />  
<bind joystick="0" button="5" modifier="none" command="MisSelKey" /> 
<bind joystick="0" button="6" modifier="none" command="WeapSelKey" />
<bind joystick="0" button="7" modifier="none" command="ToggleWarpDrive" />   
<bind joystick="0" button="8" modifier="none" command="SheltonKey" />  
<bind joystick="0" button="9" modifier="none" command="DecelKey" /> 

<axis joystick="0" axis="0" name="x" inverse="false" />
<axis joystick="0" axis="1" name="y" inverse="false" />
<axis joystick="0" axis="2" name="z" inverse="true" />  

<axis name="throttle" joystick="0" axis="3"/>

<axis joystick="0" axis="4" name="hatswitch" nr="0" margin="0.25" inverse="false">
  <hatswitch value="-0.75"/>
  <hatswitch value="0.75"/>
</axis>
<axis joystick="0" axis="5" name="hatswitch" nr="1" margin="0.25"  inverse="false">
  <hatswitch value="-1.0"/>
  <hatswitch value="1.0"/>
</axis>

<bind hatswitch="0" button="0" modifier="none" command="Cockpit::InsideLeft" />
<bind hatswitch="0" button="1" modifier="none" command="Cockpit::InsideRight" />
<bind hatswitch="1" button="0" modifier="none" command="Cockpit::Inside" />
<bind hatswitch="1" button="1" modifier="none" command="Cockpit::InsideBack" />

<!-- #end -->
Pontiac
Post Reply