QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: SirCrow on August 21, 2018, 05:15:25 pm

Title: Checking for JOYSTICK Input
Post by: SirCrow on August 21, 2018, 05:15:25 pm
Okay, so _MOUSEINPUT is how we check for any new mouse info;  is there an equivalent for a joystick?
Or do I always have to check for every possible move or button press using STICK and STRIG? Thanks.
Title: Re: Checking for JOYSTICK Input
Post by: SMcNeill on August 21, 2018, 05:18:26 pm
http://qb64.org/wiki/DEVICES <--- If you're looking for joystick support, this is the set of commands you'll want to use.

 
Code: QB64: [Select]
  1.   PRINT STR$(i) + ") " + _DEVICE$(i) + " Buttons:"; _LASTBUTTON(i); ",Axis:"; _LASTAXIS(i); ",Wheel:"; _LASTWHEEL(i)
  2.  
  3.   d& = _DEVICEINPUT
  4.   IF d& THEN '             the device number cannot be zero!
  5.     PRINT "Found"; d&;
  6.     FOR b = 1 TO _LASTBUTTON(d&)
  7.       PRINT _BUTTONCHANGE(b); _BUTTON(b);
  8.     NEXT
  9.     FOR a = 1 TO _LASTAXIS(d&)
  10.       PRINT _AXIS(a);
  11.     NEXT
  12.     FOR w = 1 TO _LASTWHEEL(d&)
  13.       PRINT _WHEEL(w);
  14.     NEXT
  15.     PRINT
  16.   END IF
  17. LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
  18.  
  19. END  [\code]
Title: Re: Checking for JOYSTICK Input
Post by: johnno56 on August 21, 2018, 05:47:18 pm
I just tried the listings in the wiki DEVICES... Mouse worked great...
Dare I test my dust covered joystick? Dare I did...
It detected all 12 buttons and all 6 axes... Cool.

Are there any QB64 games that are written for a stick? (I know... I know... 'Why not try making one'? Right? *sigh*)
Title: Re: Checking for JOYSTICK Input
Post by: FellippeHeitor on August 21, 2018, 06:04:56 pm
My Spaceship game does use a joystick if available: https://github.com/FellippeHeitor/Spaceship
Title: Re: Checking for JOYSTICK Input
Post by: johnno56 on August 21, 2018, 07:28:13 pm
I think the game is looking for a gamepad-like device as a controller. It detects my joystick ok but when assigning the functions it's asking for 'buttons' and will not accept the stick axes. I do not know enough of QB64 and it's stick commands to fix it. Sorry.

J
Title: Re: Checking for JOYSTICK Input
Post by: FellippeHeitor on August 21, 2018, 07:28:46 pm
I programmed it to use buttons only indeed. I play it at home with a PS4 controller.
Title: Re: Checking for JOYSTICK Input
Post by: johnno56 on August 21, 2018, 07:39:26 pm
Not a problem. At least I can still use the keyboard... lol  Besides, keyboard; stick or pad, I still get killed off to quickly... lol

Title: Re: Checking for JOYSTICK Input
Post by: SirCrow on August 21, 2018, 07:47:30 pm
http://qb64.org/wiki/DEVICES (http://qb64.org/wiki/DEVICES) <--- If you're looking for joystick support, this is the set of commands you'll want to use.  .
.
.
.

Thanks.  I tried  IF _DEVICEINPUT(3) THEN ...  and it seems to work, but I can't get it to turn my spaceship and fire at the same time...at least not very nicely.
There's a conflict of some kind, and I can't identify it.  I'll keep working on it.
Title: Re: Checking for JOYSTICK Input
Post by: SirCrow on August 21, 2018, 09:37:55 pm
UPDATE: I've figured it out and now my StarBlast ship can both turn and fire simultaneously using a joystick
Now it's just a matter of tweaking it and getting over the initial awkwardness of controlling it in this new way.