MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
quarc_host_mouse_demoQUARC 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.
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 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 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.
from the menu of the diagram, or pressDouble-click on the XY Figure block to open the figure in a separate window.
Click on the
button or select from the menu of the diagram to connect to the model.Start the model by clicking on the
button or selecting from the menu of the diagram. The item of the 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.
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
button or select from the menu of the diagram to stop the model. The item of the 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.
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.