• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

XML: Joystick 'value'

Messages
1,564
Country
thailand
Is there any way to read the value generated by use of a joystick HAT button from XML script?

Or, maybe trap a joystick HAT move event. I'm familiar with Key traps but don't know how to approach a joystick trap.

Any ideas?

Bob

I've looked through the XMLEvents docs from XMLTools, so a joystick trap appears possible... but I don't know how to define it.
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
Hi Bob,

A joystick HAT button triggers PAN_VIEW event, passing the direction in degrees of the pan.
For example, moving the switch to the right assigns 90 to PAN_LEFT, to front, 0, to back, 180, left 270, etc.
It is very simple to detect with XMLEvents utility.

Also would be very simple to capture and detect the value passed to the event.
Take a look at XMLEvents examples in XMLTools' documentation to learn how to capture passed values to any event, something that is not possible to detect in FS's basic XML.

Tom
 
Last edited:
Messages
1,564
Country
thailand
Fascinating. XMLEvents Logger is an eye opener and very cool.

When my HAT button press concludes, I get a -1 value event. Is that the "spring-back" to the original position?

While using this, one thing came became apparent ... its hard to see the HAT PAN_VIEW event action because if you even breathe on the joystick when trying to touch the HAT button you get overwhelmed with aileron events and the PAN_VIEW event logs get lost in a sea of aileron data. I wish I could have turned off the aileron logging momentarily.

Are you sure people won't need Events Logger ported to Robbie's LOGGER so you can record this stuff to .csv file, together with a time value like ABSOLUTE TIME? There are so many events firing it might be useful to put them in a file that can be analyzed using spreadsheet. Perhaps this wouldn't be used enough to justify the time spent on it, but you would have a good perspective on it.

Additionally, I was a bit surprised that an event trap in my gauge did not capture the PAN_VIEW event:

Code:
<Keys>
  <On Key="PAN_VIEW">
    (L:ClicksPanView, enum) ++ (>L:ClicksPanView, enum)
  </On>
</Keys>

L:ClicksPanView never increments. Probably, I set it up incorrectly.

Bob
 
Last edited:
Messages
1,564
Country
thailand
Now what I want to be able to do is access that HAT PAN_VIEW event value and use it in my XML gauge in real time. Possible?
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
Bob,
Additionally, I was a bit surprised that an event trap in my gauge did not capture the PAN_VIEW event:
Probably, I set it up incorrectly.

Yes, you did so. Replace <On Key> with <On Event>

Now what I want to be able to do is access that HAT PAN_VIEW event value and use it in my XML gauge in real time. Possible?

Of course.

Code:
<Macro Name="OnEvent">
     '@1' (>C:XMLEVENTS:EventName,string) '@2' (>C:XMLEVENTS:EventString,string)
</Macro>

<Macro Name="PAN_VIEW">          
   *PAN_VIEW 0 ==
   if{
             (* pan is to front *)
     }
   *PAN_VIEW 90 ==
   if{
             (* pan is to the right *)
     }
   *PAN_VIEW 180 ==
   if{
             (* pan is to back *)
     }
   *PAN_VIEW 270 ==
   if{
             (* pan is to the left *)
     }
   *PAN_VIEW -1 ==
   if{
             (* pan is reset *)
     }
  *PAN_VIEW (>L:SaveMyPanView,number)
  (* etc ... *)
</Macro>

<Update>      
   (L:EventInit,bool) !    
   if{
        @OnEvent(PAN_VIEW,@PAN_VIEW)
        1 (>L:EventInit,bool)
     }
</Update>

Tom
 
Messages
1,564
Country
thailand
Bob,
Yes, you did so. Replace <On Key> with <On Event>
OMG. hahahahah. :banghead:

Actually, I blame it all on the green curry which has been too spicy lately and must be killing brain cells. What else could it be??!!

Bob
 
Last edited:
Messages
1,564
Country
thailand
Tom,

I had to read the XMLEVENTS docs a few times to understand what you were doing in your macro examples, above (the asterisk was new to me for starters), but it turns out, this is quite simple.

Powerful stuff and I like it.

Thx for the help with the macros.

Bob
 
Top