Board index FlightGear Support Hardware

Just a comment

Joysticks, pedals, monitors.

Re: Just a comment

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

@Philosopher I only pass one variable, so I changed arg... to arg. Changed it back, and changed back to
Code: Select all
return call(fn, arg, me);
and it works that way.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby macnab » Fri Jul 19, 2013 6:36 am

Progress report:

Everything to go through the library. Never know when that might be useful in the future.
Where possible, passed straight to controls.nas and gui.nas.
All buttons are repeatable.
All buttons pass value 0 for mod-up.
Where applicable, +ve and -ve used for direction.
Some controls use 1, 2 and 3 for speed.
Where repeat-rate is best at system rate, they are passed on as is.
Where repeat-rate is best controlled, they use timedControl.
Non-repeatable buttons use timedControl to force them to be one-shot. The timeout_dur is set to -1.
I am adding lots of stuff that doesn't already exist.
There is a vector to store all the timedControl functions. Might be useful.
There will now be very few variables.

@Philosopher:
All timedControls declared at the top of the file, together with the parameters, if not standard.
Comment list of all axes at the top of the file.
Comment list of all non timedControls at the top of the file.
So, no need to go scrolling through the file to find which functions exist.
Joystick Library.txt is the beginnings of the readme file. It makes suggestions for the dropdown list for functions. You are welcome to make changes.

timedControl:
To make sure of non-repeatable actions, and to handle the TapHold functions, it now looks like this.
Code: Select all
var timedControl = {
      last_busy: 0, # systime of last use
      timeout_dur: 1.0, # time before action is taken again, 
                        # nil or -1 for never (one-shot)
      tap: 0,  # for TapHold functions
      new: func() {
          return { parents:[me] };
      },
      stop: func() { me.last_busy = 0; tap = 0 },
      _call: func(fn, arg...) {
        if ((me.timeout_dur == nil or me.timeout_dur == -1) and
                  me.last_busy != 0) return;
        if (tap) return;
        var time = systime();
        if (time < me.timeout_dur + me.last_busy) return;
        me.last_busy = time;
        return call(fn, arg, me);
      }
};


createTimedControl looks like this:
Code: Select all
var arrayTimedControls = [];

var createTimedControl = func(timeout) {
        var name = timedControl.new();
        name.timeout_dur = timeout;
        name.tap = 0;
        append(arrayTimedControls, name);
        return name;
}


Controlled repeatable button example
Code: Select all
# 1 decimals, 2 units, 3 tens
var NAV1Freq = createTimedControl(radioButtonRate);


Non-repeatable button example
Code: Select all
var flapsDown = createTimedControl(-1);


This is going to take me a few hours to complete.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby macnab » Fri Jul 19, 2013 3:16 pm

We still don't have a way/folder where views can be saved, do we? And if we do, where? (Has to be read/write of course.)

Currently have just over 60 functions, and I still need to do
  • Look Up/Down/Left/Right/Reset Front
  • Zoom
  • Slider Move Head Position/Zoom
  • Button Move Head Position
  • Screenshot
  • Map Open/Close
Won't be long until XPlane are burning with jealousy and burning the midnight oil to catch up. :D

Can someone tell me how to provide the link to a specific post, not just a thread.
And what does the List= button do?
And code2=?
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Hooray » Fri Jul 19, 2013 5:15 pm

I think you could save custom views in $FG_HOME, I am just not sure how "smart" the C++ system is to support custom, runtime views, in non-default locations, need to check ...

To get the link to a certain posting, you can click the posting's title, i.e. copy/paste URL - or what I tend to do, is simply click on the PM button next to the posting, which will give me the URL, including the title of the posting/thread and then just paste that into your posting (ya, I'm that lazy ...)

Regarding the list/code phpBB tags, I never used those either, but I just played around with it, seems that you can assign numbers/letters for your list:

Code: Select all
[list=a]
[*] Hello
[*] Macnab
[/list]



[list=a]
[*] Hello
[*] Macnab[/list]

[code]
[list=1]
[*] Hello
[*] Macnab
[/list]



  1. Hello
  2. Macnab

Equally for code2:
Code (Macnab's code): Select all
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: 12267
Joined: Tue Mar 25, 2008 8:40 am

Re: Just a comment

Postby macnab » Sat Jul 20, 2013 5:19 am

@Philosopher

This wiki refers http://wiki.flightgear.org/AV8R_2nd_Throttle_as_pan_speed_control

This, as written, refers specifically to the AV8R. It could be possible to use it with other joysticks, where a spare axis is available. Do you think that the following is feasible with the new GUI:
  • Select a button.
  • Select which view function applies. (All standard, so far.)
  • Select which axis to use.
  • Pass the axis number as one of the parameters.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby macnab » Mon Jul 22, 2013 8:50 am

I have committed the latest version of the library. "For checking/approval."

I have written a wiki about timedControl [url][url]http://wiki.flightgear.org/Accurate_control_of_button_repeat_rate[/url].[/url]

Before I go any further (or no further :) ) I have sent Stuart a PM asking him to have a look at the library, to see if he would be prepared to commit it, the way things have been done.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby sim » Wed Jul 24, 2013 3:01 pm

Did you mean? :wink:

I have written a wiki about timedControl http://wiki.flightgear.org/Accurate_control_of_button_repeat_rate
User avatar
sim
 
Posts: 1431
Joined: Tue Jun 30, 2009 2:13 pm
Location: Shropshire England
Callsign: Fly4Fun
Version: 0.9.10 up
OS: 64 Win 10 HD6450

Re: Just a comment

Postby macnab » Wed Jul 24, 2013 3:13 pm

So much for Preview to check that all is OK. :oops:
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby stuart » Wed Jul 24, 2013 9:05 pm

Hi Guys,

I've had a look at the code, and have a couple of immediate thoughts.

At a high level, it seems wrong that you are having to work around what is basically a limitation in the binding C code. I wonder whether it would be better to change the binding code to allow individual bindings to repeat, which would avoid the need for the timer Nasal code. At the same time it might be worth adding support for <condition> blocks as well. The input binding code is pretty straightforward, and at first glance both of these things look straightforward. I'd be happy to review a patch to that code, or may take a look myself when I have time. BTW - this would make a great introductory project for someone wanting to get into the C-coding side of things :).

Second comment is that I think you should be able to set up the timers (if required) and also assign the bindings within a single constructor, rather than assigning them separately later. I think that would make the code cleaner.

-Stuart
G-MWLX
User avatar
stuart
Moderator
 
Posts: 1591
Joined: Wed Nov 29, 2006 9:56 am
Location: Edinburgh
Callsign: G-MWLX

Re: Just a comment

Postby Hooray » Wed Jul 24, 2013 9:07 pm

it seems wrong that you are having to work around what is basically a limitation in the binding C code. I wonder whether it would be better to change the binding code to allow individual bindings to repeat, which would avoid the need for the timer Nasal code.

hilarious, that's what they've been talking about all the time (like for 12 months): getting the core changed to support a repeatable flag - nobody would respond, which is why they came up with this neat hack :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: 12267
Joined: Tue Mar 25, 2008 8:40 am

Re: Just a comment

Postby macnab » Thu Jul 25, 2013 3:13 am

Second comment is that I think you should be able to set up the timers (if required) and also assign the bindings within a single constructor

timedControl was "invented" originally for precise control of certain properties, such as the radio frequencies. The one-shot capability derived from that later. I can modify createTimedControl to handle the creation of the entire function. Shouldn't be too much of a problem.

it seems wrong that you are having to work around what is basically a limitation in the binding C code

If you are going to do this, I will make a copy of the nas file, where the buttons send a repeat this or don't repeat this flag, whether through fgcommand or whatever. But that does require the use of cmdarg() and 4 or 5 lines of code to get the joystick number and the button number, and then these have to be passed with the flag. Everytime the button is pressed.

It seems to me that the approaches are six of one, half a dozen of the other. Passing a flag seems the correct way, using timedControl seems the logical way.

EDIT:
At the same time it might be worth adding support for <condition> blocks as well.

I'm not sure I know what you mean.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Philosopher » Thu Jul 25, 2013 3:22 am

Actually macnab, I would prefer to handle this at a higher level: register a listener on the modifier flag and change the repeatability of buttons as a result of that (this would be at more of the joystick configuration level). Basically I would have button/mod[n]/repeatable flags and those would get copied to button/repeatable as the modifier changes.

@Stuart:
Re: Comment 1: I could take a look at it and get something going, but be warned that I can't test it and all of my (2) patches have been tweaked after submission ;).
Re: Comment 2: Yeah, that is partly my fault, I was looking for a way to get sensible names for the .method() (instead of a .call, say a .adj if that makes sense, or a .toggle()...), but I could make it just a function instead of an object and thus be directly executable.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1588
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Just a comment

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

@Stuart/Philosopher. I'll wait until the 2 of you sort out how/where what will happen, and then make joylib.nas work with that approach.

EDIT:
I see a few approaches, all with pros and cons:
  1. Keep joylib as is, except for the create.. function adding the .do entry
    • This makes xml files easy, especially for someone who wants to modify the xml file a bit.
    • Gets round the repeatable problem "behind the scenes"
  2. Change the C code to handle dynamic repeatable switching and do it from joylib
    • Seems a logical approach
    • Legacy xml files won't be able to take advantage of it unless they change the code to call joylib
    • Gets rid of the repeatable problem behind the scenes
  3. Modify the C code to handle dynamic repeatable switching and do it from the xml file
    • The most logical approach
    • Will make the xml file very complicated, especially for basic users to modify. Once again this forum will be inundated with requests for help, all telling them to paste such-and-such a block of code at the top of the xml file, and then complicated code for the actual button.
    • This is the only approach that really allows a user to write his own little routines in the xml file. The others require modifying joylib, or asking for it to be modified and waiting.

I'm sure there are many other pros and cons that can be added.
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby macnab » Thu Jul 25, 2013 3:34 pm

@ Philosopher. Just did a quick test of joystick.nas. Don't know if this is a valid criticism or not (don't know what you've fully implemented). With both my Saitek Rudder Pedals and my Saitek Yoke it only sees one axis each (axes 0). No buttons.

var MAX_AXES = 8;
var MAX_BUTTONS = 24;
var MAX_NASALS = 8;


With a Saitek Yoke (which comes with a throttle quadrant) and Saitek Rudder pedals I have 8 axes. (Assuming you count the hat switch as buttons.) Another quadrant and...

Counting the hat switch as 4 buttons, I have 21 buttons. Another quadrant and I have 30!.

I have no conception of MAX_NASALS.

EDIT: Just used my brains and checked the error messages.
On opening Joystick Configuration it says no such member: getName at __dlg:joystick-config, line 70.
Does the same when I switch between Yoke and pedals.

EDIT EDIT: Maybe you've change joystick-config.xml and need to push it?
macnab
 
Posts: 885
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Just a comment

Postby Philosopher » Thu Jul 25, 2013 3:49 pm

Those were Stuart's values, and here's the equivalent in the C++ source: https://gitorious.org/fg/flightgear/blo ... hxx#line48. Also, the hat usually shows up as two axes (unless yours is different than most). MAX_NASALS is just to limit the number of <nasal><script>s at the top (I lost track of what it was related to, but it's arbitrary and rather huge ;)).

As for the error: this doesn't use the old PUI dialog, add this to gui/dialogs/menubar.xml:
Code: Select all
      <item>
         <name>joystick-config</name>
         <binding>
            <!--
            <command>dialog-show</command>
            <dialog-name>joystick-config</dialog-name>
            -->
            <command>nasal</command>
            <script>joystick.Main_Window.open()</script>
         </binding>
      </item>

EDIT: thanks goodness for the topic review/discussion summary window!
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1588
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

PreviousNext

Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests