Author Topic: Checking for JOYSTICK Input  (Read 4145 times)

0 Members and 1 Guest are viewing this topic.

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Checking for JOYSTICK Input
« 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.
I may not always finish what I've started....

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Checking for JOYSTICK Input
« Reply #1 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]
« Last Edit: August 21, 2018, 05:21:11 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Checking for JOYSTICK Input
« Reply #2 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*)
Logic is the beginning of wisdom.

FellippeHeitor

  • Guest
Re: Checking for JOYSTICK Input
« Reply #3 on: August 21, 2018, 06:04:56 pm »
My Spaceship game does use a joystick if available: https://github.com/FellippeHeitor/Spaceship

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Checking for JOYSTICK Input
« Reply #4 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
Logic is the beginning of wisdom.

FellippeHeitor

  • Guest
Re: Checking for JOYSTICK Input
« Reply #5 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.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Checking for JOYSTICK Input
« Reply #6 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

Logic is the beginning of wisdom.

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Checking for JOYSTICK Input
« Reply #7 on: August 21, 2018, 07:47:30 pm »
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.
I may not always finish what I've started....

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: Checking for JOYSTICK Input
« Reply #8 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.
I may not always finish what I've started....