LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

driving the force feedback of an MS joystick

I'd like to drive the force feedback of a joystick (sidewinder) with Labview 7.0. How can I do ?
I hope anyone could answer me.
Thanks
0 Kudos
Message 1 of 3
(3,361 Views)
I think for this you will have to have some C code interface. The force feedback of a joystick is controlled through the IDirectInputDevice COM object, such as:

IDirectInputDevice8->CreateEffect() or IDirectInputDevice8->SetParameters()

I don't think these are fully featured Active X objects so you can't control thrm through the Active X interface in LabVIEW. This leaves only a DLL which you have to write in C or C++.

Rolf K
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 3
(3,361 Views)

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. 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

 

P.S. I apologize for posting this message in an old thread. I have been following many such threads and this one in particular seemed pretty close to the problem I am currently facing.

0 Kudos
Message 3 of 3
(2,959 Views)