diff --git a/VisualC/SDL/SDL_VS2005.vcproj b/VisualC/SDL/SDL_VS2005.vcproj
index d512b16e8..5a3223c13 100644
--- a/VisualC/SDL/SDL_VS2005.vcproj
+++ b/VisualC/SDL/SDL_VS2005.vcproj
@@ -907,6 +907,10 @@
RelativePath="..\..\src\SDL_hints.c"
>
+
+
diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj
index 4c16d7bc2..3c37fb64c 100644
--- a/VisualC/SDL/SDL_VS2008.vcproj
+++ b/VisualC/SDL/SDL_VS2008.vcproj
@@ -896,6 +896,10 @@
RelativePath="..\..\src\SDL_hints.c"
>
+
+
diff --git a/VisualC/SDL/SDL_VS2010.vcxproj b/VisualC/SDL/SDL_VS2010.vcxproj
index 60eb0088d..db5b16994 100644
--- a/VisualC/SDL/SDL_VS2010.vcxproj
+++ b/VisualC/SDL/SDL_VS2010.vcxproj
@@ -281,6 +281,7 @@
+
@@ -436,4 +437,4 @@
-
\ No newline at end of file
+
diff --git a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
index b506b1709..50fa59986 100755
--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
@@ -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 = ""; };
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 = ""; };
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 = ""; };
@@ -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;
};
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index e106650f1..64323917a 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -119,6 +119,20 @@ extern "C" {
*/
#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.
*
diff --git a/src/SDL_hints.c b/src/SDL_hints.c
index 659174d05..8868c4e63 100644
--- a/src/SDL_hints.c
+++ b/src/SDL_hints.c
@@ -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 @@ typedef struct SDL_Hint {
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 @@ SDL_SetHintWithPriority(const char *name, const char *value,
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 @@ SDL_SetHintWithPriority(const char *name, const char *value,
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;
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index 36f512eb0..4a8ce3989 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -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 @@ int main(int argc, char **argv) {
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 @@ int main(int argc, char **argv) {
}
- (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);