]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxJoystick.py
df61d1db1a914543c6f3c377cacacbb949871709
[wxWidgets.git] / wxPython / demo / wxJoystick.py
1
2 #----------------------------------------------------------------------------
3
4 from wxPython.wx import *
5 from joystick_wdr import *
6
7
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)
13
14 MakeJoystickTestPanel( self, true )
15
16 self.stick = wxJoystick()
17 self.stick.SetCapture(self)
18 EVT_JOYSTICK_EVENTS(self, self.OnJoystick)
19
20
21 def UpdateFields(self):
22 s = self.stick
23 self.GetXPositionCtrl().SetValue(str(s.GetPosition().x))
24 self.GetYPositionCtrl().SetValue(str(s.GetPosition().y))
25 self.GetZPositionCtrl().SetValue(str(s.GetZPosition()))
26 self.GetPovCtsPosCtrl().SetValue(str(s.GetPOVPosition()))
27 self.GetRudderPosCtrl().SetValue(str(s.GetRudderPosition()))
28 self.GetHasRudderCtrl().SetValue(str(s.HasRudder()))
29 self.GetHasZCtrl().SetValue(str(s.HasZ()))
30 self.GetHasPovCtrl().SetValue(str(s.HasPOV()))
31 self.GetHasPov4dirCtrl().SetValue(str(s.HasPOV4Dir()))
32 self.GetMfgIdCtrl().SetValue(str(s.GetManufacturerId()))
33 self.GetProdNameCtrl().SetValue(str(s.GetProductName()))
34 self.GetZMinCtrl().SetValue(str(s.GetZMin()))
35 self.GetXMaxCtrl().SetValue(str(s.GetXMax()))
36 self.GetNumButtonsCtrl().SetValue(str(s.GetNumberButtons()))
37 self.GetNumAxesCtrl().SetValue(str(s.GetNumberAxes()))
38 self.GetPollingMinCtrl().SetValue(str(s.GetPollingMin()))
39 self.GetPollingMaxCtrl().SetValue(str(s.GetPollingMax()))
40 self.GetUMinCtrl().SetValue(str(s.GetUMin()))
41 self.GetUMaxCtrl().SetValue(str(s.GetUMax()))
42 self.GetButtonStateCtrl().SetValue(str(s.GetButtonState()))
43 self.GetPovPositionCtrl().SetValue(str(s.GetPOVPosition()))
44 self.GetUPositionCtrl().SetValue(str(s.GetUPosition()))
45 self.GetVPositionCtrl().SetValue(str(s.GetVPosition()))
46 self.GetHasUCtrl().SetValue(str(s.HasU()))
47 self.GetHasVCtrl().SetValue(str(s.HasV()))
48 self.GetHasPovCtsCtrl().SetValue(str(s.HasPOVCTS()))
49 self.GetNumSticksCtrl().SetValue(str(s.GetNumberJoysticks()))
50 self.GetXMinCtrl().SetValue(str(s.GetXMin()))
51 self.GetYMinCtrl().SetValue(str(s.GetYMin()))
52 self.GetYMaxCtrl().SetValue(str(s.GetYMax()))
53 self.GetZMaxCtrl().SetValue(str(s.GetZMax()))
54 self.GetMaxButtonsCtrl().SetValue(str(s.GetMaxButtons()))
55 self.GetMaxAxesCtrl().SetValue(str(s.GetMaxAxes()))
56 self.GetRudderMinCtrl().SetValue(str(s.GetRudderMin()))
57 self.GetRudderMaxCtrl().SetValue(str(s.GetRudderMax()))
58 self.GetVMinCtrl().SetValue(str(s.GetVMin()))
59 self.GetVMaxCtrl().SetValue(str(s.GetVMax()))
60
61
62 def OnJoystick(self, evt):
63 self.UpdateFields()
64
65
66 # WDR: methods for JoystickTestPanel
67
68 def GetYPositionCtrl(self):
69 return wxPyTypeCast( self.FindWindowById(ID_Y_Position_Ctrl), "wxTextCtrl" )
70
71 def GetXPositionCtrl(self):
72 return wxPyTypeCast( self.FindWindowById(ID_X_Position_Ctrl), "wxTextCtrl" )
73
74
75 def GetVMaxCtrl(self):
76 return wxPyTypeCast( self.FindWindowById(ID_V_Max_Ctrl), "wxTextCtrl" )
77
78 def GetVMinCtrl(self):
79 return wxPyTypeCast( self.FindWindowById(ID_V_Min_Ctrl), "wxTextCtrl" )
80
81 def GetRudderMaxCtrl(self):
82 return wxPyTypeCast( self.FindWindowById(ID_Rudder_Max_Ctrl), "wxTextCtrl" )
83
84 def GetRudderMinCtrl(self):
85 return wxPyTypeCast( self.FindWindowById(ID_Rudder_Min_Ctrl), "wxTextCtrl" )
86
87 def GetMaxAxesCtrl(self):
88 return wxPyTypeCast( self.FindWindowById(ID_Max_Axes_Ctrl), "wxTextCtrl" )
89
90 def GetMaxButtonsCtrl(self):
91 return wxPyTypeCast( self.FindWindowById(ID_Max_Buttons_Ctrl), "wxTextCtrl" )
92
93 def GetZMaxCtrl(self):
94 return wxPyTypeCast( self.FindWindowById(ID_Z_Max_Ctrl), "wxTextCtrl" )
95
96 def GetYMaxCtrl(self):
97 return wxPyTypeCast( self.FindWindowById(ID_Y_Max_Ctrl), "wxTextCtrl" )
98
99 def GetYMinCtrl(self):
100 return wxPyTypeCast( self.FindWindowById(ID_Y_Min_Ctrl), "wxTextCtrl" )
101
102 def GetXMinCtrl(self):
103 return wxPyTypeCast( self.FindWindowById(ID_X_Min_Ctrl), "wxTextCtrl" )
104
105 def GetNumSticksCtrl(self):
106 return wxPyTypeCast( self.FindWindowById(ID_Num_Sticks_Ctrl), "wxTextCtrl" )
107
108 def GetHasPovCtsCtrl(self):
109 return wxPyTypeCast( self.FindWindowById(ID_Has_POV_CTS_Ctrl), "wxTextCtrl" )
110
111 def GetHasVCtrl(self):
112 return wxPyTypeCast( self.FindWindowById(ID_Has_V_Ctrl), "wxTextCtrl" )
113
114 def GetHasUCtrl(self):
115 return wxPyTypeCast( self.FindWindowById(ID_Has_U_Ctrl), "wxTextCtrl" )
116
117 def GetVPositionCtrl(self):
118 return wxPyTypeCast( self.FindWindowById(ID_V_Position_Ctrl), "wxTextCtrl" )
119
120 def GetUPositionCtrl(self):
121 return wxPyTypeCast( self.FindWindowById(ID_U_Position_Ctrl), "wxTextCtrl" )
122
123 def GetPovPositionCtrl(self):
124 return wxPyTypeCast( self.FindWindowById(ID_POV_Position_Ctrl), "wxTextCtrl" )
125
126 def GetButtonStateCtrl(self):
127 return wxPyTypeCast( self.FindWindowById(ID_Button_State_Ctrl), "wxTextCtrl" )
128
129 def GetUMaxCtrl(self):
130 return wxPyTypeCast( self.FindWindowById(ID_U_Max_Ctrl), "wxTextCtrl" )
131
132 def GetUMinCtrl(self):
133 return wxPyTypeCast( self.FindWindowById(ID_U_Min_Ctrl), "wxTextCtrl" )
134
135 def GetPollingMaxCtrl(self):
136 return wxPyTypeCast( self.FindWindowById(ID_Polling_Max_Ctrl), "wxTextCtrl" )
137
138 def GetPollingMinCtrl(self):
139 return wxPyTypeCast( self.FindWindowById(ID_Polling_Min_Ctrl), "wxTextCtrl" )
140
141 def GetNumAxesCtrl(self):
142 return wxPyTypeCast( self.FindWindowById(ID_Num_Axes_Ctrl), "wxTextCtrl" )
143
144 def GetNumButtonsCtrl(self):
145 return wxPyTypeCast( self.FindWindowById(ID_Num_Buttons_Ctrl), "wxTextCtrl" )
146
147 def GetXMaxCtrl(self):
148 return wxPyTypeCast( self.FindWindowById(ID_X_Max_Ctrl), "wxTextCtrl" )
149
150 def GetZMinCtrl(self):
151 return wxPyTypeCast( self.FindWindowById(ID_Z_Min_Ctrl), "wxTextCtrl" )
152
153 def GetProdNameCtrl(self):
154 return wxPyTypeCast( self.FindWindowById(ID_Prod_Name_Ctrl), "wxTextCtrl" )
155
156 def GetMfgIdCtrl(self):
157 return wxPyTypeCast( self.FindWindowById(ID_Mfg_ID_Ctrl), "wxTextCtrl" )
158
159 def GetHasPov4dirCtrl(self):
160 return wxPyTypeCast( self.FindWindowById(ID_Has_POV_4DIR_Ctrl), "wxTextCtrl" )
161
162 def GetHasPovCtrl(self):
163 return wxPyTypeCast( self.FindWindowById(ID_Has_POV_Ctrl), "wxTextCtrl" )
164
165 def GetHasZCtrl(self):
166 return wxPyTypeCast( self.FindWindowById(ID_Has_Z_Ctrl), "wxTextCtrl" )
167
168 def GetHasRudderCtrl(self):
169 return wxPyTypeCast( self.FindWindowById(ID_Has_Rudder_Ctrl), "wxTextCtrl" )
170
171 def GetRudderPosCtrl(self):
172 return wxPyTypeCast( self.FindWindowById(ID_Rudder_Pos_Ctrl), "wxTextCtrl" )
173
174 def GetPovCtsPosCtrl(self):
175 return wxPyTypeCast( self.FindWindowById(ID_POV_CTS_Pos_Ctrl), "wxTextCtrl" )
176
177 def GetZPositionCtrl(self):
178 return wxPyTypeCast( self.FindWindowById(ID_Z_Position_Ctrl), "wxTextCtrl" )
179
180 # WDR: handler implementations for JoysticktestPanel
181
182
183 #----------------------------------------------------------------------
184
185 def runTest(frame, nb, log):
186 win = JoystickTestPanel(nb, -1)
187 return win
188
189 #----------------------------------------------------------------------
190
191
192 overview = """\
193 """