Host Heartbeat Host Game Controller navigation bar

Table of Contents

Host Keyboard

This block outputs a vector in which each elements is 1 if the corresponding key is pressed and 0 if the key is not pressed.

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 Keyboard

The Host Keyboard block reads the state of the specified virtual keys on the host and outputs a vector of boolean values to indicate whether or not the keys are pressed at the current sampling instant. 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 keyboard events. It also configures how the keyboard 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 Host Keyboard block can read the state of more than one key at the same time. The keys to be monitored are selected in the block parameters dialog, which shows the list of keys. Keys may be added, modified or removed from the list of keys using the Add, Edit and Delete buttons respectively. The order of the elements in the keys output vector correspond to the order of the keys listed in the parameters dialog. To reorder the keys, select the keys to move in the list and use the Up and Down buttons to change their position in the list.

The new output indicates when new data is received from the keyboard. The output is high for one sampling instant whenever new data arrives. Since typing on the keyboard is must slower than a typical control system, the new output will go up and down infrequently as buttons are being pressed. The new output can be fed to a Triggered Subsystem to only respond when the keyboard state changes.

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. Generally, however, it indicates the instant at which any of the keys being monitored are pressed or released. Alternatively, look for rising or falling edges on the keys output via a Triggered Subsystem.

keys

A boolean vector indicating whether or not the virtual keys are being pressed on the host machine at the current sampling instant. Each elements of the output vector is true if the corresponding key is being pressed and false if the key is not being pressed at the current sampling instant.

Parameters and Dialog Box

Host Keyboard

Host name

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

List of keys (tunable offline)

The list of keys shows the set of keys being monitored, in order. The order that keys appear in this list reflects the same order that they appear in the keys output vector. Double-click on any single item in the list to edit the key. Select any set of keys in the list and use the buttons described below to modify the list. To select a single key in the list, just click on the name of that key. To select more than one key, click on the additional keys while holding down the Ctrl key. To choose a set of consecutive keys, click on the first key to select it and then click on the last key in the set while holding down the Shift key.

Add

Press the Add button to add a new key to the list. A dialog box will appear containing three fields labelled: Category, Key name and Or press key.

The easiest way to select the key is to click in the Or press key field and then simply press the desired key. Most keys are recognized. However, if the desired key is not recognized then the Category and Key name fields may be used to choose the key.

The Category combobox allows the key to be selected from a number of categories, including alphanumeric keys, the numeric keypad, punctuation, modifiers, editing keys, function keys, navigation keys, multimedia keys and language keys.

Once a category is selected, the contents of the Key name combobox will change to a list of keys that fall within that category. Choose a key from the Key name list to select the desired key.

Edit

Pressing the Edit button after selecting a key in the list of keys allows that key to be changed. A dialog box will appear allowing a different key to be selected. Refer to the description of the Add button for details on the edit dialog.

Delete

Pressing the Delete button after selecting keys in the list will remove those keys from the list.

Up

To move a key, or set of keys, upward in the list, select the keys in the list and then press the Up button.

Down

To move a key, or set of keys, downward in the list, select the keys in the list and then press the Down button.

Sample time

The sampling period (in seconds) at which the block checks whether the specified virtual key is being pressed. 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.

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 keyboard 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