iOS System Callback (attn: Piotr Drapich) (fwd)

Hi Brian,
Here’s a diff for my callback implementation based on the latest
SDL source from hg. It also implements all important iOS events as SDL
events:

SDL_SYSEVENT_TERMINATE
SDL_SYSEVENT_WILL_SUSPEND
SDL_SYSEVENT_SUSPEND
SDL_SYSEVENT_WILL_RESUME
SDL_SYSEVENT_RESUME
SDL_SYSEVENT_LOWMEMORY

regards,
PiotrOn Sun, 18 Mar 2012, Brian Barnes wrote:

I’m finally getting back to this. Has there been any movement or additional thought on Poitr’s patch? The original message:

http://forums.libsdl.org/viewtopic.php?t=7733&sid=21dffacbd29855581fe66d8a1126a1df

Piotr, do you have a new version of this patch that conforms with the current trunk of SDL2? I’ll retest it for you.

diff -r 6bb657898f55 include/SDL_events.h — a/include/SDL_events.h Tue
Feb 28 21:58:36 2012 -0500 +++ b/include/SDL_events.h Thu Mar 22 04:10:18
2012 +0100 @@ -104,11 +104,27 @@
SDL_MULTIGESTURE,

 /* Clipboard events */ +
 SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
  • /* System events */ + + SDL_SYSEVENT_TERMINATE = 0xa00, +
    SDL_SYSEVENT_WILL_SUSPEND, + SDL_SYSEVENT_SUSPEND, +
    SDL_SYSEVENT_WILL_RESUME, + SDL_SYSEVENT_RESUME, + SDL_SYSEVENT_LOWMEMORY,

  • /* Drag and drop events */
    SDL_DROPFILE = 0x1000, /**< The system requests a file open */

    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
    * and should be allocated with SDL_RegisterEvents()
    */ @@ -382,6 +398,16 @@
    Uint32 timestamp;
    } SDL_QuitEvent;

+/** + * \brief System event + */ + +typedef struct SDL_SystemEvent +{ +
Uint32 type; + Uint32 timestamp; + void *data; +} SDL_SystemEvent;

/**

  • \brief A user-defined event type (event.user.*) @@ -413,6 +439,36 @@
    SDL_SysWMmsg *msg; /**< driver dependent data, defined in
    SDL_syswm.h */
    } SDL_SysWMEvent;

/**

  • \brief General event structure
    */ @@ -438,6 +494,14 @@
    SDL_MultiGestureEvent mgesture; /< Multi Finger Gesture data */
    SDL_DollarGestureEvent dgesture; /
    < Multi Finger Gesture data */
    SDL_DropEvent drop; /< Drag and drop event data */ +
    SDL_SystemEvent sysevent; /
    < System event data */
    } SDL_Event;

@@ -619,6 +683,16 @@
*/
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);

+/** + * Set system event hook + * + / +typedef int (SDLCALL *
SDL_SystemEventHandler) (SDL_Event
event); + +extern DECLSPEC void
SDLCALL SDL_SetSystemEventHook(SDL_SystemEventHandler handler); + + +
/* Ends C function definitions when using C++ /
#ifdef __cplusplus
/
INDENT-OFF / diff -r 6bb657898f55 src/events/SDL_events.c —
a/src/events/SDL_events.c Tue Feb 28 21:58:36 2012 -0500 +++
b/src/events/SDL_events.c Thu Mar 22 04:10:18 2012 +0100 @@ -36,6 +36,7 @@
/
Public data – the event filter */
SDL_EventFilter SDL_EventOK = NULL;
void *SDL_EventOKParam; +SDL_SystemEventHandler SDL_SysEventHandler =
NULL;

typedef struct SDL_EventWatcher {
SDL_EventFilter callback; @@ -359,6 +360,7 @@
{
SDL_EventWatcher *curr;
event->window.timestamp = SDL_GetTicks(); +
if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
return 0;
} @@ -529,4 +531,13 @@
return (posted);
}

+void +SDL_SetSystemEventHook(SDL_SystemEventHandler handler) +{ + if
(handler) + { + SDL_SysEventHandler=handler; + } +} +
/* vi: set ts=4 sw=4 expandtab: / diff -r 6bb657898f55
src/events/SDL_events_c.h — a/src/events/SDL_events_c.h Tue Feb 28
21:58:36 2012 -0500 +++ b/src/events/SDL_events_c.h Thu Mar 22 04:10:18
2012 +0100 @@ -1,6 +1,7 @@
/

Simple DirectMedia Layer
Copyright © 1997-2012 Sam Lantinga + Copyright
© 1997-2011 Sam Lantinga

This software is provided ‘as-is’, without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -46,4 +47,7 @@
extern SDL_EventFilter SDL_EventOK;
extern void *SDL_EventOKParam;

+/* The system event hook function / +extern SDL_SystemEventHandler
SDL_SysEventHandler; +
/
vi: set ts=4 sw=4 expandtab: */ diff -r 6bb657898f55
src/video/uikit/SDL_uikitappdelegate.m —
a/src/video/uikit/SDL_uikitappdelegate.m Tue Feb 28 21:58:36 2012 -0500
+++ b/src/video/uikit/SDL_uikitappdelegate.m Thu Mar 22 04:10:18 2012
+0100 @@ -123,7 +123,12 @@

  • (void)applicationWillTerminate:(UIApplication )application
    { - SDL_SendQuit(); + SDL_Event event; +
    event.type=SDL_SYSEVENT_TERMINATE; + event.sysevent.data=NULL; + if
    (SDL_SysEventHandler) + SDL_SysEventHandler(&event); + else
    SDL_SendQuit();
    /
    hack to prevent automatic termination. See SDL_uikitevents.m for
    details /
    longjmp(
    (jump_env()), 1);
    } @@ -131,37 +136,81 @@

  • (void) applicationWillResignActive:(UIApplication*)application
    {
    //NSLog(@"%@", NSStringFromSelector(_cmd)); + SDL_Event event; +
    event.type=SDL_SYSEVENT_WILL_SUSPEND; + event.sysevent.data=NULL; + if
    (SDL_SysEventHandler) + SDL_SysEventHandler(&event); + else { + // Send
    every window on every screen a MINIMIZED event. + SDL_VideoDevice *_this =
    SDL_GetVideoDevice(); + if (!_this) { + return; + }

  • // Send every window on every screen a MINIMIZED event. -
    SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (!_this) { - return; -
    } + SDL_Window *window; + for (window = _this->windows; window != nil;
    window = window->next) { + SDL_SendWindowEvent(window,
    SDL_WINDOWEVENT_MINIMIZED, 0, 0); + } + } +}

  • SDL_Window window; - for (window = _this->windows; window != nil;
    window = window->next) { - SDL_SendWindowEvent(window,
    SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); - SDL_SendWindowEvent(window,
    SDL_WINDOWEVENT_MINIMIZED, 0, 0); - } ±
    (void)applicationDidEnterBackground:(UIApplication
    )application +{ +
    //NSLog(@"%@", NSStringFromSelector(_cmd)); + + SDL_Event event; +
    event.type=SDL_SYSEVENT_SUSPEND; + event.sysevent.data=NULL; + if
    (SDL_SysEventHandler) + SDL_SysEventHandler(&event); +} + ±
    (void)applicationWillEnterForeground:(UIApplication*)application +{ +
    //NSLog(@"%@", NSStringFromSelector(_cmd)); + + SDL_Event event; +
    event.type=SDL_SYSEVENT_WILL_RESUME; + event.sysevent.data=NULL; + if
    (SDL_SysEventHandler) + SDL_SysEventHandler(&event);
    }

  • (void) applicationDidBecomeActive:(UIApplication*)application
    {
    //NSLog(@"%@", NSStringFromSelector(_cmd));

  • // Send every window on every screen a RESTORED event. - SDL_VideoDevice
    *_this = SDL_GetVideoDevice(); - if (!_this) { - return; - } + SDL_Event
    event; + event.type=SDL_SYSEVENT_RESUME; + event.sysevent.data=NULL; + if
    (SDL_SysEventHandler) + SDL_SysEventHandler(&event); + else { + // Send
    every window on every screen a RESTORED event. + SDL_VideoDevice *_this =
    SDL_GetVideoDevice(); + if (!_this) { + return; + }

  • SDL_Window *window; - for (window = _this->windows; window != nil;
    window = window->next) { - SDL_SendWindowEvent(window,
    SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); - SDL_SendWindowEvent(window,
    SDL_WINDOWEVENT_RESTORED, 0, 0); - } + SDL_Window *window; + for (window =
    _this->windows; window != nil; window = window->next) { +
    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); +
    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); + } + }
    }

± (void)applicationDidReceiveMemoryWarning:(UIApplication*)application +{

  • //NSLog(@"%@", NSStringFromSelector(_cmd)); + + SDL_Event event; +
    event.type=SDL_SYSEVENT_LOWMEMORY; + event.sysevent.data=NULL; + if
    (SDL_SysEventHandler) + SDL_SysEventHandler(&event); +}
    @end

#endif /* SDL_VIDEO_DRIVER_UIKIT */

It seems that it got mangled somehow so I’m sending it again.
P.On Tue, 27 Mar 2012 @Piotr_Drapich wrote:

Hi Brian,
Here’s a diff for my callback implementation based on the latest
SDL source from hg. It also implements all important iOS events as SDL
events:

SDL_SYSEVENT_TERMINATE
SDL_SYSEVENT_WILL_SUSPEND
SDL_SYSEVENT_SUSPEND
SDL_SYSEVENT_WILL_RESUME
SDL_SYSEVENT_RESUME
SDL_SYSEVENT_LOWMEMORY

regards,
Piotr

On Sun, 18 Mar 2012, Brian Barnes wrote:

I’m finally getting back to this. Has there been any movement or additional thought on Poitr’s patch? The original message:

http://forums.libsdl.org/viewtopic.php?t=7733&sid=21dffacbd29855581fe66d8a1126a1df

Piotr, do you have a new version of this patch that conforms with the current trunk of SDL2? I’ll retest it for you.

diff -r 6bb657898f55 include/SDL_events.h
— a/include/SDL_events.h Tue Feb 28 21:58:36 2012 -0500
+++ b/include/SDL_events.h Thu Mar 22 04:10:18 2012 +0100
@@ -104,11 +104,27 @@
SDL_MULTIGESTURE,

 /* Clipboard events */
  • SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */

  • /* System events */

  • SDL_SYSEVENT_TERMINATE = 0xa00,

  • SDL_SYSEVENT_WILL_SUSPEND,

  • SDL_SYSEVENT_SUSPEND,

  • SDL_SYSEVENT_WILL_RESUME,

  • SDL_SYSEVENT_RESUME,

  • SDL_SYSEVENT_LOWMEMORY,

  • /* Drag and drop events */
    SDL_DROPFILE = 0x1000, /**< The system requests a file open */

    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
    * and should be allocated with SDL_RegisterEvents()
    */
    @@ -382,6 +398,16 @@
    Uint32 timestamp;
    } SDL_QuitEvent;

+/**

    • \brief System event
  • */

+typedef struct SDL_SystemEvent
+{

  • Uint32 type;
  • Uint32 timestamp;
  • void *data;
    +} SDL_SystemEvent;

/**

  • \brief A user-defined event type (event.user.*)
    @@ -413,6 +439,36 @@
    SDL_SysWMmsg *msg; /**< driver dependent data, defined in
    SDL_syswm.h */
    } SDL_SysWMEvent;

/**

  • \brief General event structure
    */
    @@ -438,6 +494,14 @@
    SDL_MultiGestureEvent mgesture; /< Multi Finger Gesture data */
    SDL_DollarGestureEvent dgesture; /
    < Multi Finger Gesture data */
    SDL_DropEvent drop; /**< Drag and drop event data */
  • SDL_SystemEvent sysevent; /**< System event data */
    } SDL_Event;

@@ -619,6 +683,16 @@
*/
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);

+/**

    • Set system event hook
  • /
    +typedef int (SDLCALL * SDL_SystemEventHandler) (SDL_Event
    event);

+extern DECLSPEC void SDLCALL
SDL_SetSystemEventHook(SDL_SystemEventHandler handler);
+
+
+
/* Ends C function definitions when using C++ /
#ifdef __cplusplus
/
INDENT-OFF /
diff -r 6bb657898f55 src/events/SDL_events.c
— a/src/events/SDL_events.c Tue Feb 28 21:58:36 2012 -0500
+++ b/src/events/SDL_events.c Thu Mar 22 04:10:18 2012 +0100
@@ -36,6 +36,7 @@
/
Public data – the event filter */
SDL_EventFilter SDL_EventOK = NULL;
void *SDL_EventOKParam;
+SDL_SystemEventHandler SDL_SysEventHandler = NULL;

typedef struct SDL_EventWatcher {
SDL_EventFilter callback;
@@ -359,6 +360,7 @@
{
SDL_EventWatcher *curr;
event->window.timestamp = SDL_GetTicks();
+
if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
return 0;
}
@@ -529,4 +531,13 @@
return (posted);
}

+void
+SDL_SetSystemEventHook(SDL_SystemEventHandler handler)
+{

  • if (handler)
  • {
  •   SDL_SysEventHandler=handler;
    
  • }
    +}

/* vi: set ts=4 sw=4 expandtab: /
diff -r 6bb657898f55 src/events/SDL_events_c.h
— a/src/events/SDL_events_c.h Tue Feb 28 21:58:36 2012 -0500
+++ b/src/events/SDL_events_c.h Thu Mar 22 04:10:18 2012 +0100
@@ -1,6 +1,7 @@
/

Simple DirectMedia Layer
Copyright © 1997-2012 Sam Lantinga

  • Copyright © 1997-2011 Sam Lantinga

    This software is provided ‘as-is’, without any express or implied
    warranty. In no event will the authors be held liable for any damages
    @@ -46,4 +47,7 @@
    extern SDL_EventFilter SDL_EventOK;
    extern void *SDL_EventOKParam;

+/* The system event hook function /
+extern SDL_SystemEventHandler SDL_SysEventHandler;
+
/
vi: set ts=4 sw=4 expandtab: */
diff -r 6bb657898f55 src/video/uikit/SDL_uikitappdelegate.m
— a/src/video/uikit/SDL_uikitappdelegate.m Tue Feb 28 21:58:36 2012
-0500
+++ b/src/video/uikit/SDL_uikitappdelegate.m Thu Mar 22 04:10:18 2012
+0100
@@ -123,7 +123,12 @@

  • (void)applicationWillTerminate:(UIApplication *)application
    {
  • SDL_SendQuit();
  • SDL_Event event;
  • event.type=SDL_SYSEVENT_TERMINATE;
  • event.sysevent.data=NULL;
  • if (SDL_SysEventHandler)
  •   SDL_SysEventHandler(&event);
    
  • else SDL_SendQuit();
    /* hack to prevent automatic termination. See SDL_uikitevents.m for
    details /
    longjmp(
    (jump_env()), 1);
    }
    @@ -131,37 +136,81 @@
  • (void) applicationWillResignActive:(UIApplication*)application
    {
    //NSLog(@"%@", NSStringFromSelector(_cmd));
  • SDL_Event event;
  • event.type=SDL_SYSEVENT_WILL_SUSPEND;
  • event.sysevent.data=NULL;
  • if (SDL_SysEventHandler)
  •   SDL_SysEventHandler(&event);
    
  • else {
  • // Send every window on every screen a MINIMIZED event.
  •   SDL_VideoDevice *_this = SDL_GetVideoDevice();
    
  •   if (!_this) {
    
  •   	return;
    
  •   }
    
  • // Send every window on every screen a MINIMIZED event.
  • SDL_VideoDevice *_this = SDL_GetVideoDevice();
  • if (!_this) {
  •    return;
    
  • }
  •   SDL_Window *window;
    
  •   for	(window = _this->windows; window != nil; window =
    

window->next) {

  •   	SDL_SendWindowEvent(window,
    

SDL_WINDOWEVENT_MINIMIZED, 0, 0);

  •   }
    
  • }
    +}
  • SDL_Window *window;
  • for (window = _this->windows; window != nil; window = window->next) {
  •    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
    
  •    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
    
  • }
    ± (void)applicationDidEnterBackground:(UIApplication*)application
    +{
  • //NSLog(@"%@", NSStringFromSelector(_cmd));
  • SDL_Event event;
  • event.type=SDL_SYSEVENT_SUSPEND;
  • event.sysevent.data=NULL;
  • if (SDL_SysEventHandler)
  •   SDL_SysEventHandler(&event);
    

+}
+
± (void)applicationWillEnterForeground:(UIApplication*)application
+{

  • //NSLog(@"%@", NSStringFromSelector(_cmd));
  • SDL_Event event;
  • event.type=SDL_SYSEVENT_WILL_RESUME;
  • event.sysevent.data=NULL;
  • if (SDL_SysEventHandler)
  •   SDL_SysEventHandler(&event);
    

}

  • (void) applicationDidBecomeActive:(UIApplication*)application
    {
    //NSLog(@"%@", NSStringFromSelector(_cmd));

  • // Send every window on every screen a RESTORED event.

  • SDL_VideoDevice *_this = SDL_GetVideoDevice();

  • if (!_this) {

  •    return;
    
  • }

  • SDL_Event event;
  • event.type=SDL_SYSEVENT_RESUME;
  • event.sysevent.data=NULL;
  • if (SDL_SysEventHandler)
  •   SDL_SysEventHandler(&event);
    
  • else {
  •   // Send every window on every screen a RESTORED event.
    
  •   SDL_VideoDevice *_this = SDL_GetVideoDevice();
    
  •   if (!_this) {
    
  •   	return;
    
  •   }
    
  • SDL_Window *window;
  • for (window = _this->windows; window != nil; window = window->next) {
  •    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
    
  •    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
    
  • }
  •   SDL_Window *window;
    
  •   for (window = _this->windows; window != nil; window =
    

window->next) {

  •    	SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED,
    

0, 0);

  •    	SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0,
    

0);

  •   }
    
  • }
    }

± (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
+{

  • //NSLog(@"%@", NSStringFromSelector(_cmd));
  • SDL_Event event;
  • event.type=SDL_SYSEVENT_LOWMEMORY;
  • event.sysevent.data=NULL;
  • if (SDL_SysEventHandler)
  •   SDL_SysEventHandler(&event);
    

+}
@end

#endif /* SDL_VIDEO_DRIVER_UIKIT */

I sort of wonder if it’s a good idea expose the functionality by events
as well as it implies it is expected to work OK where in many situations
it won’t. It also means the same functionality is exposed in two
different ways; this may be confusing.

Good work though :). I think your patch may be mixing spaces and tabs.On 27/03/2012 08:19, sdl at union.pl wrote:

It also implements all important iOS events as SDL
events:

SDL_SYSEVENT_TERMINATE
SDL_SYSEVENT_WILL_SUSPEND
SDL_SYSEVENT_SUSPEND
SDL_SYSEVENT_WILL_RESUME
SDL_SYSEVENT_RESUME
SDL_SYSEVENT_LOWMEMORY

Kudos for the patch!
However if you want to quickly respond to events on ios isn’t it
faster to just subclass the appdelegate and override the appropriate
methods (applicationWillTerminate and friends)?

VittorioOn Tue, Mar 27, 2012 at 10:59 AM, Tim Angus wrote:

On 27/03/2012 08:19, sdl at union.pl wrote:

It also implements all important iOS events as SDL
events:

SDL_SYSEVENT_TERMINATE
SDL_SYSEVENT_WILL_SUSPEND
SDL_SYSEVENT_SUSPEND
SDL_SYSEVENT_WILL_RESUME
SDL_SYSEVENT_RESUME
SDL_SYSEVENT_LOWMEMORY

I sort of wonder if it’s a good idea expose the functionality by events as
well as it implies it is expected to work OK where in many situations it
won’t. It also means the same functionality is exposed in two different
ways; this may be confusing.

Good work though :). I think your patch may be mixing spaces and tabs.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Tim Angus wrote:

I sort of wonder if it’s a good idea expose the functionality by events
as well as it implies it is expected to work OK where in many situations
it won’t. It also means the same functionality is exposed in two
different ways; this may be confusing.

Good work though :). I think your patch may be mixing spaces and tabs.

I second the good job, I’ll be checking this out tonight.

Tim: Yeah, that would be part 2 if the powers that be eventually accept
this patch. We will also need to remove all internal calls to pump
events (not counting any poll event functions, obviously.) The most
notable is in the GL swap.

All of that together should make SDL work well with iOS (as far as I know.)

[>] Brian

An observation: all iOS apps must respond to these events - they can be dummy handlers in some cases but they must respond, and any developer who isn’t providing these callbacks deserves to be slapped
with a compile error.

Therefore, why not require that any SDL2 app compiled on iOS provide these functions? In other words, like SDL_main, there would be a requirement for the app to have functions named
SDL_iOS_App_Terminate() and so on.

I leave the naming of these functions wide open to discussion, I’m just noting that an SDL2 app should not successfully compile on iOS unless it addresses these issues.On 03/27/2012 06:43 AM, Vittorio Giovara wrote:

Kudos for the patch!
However if you want to quickly respond to events on ios isn’t it
faster to just subclass the appdelegate and override the appropriate
methods (applicationWillTerminate and friends)?

Vittorio

On Tue, Mar 27, 2012 at 10:59 AM, Tim Angus wrote:

On 27/03/2012 08:19, sdl at union.pl wrote:

It also implements all important iOS events as SDL
events:

SDL_SYSEVENT_TERMINATE
SDL_SYSEVENT_WILL_SUSPEND
SDL_SYSEVENT_SUSPEND
SDL_SYSEVENT_WILL_RESUME
SDL_SYSEVENT_RESUME
SDL_SYSEVENT_LOWMEMORY

I sort of wonder if it’s a good idea expose the functionality by events as
well as it implies it is expected to work OK where in many situations it
won’t. It also means the same functionality is exposed in two different
ways; this may be confusing.

Good work though :). I think your patch may be mixing spaces and tabs.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier

Forest Hale wrote:

An observation: all iOS apps must respond to these events - they can be dummy handlers in some cases but they must respond, and any developer who isn’t providing these callbacks deserves to be slapped
with a compile error.

Therefore, why not require that any SDL2 app compiled on iOS provide these functions? In other words, like SDL_main, there would be a requirement for the app to have functions named
SDL_iOS_App_Terminate() and so on.

I leave the naming of these functions wide open to discussion, I’m just noting that an SDL2 app should not successfully compile on iOS unless it addresses these issues.

I’ve got nothing against that but it means Piotr’s patch solution won’t
be workable, as it’s more open ended, and, frankly, nothing stops you
from creating SDL_iOS_App_Terminate() with no function body.

Piotr’s patch solution, on the other, will work for further systems down
the line (with different patch points.)

Is it really SDL2’s responsibility to police programmers?

(If I do have one requested change in Piotr’s stuff, it’s to add IOS
to all the system event constants. They should probably be very
specific to iOS and the android ones have ANDROID and be specific to
that.)

[>] Brian

In my experience anything important to basic functionality has every right to produce a compile error.

In this case, if someone forgets to handle all these callbacks, they run the risk of being rejected from the iOS appstore, a compile error is much more pleasant.On 03/27/2012 01:39 PM, Brian Barnes wrote:

Is it really SDL2’s responsibility to police programmers?


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier

Piotr, could you put up that patch as a file somewhere? I’m not the expert on mercurial but it refuses to patch and I suspect it’s a copy-and-paste gremlin or a line-ending error.

[>] Brian

Let’s not rush things, shall we? The hypothetical “maybe i will be
rejected” is a threat that might be good to scare managers off, but
for people who managed to get their code on ios, know that, unless
you’re producing a very similar application the default ones or using
private apis or trying to access network without checking if there is
connectivity, it is quite unlikely to get a rejection these days.

Non responding to events will at worst cause crashes while entering or
exiting background, and this will just lead to bad customer reviews…
I don’t want to get a compile error for that… moreover SDL is being
used also on Cydia, were there is no such restriction, why adding
burden to those developers as well?

Finally, there other ways, like the one I mentioned, to respond to any
event you like, just by subclassing the SDL_UikitAppDelegate and
override the methods you are interested in.

jm2c
VittorioOn Wed, Mar 28, 2012 at 12:18 AM, Forest Hale wrote:

On 03/27/2012 01:39 PM, Brian Barnes wrote:

Is it really SDL2’s responsibility to police programmers?

In my experience anything important to basic functionality has every right to produce a compile error.

In this case, if someone forgets to handle all these callbacks, they run the risk of being rejected from the iOS appstore, a compile error is much more pleasant.


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Finally, there other ways, like the one I mentioned, to respond to any
event you like, just by subclassing the SDL_UikitAppDelegate and
override the methods you are interested in.

jm2c
Vittorio

I really appreciate the work being done by everyone to solve these
issues and to make the patch work as best as possible, but I’d like to
know…if what Vittorio says is true, that you can subclass
SDL_UikitAppDelegate and implements the callbacks there, it seems to
me that would be the perfect solution as it would remain in the
developer domain how to do so, and SDL will remain pristine in its
throne of cross platformness (?). Worst case we can add some forced
errors to warn developer that they must subclass…right?–
Gabriel.

Hi Vittorio,
I think that you missed the whole point of this callback system:
it is meant to be a “generic” implementation of system events on mobile
platforms, not tied to a specific platform or operating system. It
should provide a common set of system events and an unified way of
handling them.

Here’s a table how these events map to various existing platforms:
SDL iOS
Android PlayBook Bada
SDL_SYSEVENT_TERMINATE applicationWillTerminate
OnDestroy NAVIGATOR_EXIT
Osp::App::Application::OnAppTerminating
SDL_SYSEVENT_WILL_SUSPEND applicationWillResignActive
OnPause
SDL_SYSEVENT_SUSPEND applicationDidEnterBackground
onStop NAVIGATOR_WINDOW_INACTIVE
Osp::App::Application::OnBackground
SDL_SYSEVENT_WILL_RESUME applicationWillEnterForeground
SDL_SYSEVENT_RESUME applicationDidBecomeActive
OnResume NAVIGATOR_WINDOW_ACTIVE
Osp::App::Application::OnForeground
SDL_SYSEVENT_LOWMEMORY applicationDidReceiveMemoryWarning
NAVIGATOR_LOW_MEMORY Osp::App::Application::OnLowMemory
SDL_SYSEVENT_ORIENTATION_CHANGED didRotateFromInterfaceOrientation
OnOrientationChanged NAVIGATOR_ORIENTATION_CHECK
OnOrientationChanged

regards,
Piotr

btw: Of course, you can subclass appdelegate which may be faster, but it
will make your code platform dependent.On Wed, 28 Mar 2012, Vittorio Giovara wrote:

Let’s not rush things, shall we? The hypothetical “maybe i will be
rejected” is a threat that might be good to scare managers off, but
for people who managed to get their code on ios, know that, unless
you’re producing a very similar application the default ones or using
private apis or trying to access network without checking if there is
connectivity, it is quite unlikely to get a rejection these days.

Non responding to events will at worst cause crashes while entering or
exiting background, and this will just lead to bad customer reviews…
I don’t want to get a compile error for that… moreover SDL is being
used also on Cydia, were there is no such restriction, why adding
burden to those developers as well?

Finally, there other ways, like the one I mentioned, to respond to any
event you like, just by subclassing the SDL_UikitAppDelegate and
override the methods you are interested in.

jm2c
Vittorio

On Wed, Mar 28, 2012 at 12:18 AM, Forest Hale wrote:

On 03/27/2012 01:39 PM, Brian Barnes wrote:

Is it really SDL2’s responsibility to police programmers?

In my experience anything important to basic functionality has every right to produce a compile error.

In this case, if someone forgets to handle all these callbacks, they run the risk of being rejected from the iOS appstore, a compile error is much more pleasant.


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org