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
Developer
razorek
Posts: 65
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE

Screen (Gamepad) events in Cascades

[ Edited ]

Hi,

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;
	
subscribe(screen_get_domain());
bps_initialize();
screen_request_events(screenContext);

 

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?

 

Please use plain text.
Developer
ETitus
Posts: 54
Registered: ‎05-14-2013
My Device: LE Z10

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!
Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

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
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.
Developer
razorek
Posts: 65
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE

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 :smileyhappy:!

Please use plain text.