blackberry / SDL

Simple DirectMedia Layer is an open-source, cross-platform multimedia library designed to provide a low level API.
GNU Lesser General Public License v2.1
86 stars 46 forks source link

Push BPS events using SDL_SysWMEvent #33

Closed jgranick closed 11 years ago

jgranick commented 11 years ago

Hi again,

I apologize for how the diff turned out on this commit. I'm using GitHub for Windows instead of using GIT from a terminal directly, and I was running into some trouble.

This makes a small change to the SDL_SysWMmsg struct for PlayBook, and adds "handleCustomEvent" in the PlayBook events file.

When a BPS event comes through that is not a navigator or screen event, it can now be pushed up using SDL_SysWMEvent, so long as the developer has used SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE); in his code.

Then you can get the BPS event if you catch a SDL_SYSWMEVENT, then use (inEvent.syswm.msg)->event

Now you can use the sensor API, BBM and other platform services while still using SDL. This seemed like the right place to put it, since SDL_SysWMEvent is platform-specific. Strictly speaking, I wouldn't consider BPS a window manager event, but using the existing SDL API in this way seemed like the cleanest way to handle other kinds of BPS events higher up the chain.

jnicholl commented 11 years ago

It definitely seems like the right place. Otherwise people would have to spawn a new thread to handle these events, I suppose. I'm guessing the diff is flagging line-ending differences somewhere and that's why the whole file is considered different. I checked the diff on my machine and it looks fine.