Joypad Wait
BlitzMax Forums/BlitzMax Programming/Joypad Wait
| ||
Does anyone have a good tip for how to make a WaitJoy() function that actually WAITS for joypad inputs? And by that I don't mean just lock the code in a loop until a joypad button is pressed, because that will still eat lots of CPU. I found this: http://www.blitzmax.com/Community/posts.php?topic=82706#932872 But it does exactly what I don't want it to do. It locks the code in a loop untill a joypad button is pressed, but look at how much CPU it eats. (20% of my CPU) Compare it to something like WaitEvent() or WaitSystem(), that will eat 0% of my CPU. Thanks! EDIT: Infact, NOT using WaitJoy() drops the CPU usage down from 20% to just 4-5%. So it's so bad it actually works in reverse heh... Funny. x) EDIT2: I found that if you place a Delay(1) inside the WaitJoy() loop, it'll decrease to 0% CPU. A bit dirty but it sorta works. Last edited 2012 |
| ||
Hey I read your post then saw the edit2. I was going to point to just a simple Delay(x). Delay is not dirty it tells the cpu hey dont worry about me till this delay:) It is actually an efficient way to drop the cpu usage in very small loops like wait for joypad inputs. |