BlueMonkMN's picture

Shall I Implement Joystick support on Windows platform

Because I'm trying to eliminate all traces of DirectX from SGDK2, I'll be manually implementing joystick support using winmm.dll. I've copied a couple lines from Tao because I didn't know the correct MarshalAs attributes to apply to some strings in the JOYCAPS structure, and a Google search for JOYCAPS returned a page of Tao source code. (Is that kosher?)

Might you be interested in the Joystick class when it's done, or will you be basing Joystick support on something else?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

I've attached the code I'm working on. It's not 100% ready (works with polling but no events of any kind), but it should be easy to flesh out. It builds on your code for windows.

The idea is quite simple:

You instantiate an IJoystickDriver that enumerates all connected joystick devices. You can then access available joysticks like this:

driver.Poll();   // Call once per frame to update state.
foreach (Joystick js in driver.Joysticks)
    foreach (float axis in js.Axes)
    foreach (bool button in js.Buttons)

You have to poll the driver, because the Joystick class is dumb and doesn't know how to update itself (by design).

Edit: really attached this time.

Edit 2: fixed implementation windows, please download the new file!

Joystick r2.7z37.61 KB