Tal's picture

[Solved Mostly]Can't read joystick properly

Here is my Joystick test(part of a GameWindow code and I use VS debugger):

protected override void OnUpdateFrame(FrameEventArgs e)
{
    base.OnUpdateFrame(e);
 
    if (Keyboard[Key.Escape])
        Exit();
    int cont = Joysticks[0].Button.Count;
    for (int i = 0; i < cont; i++ )
        if (Joysticks[0].Button[i])
            throw (new Exception());
}

As you can guess by the title, no exeption is thrown when I push all the buttons!
I also check that the I have one and only one joystick by this test:

protected override void OnUpdateFrame(FrameEventArgs e)
{
    base.OnUpdateFrame(e);
 
    if (Keyboard[Key.Escape])
        Exit();
 
    int cont = Joysticks.Count;
    if (cont == 1)
        throw (new Exception());
}

And as you can guess, the exeption was thrown.
(Please don't critic me about my tests that they are'nt like NUnit and etc. :-) )
My joystick is made by Xcom and it looks like a standard Playstation's joystick. Here is a picture of it(sorry about the size):

It's fully supported by DirectX, and I play TrackMania with it without problems.
So what is the problem here?


Comments

Comment viewing options

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

very good work JWman,
thanks a lot for sharing!

int 10h

zekimen's picture

Thanks for this, helped me to solve a problem