Jump to content
  • Advertisement
Sign in to follow this  
suliman

Controller support for directx 8.0 or general windows game?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
Share on other sites

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

https://www.sfml-dev.org/tutorials/2.4/window-inputs.php

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!