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$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@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}
|
|
|
|
@category{FIXME}
|
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-03-09 08:33:59 -04:00
|
|
|
Constructor. @a joystick may be one of wxJOYSTICK1, wxJOYSTICK2, indicating the
|
2008-03-08 08:52:38 -05:00
|
|
|
joystick
|
|
|
|
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
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
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-03-09 12:24:26 -04:00
|
|
|
int GetButtonState() const;
|
|
|
|
const bool GetButtonState(unsigned 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.
|
|
|
|
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
|
|
|
|
degree units,
|
|
|
|
but limited to return 0, 9000, 18000 or 27000.
|
|
|
|
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
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
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-03-09 12:24:26 -04:00
|
|
|
wxPoint GetPosition() const;
|
|
|
|
const int GetPosition(unsigned 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
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the joystick point-of-view supports discrete values (centered,
|
|
|
|
forward, backward, left, and right).
|
|
|
|
*/
|
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-03-09 12:24:26 -04:00
|
|
|
#define bool HasPOVCTS() const /* implementation is private */
|
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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the capture to direct joystick events to @e 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-03-09 08:33:59 -04:00
|
|
|
If zero, movement events are sent when above the
|
|
|
|
threshold. If greater than zero, events are received every pollingFreq
|
2008-03-08 08:52:38 -05:00
|
|
|
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
|
|
|
|
deemed to have
|
|
|
|
moved.
|
|
|
|
*/
|
|
|
|
void SetMovementThreshold(int threshold);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|