Jump to content
  • Advertisement
Sign in to follow this  
AmbushGames

Gamepads in Assembly

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

Advertisement


(be sure to support USB hubs as well, not every USB port will have its own dedicated connection to the controller)
Just FYI, hubs are a mandatory part of the protocol. Even the ports on your PC are actually downstream-facing ports of an internal hub. If you only have one port on your entire computer, that's internally a hub with one downstream-facing port. The only difference between it and an external port multiplexer is that the built-in hubs' upstream interface is a PCI client controller or suchlike, instead of being an upstream USB port.

Share this post


Link to post
Share on other sites

How do I use the USB hubs? Couldn't find a tutorial and my knowledge doesn't reach that far.

 

In assembly and you're writing an OS?

 

For how to write to the hardware, you use the various port instructions (in/out, ins/outs, insd/outsd) and writing to specific memory addresses.  If you are writing an OS in assembly those should be within your knowledge.  

 

You'll need to implement quite a lot of functionality to work with the devices, as they are implemented as plug and play interfaces.  You'll have a phase of scanning and detection, a phase of self-configuration, implementing all of that is going to be a bit of work.  You can look at how the Linux kernel and a few other open source systems do it, but they mostly used C for most of the heavy work and their own libraries for the CPU-specific blocks of assembly code for the lowest-level hardware access mentioned above.  Intel has documentation for that.

 

Once you're able to talk to the hardware, and you're able to run the plug-and-play configuration code, you'll need to communicate with the USB protocols.  It is packet based and works in a daisy-chain fashion where you (the OS implementer) will need to track the paths through to the devices and different devices have their own sub-protocols. At the least you'll need to implement the protocol for host, interconnect, and hub functionality, plus you'll need device function enumeration. The OSDev Wiki linked to above has many specific that can help there and F/OSS implementations can serve as reference.

 

Once you've finally got through to the USB device itself, and you've identified it as a HID gamepad device you are willing to support, you'll need to implement the protocol for that as well.  Again, the OS Wiki and existing F/OSS implementations can serve as reference.

 

 

What you describe is an enormous project. The only ones that have succeeded have required large public communities or well-funded corporations. Good luck on whatever you are attempting to achieve.

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!