Jump to content
  • Advertisement
Sign in to follow this  
EGD Eric

What if I were to make a game controller?

This topic is 3620 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

Say I were making a game controller, and I stuck a motor in it, and I wanted that controller to respond to any existing PC game's rumble code? Is this possible? I don't know anything about driver programming, so does anyone know of any good books or articles I can read about this - to help me get started - thanks!

Share this post


Link to post
Share on other sites
Advertisement
Spider-Man 3, Spider-Man: Friend or foe, to name 2. Any game that's a port of a console game will probably have it. There's plenty of PC game controllers with rumble, I assume they didn't equip them with motors for nothing.

What is rumble code? Its like, when you're playing Spider-Man 3, and you jump off a building, land on the ground, you feel rumble. They must have had some code somewhere that said: when he lands, do a little vibration scaled to how hard he landed (how high he jumped from).

pController->Rumble(magnitude)

something like that. And it would be universal. DirectInput has functions you can call that will work on any game controller out there. There's no way these developers are writing code separately for each and every controller on the market.

What I want to know is: How can I get my controller to respond to DirectInput rumble calls. I'd need to write that into its driver somehow, right?

Of course, I should probably find out how to write a game controller's driver to begin with, so if anyone knows any good books on that, that'd be great, but I'm especially interested in the part about getting it to respond to DirectInput rumble.

PS: I know C/C++, but no assembler.

Share this post


Link to post
Share on other sites
Quote:
pController->Rumble(magnitude)

something like that. And it would be universal.


Except that it's not universal.

At some software library level, the function call you may might be universal (I don't know about windows). The driver level, and what is sent to the hardware (via USB, presumably) will differ from one controller to the next. xbox 360 controllers and, say, logitech dual-action rumble controllers do not work the same way, and have different drivers that send different things.

There's also potential patent issues if you're doing anything other than trying to make a controller for your own personal use (not even sure that's ok under patent law, but... I'm not a lawyer, so don't listen to me on that front.)

Look up a company named Immersion though, they've got the rumble patents.

The problem with trying to make a piece of hardware that would respond to "any rumble code" is that the "rumble code" is going through a driver, and the driver is likely (on linux, not sure about windows, but it's probably similar) going to be a bit picky about what hardware it talks to. So, in order for your hardware to even receive the "rumble codes" for an xbox 360 controller, say, it would have to pretend to *be* an xbox 360 controller. But in order for it to receive rumble codes for a logitech dual action rumble, it would have to pretend to *be* a logitech. It cannot pretend to be both... so I think you can't do what you want to do.

BTW, the interface to the xbox 360 rumble effect (as implemented by the linux driver anyhow) is that you can set up several "effects" that have properties like, magnitude, waveform, frequency, duration, etc (I forget
what they all are, but along those lines) and then when you trigger them, you don't specify all that, you just specify the number, like "tell the controller to play effect 1" where effect 1 was previously set up to be some particular kind of rumble. I imagine the windows interface is similar, as I suspect this scheme goes beyond the driver and is mirrored in the hardware. No idea if the logitech or others work similarly, but sure they don't work identically.

To sum up, I don't think you can build something that does what you want, unfortunately.




Share this post


Link to post
Share on other sites
Quote:
Original post by smcameron
To sum up, I don't think you can build something that does what you want, unfortunately.


Of course you can! You just need to make sure you write the HID driver for your hardware.

To be honest, though, if you don't know about writing drivers already, you've got a long road ahead of you before you can actually make a controller [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Codeka
Quote:
Original post by smcameron
To sum up, I don't think you can build something that does what you want, unfortunately.


Of course you can! You just need to make sure you write the HID driver for your hardware.

To be honest, though, if you don't know about writing drivers already, you've got a long road ahead of you before you can actually make a controller [smile]


Well, my presumption was that he wanted to make a piece of hardware that he could just plug in, and it would somehow use existing drivers. Perhaps my presumption was wrong (or, even stupid :) ). Also, a windows drivers is hardly "universal," though, granted, it might be "universal" enough for the OP's purposes.

Share this post


Link to post
Share on other sites
Quote:
Original post by smcameron
Well, my presumption was that he wanted to make a piece of hardware that he could just plug in, and it would somehow use existing drivers. Perhaps my presumption was wrong (or, even stupid :) ). Also, a windows drivers is hardly "universal," though, granted, it might be "universal" enough for the OP's purposes.


He did say "I'd need to write that into its driver somehow, right?" so I'm guessing that's where he was going with it. Anyway, yeah, we both agree that you'd have to write a driver (whether for Windows or Linux or whatever you want the hardware to work with)

Share this post


Link to post
Share on other sites
Yeah, I basically wanted to write my own driver. Do I need to know assembler for that? Or is there a language specific to drivers? C/C++ is what I know...

From what I can tell, there's really 2 types of controllers: DirectInput controllers (like logitechs and all the other ones) & XBox controllers. XBox controllers use XInput. If my controller can act as a DirectInput controller, then all DirectInput code should work for that one, right? XInput code wouldn't work, but that's OK.

Thanks for the responses, Does anyone know of any good books on writing drivers for game controllers?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!