Table of Contents
Game Controller
Reads the state of a game controller on 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/Target')Description
The Game Controller block reads the state of the game controller on the target and outputs the game controller
coodinates and button information. The 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 and rotation 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. Slider coordinates are output as double-precision values in the range 0.0 to 1.0.
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.
Limitations
Calibration
In external mode, the game controller may not use the calibration settings configured in the Control Panel. As a result, the range of some or all of the axes may be incorrect. The problem is due to the fact that QUARC runs in a specialized environment in order to provide real-time performance and may not have access to the calibration settings for a particular game controller. To resolve this issue, try installing the driver software supplied with the game controller and using its calibration utility to calibrate the game controller. This solution has been known to work with other game controllers, such as the Logitech Wingman Force 3D. Alternatively, scale the uncalibrated data manually in the Simulink model itself or use the Host Game Controller block instead. Quanser recommends using the calibration utility supplied by the manufacturer of the game controller or using the Host Game Controller block.
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.
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 in the X
axis in normalized
coordinates (-1.0=minimum, 1.0=maximum).
Ry
The absolute rotation of the game controller in the Y
axis in normalized
coordinates (-1.0=minimum, 1.0=maximum).
Rz
The absolute rotation of the game controller in 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
Controller number (tunable offline)
The number of the game controller to read. Up to 16 game controllers are supported on a Windows target. 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 rate at which the game controller coordinates and button states are acquired and output from the Game Controller block.
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 |
||
No |
No |
||
No |
No |
||
No |
No |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
No |
No |
||
No |
No |
||
No |
No |
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 |
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.