# Controller support for directx 8.0 or general windows game?

This topic is 796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi

Im using a game engine that utilizes directx 8.0 (so only windows!) and as input I can use mouse and keyboard fine. However any tips on how to add support for a controller? (preferably one with analog sticks as well such as the xbox 360 controller, even though input such as none, left, left-up etc is ok for the analog controller).

Can I do it directly? Any free library I can use? I prefer if it's as simple as possible, and prefer if I can add support for TWO controllers (USB-connected is what I know is used i guess).

Thanks!
Erik

##### Share on other sites

DirectInput is still working and being fine for all controllers. It's marked as deprecated my MS, however I still do not see a full viable replacement for it yet.

A newer option would be XInput, which however does not support the full range of devices like DirectInput does. I haven't looked but last time it didn't support Force Feedback either.

And then there's RawInput, which is a bit of a hassle to get going, but is also able to support all kind of devices. Albeit you may have to interop with DirectInput if you want to get sensible display names for controls/devices.

##### Share on other sites

It doesnt seem very straightforward to set up. Would you recommend some library like SFML:

instead of doing it "raw" from directx 8.0? Im not sure were to start. I basically want to be able to check key-states like:

if(controller[0].keyIsPressed(_FORWARD_KEY))
moveForward();

Must also be able to check if controllers are plugged in (and what their indexes are)

Edited by suliman

##### Share on other sites

Of course SFML could be used, that usually also takes off the work of all the other parts you set up already.

RawInput isn't that hard to set up though if you only go for the basic things (keyboard, mouse) first. It's only a bit finicky with other controllers. You do get everything packed up, the trouble is, that raw input does not provide nice texts, just the data.

The sample code at https://msdn.microsoft.com/en-us/library/windows/desktop/ms645546(v=vs.85).aspx is basically all you need for mouse and keyboard.

##### Share on other sites

Did some research.

DirectInput might be best for me if I want general controller support. It can still handle analog sticks right? (different "amounts" of right or left etc).

Is there any minimal tutorials out there? All i find are walls of texts and not fully compilable, easy to understand examples.

Thanks!

##### Share on other sites

Yeah, of course it can do analog.

Regarding samples, you might have luck in older DirectX SDKs, they had nice samples.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 56
• 17
• 28