Start of trail End of trail navigation bar

Table of Contents

Host Force Feedback Game Controller

Reads the state of a force feedback game controller on the host, rather than the target.

Library

QUARC Targets/Devices/Peripherals/Host/Force Feedback Game Controllers/Configuration

Description

Host Force Feedback Game Controller

The Host Force Feedback Game Controller block reads the state of the force feedback game controller on the host and outputs the game controller coodinates and button information. It also configures the maximum number of force feedback effects that may be used with the game controller. Force feedback effects are implemented using the other force feedback game controller blocks, such as the Host Force Feedback Constant Force block. A Host Force Feedback Game Controller block must be present in the model for the other force feedback game controller blocks to be used. There must be one Host Force Feedback Game Controller block for each force feedback game controller used.

The Host Force Feedback Game Controller block 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.

Warning Note that force feedback game controllers are enumerated differently than regular game controllers. The controller number specified for a Host Force Feedback Game Controller block is based solely on the number of force feedback game controllers attached to the system, while the controller number specified for a Host Force Feedback block is based on the total number of game controllers attached to the system, whether they support force feedback or not.

The Host Force Feedback Game Controller block acquires the absolute (x,y,z) position coordinates, absolute rotation (Rx, Ry, Rz) coordinates, two slider coordinates, the positions of up to four point-of-view hats and the state of up to 32 game controller buttons.

The position, rotation and slider coordinates are output as double-precision values scaled to the range -1.0 to +1.0, where -1.0 represents the minimum value in range of the axis, 0.0 represents the middle of the range and +1.0 represents the maximum value in the range of the axis.

The point-of-view positions are output as an angular position in radians, where 0 is the minimum position (North) and 2π is the maximum position. A special value of -1.0 indicates that the point-of-view hat is in the center position.

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, and it is recommended that the sampling time be no less than 50ms.

The new output indicates when new data is received from the game controller. The output is high for one sampling instant whenever new data arrives. Game controllers 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 game controller is moving or buttons are being pressed. The new output can be fed to a Triggered Subsystem to only respond when the game controller state changes.

Important Notes

Force Feedback Drivers

Note Force feedback game controllers typically require that a driver installed before the device will support force feedback. Without the driver installed, the force feedback game controller will likely appear as a regular game controller without support for force feedback.

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 vector indicating the state of the game controller 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 vector has 32 elements since up to 32 buttons are supported. Use the Selector block to extract the state of a particular button, or a set of them, within the vector.

sliders

A vector indicating the absolute position of the game controller sliders in normalized coordinates (-1.0=minimum, 1.0=maximum). This output is a 2-vector since up to 2 sliders are supported. Use the Selector block to extract the state of a particular slider, or a set of them, within the vector.

x

The absolute position of the game controller in the X axis in normalized coordinates (-1.0=minimum, 1.0=maximum).

y

The absolute position of the game controller in the Y axis in normalized coordinates (-1.0=minimum, 1.0=maximum).

z

The absolute position of the game controller in the Z axis in normalized coordinates (-1.0=minimum, 1.0=maximum).

Rx

The absolute rotation of the game controller about the X axis in normalized coordinates (-1.0=minimum, 1.0=maximum).

Ry

The absolute rotation of the game controller about the Y axis in normalized coordinates (-1.0=minimum, 1.0=maximum).

Rz

The absolute rotation of the game controller about the Z axis in normalized coordinates (-1.0=minimum, 1.0=maximum).

povs

A vector indicating the absolute position of the game controller point-of-view hats in normalized coordinates (-1.0=center position, 0=minimum [North], 2π=maximum). This output is a 4-vector since up to 4 point-of-view hats are supported. Use the Selector block to extract the state of a particular point-of-view hat, or a set of them, within the vector.

Parameters and Dialog Box

Host Force Feedback Game Controller

Go to Host blocks using this host interface

Opens a dialog that lists all the Host blocks in the model which are currently using the same host selected in the Host name parameter. The dialog may be used to go to another Host block in the model just by double-clicking on the name of the block in the dialog box.

Go to Host Force-Feedback blocks using this game controller

Opens a dialog that lists all the Host Force-Feedback blocks in the model which are currently using the same game controller selected in the Controller name parameter. The dialog may be used to go to another Host Force-Feedback block in the model just by double-clicking on the name of the block in the dialog box.

Host name

The identity of the associated Host Initialize block. The Host Force Feedback Game Controller block must be associated with a Host Initialize block.

Controller name

A name used to identify this force feedback game controller. This name is used by other Host Force Feedback blocks to refer to this game controller.

Controller number (tunable offline)

The number of the force feedback game controller to read. Up to 16 game controllers are supported on a Windows host. Force Feedback Game controllers are numbered sequentially starting at 1.

Deadzone per axis (tunable offline)

A vector representing the amount of dead-zone to incorporate into each axis. If an empty matrix is specified then the dead-zone is not changed. Each element must be a number between 0 and 1 indicating a percentage of full scale range. If an element is set to -1 then the dead-zone for that axis is not changed. For example, if the dead-zone is set to 0.4, then the outputs will not change until the game controller moves to at least 40% of its full scale range. Up to six elements may be specified, corresponding to the x, y, z, Rx, Ry, and Rz axes respectively.

Saturation per axis (tunable offline)

A vector representing saturation values to apply to each axis. If an empty matrix is specified then the saturation values are not changed. Each element must be a number between 0 and 1 indicating a percentage of full scale range. If an element is set to -1 then the saturation for that axis is not changed. For example, if the saturation is set to 0.4, then the outputs will reach a magnitude of 1 as soon as the game controller reaches 40% of its full scale range. Up to six elements may be specified, corresponding to the x, y, z, Rx, Ry, and Rz axes respectively.

Buffer size (tunable offline)

The size of the buffer, in samples, used by the game controller driver to buffer events. The buffer is used to accumulate game controller events when the software cannot respond fast enough to the game controller interrupts. This setting rarely needs to be changed.

Maximum number of force feedback effects (tunable offline)

The maximum number of force feedback effects allowed for this game controller. This parameter determines how many host game controller force feedback blocks may be present in the diagram.

Force-feedback gain (tunable offline)

The overall force-feedback gain to apply to all force effects. This parameter may be used to scale down all the force feedback effects at the same time.

Sample time

The sampling period (in seconds) at which the game controller coordinates and button states are acquired and output from the Host Force Feedback Game Controller 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.

Auto-center (tunable offline)

Check this option to cause the game controller to auto-center itself. Not all game controllers support this option. It is unchecked by default because auto-centering can interfere with force feedback effects.

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 the game controller is not attached.

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