Controller support for directx 8.0 or general windows game?

Started by
5 comments, last by Endurion 6 years, 7 months ago

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

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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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)

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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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!

Yeah, of course it can do analog.

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

 

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement