XInput / 360 controller emulation

Started by
1 comment, last by ubersheep 16 years, 1 month ago
Hi all, As part of my course, we are required to build an app that supports the Xbox 360 Controllers for PC. I currently don't have a 360 Controller, just an old 'PS2-style' controller :( Is there a chance that my standard controller could be supported by XInput (without using *any* of DirectInput?) Alternatively, is there such thing as an app to fool my app/Windows into thinking that a 360 controller is connected (in order for me to do any testing away from University, where 360 controllers are plentiful :-\ ) Also alternatively, is there any kind of 360 controller emulator, that could send/receive controller messages? Sorry if this has been asked before, thanks in advance :) -=ubersheep=-
Advertisement
1. Nope. XInput won't work with controllers that it doesn't know about. This includes old ones that only have DirectInput drivers. You'd need an updated driver for your joypad for it to show up in XInput.


2. I don't know of anything to fool XInput into seeing a DirectInput device though it should be possible. I suspect that to do it properly would likely involve writing a device driver (and handling mapping between the controller and what XInput expects). Even to do it hackily is going to involve fooling the device node structures into thinking you'd just inserted an XInput controller. To be honest I'd save the headaches and spend the £20 on a wired Xbox controller.


3a. I take it the focus of the task/application is to do something interesting that has controller input rather than just "make an application that uses XInput"?

3b. XInput doesn't have many functions. What I'd do (assuming no access to a real controller) is write fake versions of all the XInput functions the app needs to use (with identical names and function prototypes) and not link against xinput.lib whilst using the fakes instead of the real ones.

3c. What your fake functions actually do is up to you - they could just return known test values; or you could fake some input using the keyboard and GetAsyncKeyState(); or you could even read DirectInput joypad input and present it in an XInput way. All of those options should be quite easy to implement.

3d. 3c is actually quite good practice IMO, particularly wrapping DirectInput with what to your app looks like XInput. It's similar to the things you can face in the professional game development world.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

The task we have been set is an odd one - it's a graphics demo; terrain, objects, cameras, that sort of thing, but a core requirement is that we use the Xbox360 Controllers, and I guess as a result, XInput.

I didn't particularly fancy shelling out for a controller, I'm not much of a PC gamer (outside of RTS's and the odd game of Day Of Defeat), so didn't want to spend money on a controller I would barely use... though come to think of it, if it's as good as I've heard, I may end up using it anyway.

That is a really good idea, implementing faux functions to replace the XInput ones for the time being :) will give this a go either today or tomorrow.

You're right though - I should attempt to integrate DirectInput as well, especially as it will be good practice. For now (for the next few weeks at least) will focus on implementing XInput.



BTW, I saved the headache with it all in the end:

£18 + free shipping from Play.com
http://www.play.com/PC/PCs/4-/842412/Microsoft-XBox-360-Controller-For-Windows/Product.html

- can't go wrong :)


Thanks :) Much appreciated

This topic is closed to new replies.

Advertisement