Board index FlightGear Support Hardware

Just a comment

Joysticks, pedals, monitors.

Re: Just a comment

Postby TheTom » Wed Jul 10, 2013 8:46 am

Before creating new widgets please have a look at my fgdata branch: http://gitorious.org/~tomprogs/fg/toms- ... s-gui-demo I'm currently working on creating a standard widget and layout system (similar to eg. Qt). At the moment there only exists a button widget (but already with focus, and hover/press effects).
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: Just a comment

Postby Philosopher » Wed Jul 10, 2013 12:46 pm

Thanks Tom, I was wondering how much things would change from what I'm developing on (expecially with the window decorations). But I have Combo, Button, and title-bar widgets which are pretty much just hacks in terms of prettiness (I couldn't even get a background to display behind the button!). Great to hear there will be support for layout management; I find configuring pixel positions rather time-consuming ;).
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
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 » Wed Jul 10, 2013 1:22 pm

@Philosopher. Regarding layout, you don't perhaps have some sort of drawing app that works in pixels. You can then do a nice layout, and get the pixel positions from the drawing.
macnab
 
Posts: 886
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 » Wed Jul 10, 2013 1:31 pm

I just make up numbers until it fits ;). Actually a good "development extension" would be one that shows the position in pixels when you click on a Canvas -- so I could just say "I want my text *here* [click]" and then copy that out of a small dialog that would be showing the info. But I'm not sure if that would work since it would have to add listeners to all Canvases, and I'm not sure if that's possible... :P
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
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 TheTom » Wed Jul 10, 2013 2:04 pm

Philosopher wrote in Wed Jul 10, 2013 12:46 pm:expecially with the window decorations

With fg >= 2.11 you don't need to create window decoration on your own anymore. Creating a canvas window with a default dialog decoration just requires:

Code: Select all
var dlg = canvas.Window.new([400,300], "dialog");


The actual decoration is then created by the window decorator theme (which can be full customized). Currently "dialog" is the only supported decoration type but more are likely to follow.

Philosopher wrote in Wed Jul 10, 2013 12:46 pm: I find configuring pixel positions rather time-consuming ;).

Me too :-P

Philosopher wrote in Wed Jul 10, 2013 1:31 pm:I just make up numbers until it fits ;).

Hopefully using the property browser? ;-)

Philosopher wrote in Wed Jul 10, 2013 1:31 pm:Actually a good "development extension" would be one that shows the position in pixels when you click on a Canvas -- so I could just say "I want my text *here* [click]"


Code: Select all
my_canvas.addEventListener("click", func(e) globals.gui.popupTip(sprintf("click (%.1f|%.1f)", e.clientX, e.clientY)));
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: Just a comment

Postby Hooray » Wed Jul 10, 2013 2:30 pm

TheTom wrote in Wed Jul 10, 2013 2:04 pm:
Philosopher wrote in Wed Jul 10, 2013 1:31 pm:Actually a good "development extension" would be one that shows the position in pixels when you click on a Canvas -- so I could just say "I want my text *here* [click]"


Code: Select all
my_canvas.addEventListener("click", func(e) globals.gui.popupTip(sprintf("click (%.1f|%.1f)", e.clientX, e.clientY)));


...now change the event-listener callback to directly modify a PropertyList tree in the property tree, and you'll end up with a WYSIWYG-GUI editor that allows you placing canvas-elements on-screen while serializing everything to a runtime tree/XML file.
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: 11298
Joined: Tue Mar 25, 2008 8:40 am

Re: Just a comment

Postby macnab » Thu Jul 11, 2013 5:31 am

Going with the concept that all the joystick routines should be in a Nasal library, does anybody have a problem with this as part of this file? Note that the properties being initialised are part of my functions still to be supplied. The filename I have used is irrelevant at the moment.

Code: Select all
###################################################################################
#                                     Variables
###################################################################################

var radioButtonRate = 0.2; # Controls rate of adjustment
var apButtonRate = 0.2; # Controls rate of adjustment
var tapVS = 0; # Used to control Tap/Hold for AP VS
var tapIAS = 0; # Used to control Tap/Hold for AP IAS

# Needs to be on, as most times the object being adjusted is not visible.
var enablePopUps = 1;


###################################################################################
#                                  Initialisation
###################################################################################
var initJoystickNasal = func {
      setprop("/autopilot/settings/heading-bug-deg", 0); # Sometines is undefined

   ################################################################################
   #                                   Radio adjust busy flags
   ################################################################################

   # Initialise property-tree. These are used to slow down radio frequency adjusting
      props.globals.getNode("/busyNAV1", 1);
      setprop("/busyNAV1", 0);
      props.globals.getNode("/busyNAV2", 1);
      setprop("/busyNAV2", 0);
      props.globals.getNode("/busyADF1", 1);
      setprop("/busyADF1", 0);
      props.globals.getNode("/busyADF2", 1);
      setprop("/busyADF2", 0);

   # When a busy flag is set, clears it after radioButtonRate seconds.
   # Sets rate of change
      setlistener("/busyNAV1", func { if (getprop("/busyNAV1")) settimer(busyNAV1Clear, radioButtonRate, 1); });
      setlistener("/busyNAV2", func { if (getprop("/busyNAV2")) settimer(busyNAV2Clear, radioButtonRate, 1); });
      setlistener("/busyADF1", func { if (getprop("/busyADF1")) settimer(busyADF1Clear, radioButtonRate, 1); });
      setlistener("/busyADF2", func { if (getprop("/busyADF2")) settimer(busyADF2Clear, radioButtonRate, 1); });


   ################################################################################
   #                                   IAS and VS busy flags
   ################################################################################

   # Used to implement tap/hold button function.
   # Tap the button and AP IAS set to current IAS or AP VS set to current VS.
   # Hold button, AP IAS adjust up/down or AP VS adjust uip/down.

      props.globals.getNode("/busyVS", 1);
      setprop("/busyVS", 0);
      props.globals.getNode("/busyIAS", 1);
      setprop("/busyIAS", 0);

   # When a busy flags is set, clears it after apButtonRate seconds.
   # Sets rate of value change.
      setlistener("/busyVS", func { if (getprop("/busyVS")) settimer(busyVSClear, apButtonRate, 1); });
      setlistener("/busyIAS", func { if (getprop("/busyIAS")) settimer(busyIASClear, apButtonRate, 1); });

}


# These are the routines for clearing the busy flags.
var busyNAV1Clear = func {
      setprop("/busyNAV1", 0);
}

var busyNAV2Clear = func {
      setprop("/busyNAV2", 0);
}

var busyADF1Clear = func {
      setprop("/busyADF1", 0);
}

var busyADF2Clear = func {
      setprop("/busyADF2", 0);
}

var busyVSClear = func {
      setprop("/busyVS", 0);
}

var busyIASClear = func {
      setprop("/busyIAS", 0);
}


# Library routines will start here
macnab
 
Posts: 886
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 » Thu Jul 11, 2013 6:50 am

FWIW, it might be a good idea to explicitly arrange such a library in a fashion that it supports "hot code swapping" by design, i.e. allowing the library to be properly suspended (all loops, timers, callbacks, listeners gracefully stopped through a listener) and reloaded/restarted, we already have too much Nasal code that doesn't keep reset/re-init requirements in mind. And for rapid-prototyping, having some form of explicit design/framework in place would also allow people to easily edit/update the code at runtime, without having to quit and restart FG. Probably, this would require some namespace magic, and providing a bunch of wrappers/helpers that would be used by the script, instead of the more low-level Nasal APIs, like settimer/setlistener. Also, versioning should be a built-in concept of any library in general, so that it can inspected at runtime and certain assumption be made - the canvas Nasal APIs should be our role model here for the time being.
Versioning, and other meta info, would be particularly important in case you really want to provide a feature to allow snippets to be shared online, and dynamically downloaded, and locally saved in $FG_HOME.

Having the feeling that P's latest invention could be useful with the namespace thingy:
Image
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: 11298
Joined: Tue Mar 25, 2008 8:40 am

Re: Just a comment

Postby macnab » Thu Jul 11, 2013 7:21 am

I'll put a listener in that will clear/reset anything that needs it with a re-init. (We can always do name matches later.)

The experts can look at it after I have made my changes so I can fix. I'm still busy organising the library. In view of the requirements I will copy the necessary from controls.nas so they can be "controlled". Leaving controls.nas as is will provide backward compatibility - there are many people who wouldn't give up their customised xml file for anything.

Where (specific files) should I look for versioning info?
macnab
 
Posts: 886
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 11, 2013 7:49 am

I will put in a listener "joysticklibrary-shutdown" to clear all loops, etc.

To enable a user to edit the library for his own personal preferences I understand we would have to:
1) Shutdown the library
2) Unload the library
3) Empty the namespace used for the library
4) Open the library in an editor
5) Save the library
6) Set a flag saying use personal copy
7) Open the personal library

Much the same if re-init for some other reason.

Step 1: Library will have to send a signal that shutdown is complete
Step 3: Alternatively, the library can remove all local variables as part of shutdown. (Make them null?)
macnab
 
Posts: 886
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 11, 2013 10:23 am

Philospher pay particular attention.

We want to make this as comprehensive as possible. This means a lot of functions in the Advanced section. This means problems with dropdown lists.

There are three possible approaches:
1) Have long lists op actions
2) Have 2 dropdowns, one for Category which limits the choices in the Action dropdown
3) Have separate pages for the Categories

All the choices have pros and cons.

Have a look at this for a start on the README.
Code: Select all
RADIO FUNCTIONS

Adjust the Standby frequency of a radio
   Adjust upwards in small steps
      NAV1 Up Small, NAV2 Up Small, etc.

   Adjust the upwards in large steps
      NAV1 Up Large, COM2 Up Large, etc.

   Adjust downwards in small steps
      NAV1 Down Small, ADF2 Down Small, etc.

   Adjust downwards in large steps
      NAV1 Down Large, NAV2 Down Large, etc.


Swap the Selected and Standby frequencies (Transfer)
   Swap NAV1, Swap NAV2, Swap ADF1, etc.


NAVIGATION FUNCTIONS

Set the radials for the radios
   Adjust clockwise in small steps
      NAV1 Right Small, NAV2 Right Small, etc.

   Adjust clockwise in large steps
      NAV1 Right Large, ADF1 Right Large, etc.

   Adjust anti-clockwise in small steps
      NAV1 Left Small, ADF2 Left Small, etc.

   Adjust anti-clockwise in large steps
      NAV1 Left Large, NAV2 Left Large, etc.


Heading bug
   Adjust clockwise
      HdgBug Right

   Adjust anti-clockwise
      HdgBug Left


Select NAV1 or NAV2 to DME display
   NAV1 to DME, NAV2 to DME


AUTOPILOT FUNCTIONS

Toggle AP On/Off
   AP Toggle

Of course, here it has lost Underline, Bold, etc., hence the block Letters
macnab
 
Posts: 886
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 » Fri Jul 12, 2013 2:02 am

Hi macnab, sorry my mind can't focus right now and I somehow missed these latest posts, but look at how the select-a-button works right now: there's columns for categories and a table of buttons for each assignment type. But yes, tabs would be doable if we need to -- I'll decide that later.

@TheTom: Where can I find your Canvas demo that had selectable text, tabs, and scrolling ? You made a video of it on the wiki.

Backt to macnab: next comment: you can't copy controls.nas: what happens when it gets overriden with aircraft-specifics?

Also I was thinking: choose button, choose modifier, choose control, choose procedure (set, step, toggle, custom). But that would be for de Philosopher mode ofc. I think the middle mode would just have a more comprehensive set of bindings, I'm now (3AM UTC) thinking organized into tabs since you have stuff like ap adjustments :).

Also, for stuff like enablePopupTips, I would prefer to have that in the property tree.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
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 » Fri Jul 12, 2013 4:07 am

but look at how the select-a-button works right now:

Silly me - when I had a quick look I looked only at the axes (which are dropdowns), not the buttons.

you can't copy controls.nas: what happens when it gets overridden with aircraft-specifics

If it gets overridden (in aircraft-set.xml if I remember correctly) then that code takes preference. (Load order.)

Linking to controls.nas for existing functions would mean either setting repeatable/non-repeatable and then calling controls.nas, or rewriting controls.nas
It also means that the user will not be able to tweak these, as controls.nas is in read-only area.

Aircraft that override controls.nas raise the problem of dynamic repeatable/non-repeatable switching. This is a major issue.

enablePopupTips. Can leave it to user to set. Can explain it and the possible need for it in the Joystick GUI readme. (Plenty of people don't know about it.)

Regarding columns/tabs. We may very well need a combination of both to limit the size of the window. I suspect that we are going to have a large number of functions. And it could grow over time. Maybe start off with tabs which still have space for empty columns and rows. I will start compiling a list of functions so you have an idea. We, as a group, will also have to add to the list and possibly pare it down a bit.

Example of possibility of huge number of functions:
Bearing in mind that we should offer a range of solutions.
Using a button to set AP IAS value:
  • TapAndHold: Press the button and AP IAS = current IAS. Hold the button and the value increases or decreases. Disadvantage is that releasing and repressing will reset it to current IAS, not carry on changing the value. So
  • have a button (function) that only sets AP IAS = current IAS, and
  • a button (function) that increases or decreases AP IAS.
This gives 5 "actions"
  • TapAndHold Increase
  • TapAndHold Decrease
  • AP IAS = IAS
  • Increase AP IAS
  • Decrease AP IAS
Of course, we could limit it to say only TapAndHold.
macnab
 
Posts: 886
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 12, 2013 7:16 am

Philosopher wrote in Fri Jul 12, 2013 2:02 am:@TheTom: Where can I find your Canvas demo that had selectable text, tabs, and scrolling ? You made a video of it on the wiki.


If I remember correctly, that was all embedded inline in menubar.xml - a while ago, I also used it for quick-prototyping, i.e. to replace the new hardcoded PUI loglist widget and use a canvas texture instead:
Image

http://wiki.flightgear.org/Canvas_GUI#R ... as_widgets
The branch is at: https://gitorious.org/~hooray/fg/hooray ... as-loglist
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: 11298
Joined: Tue Mar 25, 2008 8:40 am

Re: Just a comment

Postby macnab » Fri Jul 12, 2013 12:33 pm

A thought has occurred to me. Regarding dynamic repeatable/non-repeatable. This will have to be sent from the xml file, because of button number.
macnab
 
Posts: 886
Joined: Tue Aug 02, 2011 7: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 0 guests