Jump to content

Calling a Function node in a DLL to give force-feedback effect to


Recommended Posts

Hello,

I have been working for a couple of weeks on writing a DLL in Visual C++ Studio. My intention is to write an exported function in the DLL to initialize a Logitech Force3Dpro joystick, setup a force feedback effect and run it using DirectInput. I would like to control this force feedback effect (in particular, the intensity of the feedback) from Labview by calling the function in the DLL.

I followed the FFConst example in Microsoft SDK DirectInput Samples for making an .exe file to setup and run force feedback effects. I have been able to build the DLL successfully with an exported function that can be accessed from Labview by "Call a function node". I tested the function by running simple functions such as addition and multiplication of integers, andconfirmed the fact that the DLL was built correctly. I have also included the DirectInput code for initializing and running the force feedback effect. I am able to compile and build the DLL with no problems.

The Problem:

The only problem that I have at this point is with setting SetCooperativeLevel for the DirectInput8 joystick device. I have to provide a top-level window handle to SetCooperativeLevel so that I can give the function exclusive access to the joystick. Since I am not making a window and am building a DLL, I am not sure what handle I am supposed to provide it so that the joystick can respond. I am not sure if passing a handle to the Labview window would work because it is accessing the DLL's function? I tried passing LabView window handle to the function and read the X-axisposition off the joystick, but it read some junk (huge long integer) - which lead me to believe that the problem is something to do with initializing the joystick.

For all practical purposes, I am a complete novice at DirectInput programming and working with Visual C++. Although, I have programmed in C++previously and used Labview for about 5 years now. I am sorry for the long message, but I wanted to give a bit of background so that my aim is clear.

Any help, advice or direction with this problem be very much appreciated. Thank you for your time!

Cheers!

Abhishek

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.