Board index FlightGear Development Aircraft Cockpit development

Make knob rotate both directions  Topic is solved

Discussion about creating 2d and 3d cockpits.

Make knob rotate both directions

Postby benih » Mon Sep 11, 2017 3:10 pm

Hello,
i face a problem with my fuel selector "knob".

I want it to rotate in both directions when the mouse wheel is used on it, but it only rotes counter clock wise.
On the wiki i cannot find any input and the forum search gives overwhelming results. :(

What i have is:
Code: Select all
<animation>
        <type>knob</type>
        <object-name>FuelTankSelector</object-name>
        <property>/controls/switches/fuel_tank_selector</property>
        <visible>true</visible>
        <factor>90</factor>
        <offset-deg>90</offset-deg>
        <center>
            <x-m>0.46232</x-m>
            <y-m>0.02154</y-m>
            <z-m>0</z-m>
        </center>
        <axis>
            <x>0</x>
            <y>0</y>
            <z>1</z>
        </axis>
        <action>
            <binding>
                <command>property-adjust</command>
                <property>/controls/switches/fuel_tank_selector</property>
                <wrap>true</wrap>
                <step>1</step>
                <min>0</min>
                <max>4</max> <!-- 0=off, 1=right, 2=both, 3=left -->
            </binding>
        </action>
        <hovered>
            <binding>
                <command>set-tooltip</command>
                <tooltip-id>fuel-tank-selector</tooltip-id>
                <label>Fuel tank selector: %s</label>
                <property>/controls/switches/fuel_tank_selector</property>
                <mapping>nasal</mapping>
                <script>
                    var m = arg[0];
                    if (m == 1) return 'RIGHT';
                    if (m == 2) return 'BOTH';
                    if (m == 3) return 'LEFT';
                    return 'OFF';
                </script>
            </binding>
        </hovered>
</animation>
benih
 
Posts: 96
Joined: Tue Aug 15, 2017 9:34 am

Re: Make knob rotate both directions

Postby Bomber » Mon Sep 11, 2017 4:44 pm

create 2 action points.... one on the left of the switch and one on the right...

lefts action

<action>
<binding>
<command>property-adjust</command>
<property>/controls/switches/fuel_tank_selector</property>
<wrap>true</wrap>
<step>-1</step>
<min>0</min>
<max>4</max> <!-- 0=off, 1=right, 2=both, 3=left -->
</binding>
</action>

rights action (as is)

<action>
<binding>
<command>property-adjust</command>
<property>/controls/switches/fuel_tank_selector</property>
<wrap>true</wrap>
<step>1</step>
<min>0</min>
<max>4</max> <!-- 0=off, 1=right, 2=both, 3=left -->
</binding>
</action>

you might also be able to use a keyboard mod-up in conjunction such as a ctrl or shift but I'm not sure on this......
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchel
Bomber
 
Posts: 1934
Joined: Fri Dec 14, 2007 7:06 pm
OS: Windows XP and 10

Re: Make knob rotate both directions

Postby Thorsten » Mon Sep 11, 2017 4:55 pm

create 2 action points.... one on the left of the switch and one on the right...


That doesn't really help him, because

I want it to rotate in both directions when the mouse wheel is used on it, but it only rotes counter clock wise.

Altimeter codes (such as for the C-172p) typically have the binding - so just copy-paste the code from the knob there and adapt it to your needs.
Thorsten
 
Posts: 11057
Joined: Mon Nov 02, 2009 8:33 am

Re: Make knob rotate both directions  

Postby PINTO » Mon Sep 11, 2017 5:06 pm

Looking at the wiki (haven't experimentd myself), it looks like you need to remove the <step> tag from your <binding>.

http://wiki.flightgear.org/Knob_/_slider_animation#Binding_Actions wrote:Note that if you are using a property-adjust binding, you must use <factor> to control the numerical change, since this scales the <offset> parameter. If you use <step>, bidirectional control via the same binding will not work. If for some reason your actions are asymmetric, then you will need separate increase and decrease bindings as described above. However, an asymmetric instrument might not be a good choice for these animations, for the sake of end-user understanding!
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 945
Joined: Wed Oct 21, 2015 6:28 pm
Callsign: pinto
Version: 2016.3.0
OS: Win10

Re: Make knob rotate both directions

Postby benih » Mon Sep 11, 2017 5:43 pm

Looking at the wiki (haven't experimentd myself), it looks like you need to remove the <step> tag from your <binding>.

That did the trick, thank you!
benih
 
Posts: 96
Joined: Tue Aug 15, 2017 9:34 am


Return to Cockpit development

Who is online

Users browsing this forum: No registered users and 1 guest