Table of Contents
Host Game Controller
Reads the state of a game controller on the host, rather than the target.
Library
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
The Host Game Controller block reads the state of the game controller on the host and outputs the game controller coodinates and button information. The Host 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. 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 game controller 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 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 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.
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 (0.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 name
The identity of the associated Host Initialize block. The Host Game Controller block must be associated with a Host Initialize block.
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.
Sample time
The sampling period (in seconds) at which the game controller coordinates and button states are acquired and output from the Host 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.
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 |
---|---|---|---|
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
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 |
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.