Board index FlightGear Support Hardware

Just a comment

Joysticks, pedals, monitors.

Re: Just a comment

Postby macnab » Sun Jul 14, 2013 4:17 am

@Philosopher We are going to keep our files at Git:fgjoystickgui. I'll need to add you as a contributer.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby macnab » Sun Jul 14, 2013 5:41 am

Do you think we should put continuous flaps on a lever as Basic or Advanced?
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Hooray » Sun Jul 14, 2013 9:35 am

from an integration/deployment standpoint it may be easier to consider the whole folder a Nasal submodule for the time being, so that it can be easily tested by putting stuff into $FG_ROOT/Nasal/joystickGUI - we only need to register a listener to /nasal/joystickGUI/loaded to delay any calls ...
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Just a comment

Postby macnab » Tue Jul 16, 2013 7:03 am

Just pushed joylib.nas v1.0.0. Need comments/suggestions/etc. It needs a bit of help - listener to init it, things like that.

The txt file is the start of the readme. It currently has a lot of comments "Philosopher:". These will be removed later.

@Philsopher Got your Git logon yet?
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Hooray » Tue Jul 16, 2013 10:50 am

listener to init: see wiki sub module docs: http://wiki.flightgear.org/Creating_new ... ub_modules
So, it's just "module name" - which boils down to FOLDER name of the Nasal sub directory
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Just a comment

Postby macnab » Tue Jul 16, 2013 11:33 am

Even when finished and implemented fully, there is no harm in having the files in nasal/sub-folder so that the joystick configurator is only loaded on demand. joystick_configure seems like a good choice to me. I will use that name in the meantime. Easy enough to change.

EDIT: Using this folder name, the functions to be called by the joystick xml file world then be joystick_configure.gearDown(), etc? If this is true, maybe joylib is a better choice. We will also have to watch for name conflicts between the 2 files, although it is unlikely.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Hooray » Tue Jul 16, 2013 12:00 pm

yeah, please make it short and intuitive, or we'll have to use Philosopher's namespace browser to actually find the correct namespace... :lol:
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Just a comment

Postby Philosopher » Tue Jul 16, 2013 2:56 pm

Three comments on property tree/Nasal use:

1. I would prefer that instead of busyTapHoldVS, et al. being in the property tree, you instead put them in Nasal, and I would actual use systime() for this. First of all, make a class for this (there's no need to have long, ackward symbols running around) and then make a "last used" member like so (it's basically the same concept as you had earlier, just managed through systime instead of settimer):
Code: Select all
# General base class to take care of the systime() aspects:
var TimedControl = {
    last_busy: 0, # systime of last use
    timeout_dur: 1.0, # time before action is taken again or nil for never
    new: func() {
        return { parents:[me] };
    },
    stop: func() me.last_busy = 0,
    _call: func(fn, arg...) {
        if (me.timeout_dir == nil and me.last_busy != 0) return;
        var time = systime();
        if (time < me.timeour_dir + me.last_busy) return;
        me.last_busy = time;
        return call(fn, arg, me);
    },
};

# Specific class:
var ADF1Freq = TimedControl.new();
# Settings:
ADF1Freq.timeout_dir = 1.0;
# Public function: interface to me._adj making sure
ADF1Freq.adj = func(dir, big) me._call(me._adj, dir, big);
# Private function: does the work if timeout is reached
ADF1Freq._adj = func(dir, big) {
      if (!dir) { me.stop(); return }
      step = 1 * dir;
      if (math.abs(dir) == 1) step = step * 10;
      if (math.abs(dir) == 2) step = step * 100;
      curr = getprop("/instrumentation/adf/frequencies/standby-khz");
      setprop("/instrumentation/adf/frequencies/standby-khz", curr + step);
      curr = getprop("/instrumentation/adf/frequencies/standby-khz");
      if (curr > 1799) {
        curr = 200;
        setprop("/instrumentation/adf/frequencies/standby-khz", curr)
      }
      if (curr < 200) {
        curr = 1799;
        setprop("/instrumentation/adf/frequencies/standby-khz", curr)
      }
      if (enablePopUps) gui.popupTip(sprintf("ADF1 %d",curr));
}


2. Properties set per-joystick will belong in /input/joysticks/js nodes – I'm especially thinking of popupTip preferences (since you might want it for one device and not another). I think the best way would be to use cmdarg() and then .getParent() until .getName() == "js", then .getNode("enable-popups").getValue() or such.
3. Other properties, those that are more global (i.e. a "using the dialog" level, not "using the joystick"), should go in /sim/gui/dialogs/joystick-config/ (which is where they currently are with Stuart's work). Specifically these lines:
Code: Select all
# NB NB NB NB Need a listener to call initJoyLib, but don'y know which
setlistener("/sim/gui/dialogs/joystick-config/init-joy-lib", func(n) if (n.getValue()) initJoyLib());


Thank you for you work, macnab! I see that you noticed the need for a "gear toggle" function like I did :lol:
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Just a comment

Postby macnab » Tue Jul 16, 2013 4:35 pm

Firstly, Part 3). The settimer would suggest that the library only gets an init if the GUI is opened. But the library should be loaded if the user has a "configured" joystick. Which means that:
1) It should be in ..../Nasal, or
2) It can be in a sub-folder, and something detects a "configured" joystick, loads the module and sets the listener flag

Next - isn't there a typo here, ignoring the flag
Code: Select all
setlistener("/sim/gui/dialogs/joystick-config/init-joy-lib", func(n) if (n.getValue()) initJoyLib());


EDIT EDIT: The following is nonsense. (TimedControl prevents the function from being run.)
Part1) The timer calls the function every timeout_dir seconds, until mod-up passes 0 as the value. But what about the system repeat rate for repeatable buttons? Or will all buttons be non-repeatable? In which case the flag to prevent non-repeatable functions is redundant?

EDIT: Wouldn't it be nice if we could sit in a conference room and brainstorm these issues?

EDIT EDIT:
Personally I think that joylib should be in /Nasal, and that init should be called when nasal loading is complete. Init will only create and setup the TimedControls.

Having joylib always loaded will slow down startup time, unless we can find a way of detecting "configured" joysticks.

On the other hand, seeing as there are a number of functions which don't exist in controls.nas, if joylib is always loaded, then users who write their own joystick xml files can use these functions, without using the configure GUI. And then those users can ask for functions to be added. (This will mean the GUI will have to be updated. :D )
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Philosopher » Tue Jul 16, 2013 7:03 pm

Yeah, that wasn't thought out very well on my part: having it in Nasal/ and having the listener on "/sim/signals/nasal-dir-loaded" or in a sub module joylib (dunno, maybe a better name) and listener on "/sim/nasal/joylib/loaded" would be best.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Just a comment

Postby macnab » Wed Jul 17, 2013 7:01 am

OK. Changed everything. It loads when placed in /Nasal. Even sorted out the listeners for init and reinit.

Testing complains about this line
Code: Select all
return call(fn, arg, me);
missing argument, called from
Code: Select all
HdgBug.adj = func(dir) me._call(me._adj, dir);

I suspect it should be
Code: Select all
return call(fn, arg);
There doesn't seem to be a need to pass me, we already have the correct fn and only need to pass the original parameter of the call (arg).

EDIT: Fixed. It should be
Code: Select all
return call(fn, [arg], me);

The Stop is not needed, but does no harm.

Have just added Reverse Thrust, Trigger One Shot and Trigger Continuous. Will wait for more comments/ideas/suggestions before doing another commit.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Philosopher » Thu Jul 18, 2013 12:32 am

It shouldn't be [arg], because the ellipsis after the arg (...) guarantees that it is a vector and so you shouldn't need to vectorize it.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Just a comment

Postby macnab » Thu Jul 18, 2013 3:31 am

Plausable.org says it must be.
Code: Select all
call(fn, args=[], me=nil, namespace=nil, error=nil)
And it doesn't work without it. Says it's bad/missing.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Philosopher » Thu Jul 18, 2013 3:35 am

Can you post your code? I'm not sure if you wrote it down correctly -- specifically the function argument definitions, which should read:
Code: Select all
_call: func(fn, arg...)
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Just a comment

Postby macnab » Thu Jul 18, 2013 4:39 am

To remove all those busy variables I am going to do the non-repeatables as timedControls as well.

Then, to really plan for the future I want to use a function to create them and store them in an array, for easy removal on re-init. If only I can find the article that described how to do. Would have put it in my favourites, but with latest version of Firefox favourites no longer work.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 8:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

PreviousNext

Return to Hardware

Who is online

Users browsing this forum: No registered users and 2 guests