Add wx.adv.Joystick

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-05-22 00:17:14 +00:00
parent 276acdab9a
commit 48d5c078f0
5 changed files with 163 additions and 2 deletions

View File

@@ -126,7 +126,6 @@ other dev stuff
* axbase (ActiveX. Need to figure out best ways to do MSW-only items...)
* check that all items in _functions.i and _misc.i have been wrapped
* joystick
* PseudoDC
* Add wxCHMHelpController (MSW-only)

View File

@@ -35,6 +35,7 @@ INCLUDES = [
'tipdlg',
'taskbar',
'sound',
'joystick',
# TODOs -
@@ -44,7 +45,6 @@ INCLUDES = [
#'bannerwindow',
#'bmpcbox',
#'editlbox',
#'joystick',
#'laywin',
#'notifmsg',
#'odcombo',

109
etg/joystick.py Normal file
View File

@@ -0,0 +1,109 @@
#---------------------------------------------------------------------------
# Name: etg/joystick.py
# Author: Robin Dunn
#
# Created: 19-May-2012
# Copyright: (c) 2012 by Total Control Software
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_adv"
NAME = "joystick" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ "wxJoystick",
]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
module.addHeaderCode("""\
#if !wxUSE_JOYSTICK && !defined(__WXMSW__)
// A C++ stub class for wxJoystick for platforms that don't have it.
class wxJoystick : public wxObject {
public:
wxJoystick(int joystick = wxJOYSTICK1) {
wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyErr_SetString(PyExc_NotImplementedError,
"wxJoystick is not available on this platform.");
wxPyEndBlockThreads(blocked);
}
wxPoint GetPosition() const { return wxPoint(-1,-1); }
int GetPosition(unsigned axis) const { return -1; }
int GetZPosition() const { return -1; }
int GetButtonState() const { return -1; }
int GetButtonState(unsigned button) const { return -1; }
int GetPOVPosition() const { return -1; }
int GetPOVCTSPosition() const { return -1; }
int GetRudderPosition() const { return -1; }
int GetUPosition() const { return -1; }
int GetVPosition() const { return -1; }
int GetMovementThreshold() const { return -1; }
void SetMovementThreshold(int threshold) {}
bool IsOk(void) const { return false; }
static int GetNumberJoysticks() { return -1; }
int GetManufacturerId() const { return -1; }
int GetProductId() const { return -1; }
wxString GetProductName() const { return wxEmptyString; }
int GetXMin() const { return -1; }
int GetYMin() const { return -1; }
int GetZMin() const { return -1; }
int GetXMax() const { return -1; }
int GetYMax() const { return -1; }
int GetZMax() const { return -1; }
int GetNumberButtons() const { return -1; }
int GetNumberAxes() const { return -1; }
int GetMaxButtons() const { return -1; }
int GetMaxAxes() const { return -1; }
int GetPollingMin() const { return -1; }
int GetPollingMax() const { return -1; }
int GetRudderMin() const { return -1; }
int GetRudderMax() const { return -1; }
int GetUMin() const { return -1; }
int GetUMax() const { return -1; }
int GetVMin() const { return -1; }
int GetVMax() const { return -1; }
bool HasRudder() const { return false; }
bool HasZ() const { return false; }
bool HasU() const { return false; }
bool HasV() const { return false; }
bool HasPOV() const { return false; }
bool HasPOV4Dir() const { return false; }
bool HasPOVCTS() const { return false; }
bool SetCapture(wxWindow* win, int pollingFreq = 0) { return false; }
bool ReleaseCapture() { return false; }
};
#endif
""")
#c = module.find('')
#assert isinstance(c, etgtools.ClassDef)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -204,3 +204,13 @@ EVT_TEXT_PASTE = wx.PyEventBinder( wxEVT_COMMAND_TEXT_PASTE )
EVT_THREAD = wx.PyEventBinder( wxEVT_THREAD )
EVT_WINDOW_MODAL_DIALOG_CLOSED = wx.PyEventBinder( wxEVT_WINDOW_MODAL_DIALOG_CLOSED )
EVT_JOY_BUTTON_DOWN = wx.PyEventBinder( wxEVT_JOY_BUTTON_DOWN )
EVT_JOY_BUTTON_UP = wx.PyEventBinder( wxEVT_JOY_BUTTON_UP )
EVT_JOY_MOVE = wx.PyEventBinder( wxEVT_JOY_MOVE )
EVT_JOY_ZMOVE = wx.PyEventBinder( wxEVT_JOY_ZMOVE )
EVT_JOYSTICK_EVENTS = wx.PyEventBinder([ wxEVT_JOY_BUTTON_DOWN,
wxEVT_JOY_BUTTON_UP,
wxEVT_JOY_MOVE,
wxEVT_JOY_ZMOVE,
])

View File

@@ -0,0 +1,43 @@
import imp_unittest, unittest
import wtc
import wx
import wx.adv
#---------------------------------------------------------------------------
class joystick_Tests(wtc.WidgetTestCase):
def test_joystick1(self):
wx.JOYSTICK1
wx.JOYSTICK2
wx.JOY_BUTTON_ANY
wx.JOY_BUTTON1
wx.JOY_BUTTON2
wx.JOY_BUTTON3
wx.JOY_BUTTON4
wx.wxEVT_JOY_BUTTON_DOWN
wx.wxEVT_JOY_BUTTON_UP
wx.wxEVT_JOY_MOVE
wx.wxEVT_JOY_ZMOVE
wx.EVT_JOY_BUTTON_DOWN
wx.EVT_JOY_BUTTON_UP
wx.EVT_JOY_MOVE
wx.EVT_JOY_ZMOVE
wx.EVT_JOYSTICK_EVENTS
def test_joystick2(self):
# Creating a Joystick object should fail on Mac. Currently it isn't...
if 'wxMac' in wx.PlatformInfo:
with self.assertRaises(NotImplementedError):
j = wx.adv.Joystick()
else:
j = wx.adv.Joystick()
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()