> -----Ursprüngliche Nachricht----- > Von: "Thomas Heller" <[EMAIL PROTECTED]> > Gesendet: 25.09.08 21:30:30 > An: comtypes-users@lists.sourceforge.net > Betreff: Re: [comtypes-users] Events for device not working since version > 0.3.2 > > Malte Skarupke schrieb: > > I'm trying to get the 3D Space Navigator > > (http://www.3dconnexion.com/) to work in Python. I quickly found a > > solution using comtypes on the 3DConnexion developer forum: > > http://www.3dconnexion.com/forum/viewtopic.php?t=984&start=30 > > > > However that solution only works with comtypes version 0.2.1. Any > > newer version will result in the events not registering. > > I've looked up the thread in the forum. A user codenamed 'kitsu' wrote: > > Note that there is a error in the comtypes 0.3.2 GetEvents function which > causes it to miss all events. I've reported it to the mailing list, but > until it is fixed use comtypes 0.2.1. > > I have not found the 'report' he mentions on the mailing list. > Dois the code snippet that he posted here > http://www.3dconnexion.com/forum/viewtopic.php?t=984&start=33 > work with comtypes 0.2.1, and not with later comtypes? >
The code from the forum works with version 0.2.1, but not with 0.3.2 or any newer version. I have copied the output of the code for both version 0.2.1 and 0.5.2 to the end of this mail. I think the 'report' he mentions is this: http://sourceforge.net/mailarchive/forum.php?thread_name=302672.78110.qm%40web50206.mail.re2.yahoo.com&forum_name=comtypes-users > > I believe, that this is enough output, because I believe the line > > "DEBUG:comtypes:Release <POINTER(ISensor) ptr=0x9f2170 at c14d50>" > > shows, where the bug originates. If you need any further testing, I > > would be glad to help. > > Why do you think this? What does it tell you? > If you compare the output from 0.2.1 and 0.5.2 (see below), you will notice, that in version 0.2.1 it stops at "DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at 0x01380310>.AddRef() -> 1", but in version 0.5.2 it continues for a couple of lines, doing garbage collection. (at least I assume that that's what it's doing) And the line that I mentioned above is the first of the lines that are added in version 0.5.2. Maybe some reference went missing during the refactoring between version 0.2.1 and 0.3.2, and that now prompts the garbage collector. But this is really weird, because when testing the GetEvents method with something other than this device, (in this case Internet Explorer) it still works. Here is the output of the code from the forum for version 0.2.1: C:\3DConnexion\Python Test>python read_ctypes.py DEBUG:comtypes.client:TDxInput.Device -> {82C5AB54-C92C-4D52-AAC5-27E25E22604C} DEBUG:comtypes.client:CoCreateInstance({82C5AB54-C92C-4D52-AAC5-27E25E22604C}, clsctx=None, interface=None) INFO:comtypes.client:wrap(<POINTER(IUnknown) object c07990>) INFO:comtypes.client:Does implement IProvideClassInfo # Generating comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0 # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0 # Generating comtypes.gen.stdole # Generating comtypes.gen.TDxInput INFO:comtypes.client:Implements default interface from typeinfo <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0.ISimpleDevice'> INFO:comtypes.client:Final result is <POINTER(ISimpleDevice) object c07bc0> SpaceNavigator : Connected! INFO:comtypes.client:wrap_outparam(<POINTER(IKeyboard) object c07990>) DEBUG:comtypes.client:<POINTER(IKeyboard) object c07990> using sinkinterface <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._IKeyboardEvents'> DEBUG:comtypes.client:Start advise <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._IKeyboardEvents'> DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at 0x013D34D0>.QueryInterface({6B6BB0A8-4491-40CF-B1A9-C15A801FE151}) -> S_OK DEBUG:comtypes._comobject:1 active COM objects: Added <comtypes.client.DispEventReceiver object at 0x013D34D0> DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at 0x013D34D0>.AddRef() -> 1 INFO:comtypes.client:wrap_outparam(<POINTER(ISensor) object c07f80>) DEBUG:comtypes.client:<POINTER(ISensor) object c07f80> using sinkinterface <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._ISensorEvents'> DEBUG:comtypes.client:Start advise <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._ISensorEvents'> DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at 0x01380310>.QueryInterface({E6929A4A-6F41-46C6-9252-A8CC53472CB1}) -> S_OK DEBUG:comtypes._comobject:2 active COM objects: Added <comtypes.client.DispEventReceiver object at 0x01380310> DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at 0x01380310>.AddRef() -> 1 When I move the device at this point, I get lots of output like this: Buttonpress: WARNING:comtypes._comobject:<class 'comtypes.automation.IDispatch'> Traceback (most recent call last): File "C:\Python25\Lib\site-packages\comtypes\_comobject.py", line 35, in func return mth(*args, **kw) File "C:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 382, in IDispatch_Invoke self.dispmap[memid](None, *args[::-1]) File "read_ctypes.py", line 65, in KeyDown print 'Keydown: %s, %s' %(code, self.keyboard.GetKeyName(code)) COMError: (-2147467259, 'Unbekannter Fehler', (None, None, None, 0, None)) WARNING:comtypes._comobject:<class 'comtypes.automation.IDispatch'> Traceback (most recent call last): File "C:\Python25\Lib\site-packages\comtypes\_comobject.py", line 35, in func return mth(*args, **kw) File "C:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 382, in IDispatch_Invoke self.dispmap[memid](None, *args[::-1]) File "read_ctypes.py", line 70, in KeyUp print 'Keyup: %s, %s' %(code, self.keyboard.GetKeyName(code)) COMError: (-2147467259, 'Unbekannter Fehler', (None, None, None, 0, None)) This error is probably not comtypes related, - it is likely just a bug in the code from the forum. But it shows, that the method that should execute is executed. Sensor Event: Rot: INFO:comtypes.client:wrap_outparam(<POINTER(IAngleAxis) object c2be40>) 0.0INFO:comtypes.client:wrap_outparam(<POINTER(IAngleAxis) object c2be40>) 0.0INFO:comtypes.client:wrap_outparam(<POINTER(IAngleAxis) object c2be40>) 0.0 Trans: INFO:comtypes.client:wrap_outparam(<POINTER(IVector3D) object c2be40>) 10.41875INFO:comtypes.client:wrap_outparam(<POINTER(IVector3D) object c2be40>) -2.08375INFO:comtypes.client:wrap_outparam(<POINTER(IVector3D) object c2be40>) -11.460625 So here we see, that the code works correctly. Here I moved the device. (so the trans-values are changed) Rotation works fine, too. And here is the output for version 0.5.2 C:\3DConnexion\Python Test>python read_ctypes.py DEBUG:comtypes.client:TDxInput.Device -> {82C5AB54-C92C-4D52-AAC5-27E25E22604C} DEBUG:comtypes.client:CoCreateInstance({82C5AB54-C92C-4D52-AAC5-27E25E22604C}, clsctx=None, interface=None) DEBUG:comtypes.client:GetBestInterface(<POINTER(IUnknown) ptr=0x9f3ff0 at c0cdf0>) DEBUG:comtypes.client:Does implement IProvideClassInfo DEBUG:comtypes.client:Default interface is {CB3BF65E-0816-482A-BB11-64AF1E837812} DEBUG:comtypes:Release <POINTER(IUnknown) ptr=0x9f3ff0 at c58760> DEBUG:comtypes.client._generate:GetModule(TLIBATTR(GUID={7858B9E0-5793-4BE4-9B53-661D922790D2}, Version=1.0, LCID=0, FLags=0x8)) INFO:comtypes.client._generate:Could not import comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0: No module named _7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0 # Generating comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0 DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x2540a4 at c761c0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c58ee0> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x252690 at c76260> ... snipped over 50 lines here... DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c58b70> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x2555b4 at c58f30> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x255614 at c58c10> DEBUG:comtypes.client._generate:GetModule(TLIBATTR(GUID={00020430-0000-0000-C000-000000000046}, Version=2.0, LCID=0, FLags=0x8)) INFO:comtypes.client._generate:Could not import comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0: No module named _00020430_0000_0000_C000_000000000046_0_2_0 # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0 DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c58b70> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x2540d0 at c58f30> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c58f30> ... snipped over 100 lines here... DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x2547b0 at c58b70> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76da0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76b20> INFO:comtypes.client._generate:Could not import comtypes.gen.stdole: No module named stdole # Generating comtypes.gen.stdole DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c58ee0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c765d0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c58c60> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c761c0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c76620> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c766c0> INFO:comtypes.client._generate:Could not import comtypes.gen.TDxInput: No module named TDxInput # Generating comtypes.gen.TDxInput DEBUG:comtypes.client:Implements default interface from typeinfo <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0.ISimpleDevice'> DEBUG:comtypes.client:Final result is <POINTER(ISimpleDevice) ptr=0x9f3ff0 at c58800> DEBUG:comtypes:Release <POINTER(IProvideClassInfo) ptr=0x9f68d8 at c585d0> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x2525b4 at c584e0> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x2525e0 at c58620> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x251d48 at c58760> DEBUG:comtypes:Release <POINTER(IUnknown) ptr=0x9f3ff0 at c0cdf0> SpaceNavigator : Connected! DEBUG:comtypes.client:wrap_outparam(<POINTER(IKeyboard) ptr=0x9f2270 at c0cdf0>) DEBUG:comtypes.client._events:<POINTER(IKeyboard) ptr=0x9f2270 at c0cdf0> using sinkinterface <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._IKeyboardEvents'> DEBUG:comtypes:Release <POINTER(IProvideClassInfo2) ptr=0x9f2294 at a954e0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76350> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76490> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c763a0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76530> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76440> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76850> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c762b0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c768a0> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x252df8 at c76a80> DEBUG:comtypes.client._events:Start advise <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._IKeyboardEvents'> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at 0x00C6E110>.QueryInterface({6B6BB0A8-4491-40CF-B1A9-C15A801FE151}) -> S_OK DEBUG:comtypes._comobject:1 active COM objects: Added <comtypes.client._events.Sink object at 0x00C6E110> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at 0x00C6E110>.AddRef() -> 1 DEBUG:comtypes:Release <POINTER(IConnectionPointContainer) ptr=0x9f2274 at c762b0> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at 0x00C6E110>.Release() -> 0 DEBUG:comtypes._comobject:0 active COM objects: Removed <comtypes.client._events.Sink object at 0x00C6E110> DEBUG:comtypes:Release <POINTER(IConnectionPoint) ptr=0x9f2288 at c76850> DEBUG:comtypes.client:wrap_outparam(<POINTER(ISensor) ptr=0x9f21a0 at c76850>) DEBUG:comtypes.client._events:<POINTER(ISensor) ptr=0x9f21a0 at c76850> using sinkinterface <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._ISensorEvents'> DEBUG:comtypes:Release <POINTER(IProvideClassInfo2) ptr=0x9f21c4 at c762b0> DEBUG:comtypes.client._events:Start advise <class 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._ISensorEvents'> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at 0x00D56730>.QueryInterface({E6929A4A-6F41-46C6-9252-A8CC53472CB1}) -> S_OK DEBUG:comtypes._comobject:1 active COM objects: Added <comtypes.client._events.Sink object at 0x00D56730> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at 0x00D56730>.AddRef() -> 1 DEBUG:comtypes:Release <POINTER(IConnectionPointContainer) ptr=0x9f21a4 at c76d00> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at 0x00D56730>.Release() -> 0 DEBUG:comtypes._comobject:0 active COM objects: Removed <comtypes.client._events.Sink object at 0x00D56730> DEBUG:comtypes:Release <POINTER(IConnectionPoint) ptr=0x9f21b8 at c763f0> When I move the device at this point, nothing happens. Neither button events nor sensor events are recorded. My initial thought was, that this is, because the naming convention for event methods has changed, (so maybe it should be _ISensorEvents_SensorInput insted of just SensorInput) but the bug also happens when using the ShowEvents method, which should record any event, no matter the name. ________________________________________________________________________ "50 erste Dates" mit Adam Sandler u. Drew Barrymore kostenlos anschauen! Exklusiv für alle WEB.DE Nutzer. http://www.blockbuster.web.de ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users