Board index FlightGear Support Hardware

FAQs: customizing joystick controls; XP/Vista joystick issue

Joysticks, pedals, monitors.

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby aok1 » Mon Jun 15, 2009 3:04 pm

If I may chime in:
Code: Select all
var rp = getprop("/controls/flight/rudder");
    if (rp > 0)
      {
        setprop("/controls/gear/brake-left",1-rp);
        setprop("/controls/gear/brake-right",1)
      }
    else
      {
        setprop("/controls/gear/brake-left",1);
        setprop("/controls/gear/brake-right",1+rp)
      }


AFAIK, this is static, eg. it reads the rudder position at start and keeps that value. I found there is another, dynamic, function available.

I am using this:
Code: Select all
setprop("/controls/gear/brake-steering", 1);
   aircraft.steering.init("/controls/gear/steering", 0.2);
   aircraft.steering.init();

and in mod-up:
Code: Select all
setprop("/controls/gear/brake-steering", 0);


Have fun!
Watch my videos and look at screenhots if you're into that sort of thing :)
aok1
 
Posts: 105
Joined: Sun Apr 19, 2009 10:02 pm

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby NicQ » Mon Jun 15, 2009 3:45 pm

aok1 wrote:Hi,
I want to have these buttons available for other controls when I fly a jet, since they are useless then. I am looking for what to check in the property tree -other than the plane itself- to find out if prop or jet. Any suggestions?
Thanks.


viewtopic.php?f=2&t=3117&p=27406

Or did you already look at that thread ? Hmmm, you probably did.

You know, maybe we should all add a simple property to (our) all aircraft that states its propulsion type : it can be added to the <sim> part of the set file, and then checked for :)

That would serve the purpose of choosing the coarse joystick config
Then, if you want a specific config for a specific plane or group of planes (ex. all DCulp's planes), you can then have configs which hinge on the aircraft model, just like radar2 instrument (actually, in radardist.nas) does for radar range and RCS (radar cross section, not reaction control system ;))

Also, iirc, one can re-bind your joystick partly, or entirely, inside the a/c setfile (eg. having your custom version of the setfile, with adds bindings for your joystick), just like we do for keyboard bindings inside an a/c set file, if it's your private version of the set file, a simple copy of the original with your specific bindings in it.
Joystick bindings are discouraged in a/c set files because of the vastly different layout of joysticks (or same joystick on different OSes), but nothing is stopping you from doing it in your installed version of the a/c.
Just be careful when you update it not to annihilate your changes, and if you're the a/c author, not to distribute that version of the set file so you don't get a ton of help requests because well, the joystick now does weird things on someone's else setup :)

You can also go look in other parts of the property tree, like engines, but not sure how reliable testing for /engines/engine[n]/EGT == nil would be in telling you this is NOT a prop plane.
Albeit, I've noticed while working on the NF-104, that a jet engine and rocket engine don't have the same property layout inside /engines/*, in that the latter has a much smaller set of properties.

That sort of thing.
IMHO, for broad joystick configs, starting to use a type tag would be the simplest, and needs no mods to the sourcecode, or make assumptions about properties that might change in the future, etc.

<type> could be simple as prop, jet, rotor and rocket, or take into account number of engines, specific subtypes (turbo or not, jet or fan, one or more engines, etc.)

For aircraft specific, well, you're going to look for a specific a/c most likely :)
Cheers,
Nic
If it ain't broke, break it. How else are you going to figure out how it works ?
Callsign: C-NICQ, amateur FGFS military and aerobatic test pilot, pushing the envelope since 2009 (sic)

FGFS Gallery
Birds Of Gear, a blog
NicQ's Workshop
NicQ
 
Posts: 429
Joined: Wed Jan 21, 2009 9:30 pm
Location: Montreal, Qc, Canada

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby aok1 » Tue Jun 16, 2009 10:52 pm

Hey NicQ,

maybe we should all add a simple property to (our) all aircraft that states its propulsion type

I started doing that for the planes I fly. I add either prop|jet|vtol to sim/ and read that out in my joystick config. The idea behind this was more or less like yours, but I ended up freeing extra buttons (prop/mixture) that I can't use for things I'd imagined them for because they are repeatable. The idea would work with multiple joystick files, but that could only work if the joystick is initialized after the aircraft. I have no way of knowing if that is the case. Maybe someone does?

Considering control of other things and the variety of commands they take, is something else. Take airbrakes, take radar. I managed to get airbrakes for most jets working on the same buttons (some use steps, other toggle), but it starts to look like an epic poem. This should not be necessary.

I've read a lot of nasal scripts, esp. controls, and I think it can provide what I think would be great: master commands for all functions: use it if it works your plane, override it in your own nasal if your plane has a different way of handling that, so that the user can use the same command, which will work, just like the keyboard-button you've assigned to that function.

I don't think the joystick bindings should be in a/c set files. What I do want is a nasal command per function that works for any/all/mostly all aircraft that I can put in my joystick-config. But for that to work it seems like there is some coordination to be done.

In the mean time, for a non-coder like myself, it is a challenge to make it all work. And yes, I do like these challenges :) The amount of time I put into Flightgear without even flying is something that took me by surprise. I did learn a lot though. The trouble with these type of things is that the examples given usually only become clear once you've understood them.

At the moment my joystick (3d extreme pro) does pretty much what I want. I have only radar-controls for f16, but I am confident I can make the others work too.

Thanks for your insights.
Watch my videos and look at screenhots if you're into that sort of thing :)
aok1
 
Posts: 105
Joined: Sun Apr 19, 2009 10:02 pm

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby MD-Terp » Sat Jun 20, 2009 7:48 pm

aok1 wrote:If I may chime in:
Code: Select all
var rp = getprop("/controls/flight/rudder");
    if (rp > 0)
      {
        setprop("/controls/gear/brake-left",1-rp);
        setprop("/controls/gear/brake-right",1)
      }
    else
      {
        setprop("/controls/gear/brake-left",1);
        setprop("/controls/gear/brake-right",1+rp)
      }


AFAIK, this is static, eg. it reads the rudder position at start and keeps that value. I found there is another, dynamic, function available.

Well, I'm not 100% clear on the difference (I am back in school for software development now, but we're still doing trivial BS like decision structures, etc.; haven't touched anything Object-Oriented yet!) but if you mean it only occurs once per button-press, that's not true. If you hold the button, and twist the rudder axis, the braking will follow the movement. Now, I guess dynamic means that the link between the values is established once (via pointers or some such), whereas what I've done above requires the code to keep cycling to update the brake values. If that's what you're getting at, then yes, it shows my more primitive programming knowledge. But it does work :)

aok1 wrote:I am using this:
Code: Select all
setprop("/controls/gear/brake-steering", 1);
   aircraft.steering.init("/controls/gear/steering", 0.2);
   aircraft.steering.init();

and in mod-up:
Code: Select all
setprop("/controls/gear/brake-steering", 0);

Ah! Well, I also was not aware of the property "/controls/gear/brake-steering". I may mess around with this approach if I get some free time one day. Thanks for sharing that.
Cheers,
-Rob.

"Retired" from FlightGear involvement as of July 2010.
viewtopic.php?f=3&t=8809
User avatar
MD-Terp
 
Posts: 2420
Joined: Wed Jan 23, 2008 6:37 am
Location: Baltimore, Maryland, USA
Callsign: N531MD, AVA0025

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby aok1 » Thu Jun 25, 2009 10:43 am

Hi,

My main computer is down at the moment (raid/lvm problems that go over my head), which also means I have no access to my FG installation to check things.

but if you mean it only occurs once per button-press, that's not true

Yes, that is what I meant, and I really did mean AFAIK. I came to that conclusion after some testing and looking at the property tree to see what happened with that function. I experienced/perceived some problems with it, and went looking for another solution when I found the brake-steering function.

If you say the value rp does update while braking and steering, I will take your word for it -I have no experience in coding except some rudimentary bash scripting and now a slight understanding of nasal. I am still very dependent on examples/recipes and trial and error. Possibly I know just enough to be dangerous. :lol:

I will definitely have another look at it when I have fixed my other computer.
Watch my videos and look at screenhots if you're into that sort of thing :)
aok1
 
Posts: 105
Joined: Sun Apr 19, 2009 10:02 pm

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby sim » Thu Jul 02, 2009 7:13 pm

sim Shropshire, England 19:55 2 Jul 2009
To MD-terp Baltimore USA
Useful tips in your article and you understand FGear stuff that baffles me. I mess about with joystick xml's with
scant knowledge but generally persevere until it works on my FlightGear setup on windows vista. Would you be kind enough to have a look at my posting on the forum (General) to see if you can find a magic script formula?

All the best for 4th July, Cheers, sim
User avatar
sim
 
Posts: 1388
Joined: Tue Jun 30, 2009 2:13 pm
Location: Shropshire England
Callsign: Fly4Fun
Version: 0.9.10 up
OS: 64 Win 10 HD6450

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby sim » Thu Jul 02, 2009 9:12 pm

Contrary to this posting's named contributor it is not "sim" at all. The Re: FAQs:customizing joystick controls; XP/Vista author is "MD-terp" from Baltimore USA. Quite how I messed up is beyond me. Please MD-terp accept this was not done intentionally. Sorry I dare not attempt to make corrections in case I do further damage to any other contributor. I do not know how to re-instate MD-terp as the true author. So anybody posting further replies please address them to MD-terp!
This is a blue on blue shoot-up and probably I deserve to be shot!
My apologies to MD-terp, sim
User avatar
sim
 
Posts: 1388
Joined: Tue Jun 30, 2009 2:13 pm
Location: Shropshire England
Callsign: Fly4Fun
Version: 0.9.10 up
OS: 64 Win 10 HD6450

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby MD-Terp » Fri Jul 03, 2009 5:20 am

Hi sim,

Welcome to the forum. Calm down. You didn't break anything. In fact I'm not quite sure what you feel you changed by accident. On the list of topics, over to the left is listed the topic's original author, while over to the right is listed the name of the last person to add a post to that topic. As far as I can tell, I'm still credited with original authorship of this post...??

Thanks for the kind words -- I actually have a pretty rudimentary understanding of programming compared to the core developers here. I'm still learning to do a lot of the object-oriented code-writing that comprise the most critical pieces of the software -- but some simple scripting here and there, like what's necessary for joystick configurations, is more my speed; and I've happily assumed (UNOFFICIALLY, of course) a role as one of the the seeming "go-to guys" for joystick XML.

If I can track down the post you are referring to, I'll be sure to peek and comment! From what little I've seen, you seem pretty bold about trying things out yourself, which is a great way to learn. There's nothing you can do that can't be undone (though worst-case scenario might involve a little work in un-doing, LOL).

Again, welcome to FG and the forum!
Cheers,
-Rob.

"Retired" from FlightGear involvement as of July 2010.
viewtopic.php?f=3&t=8809
User avatar
MD-Terp
 
Posts: 2420
Joined: Wed Jan 23, 2008 6:37 am
Location: Baltimore, Maryland, USA
Callsign: N531MD, AVA0025

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby flameout » Fri Jul 03, 2009 8:07 am

For my joysticks (a Logitech Extreme 3D and a Wingman Force 3D,) I set it up where the Extreme runs the ailerons (zero deadband, XML,) elevator (again, zero deadband, XML,) and rudder (a custom nasal script to change the deadband when there's weight on the wheels.) On the Force 3D, I have the twist axis control view direction with a deadband of 0.3, so it isn't twitchy. I have kept the hat switch working, also (I didn't like it when I disabled it, so I uncommented it. Use comments to remove stuff -- you can fix it much easier if you don't delete anything.) I also have a gear toggle switch (I think I found that here on the forums.)

I am planning to copy my files from Windoze to Ubuntu to get my new CVS install working. I will have to do some editing (ex. throttle on the Force 3D is switched,) and then I will be ready to fly again.

There's nothing you can do that can't be undone

I think I'll add that to my signature, but I'll add after it "MD-Terp, referring to FlightGear contribution" or something like that. Outside of FlightGear, unfortunately, that's all too incorrect...

Hope you have a good time and learn a lot here, sim.
Also known as Johnathan Van Why.
flameout
 
Posts: 443
Joined: Thu Dec 25, 2008 5:43 am
Location: Oregon, USA
Callsign: MSJF
Version: GIT
OS: Gentoo

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby MD-Terp » Fri Jul 03, 2009 11:23 am

I wrote:There's nothing you can do that can't be undone

flameout wrote:I think I'll add that to my signature, but I'll add after it "MD-Terp, referring to FlightGear contribution" or something like that. Outside of FlightGear, unfortunately, that's all too incorrect...

Ah, how flattering! Well, it should apply to most things one can do with a PC, limiting to that which includes typical proscribed use of standard I/O devices (i.e. not hammers or blowtorches, etcetera). Perhaps it should say:
On a PC, there's little you can do that can't be undone.
Cheers,
-Rob.

"Retired" from FlightGear involvement as of July 2010.
viewtopic.php?f=3&t=8809
User avatar
MD-Terp
 
Posts: 2420
Joined: Wed Jan 23, 2008 6:37 am
Location: Baltimore, Maryland, USA
Callsign: N531MD, AVA0025

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby aok1 » Thu Jul 09, 2009 8:01 pm

MD-Terp/Rob,

My pc is back up and I have looked at it again (you got me wondering about my original assumption).

but if you mean it only occurs once per button-press, that's not true. If you hold the button, and twist the rudder axis, the braking will follow the movement.


This I do not see happening. rp(rudder) is read at the moment of buttonpress and does not change unless the button is released and pressed again.
Anyway, I don't mean to criticize. The brake-steering just seems to do exactly what you want for coordinated braking/steering on the ground.

For easy copy/paste:
Code: Select all
<button n="0">
<name>Trigger</name>
<desc>Brakes on ground, Trigger in air</desc>
   <binding>
   <command>nasal</command>
      <script>
      var wow = getprop("/gear/gear[1]/wow") or getprop("/gear/gear[2]/wow");
         if (wow) { <!-- on the ground -->
            setprop("/controls/gear/brake-steering", 1);
            aircraft.steering.init("/controls/gear/steering", 0.2);
            aircraft.steering.init();
         } else {<!-- in the air -->   
            controls.trigger(trigger = 1);
         }
      </script>
   </binding>
<mod-up>
   <binding>
   <command>nasal</command>
      <script>
      if (wow) {
         setprop("/controls/gear/brake-steering", 0);
      } else {
         controls.trigger(trigger = 0);
      }
      </script>   
   </binding>   
</mod-up>
</button>
Watch my videos and look at screenhots if you're into that sort of thing :)
aok1
 
Posts: 105
Joined: Sun Apr 19, 2009 10:02 pm

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby MD-Terp » Fri Jul 10, 2009 7:21 am

I wrote:but if you mean it only occurs once per button-press, that's not true. If you hold the button, and twist the rudder axis, the braking will follow the movement.

aok1 wrote:This I do not see happening. rp(rudder) is read at the moment of buttonpress and does not change unless the button is released and pressed again.

Hmm. I don't dispute that this is what you are experiencing, but obviously something is different, such as perhaps an errant or missing set of <repeatable>true</repeatable> tags or something like that. Because on my end, as I sit parked and hold the brake button in and twist the rudder, I can see the values of brake-left mimic the rudder when left of center, and brake-right when right of center. Not sure why you don't see the same, but glad you found a solution that works, regardless!
Cheers,
-Rob.

"Retired" from FlightGear involvement as of July 2010.
viewtopic.php?f=3&t=8809
User avatar
MD-Terp
 
Posts: 2420
Joined: Wed Jan 23, 2008 6:37 am
Location: Baltimore, Maryland, USA
Callsign: N531MD, AVA0025

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby aok1 » Fri Jul 10, 2009 5:25 pm

or missing set of <repeatable>true</repeatable> tags


Ah, that is it! I put that code under the trigger, which is non-repeatable. Never thought about that. Thanks!
Watch my videos and look at screenhots if you're into that sort of thing :)
aok1
 
Posts: 105
Joined: Sun Apr 19, 2009 10:02 pm

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby comet4 » Wed Jul 15, 2009 4:29 pm

Hi Jester

I've just read this thread
Is your Vista proof file still available? - I'd like to try it

Cheers
comet4
 
Posts: 3
Joined: Mon Jul 13, 2009 4:49 pm

Re: FAQs: customizing joystick controls; XP/Vista joystick issue

Postby fredb » Wed Feb 17, 2010 8:41 pm

The joystick detection code is supposed to work again in version 2.0.0 for windows. js_demo is also back in the package.
No <name>Microsoft PC-Joystick Driver</name> needed anymore except in the default configuration file.
User avatar
fredb
 
Posts: 756
Joined: Fri Dec 01, 2006 10:41 am
Location: Paris, France

PreviousNext

Return to Hardware

Who is online

Users browsing this forum: BEL ISAAK and 3 guests