Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
asymmetryg
Posts: 12
Registered: ‎03-25-2012
My Device: none
My Carrier: none
Accepted Solution

Touch events lag

Hi,

 

I'm developing a native application for the PlayBook, I started with one of the samples for the Native SDK.

There is an issue with the touch event handling where there is a noticeable lag when dragging a finger on the screen:

- after a long drag and removing the finger the app will behave as if it's still receiving SCREEN_EVENT_MTOUCH_MOVE events for as long as a few seconds (depending on the length of the drag)

 

 

Is there a way to reset the event queue, or a way to avoid events piling up?

 

My event handling is:

 

    while (!exit_application)
    {
        bps_event_t *event = NULL;
        rc = bps_get_event(&event, 0);
        
        if (event)
        {
            int domain = bps_event_get_domain(event);

            if (domain == screen_get_domain())
            {
                handleScreenEvent(event);
            }
            //...
        }
    }
        
void handleScreenEvent(bps_event_t *event)
{
    int screen_val;
    int pair[2];
    screen_event_t screen_event = screen_event_get_event(event);
    screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val);
    screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION, pair);

    switch (screen_val)
    {
    case SCREEN_EVENT_MTOUCH_TOUCH:
        //...
        break;
    case SCREEN_EVENT_MTOUCH_MOVE:
        //...
        break;
    case SCREEN_EVENT_MTOUCH_RELEASE:
        //...
        break;
    default:
        break;
    }
}

 

 

 

 

Please use plain text.
New Contributor
a27med
Posts: 6
Registered: ‎03-12-2012
My Device: Non
My Carrier: Non

Re: Touch events lag

Hello Sir,

Take a look at this: https://bdsc.webapps.blackberry.com/native/reference/com.qnx.doc.screen.lib_ref/topic/rscreen_set_wi...

I would suggest adding this: SCREEN_PROPERTY_SWAP_INTERVAL

I had the same issue you had but with swiping, adding this for screen setting at screen initialization solved my lag problem :smileyhappy:
Please use plain text.
Contributor
asymmetryg
Posts: 12
Registered: ‎03-25-2012
My Device: none
My Carrier: none

Re: Touch events lag

Hello,

 

Thanks for the info.

Can you tell me what value you used to solve the lag?

 

I tried setting it to 0, 10, and 100 but still no difference.

Please use plain text.
Contributor
asymmetryg
Posts: 12
Registered: ‎03-25-2012
My Device: none
My Carrier: none

Re: Touch events lag

I have also tried to call bps_get_event many times per frame in the hope of emptying the event queue, but the scond time it returns a null event. Only after calling eglSwapBuffers the next event will be delivered.

Please use plain text.
Contributor
asymmetryg
Posts: 12
Registered: ‎03-25-2012
My Device: none
My Carrier: none

Re: Touch events lag

Ok, I managed to solve the issue by looping until there are no more events. 

(I think my previous loop was wrong.)

 

This is also done in one of the samples:

 

https://github.com/blackberry/NDK-Samples/blob/master/BelligerentBlocks/src/Platform.cpp

Please use plain text.
Contributor
Just_Bart
Posts: 23
Registered: ‎02-06-2011
My Device: BlackBerry Z10
My Carrier: Virgin Mobile

Re: Touch events lag

Thanks for the help - this worked for me I used:
const int intInterval = 0;
screen_set_window_property_iv( screen_win, SCREEN_PROPERTY_SWAP_INTERVAL, &intInterval );
Please use plain text.