]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_joystick.i
ensure that the MasedEditMixin's version of IsEmpty is the one used.
[wxWidgets.git] / wxPython / src / _joystick.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _joystick.i
3// Purpose: SWIG interface stuff for wxJoystick
4//
5// Author: Robin Dunn
6//
7// Created: 18-June-1999
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19%{
20#include <wx/joystick.h>
21%}
22
23//---------------------------------------------------------------------------
24
25
26
27// Which joystick? Same as Windows ids so no conversion necessary.
28enum
29{
30 wxJOYSTICK1,
31 wxJOYSTICK2
32};
33
34// Which button is down?
35enum
36{
37 wxJOY_BUTTON_ANY,
38 wxJOY_BUTTON1,
39 wxJOY_BUTTON2,
40 wxJOY_BUTTON3,
41 wxJOY_BUTTON4,
42};
43
44
45%{
46#if !wxUSE_JOYSTICK && !defined(__WXMSW__)
47// A C++ stub class for wxJoystick for platforms that don't have it.
48class wxJoystick : public wxObject {
49public:
50 wxJoystick(int joystick = wxJOYSTICK1) {
6e6b3557 51 wxPyBlock_t blocked = wxPyBeginBlockThreads();
81cfe5e1
RD
52 PyErr_SetString(PyExc_NotImplementedError,
53 "wxJoystick is not available on this platform.");
da32eb53 54 wxPyEndBlockThreads(blocked);
d14a1e28
RD
55 }
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) {}
66
a72f4631 67 bool IsOk(void) { return false; }
d14a1e28
RD
68 int GetNumberJoysticks() { return -1; }
69 int GetManufacturerId() { return -1; }
70 int GetProductId() { return -1; }
ecd216fc 71 wxString GetProductName() { return wxEmptyString; }
d14a1e28
RD
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; }
90
a72f4631
RD
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; }
d14a1e28 98
a72f4631
RD
99 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return false; }
100 bool ReleaseCapture() { return false; }
d14a1e28
RD
101};
102#endif
103%}
104
105
ab1f7d2a
RD
106MustHaveApp(wxJoystick);
107
d14a1e28
RD
108class wxJoystick /* : public wxObject */
109{
110public:
111 wxJoystick(int joystick = wxJOYSTICK1);
112 ~wxJoystick();
113
114 wxPoint GetPosition();
115 int GetZPosition();
116 int GetButtonState();
117 int GetPOVPosition();
118 int GetPOVCTSPosition();
119 int GetRudderPosition();
120 int GetUPosition();
121 int GetVPosition();
122 int GetMovementThreshold();
123 void SetMovementThreshold(int threshold) ;
124
125 bool IsOk(void);
126 int GetNumberJoysticks();
127 int GetManufacturerId();
128 int GetProductId();
129 wxString GetProductName();
130 int GetXMin();
131 int GetYMin();
132 int GetZMin();
133 int GetXMax();
134 int GetYMax();
135 int GetZMax();
136 int GetNumberButtons();
137 int GetNumberAxes();
138 int GetMaxButtons();
139 int GetMaxAxes();
140 int GetPollingMin();
141 int GetPollingMax();
142 int GetRudderMin();
143 int GetRudderMax();
144 int GetUMin();
145 int GetUMax();
146 int GetVMin();
147 int GetVMax();
148
149 bool HasRudder();
150 bool HasZ();
151 bool HasU();
152 bool HasV();
153 bool HasPOV();
154 bool HasPOV4Dir();
155 bool HasPOVCTS();
156
157 bool SetCapture(wxWindow* win, int pollingFreq = 0);
158 bool ReleaseCapture();
159
160 %pythoncode { def __nonzero__(self): return self.IsOk() }
76b8fa1d
RD
161
162 %property(ButtonState, GetButtonState, doc="See `GetButtonState`");
163 %property(ManufacturerId, GetManufacturerId, doc="See `GetManufacturerId`");
164 %property(MaxAxes, GetMaxAxes, doc="See `GetMaxAxes`");
165 %property(MaxButtons, GetMaxButtons, doc="See `GetMaxButtons`");
166 %property(MovementThreshold, GetMovementThreshold, SetMovementThreshold, doc="See `GetMovementThreshold` and `SetMovementThreshold`");
167 %property(NumberAxes, GetNumberAxes, doc="See `GetNumberAxes`");
168 %property(NumberButtons, GetNumberButtons, doc="See `GetNumberButtons`");
169 %property(NumberJoysticks, GetNumberJoysticks, doc="See `GetNumberJoysticks`");
170 %property(POVCTSPosition, GetPOVCTSPosition, doc="See `GetPOVCTSPosition`");
171 %property(POVPosition, GetPOVPosition, doc="See `GetPOVPosition`");
172 %property(PollingMax, GetPollingMax, doc="See `GetPollingMax`");
173 %property(PollingMin, GetPollingMin, doc="See `GetPollingMin`");
174 %property(Position, GetPosition, doc="See `GetPosition`");
175 %property(ProductId, GetProductId, doc="See `GetProductId`");
176 %property(ProductName, GetProductName, doc="See `GetProductName`");
177 %property(RudderMax, GetRudderMax, doc="See `GetRudderMax`");
178 %property(RudderMin, GetRudderMin, doc="See `GetRudderMin`");
179 %property(RudderPosition, GetRudderPosition, doc="See `GetRudderPosition`");
180 %property(UMax, GetUMax, doc="See `GetUMax`");
181 %property(UMin, GetUMin, doc="See `GetUMin`");
182 %property(UPosition, GetUPosition, doc="See `GetUPosition`");
183 %property(VMax, GetVMax, doc="See `GetVMax`");
184 %property(VMin, GetVMin, doc="See `GetVMin`");
185 %property(VPosition, GetVPosition, doc="See `GetVPosition`");
186 %property(XMax, GetXMax, doc="See `GetXMax`");
187 %property(XMin, GetXMin, doc="See `GetXMin`");
188 %property(YMax, GetYMax, doc="See `GetYMax`");
189 %property(YMin, GetYMin, doc="See `GetYMin`");
190 %property(ZMax, GetZMax, doc="See `GetZMax`");
191 %property(ZMin, GetZMin, doc="See `GetZMin`");
192 %property(ZPosition, GetZPosition, doc="See `GetZPosition`");
d14a1e28
RD
193};
194
195
196//---------------------------------------------------------------------------
197
198%constant wxEventType wxEVT_JOY_BUTTON_DOWN;
199%constant wxEventType wxEVT_JOY_BUTTON_UP;
200%constant wxEventType wxEVT_JOY_MOVE;
201%constant wxEventType wxEVT_JOY_ZMOVE;
202
203
204class wxJoystickEvent : public wxEvent
205{
206public:
d14a1e28
RD
207 wxJoystickEvent(wxEventType type = wxEVT_NULL,
208 int state = 0,
209 int joystick = wxJOYSTICK1,
210 int change = 0);
211
212 wxPoint GetPosition() const;
213 int GetZPosition() const;
214 int GetButtonState() const;
215 int GetButtonChange() const;
216 int GetJoystick() const;
217
218 void SetJoystick(int stick);
219 void SetButtonState(int state);
220 void SetButtonChange(int change);
221 void SetPosition(const wxPoint& pos);
222 void SetZPosition(int zPos);
223
224 // Was it a button event? (*doesn't* mean: is any button *down*?)
225 bool IsButton() const;
226
227 // Was it a move event?
228 bool IsMove() const;
229
230 // Was it a zmove event?
231 bool IsZMove() const;
232
233 // Was it a down event from button 1, 2, 3, 4 or any?
234 bool ButtonDown(int but = wxJOY_BUTTON_ANY) const;
235
236 // Was it a up event from button 1, 2, 3 or any?
237 bool ButtonUp(int but = wxJOY_BUTTON_ANY) const;
238
239 // Was the given button 1,2,3,4 or any in Down state?
240 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const;
aeee37c3
RD
241
242 %pythoncode {
243 m_pos = property(GetPosition, SetPosition)
244 m_zPosition = property(GetZPosition, SetZPosition)
245 m_buttonChange = property(GetButtonChange, SetButtonChange)
246 m_buttonState = property(GetButtonState, SetButtonState)
247 m_joyStick = property(GetJoystick, SetJoystick)
248 }
76b8fa1d
RD
249
250 %property(ButtonChange, GetButtonChange, SetButtonChange, doc="See `GetButtonChange` and `SetButtonChange`");
251 %property(ButtonState, GetButtonState, SetButtonState, doc="See `GetButtonState` and `SetButtonState`");
252 %property(Joystick, GetJoystick, SetJoystick, doc="See `GetJoystick` and `SetJoystick`");
253 %property(Position, GetPosition, SetPosition, doc="See `GetPosition` and `SetPosition`");
254 %property(ZPosition, GetZPosition, SetZPosition, doc="See `GetZPosition` and `SetZPosition`");
d14a1e28
RD
255};
256
257
258%pythoncode {
259EVT_JOY_BUTTON_DOWN = wx.PyEventBinder( wxEVT_JOY_BUTTON_DOWN )
260EVT_JOY_BUTTON_UP = wx.PyEventBinder( wxEVT_JOY_BUTTON_UP )
261EVT_JOY_MOVE = wx.PyEventBinder( wxEVT_JOY_MOVE )
262EVT_JOY_ZMOVE = wx.PyEventBinder( wxEVT_JOY_ZMOVE )
263
264EVT_JOYSTICK_EVENTS = wx.PyEventBinder([ wxEVT_JOY_BUTTON_DOWN,
265 wxEVT_JOY_BUTTON_UP,
266 wxEVT_JOY_MOVE,
267 wxEVT_JOY_ZMOVE,
268 ])
269
270}
271
272//---------------------------------------------------------------------------