]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxJoystick.py
df61d1db1a914543c6f3c377cacacbb949871709
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
)
16 self
.stick
= wxJoystick()
17 self
.stick
.SetCapture(self
)
18 EVT_JOYSTICK_EVENTS(self
, self
.OnJoystick
)
21 def UpdateFields(self
):
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()))
62 def OnJoystick(self
, evt
):
66 # WDR: methods for JoystickTestPanel
68 def GetYPositionCtrl(self
):
69 return wxPyTypeCast( self
.FindWindowById(ID_Y_Position_Ctrl
), "wxTextCtrl" )
71 def GetXPositionCtrl(self
):
72 return wxPyTypeCast( self
.FindWindowById(ID_X_Position_Ctrl
), "wxTextCtrl" )
75 def GetVMaxCtrl(self
):
76 return wxPyTypeCast( self
.FindWindowById(ID_V_Max_Ctrl
), "wxTextCtrl" )
78 def GetVMinCtrl(self
):
79 return wxPyTypeCast( self
.FindWindowById(ID_V_Min_Ctrl
), "wxTextCtrl" )
81 def GetRudderMaxCtrl(self
):
82 return wxPyTypeCast( self
.FindWindowById(ID_Rudder_Max_Ctrl
), "wxTextCtrl" )
84 def GetRudderMinCtrl(self
):
85 return wxPyTypeCast( self
.FindWindowById(ID_Rudder_Min_Ctrl
), "wxTextCtrl" )
87 def GetMaxAxesCtrl(self
):
88 return wxPyTypeCast( self
.FindWindowById(ID_Max_Axes_Ctrl
), "wxTextCtrl" )
90 def GetMaxButtonsCtrl(self
):
91 return wxPyTypeCast( self
.FindWindowById(ID_Max_Buttons_Ctrl
), "wxTextCtrl" )
93 def GetZMaxCtrl(self
):
94 return wxPyTypeCast( self
.FindWindowById(ID_Z_Max_Ctrl
), "wxTextCtrl" )
96 def GetYMaxCtrl(self
):
97 return wxPyTypeCast( self
.FindWindowById(ID_Y_Max_Ctrl
), "wxTextCtrl" )
99 def GetYMinCtrl(self
):
100 return wxPyTypeCast( self
.FindWindowById(ID_Y_Min_Ctrl
), "wxTextCtrl" )
102 def GetXMinCtrl(self
):
103 return wxPyTypeCast( self
.FindWindowById(ID_X_Min_Ctrl
), "wxTextCtrl" )
105 def GetNumSticksCtrl(self
):
106 return wxPyTypeCast( self
.FindWindowById(ID_Num_Sticks_Ctrl
), "wxTextCtrl" )
108 def GetHasPovCtsCtrl(self
):
109 return wxPyTypeCast( self
.FindWindowById(ID_Has_POV_CTS_Ctrl
), "wxTextCtrl" )
111 def GetHasVCtrl(self
):
112 return wxPyTypeCast( self
.FindWindowById(ID_Has_V_Ctrl
), "wxTextCtrl" )
114 def GetHasUCtrl(self
):
115 return wxPyTypeCast( self
.FindWindowById(ID_Has_U_Ctrl
), "wxTextCtrl" )
117 def GetVPositionCtrl(self
):
118 return wxPyTypeCast( self
.FindWindowById(ID_V_Position_Ctrl
), "wxTextCtrl" )
120 def GetUPositionCtrl(self
):
121 return wxPyTypeCast( self
.FindWindowById(ID_U_Position_Ctrl
), "wxTextCtrl" )
123 def GetPovPositionCtrl(self
):
124 return wxPyTypeCast( self
.FindWindowById(ID_POV_Position_Ctrl
), "wxTextCtrl" )
126 def GetButtonStateCtrl(self
):
127 return wxPyTypeCast( self
.FindWindowById(ID_Button_State_Ctrl
), "wxTextCtrl" )
129 def GetUMaxCtrl(self
):
130 return wxPyTypeCast( self
.FindWindowById(ID_U_Max_Ctrl
), "wxTextCtrl" )
132 def GetUMinCtrl(self
):
133 return wxPyTypeCast( self
.FindWindowById(ID_U_Min_Ctrl
), "wxTextCtrl" )
135 def GetPollingMaxCtrl(self
):
136 return wxPyTypeCast( self
.FindWindowById(ID_Polling_Max_Ctrl
), "wxTextCtrl" )
138 def GetPollingMinCtrl(self
):
139 return wxPyTypeCast( self
.FindWindowById(ID_Polling_Min_Ctrl
), "wxTextCtrl" )
141 def GetNumAxesCtrl(self
):
142 return wxPyTypeCast( self
.FindWindowById(ID_Num_Axes_Ctrl
), "wxTextCtrl" )
144 def GetNumButtonsCtrl(self
):
145 return wxPyTypeCast( self
.FindWindowById(ID_Num_Buttons_Ctrl
), "wxTextCtrl" )
147 def GetXMaxCtrl(self
):
148 return wxPyTypeCast( self
.FindWindowById(ID_X_Max_Ctrl
), "wxTextCtrl" )
150 def GetZMinCtrl(self
):
151 return wxPyTypeCast( self
.FindWindowById(ID_Z_Min_Ctrl
), "wxTextCtrl" )
153 def GetProdNameCtrl(self
):
154 return wxPyTypeCast( self
.FindWindowById(ID_Prod_Name_Ctrl
), "wxTextCtrl" )
156 def GetMfgIdCtrl(self
):
157 return wxPyTypeCast( self
.FindWindowById(ID_Mfg_ID_Ctrl
), "wxTextCtrl" )
159 def GetHasPov4dirCtrl(self
):
160 return wxPyTypeCast( self
.FindWindowById(ID_Has_POV_4DIR_Ctrl
), "wxTextCtrl" )
162 def GetHasPovCtrl(self
):
163 return wxPyTypeCast( self
.FindWindowById(ID_Has_POV_Ctrl
), "wxTextCtrl" )
165 def GetHasZCtrl(self
):
166 return wxPyTypeCast( self
.FindWindowById(ID_Has_Z_Ctrl
), "wxTextCtrl" )
168 def GetHasRudderCtrl(self
):
169 return wxPyTypeCast( self
.FindWindowById(ID_Has_Rudder_Ctrl
), "wxTextCtrl" )
171 def GetRudderPosCtrl(self
):
172 return wxPyTypeCast( self
.FindWindowById(ID_Rudder_Pos_Ctrl
), "wxTextCtrl" )
174 def GetPovCtsPosCtrl(self
):
175 return wxPyTypeCast( self
.FindWindowById(ID_POV_CTS_Pos_Ctrl
), "wxTextCtrl" )
177 def GetZPositionCtrl(self
):
178 return wxPyTypeCast( self
.FindWindowById(ID_Z_Position_Ctrl
), "wxTextCtrl" )
180 # WDR: handler implementations for JoysticktestPanel
183 #----------------------------------------------------------------------
185 def runTest(frame
, nb
, log
):
186 win
= JoystickTestPanel(nb
, -1)
189 #----------------------------------------------------------------------