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