ich bin gerade dabei Wii Remote Controller mit Hilfe der Native C++ Lib WiiYourself (http://wiiyourself.gl.tter.org/) mit dem Computer zu verbinden. WiiYourself hat einen Python Wrapper (Verwendung von Swig). Jedoch wurde dieser nur für Python 2.6 geschrieben.
Ich bin nun dabei zu versuchen diesen unter Python 3.2 zu verwenden. Dies habe ich auch geschafft (Konnte den Controller mit dem PC verbinden und die Events auslesen).
Jedoch gab es vorher 2,3 kleiner Probleme bei denen ich mir nicht sicher bin ob mein Workaround keine spätere Auswirkung haben wird.
1)
Code: Alles auswählen
// Python module footer code
%pythoncode %{
__all__ = []
def __cleanup_namespace():
''' Cleanup exported variables, to reduce bloat in the module.
Removes _swigregister functions and undoes the promote-to-global
modification which was applied earlier. '''
class NullClass:
pass
for i in globals().copy():
if i.endswith("_swigregister"):
del globals()[i]
elif '__' in i and not i.startswith('__') and not i.endswith('__'):
# This name was promoted to global scope to help SWIG, as SWIG
# cannot yet handle nested structs. The following code undoes the
# promotion and puts the struct back to the proper place.
path = i.split('__')
# "super-mkdir" for objects
for k in range(1,len(path)):
par = '.'.join(path[:k])
parobj = eval(par)
if not hasattr(parobj,path[k]):
setattr(parobj,path[k],NullClass)
obj = globals()[i]
setattr(parobj,path[k],obj)
obj.__name__ = '.'.join(path)
elif '__' not in i and not i.startswith('_') and i not in ['weakref', 'weakref_proxy']:
__all__.append(i)
__cleanup_namespace()
del __cleanup_namespace
# export arrays from C
wiimote.ButtonNameFromBit = tuple([wiimote.GetButtonNameFromBit(i) for i in range(TOTAL_BUTTON_BITS)])
wiimote.ClassicButtonNameFromBit = tuple([wiimote.GetClassicButtonNameFromBit(i) for i in range(TOTAL_BUTTON_BITS)])
wiimote.FreqLookup = tuple([wiimote.GetFreqLookup(i) for i in range(TOTAL_FREQUENCIES)])
[b]del i[/b]
%}
Code: Alles auswählen
File "C:\Python32\lib\site-packages\wiimote.py", line 1389, in <module>
del i
NameError: name 'i' is not defined
2) Mein 2tes Problem tritt beim Aufruf der Connect-Funktion auf.
Fehlermeldung:
Code: Alles auswählen
Traceback (most recent call last):
File "C:\script\WiiYourself!_1.15\Python\Demo\callbackdemo.py", line 22, in <module>
while not remote.Connect(remote.FIRST_AVAILABLE):
File "C:\Python32\lib\site-packages\wiimote.py", line 1214, in Connect
return _wiimote.wiimote_Connect(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'wiimote_Connect'.
Possible C/C++ prototypes are:
wiimote::Connect(unsigned int,bool)
wiimote::Connect(unsigned int)
wiimote::Connect()
Code: Alles auswählen
1208 def Connect(self, *args):
1209 """
1210 Connect(self, unsigned int wiimote_index = FIRST_AVAILABLE, bool force_hidwrites = False) -> bool
1211 Connect(self, unsigned int wiimote_index = FIRST_AVAILABLE) -> bool
1212 Connect(self) -> bool
1213 """
1214 return _wiimote.wiimote_Connect(self, *args)
Dies fuktioniert zwar, jedoch würde ich gerne verstehen wie das krrekt gelöst wird.
Wäre sehr dankbar wenn hier jemand drüber schauen könnte