Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

PureGDK / dbKeystate laaaaags

Author
Message
azzido
10
Years of Service
User Offline
Joined: 16th May 2008
Location:
Posted: 6th Jan 2010 17:19
Hi @ all - or maybe hi @ mistrel,

can u give me an example with dbkeystate to control the camera without a laag after 1-2 Seconds.

Why does the dbkeystate command not working if WindowEvent() or WaitWindowEvent() ist not used? - so i can also use the pb examinkeyboard functions ?!

Sorry but i can´t build up an example with mouse camera rotation and wasd movement that don´t lags after 1 second i hold down a key?!

Plz PLz Plz give me an example how this works?!
Mistrel
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 8th Jan 2010 00:00 Edited at: 8th Jan 2010 09:39
dbKeyState uses a simple API call. If it's lagging for you then it's something you're doing.

IanM
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Jan 2010 21:01 Edited at: 14th Jan 2010 21:07
... or maybe not doing.

Here's what I'm guessing...

What you are NOT doing is allowing DirectInput time to carry out it's own processing - you are starving it of processor time by running full out without pause.

You need to either Sleep(0) or Sleep(1) to give the DirectInput thread a chance to run, or to call one of those two functions you've listed which will give the same result.

Give one/all of these a go and see if any help.

Mistrel
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 14th Jan 2010 21:06 Edited at: 14th Jan 2010 21:10
PureGDK uses GetKeyState for dbKeyState, not DirectInput. The only thing that would affect it is if he's clogging the message queue or not pumping it often enough.

DirectInput for the mouse and keyboard is just a wrapper to the standard Win32 API; so either way, there's nothing to optimize.

IanM
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Jan 2010 21:10
Ok, my assumption was that the dbGetKeyState was a call to the GDK equivalent.

In that case, then GetKeyState is absolutely dependent on the Window Message Loop, which (again an assumption) is probably dealt with by those functions he isn't calling.

I guess the real question here is why does he not want to deal with windows events?

Mistrel
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 14th Jan 2010 21:13 Edited at: 14th Jan 2010 21:15
If he's using PureGDK with PureBasic then he's supposed to call either WindowEvent() or WaitWindoeEvent() at the end of the main loop which pumps the message queue. This is basic PureBasic functionality. If he's not calling this then the main window should appear frozen and not just "lag".

The PureGDK window has its own message pump but as a child window of the main application it won't receive any input messages if its parent doesn't.

azzido
10
Years of Service
User Offline
Joined: 16th May 2008
Location:
Posted: 14th Jan 2010 22:45
RE: Update News to my Problem.

Ive got some strange behavior and run several test.

By the why i do a WindowEvent() not a WaitWindowEvent().

Sometime i Compile - it runs without problems - on the next complie (nothing is changed in my code) it will do a kind of save my inputs. when i press w to move forward and wait 3-5 sec. and releas - it will do 1 sec. move me forward and then stops?!

next time i compile - it works fine.

Mhhmm - i am using win7 on a xps600 Dell Workstation and set the synrate in my code to 60.

Update: When i use the purge command "purge GDK Temp" i think it will laags only every 7th or 8th compiling process.


Sorry about my bad english - i hope you can understand.
Mistrel
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Jan 2010 00:06 Edited at: 15th Jan 2010 00:08
If you don't use WindowEvent() or WaitWindowEvent() then the keyboard events won't ever reach the DBP child window and dbKeyState can't function.

Post an example of what you're doing.

azzido
10
Years of Service
User Offline
Joined: 16th May 2008
Location:
Posted: 15th Jan 2010 15:13
Mistrel
13
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 16th Jan 2010 02:39
A couple things to think about:

* Are you running with the debugger on (this will cause a massive slowdown in your code)
* Try calling WindowEvent() at the very end of your loop

If you need further assistance you'll have to provide any media used in your code so that I can compile it. Also remove anything that might require a plugin unless it's part of the problem.

Login to post a reply

Server time is: 2018-12-14 18:53:48
Your offset time is: 2018-12-14 18:53:48