richardjmoss's picture

Joystick events not firing


I was trying to get joystick support working in my game project, so I started off with a simple test to try and show when the joystick (in this case an XBox 360 controller) was being accessed:

    protected override void OnLoad(EventArgs e)
      this.Joysticks[0].ButtonDown += this.ButtonTest;
      this.Joysticks[0].ButtonUp += this.ButtonTest;
      this.Joysticks[0].Move += this.MoveTest;
    public void ButtonTest(object sender, OpenTK.Input.JoystickButtonEventArgs e)
    public void MoveTest(object sender, OpenTK.Input.JoystickMoveEventArgs e)

However, when I ran this code, no output was displayed on the console. After some quick Googling, I found one approach which said to modify RaiseUpdateFrame to call InputDriver.Poll();. I changed my projects to use the OpenTK source code, and tried this approach. Now I started getting output.

But, the property is marked as obsolete (along with a whole other bunch of input interfaces). And besides, at this point I don't really want to be running on a non-standard version of OpenTK.

So if it's obsolete, what is the correct method of getting joystick input?

I haven't tried Mouse support yet but I need to add that too - am I going to have the same issues with this or does it just work?

I also noted a completely blank implementation for GamePad... is this not getting finished?

Richard Moss


Comment viewing options

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

Noticed that InputDriver property and Poll method were public so I've plugged that directly into my code instead (lucky for me as I was about to start exacting bits of Tao.Sdl to use instead).

Regardless however, that doesn't resolve the fact it's flagged as obsolete. What's the plan for Joysticks, GamePads etc? Do you intend for them to remain a part of the OpenTK core or should we be looking to external solutions (e.g. SDL)?