iliak's picture

GamePad / Joystick support

Project:The Open Toolkit library
Version:1.1.0-stable
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

Some time ago, I asked about the status of GamePad / Joystick support. What about now ? Is it a near / far / dream delay ?

Do you have any doc about how to implement it, so I can do the win32 part and give you the code to speed up things ?


Comments

Comment viewing options

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

#1

Version:all versions» 0.9.x-dev
Category:support request» task

Actually, Joystick input was implemented several months ago. Check the Joystick property of the GameWindow.

However, there's more that needs to be done for a proper solution (#969: [Input] Add static classes for Mouse, Keyboard and GamePad input). I was planning to work on this today, but was bogged down by some bugs in the binding generator.

The main idea is to provide an API that works independently of GameWindow. The win32 and x11 implementations already supports this - what we are missing is the public "frontend". Enter the input branch.

The frontend is supposed to work similar to the XNA API:

JoystickState state = Joystick.GetState(5); // Get the state of the sixth (zero-based) controller
if (state.IsButtonDown(JoystickButton.Button0)
{
    // Do something!
}

The input branch already contains an implementation for Keyboard and KeyboardState that can be used as a guide for Joystick/JoystickState.

The native implementations can be found under OpenTK/Platform/ and are named WinMMJoystick.cs/X11Joystick.cs respectively. They are created through the PlatformFactory interface (check the Keyboard code, it's very simple!)

I'd appreciate some help on this matter, there's a metric ton of work left to do for 1.0 beta1 ! :)

iliak's picture

#2

Ok, I'll make my way with my project, but I'll try to kind in mind your way. Once it's over I'll post a link to my code. But until you can go take a look at my svn.

BTW winmm.dll is a native Dx win32 dll, right (no need to install it) ?

the Fiddler's picture

#3

Alright.

Yes, winmm.dll comes preinstalled on Win98 and higher. Don't think its part of Dx, though.

iliak's picture

#4

Currently I can collect all available devices and gahter capabilities. It would be just a matter of time to poll joystick states now...

With winmm.dll you can't handle the force feedback of the joystick, and it's a must for my framework. I'll look at mdx directinput.dll to have force feedback support.

the Fiddler's picture

#5

May I suggest a slightly different approach? Check out SlimDX, they have a complete DX binding written in C++/CLI. You can either use it directly (simplest solution but unfortunately you'll have to distribute different packages for 32-/64-bit this way) or you can port the relevant directinput bindings to C#.

The issue with MDX is that it's dead technology and (last time I checked) you weren't actually allowed to redistribute it. (To be honest, that might only hold for MDX 2.0, not 1.1, but still).

I'm planning to add force feedback support for OpenTK 1.1 or another future release, but that's some way off right now.

iliak's picture

#6

Ok, I have some code sample working. You can have a look at the svn.

iliak's picture

#7

The latest revision support hot unplug events, no more crash.

the Fiddler's picture

#8

Version:0.9.x-dev» 1.1.0-stable
Status:open» closed

Implemented in opentk-1.1.0. Yay!