LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW and Force Feedback via DirectInput

Hello,

 

I looked around and saw several open questions on this, but no one with a working prototype.  So I started working on this for for a school project.  I've come up with a basic working sample.  The VI only supports the first axis on the first available device.  It is only tested for my particular use, USE AT YOUR OWN RISK.  This archive includes a Visual Studio 2013 project based on the FFConst MSDN sample code.  I also had a lot of inspriation from this ForceFeedback plugin for the Unity engine.  The VI was made with LabVIEW 2013 32bit.  It uses the call libray node without any wrapping or error handling, and it may cause some memory corruption errors when LabVIEW thinks varables are unused or calls functions with the wrong parameters.  ALWAYS USE THE NODE'S RETURN VALUE (HRESULT) for this reason or LabVIEW may crash hard.  This NI whitepaper has more information.  The Windows API Function Utilities are a good starting point for dealing with window handles and the rest of the Win32 API safely(ish).

 

I guess my question is - is any one else trying to do a similar thing?  Is the calling the Win32 API offically supported?

 

If you improve the code, please post it!

 

-Lex

0 Kudos
Message 1 of 5
(4,131 Views)

Hey Lex,

 

In regards to your question about the Win32 API, LabVIEW definitely supports calling DLLs.  As you mentioned in your post, the Call Library Function Node can be used to call the Win32 API, and as long you're wiring your inputs and outputs correctly it should work.  I've linked to a LabVIEW example about calling Win32 below.  I'm not sure if I fully understood what you were asking though, did that answer your question?

 

http://zone.ni.com/reference/en-XX/help/371361K-01/lvexcodeconcepts/ex_3_call_the_win32_api/

 

Myriam

Applications Engineer

National Instruments

0 Kudos
Message 2 of 5
(4,078 Views)

Hello, I'm trying to use your dll but I'm having some problems (for what you said I assume it's a question of data types).

Could you attach a sample VI?

 

Thanks, best regards.

0 Kudos
Message 3 of 5
(3,966 Views)

Looks like I forgot to include the demo VI.  I've attached it to this post.

0 Kudos
Message 4 of 5
(3,940 Views)

Thanks for the VI.

Seems is not working for me, I have to work it a little more Smiley Wink

 

Thanks.

0 Kudos
Message 5 of 5
(3,905 Views)