Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenTK 3.1 crashes on startup on 64+ button joysticks #1020

Closed
tyronx opened this issue Mar 3, 2020 · 5 comments
Closed

OpenTK 3.1 crashes on startup on 64+ button joysticks #1020

tyronx opened this issue Mar 3, 2020 · 5 comments

Comments

@tyronx
Copy link
Contributor

tyronx commented Mar 3, 2020

Description

OpenTK just straight up crashes if any joystick is connected to the device that has more than 64 buttons

Repro steps

  1. Install vJoy: http://vjoystick.sourceforge.net/site/index.php/download-a-install/download
  2. Configure vJoy, set one Joystick to 70 buttons
  3. Launch any application that uses OpenTK 3.1. Crashes with below exception
System.ArgumentOutOfRangeException: Das angegebene Argument liegt außerhalb des gültigen Wertebereichs.
Parametername: button
   bei OpenTK.Input.JoystickState.SetButton(Int32 button, Boolean value)
   bei OpenTK.Platform.Windows.WinRawJoystick.QueryDeviceCaps(Device stick)
   bei OpenTK.Platform.Windows.WinRawJoystick.RefreshDevices()
   bei OpenTK.Platform.Windows.WinRawJoystick..ctor(IntPtr window)
   bei OpenTK.Platform.Windows.WinRawInput.CreateDrivers()
   bei OpenTK.Platform.Windows.WinInputBase.ProcessEvents()
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ThreadHelper.ThreadStart()
-------------------------------

There's apparently a hardcoded array of 64 buttons, once it goes beyond that the init code crashes.

I already brute-force fixed this for my needs by just catching exceptions during joystick init and then ignoring that joystick, diff here: anegostudios@c40eabd

A build of OpenTk with that fix in there will roll out to a sizable amount of users within a few days so that should sufficiently test the change.

I can make a merge request to the 3.x branch if you like.

@tyronx tyronx changed the title OpenTK 3.1 crashes on startup on 64+ button joystick OpenTK 3.1 crashes on startup on 64+ button joysticks Mar 3, 2020
@peppy
Copy link
Contributor

peppy commented Mar 3, 2020

If you need a quick solution, here's our patch for it: ppy#59

@varon
Copy link
Member

varon commented Mar 6, 2020

@tyronx - Must have missed this.

We'd love to merge a fix for this.

@tyronx
Copy link
Contributor Author

tyronx commented Mar 8, 2020

@varon sure, mind if I do the PR together with some build script fixes for windows?

@varon
Copy link
Member

varon commented Mar 9, 2020

@tyronx - That would be fantastic.

@tyronx
Copy link
Contributor Author

tyronx commented Apr 21, 2020

This has been fixed in released in OpenTK 3.2, so closing issue.

@tyronx tyronx closed this as completed Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants