Lag when no joystick is plugged in
BlitzMax Forums/BlitzMax Beginners Area/Lag when no joystick is plugged in
| ||
Hi guys, my program lags heavy when no joystick is connected, but when it is connected there is no lag. I have commands that check if joyhit() and joydown(). I also recoded the whole thing to check if joycount() > 0 before I attempt to use any joyhit() or joydown() commands. No luck. :( any help would be greatly appreciated! Thanks! PS - i am in a bit of a hurry as I write this. Any additional information will be supplied if you need it. Thanks again. |
| ||
That's interesting. What version number of BlitzMax is that? |
| ||
Are you calling JoyCount multiple times per update? If so don't! I would also suggest you should only use it on your games title page / main menu as on some systems it will not be very fast. I assume also that you are not in debug mode? |
| ||
I am running 1.48 I am only calling joycount() once in my player method, which is only called once per loop. I am in debug mode and have tried running the game with and without debug mode and quick build. No luck. :/ remed out all the references to joy and it ran fine. I am using this framework: if that helps at all. Quite unsure of what is causing it. This has halted my game development. :( |
| ||
Import "--enable-stdcall-fixup" ?win32 Extern Function joyGetNumDevs:Int() End Extern Print joyGetNumDevs()+" Joysticks supported" ? For Local i:Int=0 To 10 Local t1:Int=MilliSecs() Local j:Int=JoyCount() Print "joycount time="+(MilliSecs()-t1) Next what results you get (joystick connected and disconnected? Last edited 2013 |
| ||
I can't reproduce it here. I just wrote joy support on my "Fruzzle" game here, and (at least on XP, didn't test yet on other OS) it works pretty well - no lag at all. I tested the game with no joystick and with joystick connected, then disconnected - My game stayed at 60 fps all times. In the game title screen, I check JoyCount() and set joyConnected to true if there is any joystick on the system. Then, in the game I have If joyConnected then if JoyCount()=0 then ' show joystick disconnected dialog (...) ' if joystick still disconnected if joyCount()=0 then joyConnected = false end if End if Everywhere else, I just test my joyConnected flag - not JoyCount. |
| ||
You shouldn't be calling joycount from a loop. Just once at the start of the program. Cheers Charlie |
| ||
I'm away from my computer at the moment, I'll try calling for joy input from a variable instead of joycount. That sounds like it will work. Thanks for the help. I'll post my results tonight. Also if you wanna checkout the game I'm working on Click here! Tho the most recent version up does not support game pads. Last edited 2013 |
| ||
You shouldn't be calling joycount from a loop. Just once at the start of the program. I get a little annoyed when I need to quit and restart a game because I need to plug my USB controller in so I think it is OK to poll joycount on the title page / main menu. |
| ||
Does that *actually* work though? I remember trying a few years back with no success. Cheers Charlie |
| ||
Yes, it works - but again, only tested on XP, and with an XBox 360 controller; And yes - calling joycount (or at least some other way to check if the controller is connected) is necessary during gameplay - you should pause your game if the controller gets disconnected for some reason (could be dead battery on a wireless controller, someone could trip in the cable...). |
| ||
Thinking back, i probably tested on a mac. Perhaps that's why? Cheers Charlie |
| ||
I did some testing on both Mac and Windows yesterday and yes, Mac freejoy code was not good at handling the controller being removed and added. |
| ||
@Zeke Just for it's own sake. With Joystick connected: Without Joystick connected: Good test! and the times are obviously longer for calling JoyCount() without a joystick connected. Makes me want to take a look in the source code to see why. I did some fps testing, and then fps is indeed higher with the new code, checking JoyTrue:int every loop instead of JoyCount() itself. Thanks guys. Will post back if I have any more problems. :) |