Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Error: Joystick 0 does not exist

Author
Message
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 18th Mar 2020 18:06 Edited at: 18th Mar 2020 18:07
I have this code

When I run it, it will work fine, but then when I make a change, say delta*200 to delta*100, suddenly I get the message "Error:Joystick 0 does not exist" and it will point me to the GetRawJoystickY(1) line. Even if I change the code back the way it was, it won't work. Leave the computer for a few minutes, then it works again. It seems to work all the time if I run debug, and if I compile only, then run the .exe. But when pressing the green arrow, I seem to have a few runs, then the error.
Weird thing is, I am not reading joystick 0, and the docs say that joysticks are numbered 1-8, so the error doesn't make sense to begin with.

Edit to add: I am using AppGameKit Classic 2019.12.16 version

The author of this post has marked a post as an answer.

Go to answer

SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 18th Mar 2020 20:23 Edited at: 18th Mar 2020 20:24
This post has been marked by the post author as the answer.
I think the error flags index 0 even though it starts at 1 in code. What may be happening is an intermittent failure of device enumeration prior to polling for input. And it could be getting triggered (intermittently or otherwise) by certain compile/run methods rather than others.

Are you enumerating your device(s) before trying to poll it/them? Any raw joystick commands should be preceded with this outside of the main loop:

CompleteRawJoystickDetection()

If you're not doing that, try this next and see if it changes the behavior at all. If the failure still occurs (particularly intermittently), then it's also a good idea to always check for a device's existence before trying to poll from it. So change your polling lines to something like this:



You can also optionally check for a device's existence right after enumerating, then display an error message if no device is detected before your main loop ever executes.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 18th Mar 2020 21:45
CompleteRawJoystickDetection() seems to have done the trick. Thanks

Login to post a reply

Server time is: 2024-04-18 11:54:21
Your offset time is: 2024-04-18 11:54:21