X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/05fd1c9e8e20e959f894ecc300ee40232de38377..a2482628795b7de454ef093cb24910c98ad51f1d:/wxPython/demo/Joystick.py diff --git a/wxPython/demo/Joystick.py b/wxPython/demo/Joystick.py index 8704c867d7..219dbd139f 100644 --- a/wxPython/demo/Joystick.py +++ b/wxPython/demo/Joystick.py @@ -5,7 +5,7 @@ # Author: Jeff Grimmett (grimmtoo@softhome.net), adapted from original # .wdr-derived demo # -# Created: 01/02/04 +# Created: 02-Jan-2004 # RCS-ID: $Id$ # Copyright: # Licence: wxWindows license @@ -15,10 +15,14 @@ import math import wx +haveJoystick = True +if wx.Platform == "__WXMAC__": + haveJoystick = False + #---------------------------------------------------------------------------- -# For convenience -spacer = (10, 10) +# Once all supported versions of Python support 32-bit integers on all +# platforms, this can go up to 32. MAX_BUTTONS = 16 #---------------------------------------------------------------------------- @@ -963,8 +967,17 @@ class JoystickDemoPanel(wx.Panel): #---------------------------------------------------------------------------- def runTest(frame, nb, log): - win = JoystickDemoPanel(nb, log) - return win + if haveJoystick: + win = JoystickDemoPanel(nb, log) + return win + else: + dlg = wx.MessageDialog( + frame, 'wx.Joystick is not available on this platform.', + 'Sorry', wx.OK | wx.ICON_INFORMATION + ) + dlg.ShowModal() + dlg.Destroy() + #---------------------------------------------------------------------------- @@ -1002,8 +1015,8 @@ general, this data can be read once and stored to speed computation up. Analog input (the axes) is delivered as a whole, positive number. If you need to know if the axis is at zero (centered) or not, you will first have to calculate that center based on the max and min values. The demo shows a bar graph for each axis expressed -in native numerical format, plus a 'centered' X-Y axis compas showing the relationship -of that input to the calculcated stick position. +in native numerical format, plus a 'centered' X-Y axis compass showing the relationship +of that input to the calculated stick position. Analog input may be jumpy and spurious, so the control has a means of 'smoothing' the analog data by setting a movement threshold. This demo sets the threshold to 10, but @@ -1034,8 +1047,8 @@ values over 30. For that reason, this demo is limited to 16 buttons. POV hats come in two flavors: four-way, and continuous. four-way POVs are restricted to the cardinal points of the compass; continuous, or CTS POV hats can deliver input in .01 degree increments, theoreticaly. The data is returned as a whole number; the last -two digits are to the right of the decimal point, so in order to use this information, -you need to divide by 100 right off the bat. +two digits are considered to be to the right of the decimal point, so in order to +use this information, you need to divide by 100 right off the bat.
Different methods are provided to retrieve the POV data for a CTS hat versus a four-way hat. @@ -1070,4 +1083,4 @@ needed, then re-start the timer, possibly using wx.CallAfter(). if __name__ == '__main__': import sys,os import run - run.main(['', os.path.basename(sys.argv[0])]) + run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])