--- a/VisualC/SDL/SDL_VS2005.vcproj Fri Jun 10 14:23:24 2011 +0100
+++ b/VisualC/SDL/SDL_VS2005.vcproj Fri Jun 10 14:23:36 2011 +0100
@@ -908,6 +908,10 @@
>
</File>
<File
+ RelativePath="..\..\src\SDL_hints_c.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\stdlib\SDL_iconv.c"
>
</File>
--- a/VisualC/SDL/SDL_VS2008.vcproj Fri Jun 10 14:23:24 2011 +0100
+++ b/VisualC/SDL/SDL_VS2008.vcproj Fri Jun 10 14:23:36 2011 +0100
@@ -897,6 +897,10 @@
>
</File>
<File
+ RelativePath="..\..\src\SDL_hints_c.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\stdlib\SDL_iconv.c"
>
</File>
--- a/VisualC/SDL/SDL_VS2010.vcxproj Fri Jun 10 14:23:24 2011 +0100
+++ b/VisualC/SDL/SDL_VS2010.vcxproj Fri Jun 10 14:23:36 2011 +0100
@@ -281,6 +281,7 @@
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
<ClInclude Include="..\..\src\audio\windx5\SDL_dx5audio.h" />
<ClInclude Include="..\..\src\SDL_error_c.h" />
+ <ClInclude Include="..\..\src\SDL_hints_c.h" />
<ClInclude Include="..\..\src\events\SDL_events_c.h" />
<ClInclude Include="..\..\src\SDL_fatal.h" />
<ClInclude Include="..\..\src\video\SDL_glesfuncs.h" />
@@ -436,4 +437,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Fri Jun 10 14:23:24 2011 +0100
+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Fri Jun 10 14:23:36 2011 +0100
@@ -122,6 +122,7 @@
04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */; };
04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9512E23BDC00BA343D /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 22C905CD13A22646003FE4E4 /* SDL_hints_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 22C905CC13A22646003FE4E4 /* SDL_hints_c.h */; };
56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E0118A8EE200A56AA6 /* SDL_power.c */; };
56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; };
FD24846D0E5655AE0021E198 /* SDL_uikitkeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = FD24846B0E5655AE0021E198 /* SDL_uikitkeyboard.h */; };
@@ -376,6 +377,7 @@
04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
04FFAB9512E23BDC00BA343D /* SDL_shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_shape.h; path = ../../include/SDL_shape.h; sourceTree = SOURCE_ROOT; };
+ 22C905CC13A22646003FE4E4 /* SDL_hints_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_hints_c.h; path = ../../src/SDL_hints_c.h; sourceTree = "<group>"; };
56ED04E0118A8EE200A56AA6 /* SDL_power.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_power.c; path = ../../src/power/SDL_power.c; sourceTree = SOURCE_ROOT; };
56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; };
FD0BBFEF0E3933DD00D833B1 /* SDL_uikitview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitview.h; sourceTree = "<group>"; };
@@ -971,6 +973,7 @@
FD99B9D60DD52EDC00FB1D6B /* SDL_fatal.c */,
FD99B9D70DD52EDC00FB1D6B /* SDL_fatal.h */,
0442EC5412FE1C3F004C9285 /* SDL_hints.c */,
+ 22C905CC13A22646003FE4E4 /* SDL_hints_c.h */,
04BAC09B1300C1290055DE28 /* SDL_log.c */,
FD99B9D80DD52EDC00FB1D6B /* SDL.c */,
);
@@ -1241,6 +1244,7 @@
04BAC0991300C0F70055DE28 /* SDL_log.h in Headers */,
04BAC09C1300C1290055DE28 /* SDL_assert_c.h in Headers */,
0417A516130C988500578583 /* SDL_keycode.h in Headers */,
+ 22C905CD13A22646003FE4E4 /* SDL_hints_c.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- a/include/SDL_hints.h Fri Jun 10 14:23:24 2011 +0100
+++ b/include/SDL_hints.h Fri Jun 10 14:23:36 2011 +0100
@@ -120,6 +120,20 @@
#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC"
/**
+ * \brief A variable controlling whether the idle timer is disabled on iOS.
+ *
+ * When an iOS app does not receive touches for some time, the screen is
+ * dimmed automatically. For games where the accelerometer is the only input
+ * this is problematic. This functionality can be disabled by setting this
+ * hint.
+ *
+ * This variable can be set to the following values:
+ * "0" - Enable idle timer
+ * "1" - Disable idle timer
+ */
+#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED"
+
+/**
* \brief A variable controlling which orientations are allowed on iOS.
*
* In some circumstances it is necessary to be able to explicitly control
--- a/src/SDL_hints.c Fri Jun 10 14:23:24 2011 +0100
+++ b/src/SDL_hints.c Fri Jun 10 14:23:36 2011 +0100
@@ -21,6 +21,7 @@
#include "SDL_config.h"
#include "SDL_hints.h"
+#include "SDL_hints_c.h"
/* Assuming there aren't many hints set and they aren't being queried in
@@ -30,11 +31,26 @@
char *name;
char *value;
SDL_HintPriority priority;
+ SDL_HintChangedCb callback;
struct SDL_Hint *next;
} SDL_Hint;
static SDL_Hint *SDL_hints;
+SDL_bool
+SDL_RegisterHintChangedCb(const char *name, SDL_HintChangedCb hintCb)
+{
+ SDL_Hint *hint;
+
+ for (hint = SDL_hints; hint; hint = hint->next) {
+ if (SDL_strcmp(name, hint->name) == 0) {
+ hint->callback = hintCb;
+ return SDL_TRUE;
+ }
+ }
+
+ return SDL_FALSE;
+}
SDL_bool
SDL_SetHintWithPriority(const char *name, const char *value,
@@ -59,6 +75,9 @@
return SDL_FALSE;
}
if (SDL_strcmp(hint->value, value) != 0) {
+ if (hint->callback != NULL) {
+ (*hint->callback)(name, hint->value, value);
+ }
SDL_free(hint->value);
hint->value = SDL_strdup(value);
}
@@ -75,6 +94,7 @@
hint->name = SDL_strdup(name);
hint->value = SDL_strdup(value);
hint->priority = priority;
+ hint->callback = NULL;
hint->next = SDL_hints;
SDL_hints = hint;
return SDL_TRUE;
--- a/src/video/uikit/SDL_uikitappdelegate.m Fri Jun 10 14:23:24 2011 +0100
+++ b/src/video/uikit/SDL_uikitappdelegate.m Fri Jun 10 14:23:36 2011 +0100
@@ -20,6 +20,9 @@
*/
#import "../SDL_sysvideo.h"
+#import "SDL_assert.h"
+#import "SDL_hints.h"
+#import "../../SDL_hints_c.h"
#import "SDL_uikitappdelegate.h"
#import "SDL_uikitopenglview.h"
@@ -55,6 +58,13 @@
return 0;
}
+static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue) {
+ SDL_assert(SDL_strcmp(name, SDL_HINT_IDLE_TIMER_DISABLED) == 0);
+
+ BOOL disable = (*newValue != '0');
+ [UIApplication sharedApplication].idleTimerDisabled = disable;
+}
+
@implementation SDLUIKitDelegate
/* convenience method */
@@ -75,6 +85,10 @@
}
- (void)postFinishLaunch {
+
+ /* register a callback for the idletimer hint */
+ SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "0");
+ SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged);
/* run the user's application, passing argc and argv */
int exit_status = SDL_main(forward_argc, forward_argv);