]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxJoystick.py
2 #----------------------------------------------------------------------------
4 from wxPython
.wx
import *
5 from joystick_wdr
import *
8 class JoystickTestPanel(wxPanel
):
9 def __init__(self
, parent
, id,
10 pos
= wxPyDefaultPosition
, size
= wxPyDefaultSize
,
11 style
= wxTAB_TRAVERSAL
):
12 wxPanel
.__init
__(self
, parent
, id, pos
, size
, style
)
14 MakeJoystickTestPanel( self
, True )
17 self
.stick
= wxJoystick()
18 self
.stick
.SetCapture(self
)
19 EVT_JOYSTICK_EVENTS(self
, self
.OnJoystick
)
21 except NotImplementedError, v
:
22 wxMessageBox(str(v
), "Exception Message")
25 def UpdateFields(self
):
27 self
.GetXPositionCtrl().SetValue(str(s
.GetPosition().x
))
28 self
.GetYPositionCtrl().SetValue(str(s
.GetPosition().y
))
29 self
.GetZPositionCtrl().SetValue(str(s
.GetZPosition()))
30 self
.GetPovCtsPosCtrl().SetValue(str(s
.GetPOVPosition()))
31 self
.GetRudderPosCtrl().SetValue(str(s
.GetRudderPosition()))
32 self
.GetHasRudderCtrl().SetValue(str(s
.HasRudder()))
33 self
.GetHasZCtrl().SetValue(str(s
.HasZ()))
34 self
.GetHasPovCtrl().SetValue(str(s
.HasPOV()))
35 self
.GetHasPov4dirCtrl().SetValue(str(s
.HasPOV4Dir()))
36 self
.GetMfgIdCtrl().SetValue(str(s
.GetManufacturerId()))
37 self
.GetProdNameCtrl().SetValue(str(s
.GetProductName()))
38 self
.GetZMinCtrl().SetValue(str(s
.GetZMin()))
39 self
.GetXMaxCtrl().SetValue(str(s
.GetXMax()))
40 self
.GetNumButtonsCtrl().SetValue(str(s
.GetNumberButtons()))
41 self
.GetNumAxesCtrl().SetValue(str(s
.GetNumberAxes()))
42 self
.GetPollingMinCtrl().SetValue(str(s
.GetPollingMin()))
43 self
.GetPollingMaxCtrl().SetValue(str(s
.GetPollingMax()))
44 self
.GetUMinCtrl().SetValue(str(s
.GetUMin()))
45 self
.GetUMaxCtrl().SetValue(str(s
.GetUMax()))
46 self
.GetButtonStateCtrl().SetValue(str(s
.GetButtonState()))
47 self
.GetPovPositionCtrl().SetValue(str(s
.GetPOVPosition()))
48 self
.GetUPositionCtrl().SetValue(str(s
.GetUPosition()))
49 self
.GetVPositionCtrl().SetValue(str(s
.GetVPosition()))
50 self
.GetHasUCtrl().SetValue(str(s
.HasU()))
51 self
.GetHasVCtrl().SetValue(str(s
.HasV()))
52 self
.GetHasPovCtsCtrl().SetValue(str(s
.HasPOVCTS()))
53 self
.GetNumSticksCtrl().SetValue(str(s
.GetNumberJoysticks()))
54 self
.GetXMinCtrl().SetValue(str(s
.GetXMin()))
55 self
.GetYMinCtrl().SetValue(str(s
.GetYMin()))
56 self
.GetYMaxCtrl().SetValue(str(s
.GetYMax()))
57 self
.GetZMaxCtrl().SetValue(str(s
.GetZMax()))
58 self
.GetMaxButtonsCtrl().SetValue(str(s
.GetMaxButtons()))
59 self
.GetMaxAxesCtrl().SetValue(str(s
.GetMaxAxes()))
60 self
.GetRudderMinCtrl().SetValue(str(s
.GetRudderMin()))
61 self
.GetRudderMaxCtrl().SetValue(str(s
.GetRudderMax()))
62 self
.GetVMinCtrl().SetValue(str(s
.GetVMin()))
63 self
.GetVMaxCtrl().SetValue(str(s
.GetVMax()))
66 def OnJoystick(self
, evt
):
70 # WDR: methods for JoystickTestPanel
72 def GetYPositionCtrl(self
):
73 return self
.FindWindowById(ID_Y_Position_Ctrl
)
75 def GetXPositionCtrl(self
):
76 return self
.FindWindowById(ID_X_Position_Ctrl
)
79 def GetVMaxCtrl(self
):
80 return self
.FindWindowById(ID_V_Max_Ctrl
)
82 def GetVMinCtrl(self
):
83 return self
.FindWindowById(ID_V_Min_Ctrl
)
85 def GetRudderMaxCtrl(self
):
86 return self
.FindWindowById(ID_Rudder_Max_Ctrl
)
88 def GetRudderMinCtrl(self
):
89 return self
.FindWindowById(ID_Rudder_Min_Ctrl
)
91 def GetMaxAxesCtrl(self
):
92 return self
.FindWindowById(ID_Max_Axes_Ctrl
)
94 def GetMaxButtonsCtrl(self
):
95 return self
.FindWindowById(ID_Max_Buttons_Ctrl
)
97 def GetZMaxCtrl(self
):
98 return self
.FindWindowById(ID_Z_Max_Ctrl
)
100 def GetYMaxCtrl(self
):
101 return self
.FindWindowById(ID_Y_Max_Ctrl
)
103 def GetYMinCtrl(self
):
104 return self
.FindWindowById(ID_Y_Min_Ctrl
)
106 def GetXMinCtrl(self
):
107 return self
.FindWindowById(ID_X_Min_Ctrl
)
109 def GetNumSticksCtrl(self
):
110 return self
.FindWindowById(ID_Num_Sticks_Ctrl
)
112 def GetHasPovCtsCtrl(self
):
113 return self
.FindWindowById(ID_Has_POV_CTS_Ctrl
)
115 def GetHasVCtrl(self
):
116 return self
.FindWindowById(ID_Has_V_Ctrl
)
118 def GetHasUCtrl(self
):
119 return self
.FindWindowById(ID_Has_U_Ctrl
)
121 def GetVPositionCtrl(self
):
122 return self
.FindWindowById(ID_V_Position_Ctrl
)
124 def GetUPositionCtrl(self
):
125 return self
.FindWindowById(ID_U_Position_Ctrl
)
127 def GetPovPositionCtrl(self
):
128 return self
.FindWindowById(ID_POV_Position_Ctrl
)
130 def GetButtonStateCtrl(self
):
131 return self
.FindWindowById(ID_Button_State_Ctrl
)
133 def GetUMaxCtrl(self
):
134 return self
.FindWindowById(ID_U_Max_Ctrl
)
136 def GetUMinCtrl(self
):
137 return self
.FindWindowById(ID_U_Min_Ctrl
)
139 def GetPollingMaxCtrl(self
):
140 return self
.FindWindowById(ID_Polling_Max_Ctrl
)
142 def GetPollingMinCtrl(self
):
143 return self
.FindWindowById(ID_Polling_Min_Ctrl
)
145 def GetNumAxesCtrl(self
):
146 return self
.FindWindowById(ID_Num_Axes_Ctrl
)
148 def GetNumButtonsCtrl(self
):
149 return self
.FindWindowById(ID_Num_Buttons_Ctrl
)
151 def GetXMaxCtrl(self
):
152 return self
.FindWindowById(ID_X_Max_Ctrl
)
154 def GetZMinCtrl(self
):
155 return self
.FindWindowById(ID_Z_Min_Ctrl
)
157 def GetProdNameCtrl(self
):
158 return self
.FindWindowById(ID_Prod_Name_Ctrl
)
160 def GetMfgIdCtrl(self
):
161 return self
.FindWindowById(ID_Mfg_ID_Ctrl
)
163 def GetHasPov4dirCtrl(self
):
164 return self
.FindWindowById(ID_Has_POV_4DIR_Ctrl
)
166 def GetHasPovCtrl(self
):
167 return self
.FindWindowById(ID_Has_POV_Ctrl
)
169 def GetHasZCtrl(self
):
170 return self
.FindWindowById(ID_Has_Z_Ctrl
)
172 def GetHasRudderCtrl(self
):
173 return self
.FindWindowById(ID_Has_Rudder_Ctrl
)
175 def GetRudderPosCtrl(self
):
176 return self
.FindWindowById(ID_Rudder_Pos_Ctrl
)
178 def GetPovCtsPosCtrl(self
):
179 return self
.FindWindowById(ID_POV_CTS_Pos_Ctrl
)
181 def GetZPositionCtrl(self
):
182 return self
.FindWindowById(ID_Z_Position_Ctrl
)
184 # WDR: handler implementations for JoysticktestPanel
187 #----------------------------------------------------------------------
189 def runTest(frame
, nb
, log
):
190 win
= JoystickTestPanel(nb
, -1)
193 #----------------------------------------------------------------------
202 if __name__
== '__main__':
205 run
.main(['', os
.path
.basename(sys
.argv
[0])])