2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: joystick.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxJoystick
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxJoystick
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxJoystick allows an application to control one or more joysticks.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxadv}
|
2008-10-17 20:55:12 +00:00
|
|
|
@category{misc}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see wxJoystickEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxJoystick : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-17 20:55:12 +00:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
@a joystick may be one of wxJOYSTICK1, wxJOYSTICK2, indicating the joystick
|
2008-03-08 13:52:38 +00:00
|
|
|
controller of interest.
|
|
|
|
*/
|
|
|
|
wxJoystick(int joystick = wxJOYSTICK1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the wxJoystick object.
|
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual ~wxJoystick();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-10-17 20:55:12 +00:00
|
|
|
/**
|
|
|
|
Returns the state of the joystick buttons.
|
|
|
|
Every button is mapped to a single bit in the returned integer, with the
|
|
|
|
first button being mapped to the least significant bit, and so on.
|
|
|
|
|
|
|
|
A bitlist of wxJOY_BUTTONn identifiers, where n is 1, 2, 3 or 4 is available
|
|
|
|
for historical reasons.
|
|
|
|
*/
|
|
|
|
int GetButtonState() const;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Returns the state of the specified joystick button.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
The button id to report, from 0 to GetNumberButtons() - 1
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-11-10 21:33:25 +00:00
|
|
|
bool GetButtonState(unsigned int id) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the manufacturer id.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetManufacturerId() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the movement threshold, the number of steps outside which the joystick
|
|
|
|
is deemed to have
|
|
|
|
moved.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetMovementThreshold() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of axes for this joystick.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetNumberAxes() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of buttons for this joystick.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetNumberButtons() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of joysticks currently attached to the computer.
|
|
|
|
*/
|
|
|
|
static int GetNumberJoysticks();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the point-of-view position, expressed in continuous, one-hundredth of a
|
|
|
|
degree units.
|
2008-10-17 20:55:12 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Returns -1 on error.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetPOVCTSPosition() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the point-of-view position, expressed in continuous, one-hundredth of a
|
2008-10-17 20:55:12 +00:00
|
|
|
degree units, but limited to return 0, 9000, 18000 or 27000.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Returns -1 on error.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetPOVPosition() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum polling frequency.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetPollingMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum polling frequency.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetPollingMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-10-17 20:55:12 +00:00
|
|
|
/**
|
|
|
|
Returns the x, y position of the joystick.
|
|
|
|
*/
|
|
|
|
wxPoint GetPosition() const;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Returns the position of the specified joystick axis.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param axis
|
2008-03-09 12:33:59 +00:00
|
|
|
The joystick axis to report, from 0 to GetNumberAxes() - 1.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-11-10 21:33:25 +00:00
|
|
|
int GetPosition(unsigned int axis) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the product id for the joystick.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetProductId() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the product name for the joystick.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetProductName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum rudder position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetRudderMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum rudder position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetRudderMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the rudder position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetRudderPosition() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum U position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetUMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum U position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetUMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the position of the fifth axis of the joystick, if it exists.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetUPosition() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum V position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetVMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum V position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetVMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the position of the sixth axis of the joystick, if it exists.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetVPosition() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum x position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetXMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum x position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetXMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum y position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetYMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum y position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetYMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum z position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetZMax() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum z position.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetZMin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the z position of the joystick.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetZPosition() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick has a point of view control.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasPOV() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-10-17 20:55:12 +00:00
|
|
|
Returns @true if the joystick point-of-view supports discrete values
|
|
|
|
(centered, forward, backward, left, and right).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasPOV4Dir() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick point-of-view supports continuous degree bearings.
|
|
|
|
*/
|
2008-10-17 20:55:12 +00:00
|
|
|
bool HasPOVCTS() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if there is a rudder attached to the computer.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasRudder() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick has a U axis.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasU() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick has a V axis.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasV() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick has a Z axis.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasZ() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick is functioning.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsOk() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Releases the capture set by @b SetCapture.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @true if the capture release succeeded.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see SetCapture(), wxJoystickEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool ReleaseCapture();
|
|
|
|
|
|
|
|
/**
|
2008-10-17 20:55:12 +00:00
|
|
|
Sets the capture to direct joystick events to @a win.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param win
|
2008-03-09 12:33:59 +00:00
|
|
|
The window that will receive joystick events.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param pollingFreq
|
2008-10-17 20:55:12 +00:00
|
|
|
If zero, movement events are sent when above the threshold.
|
|
|
|
If greater than zero, events are received every @a pollingFreq milliseconds.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @true if the capture succeeded.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see ReleaseCapture(), wxJoystickEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool SetCapture(wxWindow* win, int pollingFreq = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the movement threshold, the number of steps outside which the joystick is
|
2008-10-17 20:55:12 +00:00
|
|
|
deemed to have moved.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetMovementThreshold(int threshold);
|
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|