quarc_host_mouse_demo.mdl
Open this model

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

quarc_host_mouse_demo

QUARC Host Mouse Demo

This example demonstrates how to use the Host Mouse block from the QUARC Targets library to obtain the X-Y coordinates of the mouse cursor in addition to the state of the mouse buttons (up to 5 buttons). For details of this block, please refer to the Host Mouse block reference page in the QUARC documentation.

Host Mouse Demo Simulink Diagram

In addition to the Host Mouse block, we have included the XY Figure block from the QUARC Targets library in this model. This implementation is much more efficient than the XY Graph block that comes with Simulink. It is also capable of plotting more than one curve on the same plot. For more information on this block, please refer to the XY Figure block reference page.

Note: The reason for negating the value of the Y coordinate is for the XY Figure block to trace the mouse cursor's path as it moves around the display.

Demonstration

Select Build from the QUARC menu of the diagram, or press Ctrl+B while the diagram is the active window. A great deal of output will appear in the Diagnostic Viewer about the progress of the build. If you cannot see the Diagnostic Viewer, you can open it by selecting View/Diagnostic Viewer from the menu of the diagram, or clicking on the View Diagnostics hyperlink at the bottom of the diagram. If you have MATLAB R2013b or earlier then the output will appear in the MATLAB Command Window.

Double-click on the XY Figure block to open the figure in a separate window.

Click on the Connect to Target button or select Connect to Target from the Simulation menu of the diagram to connect to the model.

Start the model by clicking on the Run button or selecting Run from the Simulation menu of the diagram. The Start item of the QUARC menu may also be used to both connect and start the model in one operation.

The XY Figure will trace the path taken by the mouse cursor as you move it around. A graph similar to the following figure appears on the XY Figure.

XY Figure

The buttons output port is connected to the "Buttons" display. The output signal is a vector of 5 elements, each corresponding to one button. For a three-button mouse, the left button is the first element, middle one is the second element and the third button corresponds to the third element. Click on each button to see its value on the "Buttons" display.

Click on the Stop button or select Stop from the Simulation menu of the diagram to stop the model. The Stop item of the QUARC menu may also be used.

Running the example on a different target

To run the example on a different target, refer to the instructions on the Running QUARC Examples on Remote Targets page.