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
Highlighted
Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified
Accepted Solution

App stops receiving bps events.

I'm having trouble with my game not receiving events.  The game uses one thumb for a virtual joystick and the other for a fire button.  The problem seems to happen when the virtual joystick is twirled for a bit.  I'm try to check for as many errors as I can and none have been tripped.  Eventually I never get a new event from bps_get_event().

 

//==================================================================================================
//==================================================================================================
void QnxApp::handleScreenTouchEvent( int eventType, screen_event_t screenEvent )
{
	Logger&	log	= getLogger();

	if ( PointerEvent* pe = m_PointerEventFreeList->alloc() )
	{
		int position[2];
		if ( screen_get_event_property_iv( screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position ) != 0 )
	    	log.verbose( Str( "QnxApp::handleScreenTouchEvent: error getting SCREEN_PROPERTY_SOURCE_POSITION (%d)", errno ) );

		int	id;
		if ( screen_get_event_property_iv( screenEvent, SCREEN_PROPERTY_TOUCH_ID, &id ) != 0 )
	    	log.verbose( Str( "QnxApp::handleScreenTouchEvent: error getting SCREEN_PROPERTY_TOUCH_ID (%d)", errno ) );

		pe->owner	= m_PointerEventFreeList;
		pe->id		= id;
		pe->x		= position[0];
		pe->y		= position[1];

		switch( eventType )
		{
			case SCREEN_EVENT_MTOUCH_TOUCH:
				pe->action	= PointerEvent::ACTION_DOWN;
				break;

			case SCREEN_EVENT_MTOUCH_MOVE:
				pe->action	= PointerEvent::ACTION_DRAG;
				break;

			case SCREEN_EVENT_MTOUCH_RELEASE:
				pe->action	= PointerEvent::ACTION_UP;
				break;
		}

		m_Game.postUIEvent( *pe );
	}
	else
	{
		log.verbose( "QnxApp::handleScreenTouchEvent: out of events" );
	}
}
//==================================================================================================
//==================================================================================================
void QnxApp::handleScreenEvent( bps_event_t* event )
{
	if ( screen_event_t screenEvent = screen_event_get_event( event ) )
	{
		int	eventType;
		if ( screen_get_event_property_iv( screenEvent, SCREEN_PROPERTY_TYPE, &eventType ) != 0 )
		{
			Logger&	log	= getLogger();

			log.verbose( Str( "QnxApp::handleScreenEvent: error getting SCREEN_PROPERTY_TYPE (%d)", errno ) );
		}

		switch( eventType )
		{
			case SCREEN_EVENT_MTOUCH_TOUCH:
			case SCREEN_EVENT_MTOUCH_MOVE:
			case SCREEN_EVENT_MTOUCH_RELEASE:
				handleScreenTouchEvent( eventType, screenEvent );
				break;
		}
	}
}
//==================================================================================================
//==================================================================================================
void QnxApp::handleNavigatorEvent( bps_event_t* event )
{
}
//==================================================================================================
//==================================================================================================
void QnxApp::onUpdate()
{
	Logger&	log	= getLogger();

    while( true )
    {
        bps_event_t* event = NULL;

    	int rc	= bps_get_event( &event, 0 );
        if ( rc != BPS_SUCCESS )
        	log.verbose( Str( "QnxApp::onUpdate: bps_get_event error %d\n", errno ) );

        if ( event )
        {
        	int	domain = bps_event_get_domain( event );

        	if ( domain == screen_get_domain() )
        		handleScreenEvent( event );
        	else
        	if ( domain == navigator_get_domain() )
        		handleNavigatorEvent( event );
        }
        else
        {
        	break;
        }
    }

	m_Game.onUpdate();
}

 

Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: App stops receiving bps events.

I still haven't a solution to the problem.  I tried using the memory corruption tool hoping to find somekind of buffer over run but no luck.  Also I download some of the opensource projects that RIM ported and used them as a guide.  Oddly enough the the way touch events is handle is different from app to app even though they seem to do the same thing.

 

I'm really at a lose as to what could be causing this.  I thought maybe a gesture was being triggered or something but I haven't been able to find a connection.  I'm also dumping all screen and navigator events hoping to find some connection with no luck.

 

It's a big concern as multi-touch tends to be broken on many first gen products and my game requires one thumb to be dragging a virtual gamepad around while other buttons are pressed.  This isn't the most common senario and might not be well tested.

 

At this point all I can think to do is try and reproduce the problem using the FallingBlocks example.  At some point I'm going to drop the port and finish the iOS port.  I would have expected this forum to be crawling with RIM people trying to give developers everything and anything they need to get their app done.

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: App stops receiving bps events.

Odd question, are you sure that you don't turn off screen events? Because I know games like DeadSpace do what you are trying to achieve but I haven't done any event code yet for the NDK so don't have much experence with it, so that is the first thing that comes to mind.

 

As for RIM, I only know of elena_laskavaia that actually does the NDK forums.

 

Note: I saw this post earlier (wonder why I missed it friday) and said to myself I would get to it later, your email to Crackberry reminded me of it. (Sorry? As still no one else has responded).

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: App stops receiving bps events.

Thank you for your repsonse.  The only time I disable events is when the game is destroyed and that gets logged in the console.  Still it's worth verifying.  It's odd how my game loop keeps running with the game doing a normal update.  I just get no events.

 

One thing I found that was odd, is that some examples such as the Cocos2D project.  The code creates a sceen event and saves it in a member variable. 

 

screen_create_event(&m_screenEvent);

 

Then it uses the following instead of bps_get_event() and bps_event_get_domain().

 

while (!screen_get_event(m_screenContext, m_screenEvent, 0))

 

I'm not sure what the difference is.

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: App stops receiving bps events.

It seems to be screen events without BPS, you when screen_get_event is called, it replaces the contents of the event. Possibly more efficent? Maybe it's worth a shot.
---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: App stops receiving bps events.

I already tried it with no luck.

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: App stops receiving bps events.

Hmm, does errno provide any hints as to why it failed? Also, did you reproduce the error with failling blocks?
---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: App stops receiving bps events.

[ Edited ]

LMcRae,

 

I had the same problem. The problem for me was because I was slipping in an extra bps_get_event() call into my main while-loop cycle. I had pasted code from one of the tutorial examples, not realizing right away that my own code was making its own call to bps_get_event(). The tap gestures were being absorbed by one bps_get_event() call, and being missed by the second one which was the one that handles the gesture detection. Lesson learned, bps_get_event() consumes the events (I guess that should be pretty obvious actually).

 

I don't see any double bps_get_events() calls in your code, but I thought maybe you may have slipped one in somewhere else. Have a look and see if you can find places where the screen events are getting consumed in places it shouldn't be.

 

Scott

 

 

Developer
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: App stops receiving bps events.

I haven't been able to reproduce the problem with FallingBlocks yet which makes we suspicious of my own code.  The thing is that sometimes these problems don't show up until you have an app that makes use of more resources.

 

I also did have the bug with calling bps_get_event consuming the event but I am very confident that I'm only calling it once per event.  The problem isn't with missing an up or down event but with no longer reciecving any events at all.  I would image if I could get some help from RIM they would be able to run the game and see why there are no more events.

 

Last night I finished up my network support for high scores so at this point I'm basiclly beta and just test.  All I can think to do is start to make some notes on all the things I have check to be sure I haven't missed something.

 

I'll tell you this, I'm getting pretty close to being done with RIM.  When porting Tanks to OS7 I found that VBO and interleaved to be broken and I know it's not my code bcause it's been running on over 2.5 million devices on the fragmented Android market.

 

I have sent emails and I have filled in bug reports and it's all me wasting my time.  They broken ALL OpenGL games on OS6 and never did a thing about.  Just getting sick of it.

 

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: App stops receiving bps events.

I know you're annoyed with this, but try sending a PM to .

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.