News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Getting my joystick working under Direct Input

Started by hamper, December 01, 2013, 10:00:30 AM

Previous topic - Next topic

hamper

So I'm continuing with my learning process with OpenGL, and have now managed to get a wireframe teapot rendered in fullscreen perspective view, with keyboard controls for the x, y and z axes of rotation, and using the mousewheel to control the field of view. What I'd like to do next is get my joystick working.

The regular Windows messages don't work for the joystick, so I presume it must be operating under the Direct Input system (it's a Saitek Cyborg 3D into the USB port). There are two functions that seem to be critical in using joystick input under Direct Input - SetDataFormat and GetDeviceState. Does anyone know which library files I need to "includelib" to get access to these function? I've tried dinput.lib, dinput8.lib and winmm.lib, and all I ever get is "unresolved external...", so the functions don't seem to be in any of these.

Is direct input supported by MASM32? If so, which library files do I need to includelib to get access to these functions?

My joystick works automatically under Windows, so that's not the problem. And looking at my C++ setup (Borland), it seems that I might be able to get the functions under C++. Maybe even Nasm might have them? But out of principle I'd prefer to continue to work it out under MASM32 and assembly language, if that's possible (which surely it must be, somehow). Do I need to get some additional libraries perhaps? If so, any links as to where I can get them from?

Any help appreciated.

Phil

dedndave


hamper

Yeah, I looked through all Franck's examples, but couldn't find the answer. Couldn't find anything that actually used a Direct Input joystick, just mouse and mouse wheel (which I've already got implemented). Plus lots of copies of C++ header file entries, but again no actual implementation of a Direct Input joystick. That's not to say it might not be there, just that I can't find anything.

jj2007

Dynamic linking to C:\WINDOWS\system32\dx8vb.dll is not an option, I guess?
If it's COM, http://www.japheth.de/COMnASM.html is a good starting point, plus the posts of ToutEnMasm here and in the old forum.

dedndave

also - need be, we can make in INC and import LIB

GoneFishing

Hi Hamper,

You may want to download an older DirectX SDK .
I have August 2007 version and in the \Samples\C++\DirectInput folder  I see Joystick example.
... or try searching in MSDN Code Samples

I hope you will share with us your impressing demos  ;)

hamper

Thanks everyone,

I think I'll try using the approach of dynamically linking a .dll library and see if that works.

vertograd, they're not impressing demos, not even particularly impressive - just little programs to lay out the foundations as I'm working my way through OpenGL, trying different things out to gradually learn how it all works.

Read the comments in the source code file first - e.g. spacebar exits.

dedndave

i needed glut32.dll, but...
nice teapot   :t

xp sp3
the rotation works great

GoneFishing

very nice  :t
zooming in , zooming out , rotation  - all works
it's a big progress


hamper

Well, trying to work out how to get my joystick working under assembly language has left me baffled and exhausted. I can't find any of the functions used under DirectInput anywhere within the assembly language system. And even if I could, I can't find any examples or tutorials that explain the process in language that I understand ... everything is C++, which might as well be written in Martian to me.

So it seems to me that the only way I'm ever going to accomplish this (seemingly enormous) feat is to take up C++ programming. Now I've got a C++ compiler, and I can program in C, but C++ programming seems like "la la land" programming to me, with all its classes, objects, friendships, inheritance, polymorphism, constructors, destructors and overloading etc. And Micro$oft doesn't help - why use just one data type when 5 or 6 or 7 or more equivalent datatypes but all using different names will do? And why just use a pointer when you could use a pointer to a pointer?

So it's either learn C++ programming, and especially how Micro$oft does it, or pack it in. And at the moment I'm not persuaded to learn C++ programming or learn to love the Micro$oft approach. Maybe I'll just take up server side scripting (if I knew what that was).

But thanks for your help anyway.

jj2007

#10
hamper,

Don't give up so quickly. I understand your feelings, actually I feel the same: This is COM stuff, and it's utterly clumsy for my taste.

Have a look at this old article: May the Force Feedback Be with You: Grappling with DirectX and DirectInput

We have at least four COM specialists around: Edgar, ToutEnMasm, qWord and Japheth (apologies if somebody else feels also strong enough to attack this :redface:)

Maybe one of them has some time to look into this problem...

dedndave

Jochen's right - patience

the dinput8.inc file is far from complete
it's just missing a few goodies   :P
and, the dinput8.lib file is built, based on the contents of the inc file

a little bit of an advanced technique, but we have been known to update include files and import libraries
the simplest way is probably to use dynamic linking
that will get you up and running

what slows me down (and probably Jochen and others) is that we don't happen to have joysticks
actually, i do have one out in the shed, i think - a Microsoft SideWinder
but, as i recall, it connected to a "game" port, which this machine does not have
i probably have boards, too - lol - heaven only knows if they'll work in this computer

dedndave


dedndave

hmmmm - don't recall an adapter
wonder if i have that   :P



last time i used it, i was running windows 98   :lol:
the soundblaster card on that machine has a game port

hamper

jj2007,

That's exactly the tutorial I started working my way through. I'd looked on the net for (and downloaded) anything to do with using a joystick under DirectInput, and that was one of them. When I started working my way through everything, that one seemed to be the easiest to follow. But it all came to a shuddering halt when I realised that none of the functions (at least none after the first one) were actually present in masm32.

dedndave,

USB, unfortunately. If it was one of the older gameport joysticks I could just use the regular Windows messages to pick everything up. Ahhhhh, for the old days when everthing was simpler, eh?