Why can't I access any input devices?!

Started by
22 comments, last by Bacterius 9 years, 10 months ago

For quite a while now, I've been trying to do some things that shouldn't be all that complicated, but they're seemingly impossible! Someone please, please, PLEASE tell me how to do ANY of them! I just want to get a Novint Falcon, Razer Hydra, Oculus Rift, and Logitech Force 3D Pro to all work in C#. I'm using Visual Studio 2012 Express on Windows 7 Professional.

For the first problem, Novint has instructions on how to set up a Falcon in Visual Studio, but only version 6 or 2003, which are ancient, and hardly even available/compatible anymore! And the 2012 interface is completely different. Also, their instructions are only for C++. If it's only possible to do it in C++ I can accept that, and I guess I'll have to make a wrapper for C#, but I just need it working somehow, regardless of the language. Their customer support is a joke in which I fail to see the humor. They just told me that it works the same way in 2012 as 2003, and it clearly doesn't, since the interface has almost none of the same options. When I politely explained this, they told me I should return the Falcon for a refund. However, I don't see how that would solve my goal and enable me to get it to work programmatically. Basically, I need to do these things:

- Set some environment variables (this was actually done automatically during installation)

- Set the lib and include paths (I think I may have figured that one out but I can't verify whether it's correct)

- Include the library (for some reason I can't get it into my project and have it work at all)

It's actually a lot more complicated than it sounds. I was getting a lot of errors and things weren't available that seem like they should be. I'm on a different computer now so I don't have the details, but in any case, if anyone has ever used this API or made a Falcon work programmatically AT ALL, please tell me how! If you somehow got it to work in DirectInput I'd be interested to know that as well!

As for the Razer Hydra, it seems that their API is also for C++ (although I heard something about a wrapper for C#. Does anyone know about this or its progress? BTW this is supposedly the same API that will be used by STEM.) I seemed to be able to sloppily get their DLLs and garbage imported into a simple C++ test project, in which I then just called a function to check if the Hydra is connected, and wouldn't you know it - it doesn't compile! I got a error that the DLL is invalid or some nonsense. I tried it with the 32 and 64 bit DLLs and neither work, though they each say a slightly different position in the file which is invalid. I got these files directly from Sixense (they created them) and I didn't have any error downloading them or installing anything. The drivers and everything else work, and so should this. I don't see how there could be a problem with the files, because they're the same ones that any developers would use. It seems like something else must be going wrong but I can't imagine what. Has anyone been able to get this to work, and if so, how?

Honestly, I don't even remember where I ended up with the Oculus Rift (I think it's another C++ one though. Doesn't anyone use .NET?) I think I got some third party thing because I couldn't find the files I needed directly from them. Anyway, nothing works, but I didn't mess with it much because I've been focusing on the other ones more. Regardless, if anyone has any info about this, as usual, please tell me!

The code to access the Force 3D Pro joystick works, but not the force feedback (which is the part I really need!) I know the motor is working correctly, I just can't get the code right. I'm using DirectInput in SharpDX (almost identical to SlimDX) in C#. I get an error that the device is unregistered. I don't see any function for registering the device, anywhere in the whole API. I only have vague recollections of things I did in DirectInput in C++, and since moving to C#, I haven't had to register anything, and the SharpDX documentation is terrible. So if anyone knows how to do this, it would be much appreciated!

By the way, for some reason, people often mistake me for a beginner and accuse me of biting off more than I can chew, and telling me to give up (much like the Novint customer support). If that's all you intend to do, save your breath, er... typing, because:

A) I'm never going to give up on this. It's tremendously important that I get these things working, even if it takes me 20 years!

B) I'm not a beginner at all. I've been writing code longer than some of you have been alive. It's just that they keep changing the interface in Visual Studio, so the way to import any libraries keeps changing, and these companies provide little to no support for development for their products, and nothing ever works correctly for some reason. It's like the whole world's defective, and it's driving me mad!

But I would appreciate any information that could POSSIBLY be useful! Thanks a lot!

Advertisement

I just want to get a Novint Falcon, Razer Hydra, Oculus Rift, and Logitech Force 3D Pro to all work in C#.

Interesting combination.

I think it's another C++ one though. Doesn't anyone use .NET?

No, and for good reason.

The entire reason EVERYTHING is based on C bindings (or increasingly C++ bindings, which are closely related) is that they can be used everywhere. You can access them in C, and C++, you can also access them in Python and C# and Java and Allegro and D and Lisp and assembly and ADA and Pascal and Cobol and any other language you choose.

Really, it isn't the C part that is necessary, it is the underlying binary format of the object files. As long as you can call things and put the right things in the correct registers and stack locations, everything just works. The only tricky part is getting your language to put all the data in the right places in the right format.

I guess I'll have to make a wrapper for C#, but I just need it working somehow, regardless of the language.

This is your answer.

Get a working copy of the libraries. Then use tools of your language to bind to those libraries. In the case of C#, that generally means p/invoke. It isn't THAT difficult. If it gets too tedious for you, there are many tools out there that can do it for you. Like this one, which is tiny and easy. Or this one, which is very full featured. Or you can buy one of the expensive libraries for it.

OK, first of all, I understand that C/C++ are more compatible and compiled to machine language and all that, but if you're writing a program with hundreds of classes and countless dependencies between them (often circular dependencies), do you realize how much of a nightmare that can be in C++? I always get a million circular include errors that I can never resolve. I need a FULLY object-oriented language. Java would work I guess, but it isn't very compatible with many of the things I need. Eiffel even less so, which basically leaves .NET (you mentioned D. Does anyone actually even use that?), and honestly, I just want everything to be as simple and clean as possible. Besides, I've already written a ton of other code in C# that needs to be used in conjunction with this. The .NET IDE is so much better, and I'm not sure I could even install VS6 on my PC. But supposedly, anything that works in that C++ should work in C++.NET also, right?

In any case, like I said, I use C++ in VS2012 when I absolutely HAVE TO, but otherwise, I prefer C#. So for some of these APIs that were made to be used in C++, that's what I'm doing, but trying to write a wrapper around them for .NET.

Get a working copy of the libraries.

As for having a working copy of the libraries, I can't imagine why they wouldn't be working already, since they're directly from the manufacturer's website. As I said, I suspect that somehow something else is wrong or incompatible, but for some reason it makes it seem as though the files are corrupt. And this only applies to the Hydra.

It isn't THAT difficult.

And yes, it is THAT difficult, as evidenced by the fact that I've been trying to get it to work for months now and have made very little progress. Ideally, I'd like to have it working by the end of the year if possible. Once all the DLLs are in the project and connected correctly, the rest of it (the code) will be a breeze. And I think it's mainly just that these APIs are particularly tough to set up. I never had this much trouble with DirectX (although it was long enough ago that I don't even remember what I did, but I know it wouldn't entirely fix these problems anyway).

Thanks for the links. I looked at the pages, but I won't have time to try them out until the weekend. I'll let you know how it goes. However, I have a sneaking suspicion that it may not fix the problem, only because each API has specific instructions of how to get the DLLs imported and working within the project, which involve going into options/settings from menus, which open up windows, and setting a bunch of stuff inside them (mostly typing paths and stuff into text boxes). I know that all sounds terribly generic, but the point I'm trying to make is that I need to be able to configure various project settings in a specific way, which seems to vary for each API, and at no point do any of the instructions both 1) apply to the interface I am given AND 2) actually accomplish what it's supposed to.

Also, I've noticed that in different projects, I get different options/settings available to me! It's completely inconsistent, i.e. sometimes I get a button to browse for DLLs, sometimes not; sometimes I have menu options that allow me to view project settings one way, sometimes they look an entirely different way, sometimes they're not available at all; sometimes if I put DLLs directly into my project folder, I can "add existing item" and it can be imported that way and may work or sometimes not! It's the worst interface I've ever seen, and I don't know of anywhere that will actually tell me how to use it!

So what I would really like ideally is just a step-by-step guide of how to set up any or all the APIs, similar to the guides they provide, but with one key difference: it would actually WORK! Can anyone possibly provide me that please? It would be absolutely amazing! Thanks.

As for the Razer Hydra, it seems that their API is also for C++ (although I heard something about a wrapper for C#. Does anyone know about this or its progress? BTW this is supposedly the same API that will be used by STEM.) I seemed to be able to sloppily get their DLLs and garbage imported into a simple C++ test project, in which I then just called a function to check if the Hydra is connected, and wouldn't you know it - it doesn't compile! I got a error that the DLL is invalid or some nonsense. I tried it with the 32 and 64 bit DLLs and neither work, though they each say a slightly different position in the file which is invalid. I got these files directly from Sixense (they created them) and I didn't have any error downloading them or installing anything. The drivers and everything else work, and so should this. I don't see how there could be a problem with the files, because they're the same ones that any developers would use. It seems like something else must be going wrong but I can't imagine what. Has anyone been able to get this to work, and if so, how?

You seem to be doing something wrong. DLLs don't feature during compilation at all (nevertheless you claim there are compile errors). You might be describing linker problems, but DLLs in almost all cases don't feature during linking as well (the import libraries do. You are not giving the linker the DLLs instead of the import libraries, do you?). The point where actual problems with DLLs usually happen is during runtime.
Unfortunately you are not describing what you tried nor the error message (What exactly did you do? What exactly is the error message? Do not try to paraphrase errors, copy'n'paste them).

By the way, for some reason, people often mistake me for a beginner

Yes, unfortunately I can see how that would happen. You do not describe what you did and what your exact errors are in any sufficient detail to allow helping you (I picked one of your paragraphs to write something about but I could have done something very similar with all of them).
As another example your problems with the Falcon sound like you just need more accurate descriptions on where to set the include directory/library search paths in modern MSVCs. That's the usual thing you need to do with libraries. Very occasional you need something more (like disabling exceptions for some reason). If that is truly the problem you are having (and if it is not, once again: What does the description say? What did you try? What happened?) then I would strongly suggest you spend some more time with C++ in simpler scenarios. Write some programs, work on linking with a library of your own creation.
Because right now it seems you are stuck on extremely simple things and you only have two choices:
1) wait for someone to write the C# wrappers you need.
2) get more experience with C and/or C++ and write them yourself.
Since you seem to committed to this, even if it takes 20 years, starting on (2) might not be a bad idea. Worst case, you learned some new stuff by the time (1) happens.
What exactly did you do? What exactly is the error message? Do not try to paraphrase errors, copy'n'paste them

Unfortunately I don't remember at this exact moment. I can't copy and paste anything, because I'm using a different computer and I'm not even at home. Besides, the computer on which I do my developing does not have an Internet connection. In any case, I didn't think I'd need specific details about what I did, because I was hoping someone would just have a step-by-step process for me. But I'll look into the DLL/Lib problem, but I just did what Razer's instructions said to do.

I would strongly suggest you spend some more time with C++ in simpler scenarios. Write some programs, work on linking with a library of your own creation.

Well I've spent about 15 years with C++ in fairly complicated scenarios. The code doesn't trip me up at all. It's just stuff like this that always gets me. As for making my own library, I wouldn't even know where to start, and I never seemed to find good information on that the few times I seared for it out of curiosity, though I've never needed to do it before, so I didn't really care. *sigh* I wish programming could just be programming!

As another example your problems with the Falcon sound like you just need more accurate descriptions on where to set the include directory/library search paths in modern MSVCs.

Yes! That's exactly what was going wrong! The PDF from Novint said to set the directory and library paths, but there were a couple different ways they needed to be done, and then I had to import the DLL or lib (I don't remember which), which it didn't even say how to do, so I think I just put it into the project folder and included it into the project, to no avail. I had taken some notes and sent an email to Novint support, and I'll paste the conversation here for clarification. The newest response they sent is one I just now saw, so I haven't had a chance to analyze it or try it out at all. If anyone wants to dig deeply into this, the PDF I refer to is available from Novint's website (If I remember correctly, it's included with the SDK by clicking the "here" link under "Developer Downloads" in the Support->Downloads section, but I'm not sure if you can download JUST the PDF). Anyway, you can see why I'm a bit frustrated:

ME:

I've been trying to set up the Falcon SDK to use, following the instructions in the PDF manual. I've already installed it, and the environment variables are set correctly (I didn't do that; did it happen automatically during installation?), but the Path variable has other things along with it, which don't appear to be relevant to the Falcon at all. Is that alright?

Then I saw in the instructions how to set it up in a Visual Studio 6 or 2003 program. Unfortunately, these instructions are very outdated, because I'm using Visual Studio 2012 Express. How would I set it up to use the necessary DLLs or any other files in that version? I'm just trying to get to the point where I can write code and test it, and then I can take it from there, thanks.

THEM:

Good on setting up up the environment variable ... that is set
correctly during the installation of the Novint (HDAL) SDK. The
NOVINT_DEVICE_SUPPORT environment variable tells the operating system
and applications using the Falcon where to find the DLLs, initialization
files, and in your case the Novint Falcon SDK library file locations for
the program you want . Our SDK contains all the documentation and
software development support files needed to develop applications using
the Novint Falcon haptic interface device up to and including the Haptic
Device Abstraction Layer (HDAL) level. Although you are using a more up
to date Visual Studio version, the general steps described in the
HDAL_ProgrammersGuide.pdf are the same.

ME:

I'm sorry for being contradictory, but I don't see how the steps can be the same, because I compared the instructions of section 4.1 of the HDAL_ProgrammersGuide.pdf to the options that are available to me in Visual Studio 2012, and found many extreme differences between them:

(Please bare with me, as I'm on a different computer now and writing this based on notes that I took while experimenting to try to get it to work, so I don't have any screenshots available.)

First of all, the images in the PDF of the Tools->Options window look completely different that what I saw in VS 2012. The instructions describing what to do, corresponding to that interface, couldn't be applied to the interface that I have to use.

In 4.1.1, it says to click the "show directories for:" dropdown box, and to set values for the "include files" and "library files" and to click a "browse" button at some point, none of which were present in the interface I was using. I can't find any wan to complete this step.

In 4.1.2, it says to choose the Project->Settings menu option. I don't even have that option at all. There is a Project->Properties option though (or Project->X Properties, where X is the name of the project). I looked in that and found similar information that was worded differently and set up completely differently than the screenshots in the PDF, but I think I might have figured this part out, but would like confirmation as to whether I'm actually on the right track, because I could just as easily be wrong. Here's what I did:
In Project->Properties, I chose "All Configurations" from the "Configuration" dropdown list, then in the tree view I selected Configuration Properties->VC++ Directories, and it displayed a lot of properties relevant to that on the right side. In the "Include Directories" box, I appended "$(NOVINT_DEVICE_SUPPORT)\include", and in the "Include Libraries" box I appended "$(NOVINT_DEVICE_SUPPORT)\lib". This seems to be a reasonable thing to do but I have no proof that it's correct, and it still doesn't solve 4.1.1, only 4.1.2, and only assuming it's correct.

4.1.3 says to type "hdl.lib" into the "object/library modules" textbox, but that doesn't appear anywhere, so I don't know where to put this at all. I'm guessing without this, the whole thing falls apart.

I don't mean to complain, but quite frankly, I wish there was a newer version of the PDF. Visual Studio 2003 is 11 years old now, and Visual Studio 6 was outdated even when the Falcon was first produced. By now, version 6 is practically ancient.

THEM:

We are sorry you are still having issues, but the use of our lower-level
type SDK requires comfort in using the visual studio environment and the
c++ language. We would be happy to offer you a refund if you have
purchased your Falcon in the last 45 days (normal money back guarantee
time is 30 days). Please let us know if wish to return your Falcon so
we can issue you a return authorization number and provide you with the
necessary information.

ME:

Excuse me, but I don't see how that's relevant. I am quite comfortable with Visual Studio and C++, and have been using it for about 15 years. The problem is not in my lack of understanding, but rather in the lack of accuracy and compatibility in the instructions. I would just like instructions that are compatible with Visual Studio 2012 please.

THEM:

We seem to have reached an impasse. There is nothing special about
using our SDK ... it is a library package. Your project just needs to
know where the SDK related .h and .lib files are. The actual files
required for a project (i.e., hdl.h, hdl.lib, etc.) can be found in
the/C:\Program Files (x86)\Novint\HDAL_SDK_2.1.3\include/ and/C:\Program
Files (x86)\Novint\HDAL_SDK_2.1.3\lib /folders and sub folders of the
SDK package. The NOVINT_DEVICE_SUPPORT environment variable needs to
point to C:\Program Files (x86)\Novint\HDAL_SDK_2.1.3 so that SDK
related DLLs and device bin files can be found by the system when
running SDK developed applications.

From what I can tell from the flow of conversation setting up the basic search paths for your IDE of choice is indeed the problem you seem to be having. It's not their job to teach you that - that is like buying a book from a store and then complaining to them that you are unable to read. When they say

We are sorry you are still having issues, but the use of our lower-level
type SDK requires comfort in using the visual studio environment and the
c++ language.

I can only agree with them. The should not even have to give you any special instructions. When a developer installs a library, they will usually immediately look for the headers, import libraries and DLLs and work with them as they work with any other library.

I see no chance for you to complete your project if you cannot even master to link to a library without exact screenshots and instructions guiding your way. If you have specific problems (not the 'it does not work' we get so far) then we are probably happy to help, although I would say practically all of your problems can be solved quicker by simply googling.

It's not their job to teach you that - that is like buying a book from a store and then complaining to them that you are unable to read.

I understand your point but I think it might be a bit of an overstatement. It seems API specific to me (see note below). Besides, if they're going to provide instructions for how to do something, they should at least work. Also, I don't understand why Microsoft needs to drastically alter the IDE every 5 minutes (it's not even consistent between different projects, which I mentioned before but no one else acknowledges), and do you know anybody who still uses VS 2003, or worse yet, 6.0?! Falcons aren't even that old, so it's just stupid for it to be that outdated.

When a developer installs a library, they will usually immediately look for the headers, import libraries and DLLs and work with them as they work with any other library.

Well it seems to me that whenever there are instructions for how to do this, they're always very specific to the API. There doesn't seem to be any generic way, or else there are 50 million generic ways - so everyone does it differently - and I can never get any of them to work at all!

If you have specific problems (not the 'it does not work' we get so far) then we are probably happy to help, although I would say practically all of your problems can be solved quicker by simply googling.

I was trying to give you specific information (and a lot of the stuff I put in the e-mail conversation I reposted is very specific, but it requires the PDF to understand the context), but like I said, I can't get the info from my computer and I'm not even at home.

Also, I tried searching for answers (search criteria: how to link a dll in visual studio 2012), and as usually happens whenever I try to run a search, I get nothing that solves my problem. One result page is just someone who posted a question about getting DLL files into his 2012 project directly, which is part of my problem (but doesn't address path setting), but people just say to copy a glew32.dll and a bunch of stuff that I don't think is relevant. Another page is on msdn, and links to a bunch of other related pages, like a tutorial, but I can't find where it says how to actually do it, let alone provide any screenshots. It does however have a page about creating a new DLL so I'll check that out, but I'm not sure it will fix my problem in the long run but it's worth a shot. The rest of the results degrade into increasingly irrelevant garbage.

I swear I couldn't get deeper into DLL Hell! (I know that's not quite the way the phrase is usually used, but I find it more fitting).

Despite your claims you don't ever provide any specific information. Important bits of information are:

1) what have you done?

2) what happens (including the exact verbatim error messages you are getting)?

Considering we are most likely dealing with the typical problems of someone inexperienced trying to link a library even extremely basic information regarding (2) would most likely be enough to help you (for example "C1083: Cannot open include file: 'blabla.h'").

The basic procedure for linking a library is always the same:

a) make sure the compiler can find the include files (failure to do so correctly will for example result in a C1083)

b) specify the path where import libraries can be found (failure to do so correctly will cause problems with (c))

c) link the required import libraries (missing libraries will result for example in LNK2001s; messing up during (b) will result for example in LNK1181)

Really, as far as libraries go you have the simple case to deal with. You don't have to compile any library yourself to ensure the runtime and compile time options match. You just have to get something linked that dropped into your lap. You might have to observe specific documented restrictions in extreme cases (some compile time options that need to be set in a specific way, runtime libraries that have to be used or even exact compiler version numbers), but most libraries like that don't require anything like that.

The core issue is, that after four extremely verbose posts of yourself, you still have not provided any information to help narrow down your problems into one of the categories above. As a result, helping you is nearly impossible. Very general, unspecific problems will result in very general, unspecific answers.

There is a lot of self-pity and complaining but the signal-to-noise-ratio is frighteningly low.


I tried searching for answers (search criteria: how to link a dll in visual studio 2012)

You shouldn't be trying to link DLLs to your project. You link lib files - files with the extension .lib. DLLs will get loaded at execution time, as needed by the routines you link in the lib files.

It appears you may need a refresher on setting up projects to include API header files and library files. Perhaps reviewing a sample solution from the SDK for instances mentioned below will help.

The process is generally as follows:

Set up the VC++ Directories (in project properties) -

Include Directories: complete paths to the folders where header files (files with the extension .h) can be found for various APIs.

Library Directories: complete paths to the folders where library files (files with the extension .lib) can be found for various APIs.

Note: paths that are not part of your default project setup will NOT automatically appear in your project properties. You must determine the appropriate paths for each (non-default) API you want to use.

Set up the Linker Input (in project properties) to include the libraries (files with the extension .lib) needed by your application.

The header files provide the prototype function calls. You generally specify inclusion of header files in two ways:


#include "some_header.h" // some_header.h is in your project directory
#include <other_header.h> // other_header.h is in one of the Include Directories you list

During compilation, those header files will be loaded by name by searching for them in the Include Directories you've listed in Include Directories.

After your app has been compiled, the linking phase is entered. The functions you call in your app will be searched for in the libraries listed in the Linker Input, the search for those libraries being done using the Library paths you list in Library Directories.

After successful compilation and linking, during execution of your app, DLLs will be loaded as necessary - DLLs are NOT linked directly by your app.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Despite your claims you don't ever provide any specific information.

I really appreciate all your help. Honestly I do. And I don't mean this to sound snide, but by now I don't know any other way to say it and get the point across:

A) For the 15th time, I can't give you much specific information at this moment because I'm not at home and so I don't HAVE it available, except from memory, and trust me, that's very unreliable.

B) There IS a fair amount of information in the e-mail correspondence. I stated the exact windows I opened and what I clicked and what I typed where.

So I don't understand why you keep telling me to provide info. I'll try to go through the process this weekend and put some better notes together. I didn't realize I'd need them anyway, because I was expecting that someone might give me a step-by-step explanation. If it's not that hard, as you say, then it shouldn't be hard to do that, I would think. Again, I apologize if I sound mean. I'm really not, and it's not "self-pity" either, but I'm just very, incredibly frustrated.

You shouldn't be trying to link DLLs to your project. You link lib files - files with the extension .lib. DLLs will get loaded at execution time, as needed by the routines you link in the lib files.

Honestly, I don't remember. I may have tried libs. I probably tried both actually. I've been at it a long time, but unfortunately I don't typically get any time to mess with it any time but Saturday, so it's kind of an ongoing, occasional struggle.

The header files provide the prototype function calls. You generally specify inclusion of header files in two ways:

At one point, either with the Hydra or Falcon API, I just put all the .h and .lib files from the SDK into my project folder and did "add existing files" to all of them. The headers try to include each other to an extent, and when I tried to compile I got a ton of miscellaneous errors, but some of which were that the headers trying to be included couldn't be found. I even tried both the "" and the <> notation, and then I also made sure it listed any subdirectories they were in as they appeared in the project. I never could get the errors to go away, which is weird, since if I create a .h file I never have any trouble using it.

At least both of you have now given me a relevant list of steps, but unfortunately, they say what to do, but not how to do it (i.e. what menu or button to click, which text box to type what into, etc.) so it's hard to actually follow it. As I said, with the Falcon, I think I might have figured out part of it, but it still doesn't work as I would expect it to, so obviously something must still be wrong, and there's no way for me to be sure that any of it is actually right at all. For details see the e-mail correspondence I posted earlier.

I don't see why it doesn't just let me choose from a menu "Import->Lib/DLL/whatever", then in a popup window, browse and choose what I want, click OK, and then just call functions in my code. Wouldn't that be great? I swear it seems like in earlier versions it used to be that easy!

This topic is closed to new replies.

Advertisement