Joy-stick Input , is there such a thing ?

Is Joy-stick supported? I cant find ANY documentation or guides… Cant make it work like mouse or keyboard input…

I just need to get a set of floats corresponding to the joysticks X/Y movements…

There are 2 classes you can use for getting joystick input:

  1. Gamepad.GetState(), I recommend using this one because most people only need to get input from joystick that look similar to Xbox/Play Station controller, http://www.monogame.net/documentation/?page=T_Microsoft_Xna_Framework_Input_GamePad
  2. Joystick.GetState(), this can be used when you want to get input from unconventional controllers, or you want to get even lower access than Gamepad, one thing to note is that it’s only implemented on WindowsGL, Linux and OS X, http://www.monogame.net/documentation/?page=T_Microsoft_Xna_Framework_Input_Joystick

Hi, and thanks… I guess I should have specified: I know they actually exsist, I have done searches, looked at the docs, and fiddled around to make it work without succes…

I have already visited the links you provided, but they dont explain or show how to actually GET info from the stick… As far as I can tell, they merely show that they exsist…

I am unable to get values from my joystick axis, and I can find no examples of it either… Thats why Im wondering if it is actually implemented… Shouldnt I just be able to do something like (pseudo code):

 float ship_climb_rate = Joystick[0].getState.axes[0];    ?????

… But anyways, Im using a normal windows 8 game template, so joysticks wont work ? ? ?
-But I can use gamepads instead, thumbstick code for the joystick axis ? ? ?

Vector2 leftthumbstick = GamePad.GetState().ThumbSticks.Left;

Cool… I get what you are saying, its just like other input devices…

I still have an issue though, heres why:

I found out through break-points, that no game-pads are even detected… All 4 are connected = false…
My joystick responds in the windows calibration tool though…

There isnt some special initialization I need to do, is there?

No, no special initalization logic, on WindowsDX XInput is in charge of getting Joystick devices, and it doesn’t detect all joysticks…

But under normal surcumstances, I should be able to plug in usb joystick and just use GamePad.GetState(0) … is that correct?

“and it doesn’t detect all joysticks…”
But if windows calibration gets input, mono should too right? I dont get why it cant connect to monogame but it can connect to everything else :slight_smile: Its one of those super standard models, you’d think it was supported…

MonoGame uses .net on Windows, mono part of MonoGame has nothing to do with mono(software), but it has to do with mono(word, meaning one) which could be translated to One Game as in “Write once, play everywhere”.

Xinput is used to get gamepad data on Windows, Xinput is part of Direct X.

Screw it, made my own input device for now, out of a Usb mouse + card-board, + tape… And I just get input from mouse.getState instead…

If anyone finds a fix for undetected joystick / gamepads, let me know!

When you use GetState(), it requires a player index specified… Whats that about ?

I can use 0, the number zero,

or I can use PlayerIndex.one , two, three, or four…

What is this player index, and do I need to manage it somehow?

PlayerIndex is enum, and it’s used for gamepad GetState().

In joystick GetState() you use an int, that means that unlike gamepad, joystick doesn’t have a fixed amount on how many controllers can one game support.

both are just indices representing which controller to read from.

Thanks again for your time…

…Still cant make it work though…
I pretty much have a working flight sim, with the exception of joystick input…

So there are 5 things I would appricate help with, to troubleshoot/solve my issue of detected=false for various input devices…

  1. Controllers are automatically indexed in the order they are plugged in? Or do certain USB ports correspond with certain player index numbers ?

  2. What does the zero in Gamepad.GetState(0) mean, since the other overloads are players 1 -4?

  3. Does Joystick enumeration begin at 0 for the first player?

  4. if I can use my joystick in windows, wouldnt that imply that theres a way to use it in monogame?

  5. Is there perhaps some online library of joystick support files or something ?
    Should I force load a different driver than the one windows autodetects? -Even if windows warns me of severe stability issues ? ? ?

  1. Automatically in the order starting from 0
  2. Would be player one, but you need to use PlayerIndex enum
  3. yes
  4. no…
  5. Xinput? it’s available for C#…

hmm… ok… Looks like i need a new input device…

Any idea as to why I cant use my particular stick in MY game, runnong on windows, but windows itself CAN use it?
I thought there would have been a way for me to poll windows for that data or something…
What are other programmers doing that I am not, since they can use my joystick?

And before I go buy:

Is there some sort of list of approved brands or models…?

… Also what do I tell end users? You’re USB joystick might not be compatable?

I feel like this cant be true, like I’m missing something… But maybe thats todays world?

…Anyways thanks for any replies, I think answers to these last questions should wrap up this topic for now…

This might be an important fact that was overlooked. If you are developing a Windows Store game, then XInput is the only game controller input API available, and along with it the inherent limits that XInput imposes. DirectInput is not available for Windows Store apps.

Its just a windows game, not intended for the store at all. Its just going to be a .rar file for whoever wants it… I dont care much about release on this my 2nd 3d game, I just want to fly above my terrain using this sweet ass joystick I have… :slight_smile:

Does that mean I have a shot at getting input from legacy usb devices?

There are several Windows project types, and some have different limitations than others, including input devices. That’s why the specific type of Windows project is important here. You mentioned Windows 8, which has usually meant the Windows Store project type (previously referred to as a Metro app). The Windows Desktop type is what we would call a normal Windows application, but for Windows Desktop we have support for DirectX (Windows) and OpenGL (WindowsGL via OpenTK).

If you are developing for the Windows desktop, have you tried the WindowsGL version of MonoGame? It uses OpenTK to gather input. I’m not sure what OpenTK supports internally, but it may work better for you than the Windows version of MonoGame which supports DirectX.

I see what you are saying about choosing project types, to match various tasks…

-But I still dont understand why this problem exsists in my case… Windows already gets input from my joystick, and I am making a windows game… Why cant I get those numbers from within my game somehow, like I do with screen size or system time?

Right now, I dont see any justification for making half a billion game controllers around the globe unusable… Any future joystick I buy would have the excact same components and functions as my current one, what a complete waste…