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

Posts: 67
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE
My Carrier: T-Mobile

Screen (Gamepad) events in Cascades

[ Edited ]


I've trying to implement gamepad support in my HTML5 game. I've noticed that it would be impossible in WebWorks, so I've converted the app to Hybrid.

Unfortunately, despite many attempts I haven't managed to receive screen events in Cascades. I'm pretty shure I've tried all available methods:
- subcalssing Application and implementing the virtual "event" method
- using QAbstractEventDispather
- implementing (subclassing) AbstractBpsEventHandler
- using "InstallEventFilter" method
- using foreign window control


The only way that actually allowed me to receive all screen events (with gamepad events) was to call screen_request_events on cascades screen context:

Window * win = app->mainWindow();
screen_window_t winHandle = win->handle();
void* screenContextVoid;
screen_get_window_property_pv(winHandle, SCREEN_PROPERTY_CONTEXT, &screenContextVoid);
screen_context_t screenContext = (screen_context_t)screenContextVoid;


but that brakes cascades screen handling (controls stop to work). I'm guessing that cascades message loop handles screen events using libscreen events and that's why I broke it with the bps request call?

ForeignWindowControl also gave some hope, but it seems it only receives screen events if the window has focus.


Does anyone have any other ideas how it could be done?


Posts: 54
Registered: ‎05-14-2013
My Device: LE Z10
My Carrier: Ben(T-Mobile network)

Re: Screen (Gamepad) events in Cascades

Hi Razorek,


I've actually been looking into the same, both for a hybrid game and a cascades only. But I see you've come further than I did already. I'll be following the topic for other replies, and if needed help as a tester.

I wonder if we can write a libary/custom element that will allow the user to read the gamepad events.


Don't forget to mark as solved and like my post if it helped out!
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Screen (Gamepad) events in Cascades

Actually, a community member has been working on a webworks gamepad extension. You can check it out here: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Joypad-Extension/m-p/2711073


It's open source, so you can see how it was done if you were curious.

Paul Bernhardt
Application Development Consultant

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Posts: 67
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE
My Carrier: T-Mobile

Re: Screen (Gamepad) events in Cascades

Wow, I'm shocked! This is smart - instead of listening for events, the code continuously checks gamepad state to see if something changed.


This should be easily ported to cascades.


Thanks for your help Smiley Happy!