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?
> This is the output I get from the GetEvents() function when using
> version 0.2.1:
>
>
> Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import logging
> >>> logging.basicConfig(level=logging.DEBUG)
> >>> class EventHandler:
> ... def __getattr__(self, name):
> ... print name
> ...
> >>> from comtypes.client import *
> DEBUG:comtypes:CoInitializeEx(None, 2)
> >>> x = CreateObject("TDxInput.Device")
> 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 c108a0>)
> INFO:comtypes.client:Does implement IProvideClassInfo
> 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
> c2c080>
> >>> x.Connect()
> 0
> >>> test = GetEvents(x.sensor, EventHandler)
> INFO:comtypes.client:wrap_outparam(<POINTER(ISensor) object c108a0>)
> DEBUG:comtypes.client:<POINTER(ISensor) object c108a0> 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
> 0x00C12590>.QueryInterface({E6929A4A-6F41-46C6-9252-A8CC53472CB1}) -> S_OK
> DEBUG:comtypes._comobject:1 active COM objects: Added
> <comtypes.client.DispEventReceiver object at 0x00C12590>
> DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at
> 0x00C12590>.AddRef() -> 1
> DEBUG:comtypes.client:End advise <class
> 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._ISensorEvents'>
> DEBUG:comtypes._comobject:<comtypes.client.DispEventReceiver object at
> 0x00C12590>.Release() -> 0
> DEBUG:comtypes._comobject:0 active COM objects: Removed
> <comtypes.client.DispEventReceiver object at 0x00C12590>
> >>>
>
>
>
> And this is the output I get when I use version 0.5.1:
>
>
> Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import logging
> >>> logging.basicConfig(level=logging.DEBUG)
> >>> from comtypes.client import *
> DEBUG:comtypes:CoInitializeEx(None, 2)
> >>> x = CreateObject("TDxInput.Device")
> 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=0x9f3fc0
> at c0e3f0>)
> DEBUG:comtypes.client:Does implement IProvideClassInfo
> DEBUG:comtypes.client:Default interface is
> {CB3BF65E-0816-482A-BB11-64AF1E837812}
> DEBUG:comtypes:Release <POINTER(IUnknown) ptr=0x9f3fc0 at c14080>
>
> DEBUG:comtypes.client._generate:GetModule(TLIBATTR(GUID={7858B9E0-5793-4BE4-9B53-661D922790D2},
> Version=1.0, LCID=0, FLags=0x8))
> 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=0x9f3fc0 at c14d00>
> DEBUG:comtypes:Release <POINTER(IProvideClassInfo) ptr=0x9f68a8 at
> c0ed00>
> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x24c5f4 at c0eda0>
> DEBUG:comtypes:Release <POINTER(ITypeInfo) ptr=0x24c620 at c0ee90>
> DEBUG:comtypes:Release <POINTER(ITypeLib) ptr=0x24bd88 at c0ef80>
> DEBUG:comtypes:Release <POINTER(IUnknown) ptr=0x9f3fc0 at c0e3f0>
> >>> x.Connect()
> 0
> >>> test = ShowEvents(x.sensor)
> DEBUG:comtypes.client:wrap_outparam(<POINTER(ISensor) ptr=0x9f2170 at
> c14d50>)
> DEBUG:comtypes.client._events:<POINTER(ISensor) ptr=0x9f2170 at c14d50>
> using sinkinterface <class
> 'comtypes.gen._7858B9E0_5793_4BE4_9B53_661D922790D2_0_1_0._ISensorEvents'>
> DEBUG:comtypes:Release <POINTER(IProvideClassInfo2) ptr=0x9f2194 at
> a91530>
> # event found: _ISensorEvents_SensorInput
> 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
> 0x00C52990>.QueryInterface({E6929A4A-6F41-46C6-9252-A8CC53472CB1}) -> S_OK
> DEBUG:comtypes._comobject:1 active COM objects: Added
> <comtypes.client._events.Sink object at 0x00C52990>
> DEBUG:comtypes._comobject:<comtypes.client._events.Sink object at
> 0x00C52990>.AddRef() -> 1
> DEBUG:comtypes:Release <POINTER(IConnectionPointContainer) ptr=0x9f2174
> at c843a0>
> DEBUG:comtypes:Release <POINTER(ISensor) ptr=0x9f2170 at c14d50>
> >>>
>
>
>
> 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?
--
Thanks,
Thomas
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users