]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_joystick.i
wx.App
[wxWidgets.git] / wxPython / src / _joystick.i
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.
28 enum
29 {
30 wxJOYSTICK1,
31 wxJOYSTICK2
32 };
33
34 // Which button is down?
35 enum
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.
48 class wxJoystick : public wxObject {
49 public:
50 wxJoystick(int joystick = wxJOYSTICK1) {
51 wxPyBeginBlockThreads();
52 PyErr_SetString(PyExc_NotImplementedError,
53 "wxJoystick is not available on this platform.");
54 wxPyEndBlockThreads();
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
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 ""; }
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
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; }
98
99 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return False; }
100 bool ReleaseCapture() { return False; }
101 };
102 #endif
103 %}
104
105
106 class wxJoystick /* : public wxObject */
107 {
108 public:
109 wxJoystick(int joystick = wxJOYSTICK1);
110 ~wxJoystick();
111
112 wxPoint GetPosition();
113 int GetZPosition();
114 int GetButtonState();
115 int GetPOVPosition();
116 int GetPOVCTSPosition();
117 int GetRudderPosition();
118 int GetUPosition();
119 int GetVPosition();
120 int GetMovementThreshold();
121 void SetMovementThreshold(int threshold) ;
122
123 bool IsOk(void);
124 int GetNumberJoysticks();
125 int GetManufacturerId();
126 int GetProductId();
127 wxString GetProductName();
128 int GetXMin();
129 int GetYMin();
130 int GetZMin();
131 int GetXMax();
132 int GetYMax();
133 int GetZMax();
134 int GetNumberButtons();
135 int GetNumberAxes();
136 int GetMaxButtons();
137 int GetMaxAxes();
138 int GetPollingMin();
139 int GetPollingMax();
140 int GetRudderMin();
141 int GetRudderMax();
142 int GetUMin();
143 int GetUMax();
144 int GetVMin();
145 int GetVMax();
146
147 bool HasRudder();
148 bool HasZ();
149 bool HasU();
150 bool HasV();
151 bool HasPOV();
152 bool HasPOV4Dir();
153 bool HasPOVCTS();
154
155 bool SetCapture(wxWindow* win, int pollingFreq = 0);
156 bool ReleaseCapture();
157
158 %pythoncode { def __nonzero__(self): return self.IsOk() }
159 };
160
161
162 //---------------------------------------------------------------------------
163
164 %constant wxEventType wxEVT_JOY_BUTTON_DOWN;
165 %constant wxEventType wxEVT_JOY_BUTTON_UP;
166 %constant wxEventType wxEVT_JOY_MOVE;
167 %constant wxEventType wxEVT_JOY_ZMOVE;
168
169
170 class wxJoystickEvent : public wxEvent
171 {
172 public:
173 wxPoint m_pos;
174 int m_zPosition;
175 int m_buttonChange; // Which button changed?
176 int m_buttonState; // Which buttons are down?
177 int m_joyStick; // Which joystick?
178
179 wxJoystickEvent(wxEventType type = wxEVT_NULL,
180 int state = 0,
181 int joystick = wxJOYSTICK1,
182 int change = 0);
183
184 wxPoint GetPosition() const;
185 int GetZPosition() const;
186 int GetButtonState() const;
187 int GetButtonChange() const;
188 int GetJoystick() const;
189
190 void SetJoystick(int stick);
191 void SetButtonState(int state);
192 void SetButtonChange(int change);
193 void SetPosition(const wxPoint& pos);
194 void SetZPosition(int zPos);
195
196 // Was it a button event? (*doesn't* mean: is any button *down*?)
197 bool IsButton() const;
198
199 // Was it a move event?
200 bool IsMove() const;
201
202 // Was it a zmove event?
203 bool IsZMove() const;
204
205 // Was it a down event from button 1, 2, 3, 4 or any?
206 bool ButtonDown(int but = wxJOY_BUTTON_ANY) const;
207
208 // Was it a up event from button 1, 2, 3 or any?
209 bool ButtonUp(int but = wxJOY_BUTTON_ANY) const;
210
211 // Was the given button 1,2,3,4 or any in Down state?
212 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const;
213 };
214
215
216 %pythoncode {
217 EVT_JOY_BUTTON_DOWN = wx.PyEventBinder( wxEVT_JOY_BUTTON_DOWN )
218 EVT_JOY_BUTTON_UP = wx.PyEventBinder( wxEVT_JOY_BUTTON_UP )
219 EVT_JOY_MOVE = wx.PyEventBinder( wxEVT_JOY_MOVE )
220 EVT_JOY_ZMOVE = wx.PyEventBinder( wxEVT_JOY_ZMOVE )
221
222 EVT_JOYSTICK_EVENTS = wx.PyEventBinder([ wxEVT_JOY_BUTTON_DOWN,
223 wxEVT_JOY_BUTTON_UP,
224 wxEVT_JOY_MOVE,
225 wxEVT_JOY_ZMOVE,
226 ])
227
228 }
229
230 //---------------------------------------------------------------------------