Joystick detection

Monkey Forums/Monkey Programming/Joystick detection

Sensei(Posted 2013) [#1]
Any idea how to go about detecting a joystick on a target/platform?

Because of the way I've implement control in my game, I currently have 4 control methods in place that change/set the same variables for control, ie ouya, android, keyboard, joystick.
However, I was hoping there would be a way to detect a joystick, no matter which platform (if possible) to allow that to be used instead of keyboard (for example on XNA/GLFW builds).
At the moment I basically use this code logic:

  Method getControls:Void()
    #If OUYA="1"
      updateOuyaControls()
    #ElseIf TARGET="android"
      updateAndroidControls()
    #ElseIf TARGET="html5"
      updateKeyboardControls()
    #Else
      updateKeyboardControls()
      updateJoystickControls()
    #End
  End


So for everything else it runs keydowns and joydowns which is handy as you can use both/either controls if you have them :)


Markus(Posted 2013) [#2]
its better you have a dialog where the user can press a button
and then you memory the unit id.
i can't see a enum command for input devices in monkey. :(

mixing all input devices (key+mouse+joy) together can result in problems.


ElectricBoogaloo(Posted 2013) [#3]
Indeed, just yesterday I attempted to plug in a decade old "Windows 98 compatible!" joystick into my system, only to have my game freak out a bit, and kinda lock itself up, because the joystick was sending incredibly dodgy signals.

:\

With OUYA, you've got a better range of compatibility, and until I plugged that particular joystick in, everything's been running tickity-boo. I'd say it's more a case of "Don't try using that old joystick you found lying in your drawer" than it is "OOOPS!! I KANT KODE GUDLY!!"

I honestly wouldn't worry about trying to achieve an "Anything Goes" style of brute-force coding. It doesn't seem to cause too much of an issue, as long as you then account for everything, and double check that it works properly. Be sure you leave nothing "Click Only", and have fallback buttons for everything.

If anything at all fails, the OUYA Review Team seem amazingly good at testing your games for you, too. Their feedback to me, so far, has been outstanding.


Sensei(Posted 2013) [#4]
Thanks guys. I was just hoping to detect first, then in the menu, be able to provide appropriate text, " press space to start" or "push fire to start" based on if a joystick was detected. The ouya, android and html5 are covered as can be seen. The "issue" crops up when you compile for glfw or xna.

Congrats on your Ouya game @electricboogaloo.
I should try it, as I loved it on html5.