Joystick/controller input???

Pages: 12
Feb 14, 2012 at 11:08pm
Hello guys,

I was wondering if there was any simple (or at least fairly basic) way to get input from a joystick or controller that's plugged into your computer. In Game Editor (a 2d game engine), you use two functions called: getjoystickbutton(int) and getjoystickaxis(int). These functions will return values such as whether a button is pressed or how far on the x axis a joystick has been moved. Is there a basic way for me to make similar functions? Thank you in advance =D

SuperSonic
Feb 14, 2012 at 11:41pm
If this is for Windows, have a look at DirectInput: http://msdn.microsoft.com/en-us/library/windows/desktop/ee416842(v=vs.85).aspx .

I don't have suggestions for any other OS.
Feb 14, 2012 at 11:53pm
Thanks =D

And yes, it is for Windows
Feb 15, 2012 at 4:28pm
Umm, I'm sorry for the dumb question, but where do I downlaod DirectInput? I can't find the answer anywhere =?
Feb 15, 2012 at 4:56pm
AFAIK, it is installed with Windows, so all you should need is the Windows SDK. For example, I have dinput.h in my Windows SDK 7.0 include folder.

I must tell you, though, that I have never used it so I may be wrong.
Feb 15, 2012 at 6:54pm
Also, there is the old Joystick API
http://www.google.com/search?btnI=1&q=msdn+Joysticks

Hope this helps.
Feb 16, 2012 at 4:32am
Thanks guys. I'll try to see if I can get it to work in the morning =)
Feb 16, 2012 at 4:43am
Get a game lib.

SFML has easy and crossplatform joystick support

http://www.sfml-dev.org
Feb 16, 2012 at 4:33pm
I was thinking about a game lib. But then I decided not to for the simple reason that I only want joystick support and I don't want to mess with graphics and stuff. But thank you for your tip. I'll definitely check it out later =D
Feb 17, 2012 at 8:34pm
AFAIK, it is installed with Windows, so all you should need is the Windows SDK. For example, I have dinput.h in my Windows SDK 7.0 include folder.

Ok, another silly question. I don't even know if I have a windows sdk =? Do I have to download it or something?

please note that I have little experience with libraries other than iostream so could you please explain in detail? Thanks =D
Last edited on Feb 17, 2012 at 8:37pm
Feb 17, 2012 at 9:36pm
What compiler and version are you using?
Feb 17, 2012 at 10:43pm
If you are using Visual Studio 2010, your Windows SDK is current; no need for downloading. If you have Visual Studio 2008, your SDK is for Windows Vista; you should download the latest SDK.

I don't know if other compilers/IDE's come with the SDK or not, so to be on the safe side you might want to download it.
Feb 18, 2012 at 3:47pm
I'm using Code::Blocks so I don't think I have the sdk. Is it easy to download?
Feb 18, 2012 at 4:23pm
Code::Blocks is an IDE that works with many different compilers, but it tends to come bundled with the GCC, which on Windows would be called "MinGW".

The Windows SDK is not magical -- it has to be properly implemented for each compiler. Hence, we need to know what compiler you are using.

If it is MinGW, then one of these is correct: http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/
You need to determine the version of your compiler to get the correct WinAPI kit.
Feb 18, 2012 at 6:37pm
Duoas wrote:
The Windows SDK is not magical -- it has to be properly implemented for each compiler. Hence, we need to know what compiler you are using.


Wow, really??? I really thought it was! I guess that's what I get for never using anything else than Visual Studio.

Do you know what are the changes made? Just out of curiosity. I really don't NEED to know.
Feb 19, 2012 at 8:19pm
Right now, I'm using Code::Blocks ver 10.05. What version of the api should I download?
Feb 19, 2012 at 8:37pm
I am pretty sure that DirectInput is part of the DirectX SDK. The DirectX SDK may be a part of the windows sdk, but downloading it just for DirectInput seems a bit like a waste.

Oh, and there's really no easy way of getting Joystick input, even when you're using DirectInput (actually, especially when you're using DirectInput - it's not exactly straight forward).
Feb 20, 2012 at 2:51am
@webJose
It depends on how the compiler links to external symbols, and on how to properly define and align types. That's all.
Last edited on Feb 20, 2012 at 2:52am
Feb 20, 2012 at 7:37am

Oh, and there's really no easy way of getting Joystick input, even when you're using DirectInput (actually, especially when you're using DirectInput - it's not exactly straight forward).


Nothing involving MS Windows is straight forward.
Feb 20, 2012 at 10:42pm
Bull.
Pages: 12