How does JoyHit() Work?

BlitzMax Forums/BlitzMax Programming/How does JoyHit() Work?

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

There's a bug with the JoyHit() command, but I'm not sure if it's causing your problems. The button and port parameters are transposed.

This should work...
[edit]
Doh!...No it won't, you'll have to use this fix if you can compile modules and want to add it yourself.
[/edit]
'You need the fix to run this properly!
Strict

Graphics 800, 600, 0

If Not(JoyCount()) Then RuntimeError "No joysticks found!"

Local y = -12

Repeat
  For Local thisPort = 0 Until JoyCount()
    For Local thisButton = 0 To Int(Log(JoyButtonCaps(thisPort)) / Log(2))
      If JoyHit(thisButton, thisPort)
        y :+ 12
        
        If y > (GraphicsHeight() -12)
          y = 0
          Cls
        EndIf
	DrawText "Button " + thisButton + " on Port " + thisPort + " was hit", 0, y
      EndIf
    Next
  Next
  
  Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

End