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
Contributor
Posts: 12
Registered: ‎04-23-2013
My Device: Z30
My Carrier: Truphone

Capturing screen events

[ Edited ]

I'm using the following code to try and capture (and then later re-play) screen events from input devices. However, all I seem to get is '12' - SCREEN_EVENT_IDLE.

 

Before I was doing it on the simulator and have now found out that bps event listening for screen events doesn't work, so now I'm using a real device but it doesn't work.

 

Debug: ScreenWatcher::event 
Debug: Screen event  14 
Debug: UNKNOWN :  12 
Debug: ScreenWatcher::event 
Debug: Screen event  15 
Debug: UNKNOWN :  12 

 

 

Any ideas?

 

class ScreenWatcher : public QObject, public bb::AbstractBpsEventHandler
{
public:
	ScreenWatcher(QObject * parent = 0)
		: QObject(parent),
		  eventNo(0)
	{
	screen_context_t screen_cxt;
	screen_create_context(&screen_cxt, 0);

	const int error = bps_initialize();
	if (error != BPS_SUCCESS)
	{
		qDebug() << "Failed to initialise BPS";
	}
	subscribe(screen_get_domain());
	if (screen_request_events(screen_cxt) != BPS_SUCCESS)
	{
	}
	}

	~ScreenWatcher()
	{
	}
protected:
	void event(bps_event_t *event)
	{
		if (bps_event_get_domain(event) == screen_get_domain())
		{
			qDebug() << "Screen event " << eventNo++;

			int screen_val;
			screen_event_t screen_event = screen_event_get_event(event);

			screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val);

			if (screen_val == SCREEN_EVENT_MTOUCH_TOUCH)
			{
				// Handle an initial finger press event here
				qDebug() << "SCREEN_EVENT_MTOUCH_TOUCH";
			}
			else if (screen_val == SCREEN_EVENT_MTOUCH_MOVE)
			{
				// Handle a finger move event here
				qDebug() << "SCREEN_EVENT_MTOUCH_MOVE";
			}
			else if (screen_val == SCREEN_EVENT_MTOUCH_RELEASE)
			{
				// Handle a finger release event here
				qDebug() << "SCREEN_EVENT_MTOUCH_RELEASE";
			}
			else
			{
				qDebug() << "UNKNOWN : " << screen_val;
			}
		}
	}
private:
	unsigned int eventNo;
};