Host Disk Host Speech Recognition navigation bar

Table of Contents

Host Mouse

Reads the state of the mouse on the host, rather than the target.

Library

QUARC Targets/Devices/Peripherals/Host

MATLAB Command Line

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

qc_open_library('quarc_library/Devices/Peripherals/Host')

Description

Host Mouse

The Host Mouse block reads the state of the mouse on the host and outputs the mouse coordinates and button information. The Host Mouse block acquires the (x,y) coordinates of the mouse on the host, the position of the mouse wheels and the state of up to five mouse buttons. It must be used in connection with a Host Initialize block. The Host name parameter must be set to the identity of the Host Initialize block. The Host Initialize block determines whether the virtual desktop or a special "peripheral client window" will be used for responding to mouse events. It also configures how the mouse on the host will communicate with the real-time code running on the target, which may be remote. Refer to the documentation for the Host Initialize block for details.

The (x,y) coordinates of the mouse may be output in a variety of forms: pixels, percentages or high resolution counts. To output the mouse coordinates in pixels, check the Output position in pixels option. The coordinates will be relative to the virtual desktop - the screen real estate occupied by all monitors combined, or to the peripheral client window, depending on the configuration of the Host Initialize block. A coordinate of x=0 refers to the leftmost edge of the virtual desktop or window, while a coordinate of y=0 indicates the topmost edge of the desktop or window. The coordinates in pixels will never exceed the boundaries of the virtual desktop or peripheral client window.

To output the mouse coordinates as percentages, check the Output position as percentages option. In this case the coordinates are also relative to the virtual desktop but are expressed as fractions of the desktop or peripheral window. Hence, an x-coordinate of 0.0 refers to the leftmost edge of the virtual desktop or window, while an x-coordinate of 1.0 indicates the rightmost edge of the desktop. The coordinates in percentages are always in the range 0.0 to 1.0, and never exceed the boundaries of the virtual desktop or peripheral window. Generating mouse coordinates as percentages is the most portable because the coordinates are independent of screen resolution or the number of monitors present in the system.

To output the mouse coordinates in high resolution counts, check the Output high resolution counts option. Some modern mice have a higher resolution than the 400 dots per inch (DPI) of a typical mouse. The Host Mouse block provides access to these higher resolution coordinates to make the best use of available mouse hardware. The high resolution counts are based on raw data from the mouse itself and are not expressed relative to the virtual desktop or peripheral client window. Nor will counts necessarily correspond to pixels on the screen. Because the high resolution counts may have no association with screen coordinates, the high resolution counts are not bounded.

The (x,y) coordinates are output as double-precision values, regardless whether they are configured as pixels, percentages or high resolution counts.

The mouse wheel coordinates are output as a 2-vector. The first element is the current value of the vertical scroll wheel, while the second coordinate is the value of the horizontal scroll wheel, if one exists. Note that the horizontal scroll wheel must be supported natively. Such support did not exist in Windows XP and requires Windows Vista or above.

The button states are given as a vector of boolean values indicating whether a button is currently pressed (true) or not (false). Note that the coordinates and button states are valid only at the current sampling instant. The block parameters allow the user to specify the sampling time.

The new output indicates when new data is received from the mouse. The output is high for one sampling instant whenever new data arrives. Computer mice often generate coordinates at a slower rate than a typical control system, so the new output will likely go up and down frequently when the mouse is moving or buttons are being pressed. The new output can be fed to a Triggered Subsystem to only respond when the mouse state changes.

Limitations

Horizontal Scroll Wheel

Warning The horizontal scroll wheel is only supported in Windows Vista or later. It is not supported in Windows XP.

Input Ports

This block has no input ports.

Output Ports

new

This output is high in any sampling instant in which the data at the other outputs is new. This output may go high when the other outputs don't appear to change, although new values will have been sent from the Host Peripheral Client. For example, host peripheral drivers typically send the initial state of their device when the Host Peripheral Client first connects, but this initial state may match the default outputs.

buttons

A five-element vector of boolean values representing the states of up to five mouse buttons. Each element in the vector is true if the button is being pressed at the current sampling instant and false if the button is not being pressed at the current sampling instant. The mouse button output vector represents the following mouse buttons, beginning from the first element: LEFT mouse button, MIDDLE mouse button, RIGHT mouse button, extra mouse button 1, extra mouse button 2.

wheel

A two-element vector of double-precision values representing the mouse vertical and horizontal scroll wheels respectively. Scroll wheel coordinates often changes in multiples of 120. Horizontal scroll wheels are only supported if they rely upon the native support of the operating system. Note that Windows XP does not support horizontal scroll wheels natively.

x

A double-precision value representing the mouse x-coordinate on the host in pixels.

y

A double-precision value representing the mouse y-coordinate on the host in pixels.

x%

A double-precision value representing the mouse x-coordinate on the host as a percentage of the virtual desktop or peripheral client window.

y%

A double-precision value representing the mouse y-coordinate on the host as a percentage of the virtual desktop or peripheral client window.

cx

A double-precision value representing the mouse x-coordinate on the host in high resolution counts, that are independent of the screen resolution.

cy

A double-precision value representing the mouse y-coordinate on the host in high resolution counts, that are independent of the screen resolution.

Parameters and Dialog Box

Host Mouse

Host name

The identity of the associated Host Initialize block. The Host Mouse block must be associated with a Host Initialize block.

Sample time

The sampling period (in seconds) at which the mouse coordinates and button states are acquired and output from the Host Mouse block. A sample time of 0 indicates that the block will be treated as a continuous time block. A positive sample time indicates that the block is a discrete time block with the given sample time.

A sample time of -1 indicates that the block inherits its sample time. Since this is a source block, only inherent the sample time when it is placed in a conditionally executed subsystem, like a Triggered or Enabled Subsystem, or in a referenced model.

The default sample time is set to qc_get_step_size, which is a QUARC function that returns the fundamental sampling time of the model. Hence, the default sample time is a discrete sample time with the same sampling time as the fixed step size of the model.

Output position in pixels

Check this option to output the mouse coordinates in pixels relative to the virtual desktop or peripheral client window. Note that the x and y ports are only available when this option is checked.

Output position as percentages

Check this option to output the mouse coordinates as a fraction of the virtual desktop or peripheral client window. Note that the x% and y% ports are only available when this option is checked.

Output high resolution counts

Check this option to output the mouse coordinates in raw high resolution counts. These counts are not related to the screen or peripheral client window, but are raw counts directly from the mouse and therefore are not bounded. Note that the cx and cy ports are only available when this option is checked.

Enabled (tunable offline)

Check this option to enable the block. If this option is not checked then the outputs will be set to default values. This checkbox is convenient for disabling the block when use of the mouse is not desired.

Targets

Target Name

Compatible*

Model Referencing

Comments

QUARC Win32 Target

Yes

Yes

QUARC Win64 Target

Yes

Yes

QUARC Linux Nvidia Target

Yes

Yes

QUARC Linux QBot Platform Target

Yes

Yes

QUARC Linux QCar 2 Target

Yes

Yes

QUARC Linux QDrone 2 Target

Yes

Yes

QUARC Linux Raspberry Pi 3 Target

Yes

Yes

QUARC Linux Raspberry Pi 4 Target

Yes

Yes

QUARC Linux RT ARMv7 Target

Yes

Yes

QUARC Linux x64 Target

Yes

Yes

QUARC Linux DuoVero Target

Yes

Yes

QUARC Linux DuoVero 2016 Target

Yes

Yes

QUARC Linux Verdex Target

Yes

Yes

QUARC QNX x86 Target

Yes

Yes

Last fully supported in QUARC 2018.

Rapid Simulation (RSIM) Target

Yes

Yes

S-Function Target

No

N/A

Old technology. Use model referencing instead.

Normal simulation

Yes

Yes

* Compatible means that the block can be compiled for the target.

See Also

 

navigation bar