How does JoyHit() Work?
BlitzMax Forums/BlitzMax Programming/How does JoyHit() Work?
| ||
It counts how many times you hit the button? Apparently it just sits at 0 the whole time (yes I made sure the port was correct)/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ |Function JoyHit( button,port=0 ) | |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| |Returns: Number of times button has been hit. | |Description: Check for a joystick button press. | |Information: The returned value represents the number | | of the times button has been hit since the | | last call to JoyHit with the same key. | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ Since the last call to joyhit with the same key.. What does that mean?!? |
| ||
It means you have to call it at least twice (like all the other 'hit' commands) for it to work...Repeat Print MilliSecs() Until JoyHit(0) |
| ||
Hmm I called it twice but it didnt do anything? |
| ||
Is your joystick recognized correctly? (to test that, you might go to showcase board and search for gridwars and switch its controll to joy) btw: You aren't using that within a Canvas, aren't you? |
| ||
Uhh I can use the JoyDown() Function and the JoyX and Y Functions just fine!! at any rate I did a workaround but I'd still REALLY like to see someone use JoyHit() Go ahead and try it yourself! :D The game I was working on now has gamepad control.. http://www.blitzmax.com/Community/posts.php?topic=58022 |
| ||
GeoffTheGyratingGiraffe's simple test works fine for me. |
| ||
I dont understand it, it repeats until you hit the button and prints the millisecs()? The documentation says it returns how many times the button has been hit it says Until JoyHit(0) What does that mean? Until JoyHit() = what? Isnt JoyHit returning something? Why doesnt this work: Repeat If JoyHit(0) then print "Joy Hit" Until Keyhit(Key_ESCAPE |
| ||
Wouldn't it be Until JoyHit(0) equals something other than 0? That's my understanding of what I'm reading here. I just tested out your bit of code with my joystick here and it worked just fine. Looks like it might be a bug then? |
| ||
works here too although only with one button (button 0). |
| ||
Gery: What works? the until loop or the IF joyhit?? |
| ||
this oneRepeat If JoyHit(0) then print "Joy Hit" Until Keyhit(Key_ESCAPE |
| ||
Both of them worked for me. |
| ||
Hmm that's funny JoyHit(0) doesnt work for me at all but JoyDown(0) does.. |
| ||
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 |