#include <qafJoystickSystem.h>
Most methods expect a JoystickObject
code as a parameter. See the enumerated type definition in qafJoystickSystem.h for its possible values.
If any errors are encountered during the execution of this class's methods, they will be reported in the HGE log file.
Public Member Functions | |
Joystick (LPDIRECTINPUTDEVICE8 pJoystick, HWND hWindow) | |
For internal use only.
| |
bool | isInitialized () |
For internal use only.
| |
bool | poll () |
For internal use only. This method must be called every frame to update the joystick's state. | |
int | getObjectState (JoystickObject obj) |
Returns a number representing the specified object's state. | |
const char * | getObjectName (JoystickObject obj) |
Returns a pointer to an internal string, containing the object's description. | |
const char * | getDeviceName () |
| |
bool | setHWND (HWND hWindow) |
For internal use only. Changes this joystick's target window. | |
bool | setAxesParameters (bool absolute, int minValue, int maxValue, float deadZone, float saturation) |
Sets the axes' parameters. | |
int | createVibrationEffect (float magnitude, float duration, float period) |
Creates a periodic force-feedback effect if the device supports it. | |
bool | changeVibrationMagnitude (int effectID, float newMagnitude, float newPeriod) |
Changes the vibration's magnitude of the effect specified by effectID . | |
bool | deleteEffect (int effectID) |
Unloads and deletes the effect specified by effectID . | |
bool | playEffect (int effectID, int repetitions) |
Starts the effect specified by effectID . |
qaf::Joystick::Joystick | ( | LPDIRECTINPUTDEVICE8 | pJoystick, | |
HWND | hWindow | |||
) |
For internal use only.
pJoystick | A pointer to the joystick interface. | |
hWindow | The window handle to which this device will be attached. |
bool qaf::Joystick::isInitialized | ( | ) |
For internal use only.
bool qaf::Joystick::poll | ( | ) |
For internal use only.
This method must be called every frame to update the joystick's state.
This is the Environment
's task; users need not and should not invoke this method directly.
int qaf::Joystick::getObjectState | ( | JoystickObject | obj | ) |
Returns a number representing the specified object's state.
The semantics of that value depend on the type of object read:
setAxesParameters()
method).const char* qaf::Joystick::getObjectName | ( | JoystickObject | obj | ) |
Returns a pointer to an internal string, containing the object's description.
NULL
if the object does not exist on the joystick. const char* qaf::Joystick::getDeviceName | ( | ) |
The string is statically allocated and should not be changed or freed.
bool qaf::Joystick::setHWND | ( | HWND | hWindow | ) |
For internal use only.
Changes this joystick's target window.
bool qaf::Joystick::setAxesParameters | ( | bool | absolute, | |
int | minValue, | |||
int | maxValue, | |||
float | deadZone, | |||
float | saturation | |||
) |
Sets the axes' parameters.
absolute | If set to false, the axes' data will be returned in relation to the last frame. Default: true | |
minValue | The axes' minimum value (e.g., the number returned when the X-axis is all the way to the left). Default: -1000 | |
maxValue | The axes' maximum value (e.g., the number returned when the X-axis is all the way to the right). Default: +1000 | |
deadZone | A percentage value (range [0, 1]), indicating the area at the axes' center where movement should be considered zero. Default: 0.1 | |
saturation | A percentage value (range [0, 1]), indicating the area at the axes' outer edge where movement should be considered at its maximum. Default: 1.0 |
int qaf::Joystick::createVibrationEffect | ( | float | magnitude, | |
float | duration, | |||
float | period | |||
) |
Creates a periodic force-feedback effect if the device supports it.
magnitude | A number contained in the interval [0, 1], where 0 represents no force and 1 represents the device's maximum force. | |
duration | Duration of the vibration, in seconds. | |
period | This parameter specifies the period of the effect's vibration. |
bool qaf::Joystick::changeVibrationMagnitude | ( | int | effectID, | |
float | newMagnitude, | |||
float | newPeriod | |||
) |
Changes the vibration's magnitude of the effect specified by effectID
.
It may be possible to change the effect's parameters as it is playing, depending on the device.
bool qaf::Joystick::deleteEffect | ( | int | effectID | ) |
Unloads and deletes the effect specified by effectID
.
bool qaf::Joystick::playEffect | ( | int | effectID, | |
int | repetitions | |||
) |
Starts the effect specified by effectID
.