MouseAircraft

The MouseAircraft sample illustrates how to obtain mouse information from a WebAssembly gauge. Additionally, it showcases how to trigger sound events using local variables from WebAssembly. Note that this sample builds upon the SimpleAircraft sample.

 

You can expand the link below to see the additional MouseAircraft files and folders that have been added to the SimpleAircraft project:

File OverviewFile Overview

|---+ MouseAircraft
    |---+ Sources
    |   |---+ Code
    |       |---- Toggle.cpp
    |       |---- MouseInformation.cpp
    |       |---- TriggerSound.cpp
    |       |---- MouseWasmModule.sln
    |       |---- MouseWasmModule.vcxproj
    |       |---- MouseWasmModule.vcxproj.filters
    |---+ PackageSources
        |---+ Data
            |---- entypo.ttf
            |---- LICENSE_OFL.txt
            |---- NotoEmoji-Regular.ttf
            |---- Roboto-Bold.ttf
            |---- Roboto-Light.ttf
            |---- Roboto-Regular.ttf

 

 

Mouse Callback

As described in the Handling Mouse Events section of the C Gauges reference page, mouse events can be obtained from a Gauge by declaring the corresponding mouse callback, eg:

MSFS_CALLBACK void GAUGENAME_mouse_callback(float fX, float fY, unsigned int iFlags)
    {
        switch (iFlags)
            {
                case MOUSE_MOVE:
                    ...
                    break;
                case MOUSE_LEFTSINGLE:
                    ...
                    break;
                case MOUSE_LEFTDOUBLE:
                    ...
                    break;
                case MOUSE_LEFTDRAG:
                    ...
                    break;
                case MOUSE_LEFTRELEASE:
                    ...
                    break;
                case MOUSE_RIGHTSINGLE:
                    ...
                    break;
                case MOUSE_RIGHTDOUBLE:
                    ...
                    break;
                case MOUSE_RIGHTDRAG:
                    ...
                    break;
                case MOUSE_RIGHTRELEASE:
                    ...
                    break;
                case MOUSE_MIDDLESINGLE:
                    ...
                    break;
                case MOUSE_MIDDLEDOUBLE:
                    ...
                    break;
                case MOUSE_MIDDLEDRAG:
                    ...
                    break;
                case MOUSE_MIDDLERELEASE:
                    ...
                    break;
                case MOUSE_WHEEL_DOWN:
                    ...
                    break;
                case MOUSE_WHEEL_UP:
                    ...
                    break;
            }
    }

 

 

Gauge Files

The following files are used for the gauges in this example:

  • Toggle.cpp: displays how to detect mouse events inside of an on-gauge rectangle
  • MouseInformation.cpp: provides debug information of mouse displacement and button actions
  • TriggerSound.cpp: provides a sample on how to control both single and continuous sound events

 

It is worth noting that the sound event is first declared in sounds\sound.xml, linking the WwiseEvent with the LocalVar as described in the WwiseSampleProject. Then, the LocalVar is controlled from the WebAssembly module:

int sound_lvar_id = lvarregister_named_variable("LocalVar_in_sound.xml");
    ...
    set_named_variable_value(sound_lvar_id, trigger_value);

 

 

Loading And Building The Project

Building the GdiplusAircraft project is identical to building the SimpleAircraft one. However please note that if you make changes to the C++ code and recompile the GDI+ module, you will have to build your package again (using the Build Package button in the Edit Package window). This can be done while the plane is used within the game.