# MouseAircraft The `MouseAircraft` aircraft is a preset of the [WASMAircraft](../wasmaircraft/) **modular aircraft**, illustrates how to obtain mouse information from a [WebAssembly gauge](../../../../programming-apis/wasm/webassembly/). Additionally, it showcases how to trigger sound events using local variables from WebAssembly. Once the {{< glossterm >}}wasm{{< /glossterm >}} Aircraft package has been built, this module will be available for flying from the aircraft selection screen: {{< image-center src="images/7_Samples_Tutorials/Samples/WASMAircraft/MouseAircraft/mouse_1_aircraft.png" alt="Selecting The Mouse Aircraft In The Simulation" >}}   The `WasmModules.sln` file (found in the `Sources` folder of the project) will allow you to compile the source-code with Microsoft Visual Studio (2019 or 2022) in order to create the `MouseModule.wasm` WebAssembly module which will then be loaded by the simulation. Once compiled, the module will automatically be copied into the following folder: \[ROOT\]\(PackageSources\)SimObjects\(Airplanes\)MyCompany\_Wasm\_Aircraft\(presets\)mycompany\(MouseAircraft\)panel   Note that if you make changes to the C++ code and recompile the mouse WASM module, you will have to build your package again. This *can* be done while the plane is used within the simulation.     ### Testing Once you have built the aircraft and selected it, you can go into a **Free Flight** and you will see three panels in the cockpit: {{< image-center src="images/7_Samples_Tutorials/Samples/WASMAircraft/MouseAircraft/mouse_5_screens.png" alt="The Cockpit Interior Of The Charts Aircraft" >}}   Each of these gauge displays is explained below, along with the source file that they use:   1. `MouseInformation.cpp`: This display provides debug information of mouse displacement and button actions. The display will light up the mouse buttons used - `L` for the left button, `M` for the middle button, `W` for the wheel, and `R` for the right button - as well as display the position of the cursor and an updating list of the different mouse events sent. {{< image-center src="images/7_Samples_Tutorials/Samples/WASMAircraft/MouseAircraft/mouse_3_information.png" alt="The Information Gauge In The Simulation" >}}   2. `Toggle.cpp`: This display is used to show how to detect mouse events inside of a rectangular area on the gauge screen. Clicking one of the red, green, or blue, rectangles will change the colour of the grey rectangle. {{< image-center src="images/7_Samples_Tutorials/Samples/WASMAircraft/MouseAircraft/mouse_2_toggle.png" alt="The Toggle Gauge In The Simulation" >}}   3. `TriggerSound.cpp`: This display simply contains a button that - when pressed - will play a sound. It provides an example on how to control both single and continuous sound events {{< image-center src="images/7_Samples_Tutorials/Samples/WASMAircraft/MouseAircraft/mouse_4_sound.png" alt="The Sound Gauge In The Simulation" >}} 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](../../../../sound/using-wwise/). Then, the `LocalVar` is controlled from the WebAssembly module: ``` clike int sound_lvar_id = lvarregister_named_variable("LocalVar_in_sound.xml"); ... set_named_variable_value(sound_lvar_id, trigger_value); ```     ### Mouse Events Additional Information As described in the [Handling Mouse Events](../../../../programming-apis/wasm/creating-wasm-gauges/#mouse_events) section, mouse events can be obtained from a Gauge by declaring the corresponding mouse callback, eg: ``` clike 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; } } ```