GLBasic forum

Main forum => GLBasic - en => Topic started by: Darmakwolf on 2013-Sep-09

Title: Possible glitch
Post by: Darmakwolf on 2013-Sep-09
I noticed (at least on my computer, have yet to try this on others,) with NO controller plugged in, GETDIGIY(0) returns -1. The moment I plug in a controller hub or any other controller, it returns 0.

Test it with this:
WHILE TRUE
PRINT GETDIGIX(0),5,5
PRINT GETDIGIY(0),5,25
SHOWSCREEN
WEND

with a controller plugged in, the proper value of Y should be 0. Unplugged for me it's showing up as -1.  :giveup:
Title: SOLVED!
Post by: Darmakwolf on 2013-Sep-19
Okay. It was pretty much me just coding inefficiently  :x

Basically let's say you poll joystick 0 and joystick 1, seeing what we get for input from the 1st two joysticks plugged into the computer. If they're indeed plugged in, of course you get proper input. If you had other controllers plugged in before, even if they are not not, you'll get erroneous data from the commands. To solve this, use GETNUMJOYSTICKS() and loop through available joysticks to get proper data from connected devices. Well now I know I guess :P
Title: Re: Possible glitch
Post by: MrTAToad on 2013-Sep-19
In addition, adding or removing joysticks during program execution will not update GETNUMJOYSTICKS