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 wxPyBeginBlockThreads();
52 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
53 wxPyEndBlockThreads();
55 wxPoint GetPosition() { return wxPoint(-1,-1); }
56 int GetZPosition() { return -1; }
57 int GetButtonState() { return -1; }
58 int GetPOVPosition() { return -1; }
59 int GetPOVCTSPosition() { return -1; }
60 int GetRudderPosition() { return -1; }
61 int GetUPosition() { return -1; }
62 int GetVPosition() { return -1; }
63 int GetMovementThreshold() { return -1; }
64 void SetMovementThreshold(int threshold) {}
66 bool IsOk(void) { return False; }
67 int GetNumberJoysticks() { return -1; }
68 int GetManufacturerId() { return -1; }
69 int GetProductId() { return -1; }
70 wxString GetProductName() { return ""; }
71 int GetXMin() { return -1; }
72 int GetYMin() { return -1; }
73 int GetZMin() { return -1; }
74 int GetXMax() { return -1; }
75 int GetYMax() { return -1; }
76 int GetZMax() { return -1; }
77 int GetNumberButtons() { return -1; }
78 int GetNumberAxes() { return -1; }
79 int GetMaxButtons() { return -1; }
80 int GetMaxAxes() { return -1; }
81 int GetPollingMin() { return -1; }
82 int GetPollingMax() { return -1; }
83 int GetRudderMin() { return -1; }
84 int GetRudderMax() { return -1; }
85 int GetUMin() { return -1; }
86 int GetUMax() { return -1; }
87 int GetVMin() { return -1; }
88 int GetVMax() { return -1; }
90 bool HasRudder() { return False; }
91 bool HasZ() { return False; }
92 bool HasU() { return False; }
93 bool HasV() { return False; }
94 bool HasPOV() { return False; }
95 bool HasPOV4Dir() { return False; }
96 bool HasPOVCTS() { return False; }
98 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return False; }
99 bool ReleaseCapture() { return False; }
105 class wxJoystick /* : public wxObject */
108 wxJoystick(int joystick = wxJOYSTICK1);
111 wxPoint GetPosition();
113 int GetButtonState();
114 int GetPOVPosition();
115 int GetPOVCTSPosition();
116 int GetRudderPosition();
119 int GetMovementThreshold();
120 void SetMovementThreshold(int threshold) ;
123 int GetNumberJoysticks();
124 int GetManufacturerId();
126 wxString GetProductName();
133 int GetNumberButtons();
154 bool SetCapture(wxWindow* win, int pollingFreq = 0);
155 bool ReleaseCapture();
157 %pythoncode { def __nonzero__(self): return self.IsOk() }
161 //---------------------------------------------------------------------------
163 %constant wxEventType wxEVT_JOY_BUTTON_DOWN;
164 %constant wxEventType wxEVT_JOY_BUTTON_UP;
165 %constant wxEventType wxEVT_JOY_MOVE;
166 %constant wxEventType wxEVT_JOY_ZMOVE;
169 class wxJoystickEvent : public wxEvent
174 int m_buttonChange; // Which button changed?
175 int m_buttonState; // Which buttons are down?
176 int m_joyStick; // Which joystick?
178 wxJoystickEvent(wxEventType type = wxEVT_NULL,
180 int joystick = wxJOYSTICK1,
183 wxPoint GetPosition() const;
184 int GetZPosition() const;
185 int GetButtonState() const;
186 int GetButtonChange() const;
187 int GetJoystick() const;
189 void SetJoystick(int stick);
190 void SetButtonState(int state);
191 void SetButtonChange(int change);
192 void SetPosition(const wxPoint& pos);
193 void SetZPosition(int zPos);
195 // Was it a button event? (*doesn't* mean: is any button *down*?)
196 bool IsButton() const;
198 // Was it a move event?
201 // Was it a zmove event?
202 bool IsZMove() const;
204 // Was it a down event from button 1, 2, 3, 4 or any?
205 bool ButtonDown(int but = wxJOY_BUTTON_ANY) const;
207 // Was it a up event from button 1, 2, 3 or any?
208 bool ButtonUp(int but = wxJOY_BUTTON_ANY) const;
210 // Was the given button 1,2,3,4 or any in Down state?
211 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const;
216 EVT_JOY_BUTTON_DOWN = wx.PyEventBinder( wxEVT_JOY_BUTTON_DOWN )
217 EVT_JOY_BUTTON_UP = wx.PyEventBinder( wxEVT_JOY_BUTTON_UP )
218 EVT_JOY_MOVE = wx.PyEventBinder( wxEVT_JOY_MOVE )
219 EVT_JOY_ZMOVE = wx.PyEventBinder( wxEVT_JOY_ZMOVE )
221 EVT_JOYSTICK_EVENTS = wx.PyEventBinder([ wxEVT_JOY_BUTTON_DOWN,
229 //---------------------------------------------------------------------------