safon007 / gamekit

Automatically exported from code.google.com/p/gamekit
0 stars 0 forks source link

iphone input lag hack #287

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.checkout svn
2.build
3.test

What is the expected output? What do you see instead?

on my ipod4 the touch input lags for the first couple of seconds. Quite a 
showstopper ...

What version of the product are you using? On what operating system?

osx 10.8 + xcode 4.5 + ios 5.0.1 +ipod4g

Please provide any additional information below.
i read ...

http://www.idevgames.com/forums/thread-1592.html

i pasted... into stepOneFrame

if (m_displayLinkSupported)
    {
        // NSTimerInterval is a simple typedef for double
        NSTimeInterval currentFrameTime = -[m_date timeIntervalSinceNow];
        //NSTimeInterval differenceInSeconds = currentFrameTime - m_lastFrameTime;
        m_lastFrameTime = currentFrameTime;

        while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE)==kCFRunLoopRunHandledSource);

        m_okit.stepOneFrame();
    }
it yields ... touch is working right at gamestart by beeing 0.002 seconds nice 
to ios event eating...

0.002s worked for me ... quite a sacrifice

there is a lot of talk about the "best" runLoop in the net, but i think its an 
"ok" hack? 

anyway ... give it a try ;)

thank you

Original issue reported on code.google.com by nolteme...@googlemail.com on 22 Nov 2012 at 9:36

GoogleCodeExporter commented 8 years ago
Sounds great. So it is that one while-loop doing the magic...

I will commit this after the weekend as soon as I'm on my dev-computer again.

Thx for sharing.

Original comment by thomas.t...@googlemail.com on 23 Nov 2012 at 2:15

GoogleCodeExporter commented 8 years ago
hi all

yes it's just that while-loop 

i should have marked that better... sry

Original comment by nolteme...@googlemail.com on 25 Nov 2012 at 7:05

GoogleCodeExporter commented 8 years ago
now i got rid of the while-loop and used NSRunLoopCommonModes vs 
NSDefaultRunLoopMode in 
initApp...[displayLink addToRunLoop:[NSRunLoop] forMode:NSRunLoopCommonModes];

it renders event input at gamestart fluendly too ... looks nicer!

could you please try both?

thank you

Original comment by nolteme...@googlemail.com on 25 Nov 2012 at 8:49

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Could you plz create a patch or at least show the 2nd one as the first one with 
a bit context around? :D

Original comment by thomas.t...@googlemail.com on 26 Nov 2012 at 6:33

GoogleCodeExporter commented 8 years ago
i hope you see the same (good) effect ... plz tell ... thx

Original comment by nolteme...@googlemail.com on 26 Nov 2012 at 7:20

Attachments:

GoogleCodeExporter commented 8 years ago
The thing is that I neither have a mac nor an iDevice. I always have to go to a 
friend who has apple devices. If you say the effect is as you told I will 
commit it without testing and check as soon as I can on a real device. So the 
second one would be the preferred version!?

Original comment by thomas.t...@googlemail.com on 26 Nov 2012 at 7:25

GoogleCodeExporter commented 8 years ago
PS:
the input lag is quite a mystery to me still.
and i did these mods on my gyro modified branch, i am curious if it really does 
anything good in trunk ;)

Original comment by nolteme...@googlemail.com on 26 Nov 2012 at 7:27

GoogleCodeExporter commented 8 years ago
the second is the one i use currently but as i said i modified 
IphoneAccelerometer to poll results ... so there is some differece ... btw the 
gyro patch is there ...

Original comment by nolteme...@googlemail.com on 26 Nov 2012 at 7:30

GoogleCodeExporter commented 8 years ago
The change with the NSRunLoopCommonModes change fix the lag in the input, also 
the last version broke the iPhoneDemo, should I post a patch for both issues 
here?

Original comment by rhodyl...@gmail.com on 2 Sep 2013 at 9:30

GoogleCodeExporter commented 8 years ago
Yes, that would be great

Original comment by thomas.t...@googlemail.com on 2 Sep 2013 at 11:27

GoogleCodeExporter commented 8 years ago
Here you go!

Original comment by rhodyl...@gmail.com on 3 Sep 2013 at 2:35

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, patch is applied to trunk.

Original comment by harkon...@gmail.com on 4 Sep 2013 at 9:51