MFC DLL and Attributed COM

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
salute
Posts: 4
Joined: Thu Jul 24, 2008 7:21 am

MFC DLL and Attributed COM

Post by salute »

Hello

I have a MFC Application. The logic for interaction is separated in a DLL library and I want to add the 3Dconnexion interaction code into that DLL (I use VS2008). MFC defines its own DllMain method.

I cannot use attributes and module naming for COM (only if I force it to link with the FORCE:MULTIPLE compiler option). But these are needed to use the functions __hook and __unhook. Is there a way to use callback functions without using attributes and module naming?

What am I currently missing if I use the old SDK? Will future devices also work with this old SDK?
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Your best bet is to use the old SDK (or one of the MS APIs like DirectInput, RawInput, HID).

The old SDK mechanisms will always be supported. All new devices will be supported with it.
salute
Posts: 4
Joined: Thu Jul 24, 2008 7:21 am

Post by salute »

To initialize the driver I use the following sequence:

if (SiInitialize() == SPW_DLL_LOAD_ERROR)
{
return;
}

SiOpenData spaceballData;
SiOpenWinInit(&spaceballData, m_hWnd);
SiSetUiMode(&m_hSpaceball, SI_UI_ALL_CONTROLS);

if ((m_hSpaceball = SiOpen("Test", SI_ANY_DEVICE, SI_NO_MASK, SI_EVENT, &spaceballData)) == NULL)
{
SiTerminate();
}


The problem is when the driver is not running I have quite a long timeout.

How can I detect whether a Spaceball device is plugged in?
How can I detect whether a Spaceball device is plugged out?
Is this only possible with other APIs?
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Before you make any of the Si* calls, you can check whether the 3DxWare driver is running by looking for its window:

FindWindow("SpaceWare Driver Class", NULL);

If this returns NULL, the driver isn't running. Don't call any Si* functions.
salute
Posts: 4
Joined: Thu Jul 24, 2008 7:21 am

Post by salute »

Will the name of the windows stay the same in the forseeable future? What about older drivers? Did they use the same name?

Do you have any hints for my other questions?

How can I detect whether a Spaceball device is plugged in?
How can I detect whether a Spaceball device is plugged out?
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hmmm. That reply got lost.

The window name hasn't changed in 10 years. It won't ever be changed.

It is currently sufficient to check for this window to tell if a 3Dx device is attached because the driver quits if it doesn't find a device attached.

In the next major driver release, though, the driver will run continuously even with no device attached. You can make an API call to find out if there really is a device is attached. Furthermore, you will get an event when a device arrives / departs. OTOH, your delay issue will go away since the current delay you are seeing is from the API starting the driver and it searching for any connected devices. Since it will be running continually it will respond instantly.
Post Reply