• 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.

multi button using Custom Event IDs

Messages
10
Country
germany
Hi folks,

just searching for a multi button using Custom Event IDs,C++ gauge. So far the code only works for single buttons. Instead of 2 click buttons searching for a single button logic same function.

Code:
static void FSAPI My_Event_Handler(ID32 event_id, UINT32 evdata, PVOID userdata)
{
  switch (event_id)
  {
  case KEY_NULL:
  break;
  case KEY_A:
  Test_Sw = 0;
  break;
  case KEY_B:
  Test_Sw = 1;
  break;

  default:
  break;
  }
}



single buttons works:
Code:
<MouseFlags>LeftSingle</MouseFlags>
  <EventID>0x0001101B</EventID>
Code:
<MouseFlags>RightSingle</MouseFlags>
  <EventID>0x0001101D</EventID>


same with multi button, no function occurs:
Code:
  <MouseFlags>LeftSingle+RightSingle</MouseFlags>
  <CallbackCode>
  (M:Event) 'LeftSingle'  scmp 0 == if{ (L:master,enum) -- -1 max (>L:master,enum) }
  (M:Event) 'RightSingle' scmp 0 == if{ (L:master,enum) ++ 1 min (>L:master,enum) }
  (L:master,enum) 0 == if{ (>K:0x0001101B) }
  (L:master,enum) 1 == if{ (>K:0x0001101B) }
  </CallbackCode>


Does anyone have an idea how to implement a multi button in the xml code?
The values are normally set via the xml code, checked via XML_Vars
Not sure if the event handler is the problem itself and shoud be updated for multi funtion.
 
Last edited:
Here is a different technique for a 3position 'multi-event switch'
Code:
      <CallbackCode>
        (M:Event) 'RightSingle' scmp 0 ==
        (M:Event) 'WheelDown' scmp 0 == or
        if{ (L:B737_AP_System_B_Switch, enum) -- 0 max (>L:B737_AP_System_B_Switch, enum) }

        (M:Event) 'LeftSingle' scmp 0 ==
        (M:Event) 'WheelUp' scmp 0 == or
        if{ (L:B737_AP_System_B_Switch, enum) ++ 2 min (>L:B737_AP_System_B_Switch, enum) }

        (L:B737_AP_System_B_Switch, enum) 2 == if{ 0x0001301C (>L:EVENT,enum) }
        (L:B737_AP_System_B_Switch, enum) 1 == if{ 0x0001301B (>L:EVENT,enum) }
        (L:B737_AP_System_B_Switch, enum) 0 == if{ 0x0001301A (>L:EVENT,enum) }
      </CallbackCode>
The advantage here is that I only have to declare one (L:Event,enum) variable in the C++ gauge's event handler, then "decode" the hex-values passed by the XML variable.

We had to come up with this because it is impossible to have multiple <EventID> in the same mouse routine in XML, and this (>K:0x0001101B) simply will not work, even though the SDK hints that it should...

BTW, just to play it "safe" we zero out the (L:Event,enum) variable after decoding it.
 
Last edited:
The advantage here is that I only have to declare one (L:Event,enum) variable in the C++ gauge's event handler, then "decode" the hex-values passed by the XML variable.

Great stuff:D
The tricky part itselfs was the decoding in C++, but I finally got it working. Another advantage it keeps your codes a lot shorter.

Thank you Bill
 
No problem! Where it really comes in handy is if you have something such as an FMS/FMC that has 50 or so buttons you need to "decode"...

What we've always done is first create an Excel spreadsheet (or equivalent) where we can list all of the button, knobs, switches, etc. in functional groups, then assign unique and sequential "hex-ids" each action.

When it comes to using the mouse points in the modeldef.xml scripts, this technique allows for having separate "events" for every possible mouse action.
  1. L click
  2. L release
  3. L drag
  4. MW click
  5. MW release
  6. MW roll up
  7. MW roll down
  8. R click
  9. R release
  10. R drag
 
Back
Top