Author Topic: Simple Joystick Detection and Interaction  (Read 4554 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Simple Joystick Detection and Interaction
« on: February 07, 2020, 01:13:44 pm »
A small little demo to help highlight how one would work with the joystick in QB64:

Code: QB64: [Select]
  1. D = _DEVICES 'Find the number of devices on someone's system
  2. '1 is the keyboard
  3. '2 is the mouse
  4. '3 is the joystick
  5. 'unless someone has a strange setup with multiple mice/keyboards/ect...
  6. 'In that case, you can use _DEVICE$(i) to look for "KEYBOARD", "MOUSE", "JOYSTICK", if necessary.
  7. 'I've never actually found it necessary, but I figure it's worth mentioning, just in case...
  8.  
  9.  
  10. DIM Button(_LASTBUTTON(3)) ' number of buttons on the joystick
  11. DIM Axis(_LASTAXIS(3)) 'number of axis on the joystick
  12.  
  13.  
  14.  
  15.     DO
  16.  
  17.         'This following little segment of code gets the joystick status for us
  18.         'The reason this is inside a DO...LOOP structure as I've created it,
  19.         'is so that my joystick's axis won't generate any form of lag for
  20.         'my program as I scroll them around to generate positive/negative values.
  21.  
  22.         IF _DEVICEINPUT = 3 THEN 'this says we only care about joystick input values
  23.             FOR i = 1 TO _LASTBUTTON(3) 'this is a loop to check all the buttons
  24.                 IF _BUTTONCHANGE(i) THEN Button(i) = NOT Button(i) 'and this changes my button array to indicate if a button is up or down currently.
  25.             NEXT
  26.             FOR i = 1 TO _LASTAXIS(3) 'this loop checks all my axis
  27.                 'I like to give a little "jiggle" resistance to my controls, as I have an old joystick
  28.                 'which is prone to always give minute values and never really center on true 0.
  29.                 'A value of 1 means my axis is pushed fully in one direction.
  30.                 'A value greater than 0.1 means it's been partially pushed in a direction (such as at a 45 degree diagional angle).
  31.                 'A value of less than 0.1 means we count it as being centered. (As if it was 0.)
  32.                 IF ABS(_AXIS(i)) <= 1 AND ABS(_AXIS(i)) >= .1 THEN Axis(i) = _AXIS(i) ELSE Axis(i) = 0
  33.             NEXT
  34.         ELSE EXIT DO
  35.         END IF
  36.     LOOP
  37.  
  38.     'And below here is just the simple display routine which displays our values.
  39.     'If this was for a game, I'd choose something like Axis(1) = -1 for a left arrow style input,
  40.     'Axis(1) = 1 for a right arrow style input, rather than just using _KEYHIT or INKEY$.
  41.  
  42.  
  43.     CLS
  44.     FOR i = 1 TO _LASTBUTTON(3) 'A loop for each button
  45.         PRINT "BUTTON "; i; ": "; Button(i) 'display their status to the screen
  46.     NEXT
  47.     FOR i = 1 TO _LASTAXIS(3) 'A loop for each axis
  48.         PRINT "Axis "; i; ": "; Axis(i) 'display their status to the screen
  49.     NEXT
  50.  
  51.     _LIMIT 30
  52. LOOP UNTIL _KEYHIT = 27 'ESCAPE to quit
  53.  
  54. SYSTEM 'And that's all it is to it!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #1 on: February 07, 2020, 01:36:51 pm »
Yes, that's what I was getting at in Terry's asteroids thread. I would think every gamer here would want to add something like this. I mean imagine if Atari came out with a keyboard plugin with just the wasdx and the Enter key on it. Who the hell would pay extra for that control option?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #2 on: February 16, 2020, 07:37:22 pm »
Plugged in my old USB Logitech Extreme3D Pro joystick, after blowing off all the dust... lol, and your programme  detected all 12 buttons and 6 axis correctly... I wonder which QB64 game could make use of my old joystick? Any guesses? (I don't want to put it back in storage... unless...)

J
Logic is the beginning of wisdom.

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #3 on: January 30, 2021, 09:24:57 pm »
I just gave this code a try and it worked!

Update: I figured out what was happening in my code, basically it was setting the axis and button count when the user pressed a button or moved a stick, so until that happened it had nothing to report.

Below is my updated test program to read upto 4 joysticks with 2 buttons and 3 axes each (you can increase or change by modifying the constants). Hope this helps someone.

One question though. 

In your code you check for device 3:

Code: QB64: [Select]
  1.                 IF _DEVICEINPUT = 3 THEN ' this says we only care about joystick input values
  2.             FOR i = 1 TO _LASTBUTTON(3) ' this is a loop to check all the buttons
  3.  

and I modified it to read upto 8 devices (code below), but it seems my code isn't detecting the devices until a button is pressed or the stick is moved.

Can anyone explain would you would count how many controllers are connected without the player having to move or press a button?


Code: QB64: [Select]
  1. ' ################################################################################################################################################################
  2. ' Multi gamepad test
  3.  
  4. ' BASED ON CODE BY SMcNeill FROM:
  5. ' Simple Joystick Detection and Interaction  (Read 316 times)
  6. ' https://www.qb64.org/forum/index.php?topic=2160.msg129051#msg129051
  7. ' ################################################################################################################################################################
  8.  
  9. ' =============================================================================
  10. ' GLOBAL DECLARATIONS a$=string, i%=integer, L&=long, s!=single, d#=double
  11.  
  12. ' boolean constants
  13. CONST FALSE = 0
  14. CONST TRUE = NOT FALSE
  15.  
  16. ' =============================================================================
  17. ' UDTs
  18.  
  19. ' UDT TO HOLD THE INFO FOR A PLAYER
  20. TYPE PlayerType
  21.     x AS INTEGER ' player x position
  22.     y AS INTEGER ' player y position
  23.         c AS INTEGER ' character to display on screen
  24.         xOld AS INTEGER
  25.         yOld AS INTEGER
  26.         buttonCount AS INTEGER
  27.         axisCount AS INTEGER
  28. END TYPE ' PlayerType
  29.  
  30. ' =============================================================================
  31. ' GLOBAL VARIABLES
  32. DIM ProgramPath$
  33. DIM ProgramName$
  34.  
  35. ' =============================================================================
  36. ' INITIALIZE
  37. ProgramName$ = MID$(COMMAND$(0), _INSTRREV(COMMAND$(0), "\") + 1)
  38. ProgramPath$ = LEFT$(COMMAND$(0), _INSTRREV(COMMAND$(0), "\"))
  39.  
  40. 'DIM a$ ' string
  41. 'DIM i% ' integer
  42. 'DIM L& ' long integer
  43. 'DIM s! ' single precision
  44. 'DIM d# ' double precision
  45. 'DIM bValue% ' boolean is an integer
  46.  
  47. ' =============================================================================
  48. ' TRY THE MOUSE
  49. main ProgramName$
  50.  
  51. ' =============================================================================
  52. ' FINISH
  53. SYSTEM ' return control to the operating system
  54. PRINT ProgramName$ + " finished."
  55.  
  56. ' /////////////////////////////////////////////////////////////////////////////
  57.  
  58. SUB main (ProgName$)
  59.         DIM RoutineName AS STRING :: RoutineName = "main"
  60.         DIM in$
  61.         DIM iDeviceCount AS INTEGER
  62.        
  63.         iDeviceCount = _DEVICES ' Find the number of devices on someone's system
  64.        
  65.         ' 1 is the keyboard
  66.         ' 2 is the mouse
  67.         ' 3 is the joystick
  68.         ' unless someone has a strange setup with multiple mice/keyboards/ect...
  69.         ' In that case, you can use _DEVICE$(i) to look for "KEYBOARD", "MOUSE", "JOYSTICK", if necessary.
  70.         ' I've never actually found it necessary, but I figure it's worth mentioning, just in case...
  71.        
  72.         if iDeviceCount > 2 then
  73.                 TestJoysticks
  74.         else
  75.                 PRINT "No joysticks found."
  76.         end if
  77.        
  78.         INPUT "PRESS <ENTER> TO CONTINUE", in$
  79. END SUB ' main
  80.  
  81. ' /////////////////////////////////////////////////////////////////////////////
  82.  
  83. SUB TestJoysticks()
  84.         DIM RoutineName AS STRING :: RoutineName = "TestJoysticks"
  85.        
  86.         CONST cMaxPlayers = 8
  87.         CONST cMaxButtons = 2
  88.         CONST cMaxAxis = 2
  89.        
  90.         DIM in$
  91.         DIM iDeviceCount AS INTEGER
  92.         DIM iDevice AS INTEGER
  93.        
  94.         ' WE'RE PREPARED TO SUPPORT UPTO 8 JOYSTICKS, WITH UPTO 2 BUTTONS AND 2 AXES EACH
  95.         ' (THIS IS FOR ATARI 2600 JOYSTICKS)
  96.         DIM arrButton(8, 2) ' number of buttons on the joystick
  97.         DIM arrAxis(8, 3) ' number of axis on the joystick
  98.         'DIM Button(_LASTBUTTON(3) ) ' number of buttons on the joystick
  99.         'DIM Axis(_LASTAXIS(3) ) ' number of axis on the joystick
  100.        
  101.         DIM arrPlayer(8) AS PlayerType ' holds info for each player
  102.         DIM iNumPlayers AS INTEGER
  103.         DIM iPlayerLoop AS INTEGER
  104.         DIM iNextY AS INTEGER
  105.         DIM iNextX AS INTEGER
  106.         DIM iNextC AS INTEGER
  107.         DIM iLoop AS INTEGER
  108.        
  109.         ' COUNT # OF JOYSTICKS
  110.         iDeviceCount = _DEVICES ' Find the number of devices on someone's system
  111.         IF iDeviceCount < 3 THEN
  112.                 CLS
  113.                 PRINT "NO JOYSTICKS FOUND, EXITING..."
  114.                 INPUT "PRESS <ENTER>", in$
  115.                 EXIT SUB
  116.         END IF
  117.        
  118.         ' BASE # OF PLAYERS ON HOW MANY CONTROLLERS FOUND
  119.         iNumPlayers = iDeviceCount - 2 ' TODO: find out the right way to count joysticks
  120.         IF iNumPlayers > cMaxPlayers THEN
  121.                 iNumPlayers = cMaxPlayers
  122.         END IF
  123.        
  124.         ' INITIALIZE PLAYER COORDINATES AND SCREEN CHARACTERS
  125.         iNextY = 1
  126.         iNextX = -3
  127.         iNextC = 64
  128.         FOR iPlayerLoop = 1 to iNumPlayers
  129.                 iNextX = iNextX + 4
  130.                 IF iNextX > 80 THEN
  131.                         iNextX = 1
  132.                         iNextY = iNextY + 4
  133.                 END IF
  134.                 iNextC = iNextC + 1
  135.                 arrPlayer(iPlayerLoop).x = iNextX
  136.                 arrPlayer(iPlayerLoop).y = iNextY
  137.                 arrPlayer(iPlayerLoop).c = iNextC
  138.                 arrPlayer(iPlayerLoop).xOld = iNextX
  139.                 arrPlayer(iPlayerLoop).yOld = iNextY
  140.                 arrPlayer(iPlayerLoop).buttonCount = cMaxButtons
  141.                 arrPlayer(iPlayerLoop).axisCount = cMaxAxis
  142.         NEXT iPlayerLoop
  143.        
  144.         ' CLEAR THE SCREEN
  145.         DO
  146.                 FOR iPlayerLoop = 1 to iNumPlayers
  147.                         iDevice = iPlayerLoop + 2
  148.                        
  149.                         WHILE _DEVICEINPUT(iDevice) ' clear and update the device buffer
  150.                                 'IF _DEVICEINPUT = 3 THEN ' this says we only care about joystick input values
  151.                                
  152.                                 ' check all the buttons
  153.                                 FOR iLoop = 1 TO _LASTBUTTON(iDevice)
  154.                                         IF (iLoop > cMaxButtons) THEN
  155.                                                 EXIT FOR
  156.                                         END IF
  157.                                         arrPlayer(iPlayerLoop).buttonCount = iLoop
  158.                                        
  159.                                         ' update button array to indicate if a button is up or down currently.
  160.                                         IF _BUTTONCHANGE(iLoop) THEN
  161.                                                 ' _BUTTON(number) returns -1 when a button is pressed and 0 when released.
  162.                                                 'arrButton(iLoop) = NOT arrButton(iLoop)
  163.                                                 arrButton(iPlayerLoop, iLoop) = _BUTTON(iLoop)
  164.                                         END IF
  165.                                 NEXT iLoop
  166.                                
  167.                                 FOR iLoop = 1 TO _LASTAXIS(iDevice) ' this loop checks all my axis
  168.                                         IF (iLoop > cMaxAxis) THEN
  169.                                                 EXIT FOR
  170.                                         END IF
  171.                                         arrPlayer(iPlayerLoop).axisCount = iLoop
  172.                                        
  173.                                         ' I like to give a little "jiggle" resistance to my controls, as I have an old joystick
  174.                                         ' which is prone to always give minute values and never really center on true 0.
  175.                                         ' A value of 1 means my axis is pushed fully in one direction.
  176.                                         ' A value greater than 0.1 means it's been partially pushed in a direction (such as at a 45 degree diagional angle).
  177.                                         ' A value of less than 0.1 means we count it as being centered. (As if it was 0.)
  178.                                         IF ABS(_AXIS(iLoop)) <= 1 AND ABS(_AXIS(iLoop)) >= .1 THEN
  179.                                                 arrAxis(iPlayerLoop, iLoop) = _AXIS(iLoop)
  180.                                         ELSE
  181.                                                 arrAxis(iPlayerLoop, iLoop) = 0
  182.                                         END IF
  183.                                 NEXT iLoop
  184.                         WEND ' clear and update the device buffer
  185.                        
  186.                 NEXT iPlayerLoop
  187.                
  188.                 ' And below here is just the simple display routine which displays our values.
  189.                 ' If this was for a game, I'd choose something like arrAxis(1) = -1 for a left arrow style input,
  190.                 ' arrAxis(1) = 1 for a right arrow style input, rather than just using _KEYHIT or INKEY$.
  191.                 CLS
  192.                 FOR iPlayerLoop = 1 to iNumPlayers
  193.                         FOR iLoop = 1 TO arrPlayer(iPlayerLoop).axisCount ' A loop for each axis
  194.                                 ' display their status to the screen
  195.                                 PRINT "Player " + cstr$(iPlayerLoop) + ",   Axis " + cstr$(iLoop) + " = " + cstr$(arrAxis(iPlayerLoop, iLoop) )
  196.                         NEXT iLoop
  197.                         FOR iLoop = 1 TO arrPlayer(iPlayerLoop).buttonCount ' A loop for each button
  198.                                 ' display their status to the screen
  199.                                 PRINT "Player " + cstr$(iPlayerLoop) + ", Button " + cstr$(iLoop) + " = " + cstr$(arrButton(iPlayerLoop, iLoop) )
  200.                         NEXT iLoop
  201.                 NEXT iPlayerLoop
  202.                 PRINT "PRESS <ESC> TO EXIT"
  203.                
  204.                 _LIMIT 30
  205.         LOOP UNTIL _KEYHIT = 27 ' ESCAPE to quit
  206. END SUB ' TestJoysticks
  207.  
  208. ' ################################################################################################################################################################
  209. ' BEGIN GENERAL ROUTINES
  210. ' ################################################################################################################################################################
  211.  
  212. ' /////////////////////////////////////////////////////////////////////////////
  213.  
  214. FUNCTION cstr$ (myValue)
  215.     'cstr$ = LTRIM$(RTRIM$(STR$(myValue)))
  216.     cstr$ = _TRIM$(STR$(myValue))
  217. END FUNCTION ' cstr$
  218.  
  219. FUNCTION cstrl$ (myValue AS LONG)
  220.     cstrl$ = _TRIM$(STR$(myValue))
  221. END FUNCTION ' cstrl$
  222.  
  223. ' ################################################################################################################################################################
  224. ' END GENERAL ROUTINES
  225. ' ################################################################################################################################################################
  226.  
« Last Edit: February 01, 2021, 04:42:11 pm by madscijr »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simple Joystick Detection and Interaction
« Reply #4 on: January 30, 2021, 10:29:55 pm »
I just gave this code a try and it worked!
One question though - I have 4 gamepads plugged into the system.
The code is checking for device 3:
Code: QB64: [Select]
  1.                 IF _DEVICEINPUT = 3 THEN ' this says we only care about joystick input values
  2.             FOR i = 1 TO _LASTBUTTON(3) ' this is a loop to check all the buttons
  3.  
How would you count how many gamepads are detected, and read them all?

The first line tells you the number of devices plugged in.  (D = _DEVICES)

 
D= _DEVICES  'MUST be read in order for other 2 device functions to work!
PRINT "Number of input devices found ="; devices
FOR i = 1 TO D
  PRINT _DEVICE$(i)
  PRINT "Buttons:"; _LASTBUTTON(i); "Axis:"; _LASTAXIS(i); "Wheels:"; _LASTWHEEL(i)
NEXT
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #5 on: January 30, 2021, 10:47:18 pm »
Thanks for your reply. I updated my question but I see you replied before I clicked Save.

If you see my original question, it now has my multi joystick version of the test code.

There is one problem, which is it doesn't seem to detect a given controller until that joystick is moved or its button is pressed.

So my followup question is, is there a way to detect and count the controllers that are plugged in, without each player having to first move their joystick or press a button? It's not a deal breaker, but it would be nice to know how to do that if it is possible.

Thanks again!
« Last Edit: January 30, 2021, 10:52:07 pm by madscijr »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simple Joystick Detection and Interaction
« Reply #6 on: January 31, 2021, 05:14:27 am »
Thanks for your reply. I updated my question but I see you replied before I clicked Save.

If you see my original question, it now has my multi joystick version of the test code.

There is one problem, which is it doesn't seem to detect a given controller until that joystick is moved or its button is pressed.

So my followup question is, is there a way to detect and count the controllers that are plugged in, without each player having to first move their joystick or press a button? It's not a deal breaker, but it would be nice to know how to do that if it is possible.

Thanks again!

I've never had any problems detecting the joysticks before movement.  If there's four on your system, here's a quick question:  Do any of them have a SLEEP mode which they might be entering?  My system has an usb hub which sleeps with inactivity, so anything I plug into it takes a couple of seconds to "wake up" and become responsive.  I've also got a wireless bluetooth joystick which does the same thing -- it puts itself into sleep mode to save energy, and takes a couple of seconds to wake up when I first start using it.

If either of those things are going on, it could explain the lag in detection and interaction that you're encountering.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #7 on: January 31, 2021, 11:44:50 am »
I've never had any problems detecting the joysticks before movement.  If there's four on your system, here's a quick question:  Do any of them have a SLEEP mode which they might be entering?  My system has an usb hub which sleeps with inactivity, so anything I plug into it takes a couple of seconds to "wake up" and become responsive.  I've also got a wireless bluetooth joystick which does the same thing -- it puts itself into sleep mode to save energy, and takes a couple of seconds to wake up when I first start using it.

If either of those things are going on, it could explain the lag in detection and interaction that you're encountering.

Hmm, I don't know if it has a sleep mode, and even if it does, I think the hub and/or joystick adapter isn't going to be in sleep mode, because even when I move all 4 joysticks and immediately restart the joystick test code, the behavior is the same.

FYI here is the device:
Retro USB Adapter for Atari Joysticks and Paddles - 4 Port/Players
https://www.amazon.com/Retro-Adapter-Atari-Joysticks-Paddles/dp/B08LCTP9TQ

It must be some quirk in the logic of my test program. If you have 2 gamepads and could run my code and see if you get the same behavior, that might help.

It is definitely detecting the _presence_ of one or more controller from the very start, because if it's not plugged into the USB hub, it would output

"No joysticks found.
PRESS <ENTER> TO CONTINUE

and exit. It does that if I unplug the joystick adapter from the USB hub.

But with the controllers plugged in, it isn't doing that, the output is

PRESS <ESC> TO EXIT


and it waits for input. So it is seeing controllers.

The problem is, the program isn't showing data for a given controller until I move that particular joystick or press its button. If I move joystick 2, I'll see:


Player 2,   Axis 1 = 0
Player 2,   Axis 2 = 0
Player 2, Button 1 = 0
Player 2, Button 2 = 0
PRESS <ESC> TO EXIT


Then if I move joystick 1, I'll see:

Player 1,   Axis 1 = 0
Player 1,   Axis 2 = 0
Player 1, Button 1 = 0
Player 1, Button 2 = 0
Player 2,   Axis 1 = 0
Player 2,   Axis 2 = 0
Player 2, Button 1 = 0
Player 2, Button 2 = 0
PRESS <ESC> TO EXIT


Then if I move joystick 4, the output is:
Then if I move joystick 1, I'll see:

Player 1,   Axis 1 = 0
Player 1,   Axis 2 = 0
Player 1, Button 1 = 0
Player 1, Button 2 = 0
Player 2,   Axis 1 = 0
Player 2,   Axis 2 = 0
Player 2, Button 1 = 0
Player 2, Button 2 = 0
Player 4,   Axis 1 = 0
Player 4,   Axis 2 = 0
Player 4, Button 1 = 0
Player 4, Button 2 = 0
PRESS <ESC> TO EXIT


Finally, after moving joystick 3 we see the full output:

Player 1,   Axis 1 = 0
Player 1,   Axis 2 = 0
Player 1, Button 1 = 0
Player 1, Button 2 = 0
Player 2,   Axis 1 = 0
Player 2,   Axis 2 = 0
Player 2, Button 1 = 0
Player 2, Button 2 = 0
Player 3,   Axis 1 = 0
Player 3,   Axis 2 = 0
Player 3, Button 1 = 0
Player 3, Button 2 = 0
Player 4,   Axis 1 = 0
Player 4,   Axis 2 = 0
Player 4, Button 1 = 0
Player 4, Button 2 = 0
PRESS <ESC> TO EXIT


BTW, it is detecting and displaying the input correctly.
For example, if I press the fire button on joystick #2, the output for that changes from:

Player 2, Button 1 = 0

to

Player 2, Button 1 = -1


So I'm just not sure why it doesn't show all 4 controllers from the start. Why do I have to move a stick or press its button before the program displays its values?

Am I not "initializing" reading the joysticks correctly? Or is there is just some silly bug in my logic?

Thanks again...

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #8 on: January 31, 2021, 01:41:58 pm »
I don't have usb joysticks or gamepad controls, so I can't look into this, but I do have a question about usage.

Will it also work as: WHILE _DEVICEINPUT(iDevice): WEND....you know, like WHILE _MOUSEINPUT: WEND, followed by mouse calls. The mouse wheel is the only one of those commands, which differs, and needs to be placed within that WHILE/WEND loop. How about the joystick stuff?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Simple Joystick Detection and Interaction
« Reply #9 on: January 31, 2021, 02:38:22 pm »
Will it also work as: WHILE _DEVICEINPUT(iDevice): WEND....you know, like WHILE _MOUSEINPUT: WEND, followed by mouse calls. The mouse wheel is the only one of those commands, which differs, and needs to be placed within that WHILE/WEND loop. How about the joystick stuff?

That's a good question, I'm pretty new to QB64 and have no idea. Anyone??

Update: The WHILE/WEND does seem to work with joysticks the same way.
I'll post my code which is now working as expected.
« Last Edit: February 01, 2021, 04:36:58 pm by madscijr »