1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface stuff for wxJoystick
 
   7 // Created:     18-June-1999
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  20 #include <wx/joystick.h>
 
  23 //---------------------------------------------------------------------------
 
  27 // Which joystick? Same as Windows ids so no conversion necessary.
 
  34 // Which button is down?
 
  46 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
 
  47 // A C++ stub class for wxJoystick for platforms that don't have it.
 
  48 class wxJoystick : public wxObject {
 
  50     wxJoystick(int joystick = wxJOYSTICK1) {
 
  51         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
  52         PyErr_SetString(PyExc_NotImplementedError,
 
  53                         "wxJoystick is not available on this platform.");
 
  54         wxPyEndBlockThreads(blocked);
 
  56     wxPoint GetPosition() { return wxPoint(-1,-1); }
 
  57     int GetZPosition() { return -1; }
 
  58     int GetButtonState() { return -1; }
 
  59     int GetPOVPosition() { return -1; }
 
  60     int GetPOVCTSPosition() { return -1; }
 
  61     int GetRudderPosition() { return -1; }
 
  62     int GetUPosition() { return -1; }
 
  63     int GetVPosition() { return -1; }
 
  64     int GetMovementThreshold() { return -1; }
 
  65     void SetMovementThreshold(int threshold) {}
 
  67     bool IsOk(void) { return false; }
 
  68     int GetNumberJoysticks() { return -1; }
 
  69     int GetManufacturerId() { return -1; }
 
  70     int GetProductId() { return -1; }
 
  71     wxString GetProductName() { return wxEmptyString; }
 
  72     int GetXMin() { return -1; }
 
  73     int GetYMin() { return -1; }
 
  74     int GetZMin() { return -1; }
 
  75     int GetXMax() { return -1; }
 
  76     int GetYMax() { return -1; }
 
  77     int GetZMax() { return -1; }
 
  78     int GetNumberButtons() { return -1; }
 
  79     int GetNumberAxes() { return -1; }
 
  80     int GetMaxButtons() { return -1; }
 
  81     int GetMaxAxes() { return -1; }
 
  82     int GetPollingMin() { return -1; }
 
  83     int GetPollingMax() { return -1; }
 
  84     int GetRudderMin() { return -1; }
 
  85     int GetRudderMax() { return -1; }
 
  86     int GetUMin() { return -1; }
 
  87     int GetUMax() { return -1; }
 
  88     int GetVMin() { return -1; }
 
  89     int GetVMax() { return -1; }
 
  91     bool HasRudder() { return false; }
 
  92     bool HasZ() { return false; }
 
  93     bool HasU() { return false; }
 
  94     bool HasV() { return false; }
 
  95     bool HasPOV() { return false; }
 
  96     bool HasPOV4Dir() { return false; }
 
  97     bool HasPOVCTS() { return false; }
 
  99     bool SetCapture(wxWindow* win, int pollingFreq = 0) { return false; }
 
 100     bool ReleaseCapture() { return false; }
 
 106 MustHaveApp(wxJoystick);
 
 108 class wxJoystick /* : public wxObject */
 
 111     wxJoystick(int joystick = wxJOYSTICK1);
 
 114     wxPoint GetPosition();
 
 116     int GetButtonState();
 
 117     int GetPOVPosition();
 
 118     int GetPOVCTSPosition();
 
 119     int GetRudderPosition();
 
 122     int GetMovementThreshold();
 
 123     void SetMovementThreshold(int threshold) ;
 
 126     int GetNumberJoysticks();
 
 127     int GetManufacturerId();
 
 129     wxString GetProductName();
 
 136     int GetNumberButtons();
 
 157     bool SetCapture(wxWindow* win, int pollingFreq = 0);
 
 158     bool ReleaseCapture();
 
 160     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 164 //---------------------------------------------------------------------------
 
 166 %constant wxEventType wxEVT_JOY_BUTTON_DOWN;
 
 167 %constant wxEventType wxEVT_JOY_BUTTON_UP;
 
 168 %constant wxEventType wxEVT_JOY_MOVE;
 
 169 %constant wxEventType wxEVT_JOY_ZMOVE;
 
 172 class wxJoystickEvent : public wxEvent
 
 175     wxJoystickEvent(wxEventType type = wxEVT_NULL,
 
 177                     int joystick = wxJOYSTICK1,
 
 180     wxPoint GetPosition() const;
 
 181     int GetZPosition() const;
 
 182     int GetButtonState() const;
 
 183     int GetButtonChange() const;
 
 184     int GetJoystick() const;
 
 186     void SetJoystick(int stick);
 
 187     void SetButtonState(int state);
 
 188     void SetButtonChange(int change);
 
 189     void SetPosition(const wxPoint& pos);
 
 190     void SetZPosition(int zPos);
 
 192     // Was it a button event? (*doesn't* mean: is any button *down*?)
 
 193     bool IsButton() const;
 
 195     // Was it a move event?
 
 198     // Was it a zmove event?
 
 199     bool IsZMove() const;
 
 201     // Was it a down event from button 1, 2, 3, 4 or any?
 
 202     bool ButtonDown(int but = wxJOY_BUTTON_ANY) const;
 
 204     // Was it a up event from button 1, 2, 3 or any?
 
 205     bool ButtonUp(int but = wxJOY_BUTTON_ANY) const;
 
 207     // Was the given button 1,2,3,4 or any in Down state?
 
 208     bool ButtonIsDown(int but =  wxJOY_BUTTON_ANY) const;
 
 211         m_pos = property(GetPosition, SetPosition)
 
 212         m_zPosition = property(GetZPosition, SetZPosition)
 
 213         m_buttonChange = property(GetButtonChange, SetButtonChange)
 
 214         m_buttonState = property(GetButtonState, SetButtonState)
 
 215         m_joyStick = property(GetJoystick, SetJoystick)
 
 221 EVT_JOY_BUTTON_DOWN = wx.PyEventBinder( wxEVT_JOY_BUTTON_DOWN )
 
 222 EVT_JOY_BUTTON_UP = wx.PyEventBinder( wxEVT_JOY_BUTTON_UP )
 
 223 EVT_JOY_MOVE = wx.PyEventBinder( wxEVT_JOY_MOVE )
 
 224 EVT_JOY_ZMOVE = wx.PyEventBinder( wxEVT_JOY_ZMOVE )
 
 226 EVT_JOYSTICK_EVENTS = wx.PyEventBinder([ wxEVT_JOY_BUTTON_DOWN,
 
 234 //---------------------------------------------------------------------------