From a3982939c5d235d5db9fde269ffd46c57482f910 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Mon, 12 Aug 2013 11:13:50 -0300 Subject: [PATCH 001/258] Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump. --- android-project/src/org/libsdl/app/SDLActivity.java | 5 ----- src/video/android/SDL_androidevents.c | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index ed6f4ef32..7184a329c 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -695,11 +695,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread"); enableSensor(Sensor.TYPE_ACCELEROMETER, true); SDLActivity.mSDLThread.start(); - } else { - // The app already exists, we resume via handleResume - // Multiple sequential calls to surfaceChanged are handled internally by handleResume - - SDLActivity.handleResume(); } } diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 528fce5c6..add86dfca 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -64,9 +64,9 @@ Android_PumpEvents(_THIS) else { #if SDL_ANDROID_BLOCK_ON_PAUSE if( isPausing || SDL_SemTryWait(Android_PauseSem) == 0 ) { - /* We've been signaled to pause, but before we block ourselves, we need to make sure that - SDL_WINDOWEVENT_FOCUS_LOST and SDL_WINDOWEVENT_MINIMIZED have reached the app */ - if (SDL_HasEvent(SDL_WINDOWEVENT)) { + /* We've been signaled to pause, but before we block ourselves, + we need to make sure that certain key events have reached the app */ + if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) { isPausing = 1; } else { From af05051deeda56665466515016bb3f9209c6b83c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Aug 2013 08:40:49 -0700 Subject: [PATCH 002/258] Added tag release_2.0.0 for changeset d6a8fa507a45 --HG-- extra : rebase_source : a735ace6526c8b4b32f704d7f0353912dff3cc18 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index d5c2200b9..fc45db136 100644 --- a/.hgtags +++ b/.hgtags @@ -14,3 +14,4 @@ e044e7c70a50a2f54d14ee20d0933e904e5853b6 release-1.2.9 f14cf9d71233934811774f941d0de121d5f96ccf release-1.2.14 39c22a953456f6c9e2c8993c8ff973824104102a pre-touch-removal ccf5fbfa2afabab429ad911308f362201a94d810 macosx_10_4_supported +d6a8fa507a45d9de7258e51585eab3e45c415149 release_2.0.0 From 85492cbff9d403221fe4196751991cd14b2940ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Aug 2013 08:45:37 -0700 Subject: [PATCH 003/258] Added Julian Winter to the credits for the SDL 2.0 website. --- CREDITS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREDITS.txt b/CREDITS.txt index a1c2cdcb0..74163e824 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -21,6 +21,8 @@ Thanks to everyone who made this possible, including: * Pierre-Loup Griffais for his deep knowledge of OpenGL drivers. +* Julian Winter for the SDL 2.0 website. + * Sheena Smith for many months of great work on the SDL wiki creating the API documentation and style guides. * Paul Hunkin for his port of SDL to Android during the Google Summer of Code 2010. From a100a39fe95a1c602dc9474e06fdba9f029145a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 12 Aug 2013 11:09:13 -0700 Subject: [PATCH 004/258] Mac: Fix restoring of Cmd-H-hidden fullscreen desktop windows. This should fix http://bugzilla.libsdl.org/show_bug.cgi?id=1996 --HG-- extra : histedit_source : 5d56152c804e07c2750a8490d945f65f78d3cf93 --- src/video/cocoa/SDL_cocoawindow.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 9cee4d3ba..cd4771d44 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1047,9 +1047,11 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display [nswindow setLevel:kCGNormalWindowLevel]; } - [data->listener pauseVisibleObservation]; - [nswindow makeKeyAndOrderFront:nil]; - [data->listener resumeVisibleObservation]; + if ([nswindow isVisible] || fullscreen) { + [data->listener pauseVisibleObservation]; + [nswindow makeKeyAndOrderFront:nil]; + [data->listener resumeVisibleObservation]; + } ScheduleContextUpdates(data); From 24273dd36927e2c8ec8ab4674388a25be2de35d8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Aug 2013 19:18:48 -0700 Subject: [PATCH 005/258] Fixed the tag name for the SDL 2.0 release --- .hgtags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.hgtags b/.hgtags index fc45db136..f45c716ef 100644 --- a/.hgtags +++ b/.hgtags @@ -14,4 +14,4 @@ e044e7c70a50a2f54d14ee20d0933e904e5853b6 release-1.2.9 f14cf9d71233934811774f941d0de121d5f96ccf release-1.2.14 39c22a953456f6c9e2c8993c8ff973824104102a pre-touch-removal ccf5fbfa2afabab429ad911308f362201a94d810 macosx_10_4_supported -d6a8fa507a45d9de7258e51585eab3e45c415149 release_2.0.0 +d6a8fa507a45d9de7258e51585eab3e45c415149 release-2.0.0 From a0bc6020619b467c48d4aac3fbbf5d34070a4f77 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Aug 2013 22:00:21 -0700 Subject: [PATCH 006/258] Don't print "unrecognized key" message for an X11 keycode of 0. This can happen with composed characters. --- src/video/x11/SDL_x11events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index a9a3ac996..4bdfd1c6e 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -440,7 +440,7 @@ X11_DispatchEvent(_THIS) #endif SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); #if 1 - if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) { + if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) { int min_keycode, max_keycode; XDisplayKeycodes(display, &min_keycode, &max_keycode); #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM From 16a40598f6da5cf3237e0f62c50887cbfe76e777 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Wed, 14 Aug 2013 23:30:10 -0700 Subject: [PATCH 007/258] Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency --- .../tests/loopwave/loopwave_VS2010.vcxproj | 14 ++- .../tests/loopwave/loopwave_VS2012.vcxproj | 12 +- test/checkkeys.c | 13 ++- test/loopwave.c | 20 ++-- test/testatomic.c | 109 ++++++++++-------- test/testaudioinfo.c | 25 ++-- test/testautomation.c | 3 +- test/testautomation_surface.c | 2 - test/testdraw2.c | 8 +- test/testdrawchessboard.c | 9 +- test/testerror.c | 15 ++- test/testfile.c | 17 +-- test/testgamecontroller.c | 43 +++---- test/testgesture.c | 3 + test/testgl2.c | 55 ++++----- test/testgles.c | 61 +++++----- test/testhaptic.c | 86 +++++++------- test/testiconv.c | 7 +- test/testime.c | 18 +-- test/testintersections.c | 12 +- test/testjoystick.c | 59 +++++----- test/testkeys.c | 7 +- test/testloadso.c | 18 +-- test/testlock.c | 27 +++-- test/testmessage.c | 21 ++-- test/testmultiaudio.c | 26 +++-- test/testnative.c | 21 ++-- test/testoverlay2.c | 54 ++++----- test/testplatform.c | 57 ++++----- test/testpower.c | 17 +-- test/testrelative.c | 4 +- test/testrendercopyex.c | 11 +- test/testrendertarget.c | 14 ++- test/testresample.c | 21 ++-- test/testrumble.c | 32 ++--- test/testscale.c | 11 +- test/testsem.c | 29 ++--- test/testshader.c | 22 ++-- test/testshape.c | 15 ++- test/testsprite2.c | 13 +-- test/testspriteminimal.c | 7 +- test/teststreaming.c | 15 ++- test/testthread.c | 23 ++-- test/testtimer.c | 30 ++--- test/testver.c | 11 +- test/testwm2.c | 9 +- test/torturethread.c | 15 ++- 47 files changed, 616 insertions(+), 505 deletions(-) diff --git a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj index 4ef300ad0..1fd518982 100644 --- a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj +++ b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj @@ -1,4 +1,4 @@ - + @@ -105,7 +105,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -139,7 +140,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -174,7 +176,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -208,7 +211,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL diff --git a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj index 0a648593e..ea983c5d8 100644 --- a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj +++ b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj @@ -109,7 +109,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -143,7 +144,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -178,7 +180,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -212,7 +215,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL diff --git a/test/checkkeys.c b/test/checkkeys.c index 61e8be043..5f2d14847 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -117,13 +117,13 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) static void PrintText(char *text) { - unsigned char *spot, expanded[1024]; + char *spot, expanded[1024]; expanded[0] = '\0'; for ( spot = text; *spot; ++spot ) { size_t length = SDL_strlen(expanded); - SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot); + SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); } SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text); } @@ -134,10 +134,13 @@ main(int argc, char *argv[]) SDL_Window *window; SDL_Event event; int done; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -146,7 +149,7 @@ main(int argc, char *argv[]) SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); if (!window) { - fprintf(stderr, "Couldn't create 640x480 window: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); quit(2); } @@ -166,7 +169,7 @@ main(int argc, char *argv[]) switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: - PrintKey(&event.key.keysym, event.key.state, event.key.repeat); + PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE); break; case SDL_TEXTINPUT: PrintText(event.text.text); diff --git a/test/loopwave.c b/test/loopwave.c index 22b0559de..34d07c2b2 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -80,9 +80,12 @@ main(int argc, char *argv[]) { int i; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -91,7 +94,7 @@ main(int argc, char *argv[]) } /* Load the wave file into memory */ if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) { - fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); quit(1); } @@ -109,24 +112,19 @@ main(int argc, char *argv[]) #endif /* HAVE_SIGNAL_H */ /* Show the list of available drivers */ - printf("Available audio drivers: "); + SDL_Log("Available audio drivers:"); for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { - if (i == 0) { - printf("%s", SDL_GetAudioDriver(i)); - } else { - printf(", %s", SDL_GetAudioDriver(i)); - } + SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); } - printf("\n"); /* Initialize fillerup() variables */ if (SDL_OpenAudio(&wave.spec, NULL) < 0) { - fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); SDL_FreeWAV(wave.sound); quit(2); } - printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); + SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); /* Let the audio run */ SDL_PauseAudio(0); diff --git a/test/testatomic.c b/test/testatomic.c index be60a611b..b360616d2 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -45,39 +45,39 @@ void RunBasicTest() SDL_atomic_t v; SDL_bool tfret = SDL_FALSE; - printf("\nspin lock---------------------------------------\n\n"); + SDL_Log("\nspin lock---------------------------------------\n\n"); SDL_AtomicLock(&lock); - printf("AtomicLock lock=%d\n", lock); + SDL_Log("AtomicLock lock=%d\n", lock); SDL_AtomicUnlock(&lock); - printf("AtomicUnlock lock=%d\n", lock); + SDL_Log("AtomicUnlock lock=%d\n", lock); - printf("\natomic -----------------------------------------\n\n"); + SDL_Log("\natomic -----------------------------------------\n\n"); SDL_AtomicSet(&v, 0); - tfret = SDL_AtomicSet(&v, 10) == 0; - printf("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = SDL_AtomicAdd(&v, 10) == 10; - printf("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); SDL_AtomicSet(&v, 0); SDL_AtomicIncRef(&v); - tfret = (SDL_AtomicGet(&v) == 1); - printf("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); SDL_AtomicIncRef(&v); - tfret = (SDL_AtomicGet(&v) == 2); - printf("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE); - printf("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE); - printf("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); SDL_AtomicSet(&v, 10); - tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE); - printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); value = SDL_AtomicGet(&v); - tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE); - printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); } /**************************************************************************/ @@ -120,7 +120,7 @@ static int adder(void* junk) { unsigned long N=NInter; - printf("Thread subtracting %d %lu times\n",CountInc,N); + SDL_Log("Thread subtracting %d %lu times\n",CountInc,N); while (N--) { SDL_AtomicAdd(&good, -CountInc); bad-=CountInc; @@ -152,7 +152,7 @@ void runAdder(void) end = SDL_GetTicks(); - printf("Finished in %f sec\n", (end - start) / 1000.f); + SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); } static @@ -161,28 +161,28 @@ void RunEpicTest() int b; atomicValue v; - printf("\nepic test---------------------------------------\n\n"); + SDL_Log("\nepic test---------------------------------------\n\n"); - printf("Size asserted to be >= 32-bit\n"); + SDL_Log("Size asserted to be >= 32-bit\n"); SDL_assert(sizeof(atomicValue)>=4); - printf("Check static initializer\n"); + SDL_Log("Check static initializer\n"); v=SDL_AtomicGet(&good); SDL_assert(v==42); SDL_assert(bad==42); - printf("Test negative values\n"); + SDL_Log("Test negative values\n"); SDL_AtomicSet(&good, -5); v=SDL_AtomicGet(&good); SDL_assert(v==-5); - printf("Verify maximum value\n"); + SDL_Log("Verify maximum value\n"); SDL_AtomicSet(&good, CountTo); v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); - printf("Test compare and exchange\n"); + SDL_Log("Test compare and exchange\n"); b=SDL_AtomicCAS(&good, 500, 43); SDL_assert(!b); /* no swap since CountTo!=500 */ @@ -194,7 +194,7 @@ void RunEpicTest() v=SDL_AtomicGet(&good); SDL_assert(v==44); - printf("Test Add\n"); + SDL_Log("Test Add\n"); v=SDL_AtomicAdd(&good, 1); SDL_assert(v==44); @@ -206,7 +206,7 @@ void RunEpicTest() v=SDL_AtomicGet(&good); SDL_assert(v==55); - printf("Test Add (Negative values)\n"); + SDL_Log("Test Add (Negative values)\n"); v=SDL_AtomicAdd(&good, -20); SDL_assert(v==55); @@ -223,7 +223,7 @@ void RunEpicTest() v=SDL_AtomicGet(&good); SDL_assert(v==15); - printf("Reset before count down test\n"); + SDL_Log("Reset before count down test\n"); SDL_AtomicSet(&good, CountTo); v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); @@ -231,11 +231,11 @@ void RunEpicTest() bad=CountTo; SDL_assert(bad==CountTo); - printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect); + SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect); runAdder(); v=SDL_AtomicGet(&good); - printf("Atomic %d Non-Atomic %d\n",v,bad); + SDL_Log("Atomic %d Non-Atomic %d\n",v,bad); SDL_assert(v==Expect); SDL_assert(bad!=Expect); } @@ -429,7 +429,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event } else if (delta < 0) { /* We ran into an old queue entry, which means it still needs to be dequeued */ } else { - printf("ERROR: mutex failed!\n"); + SDL_Log("ERROR: mutex failed!\n"); } SDL_UnlockMutex(queue->mutex); @@ -462,7 +462,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event) } else if (delta < 0) { /* We ran into an old queue entry, which means we've hit empty */ } else { - printf("ERROR: mutex failed!\n"); + SDL_Log("ERROR: mutex failed!\n"); } SDL_UnlockMutex(queue->mutex); @@ -598,9 +598,11 @@ static void RunFIFOTest(SDL_bool lock_free) Uint32 start, end; int i, j; int grand_total; + char textBuffer[1024]; + int len; - printf("\nFIFO test---------------------------------------\n\n"); - printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); + SDL_Log("\nFIFO test---------------------------------------\n\n"); + SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); readersDone = SDL_CreateSemaphore(0); writersDone = SDL_CreateSemaphore(0); @@ -622,7 +624,7 @@ static void RunFIFOTest(SDL_bool lock_free) #endif /* Start the readers first */ - printf("Starting %d readers\n", NUM_READERS); + SDL_Log("Starting %d readers\n", NUM_READERS); SDL_zero(readerData); SDL_AtomicSet(&readersRunning, NUM_READERS); for (i = 0; i < NUM_READERS; ++i) { @@ -634,7 +636,7 @@ static void RunFIFOTest(SDL_bool lock_free) } /* Start up the writers */ - printf("Starting %d writers\n", NUM_WRITERS); + SDL_Log("Starting %d writers\n", NUM_WRITERS); SDL_zero(writerData); SDL_AtomicSet(&writersRunning, NUM_WRITERS); for (i = 0; i < NUM_WRITERS; ++i) { @@ -668,16 +670,16 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_DestroyMutex(queue.mutex); } - printf("Finished in %f sec\n", (end - start) / 1000.f); + SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); - printf("\n"); + SDL_Log("\n"); for (i = 0; i < NUM_WRITERS; ++i) { - printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits); + SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits); } - printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER); + SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER); /* Print a breakdown of which readers read messages from which writer */ - printf("\n"); + SDL_Log("\n"); grand_total = 0; for (i = 0; i < NUM_READERS; ++i) { int total = 0; @@ -685,17 +687,21 @@ static void RunFIFOTest(SDL_bool lock_free) total += readerData[i].counters[j]; } grand_total += total; - printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits); - printf(" { "); + SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits); + SDL_snprintf(textBuffer, sizeof(textBuffer), " { "); for (j = 0; j < NUM_WRITERS; ++j) { if (j > 0) { - printf(", "); + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", "); } - printf("%d", readerData[i].counters[j]); + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]); } - printf(" }\n"); + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n"); + SDL_Log(textBuffer); } - printf("Readers read %d total events\n", grand_total); + SDL_Log("Readers read %d total events\n", grand_total); } /* End FIFO test */ @@ -704,6 +710,9 @@ static void RunFIFOTest(SDL_bool lock_free) int main(int argc, char *argv[]) { + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + RunBasicTest(); RunEpicTest(); /* This test is really slow, so don't run it by default */ diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c index c1d7fa389..a65db5fa1 100644 --- a/test/testaudioinfo.c +++ b/test/testaudioinfo.c @@ -18,18 +18,18 @@ print_devices(int iscapture) const char *typestr = ((iscapture) ? "capture" : "output"); int n = SDL_GetNumAudioDevices(iscapture); - printf("%s devices:\n", typestr); + SDL_Log("%s devices:\n", typestr); if (n == -1) - printf(" Driver can't detect specific %s devices.\n\n", typestr); + SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr); else if (n == 0) - printf(" No %s devices found.\n\n", typestr); + SDL_Log(" No %s devices found.\n\n", typestr); else { int i; for (i = 0; i < n; i++) { - printf(" %s\n", SDL_GetAudioDeviceName(i, iscapture)); + SDL_Log(" %s\n", SDL_GetAudioDeviceName(i, iscapture)); } - printf("\n"); + SDL_Log("\n"); } } @@ -38,26 +38,29 @@ main(int argc, char **argv) { int n; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Print available audio drivers */ n = SDL_GetNumAudioDrivers(); if (n == 0) { - printf("No built-in audio drivers\n\n"); + SDL_Log("No built-in audio drivers\n\n"); } else { int i; - printf("Built-in audio drivers:\n"); + SDL_Log("Built-in audio drivers:\n"); for (i = 0; i < n; ++i) { - printf(" %s\n", SDL_GetAudioDriver(i)); + SDL_Log(" %s\n", SDL_GetAudioDriver(i)); } - printf("\n"); + SDL_Log("\n"); } - printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver()); + SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver()); print_devices(0); print_devices(1); diff --git a/test/testautomation.c b/test/testautomation.c index 5eea7ec6f..6610d8a4f 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -80,8 +80,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n", + SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 3f6c56c9a..863a5bd6e 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -360,8 +360,6 @@ surface_testCompleteSurfaceConversion(void *arg) for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) { for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) { - /*printf("Converting %s -> %s\n", SDL_GetPixelFormatName(pixel_formats[i]), SDL_GetPixelFormatName(pixel_formats[j]));*/ - fmt1 = SDL_AllocFormat(pixel_formats[i]); SDL_assert(fmt1 != NULL); cvt1 = SDL_ConvertSurface(face, fmt1, 0); diff --git a/test/testdraw2.c b/test/testdraw2.c index a4509fe74..926294bfe 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -176,6 +176,9 @@ main(int argc, char *argv[]) SDL_Event event; Uint32 then, now, frames; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ num_objects = NUM_OBJECTS; @@ -218,8 +221,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", + SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", argv[0], SDLTest_CommonUsage(state)); return 1; } @@ -268,7 +270,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } return 0; } diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 002d8d717..567d3fb85 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -54,10 +54,13 @@ main(int argc, char *argv[]) SDL_Surface *surface; SDL_Renderer *renderer; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL */ if(SDL_Init(SDL_INIT_VIDEO) != 0) { - fprintf(stderr,"SDL_Init fail : %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError()); return 1; } @@ -66,14 +69,14 @@ main(int argc, char *argv[]) window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN); if(!window) { - fprintf(stderr,"Window creation fail : %s\n",SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError()); return 1; } surface = SDL_GetWindowSurface(window); renderer = SDL_CreateSoftwareRenderer(surface); if(!renderer) { - fprintf(stderr,"Render creation for surface fail : %s\n",SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError()); return 1; } diff --git a/test/testerror.c b/test/testerror.c index e7356c06b..e9c76ff1f 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -36,10 +36,10 @@ ThreadFunc(void *data) SDL_SetError("Thread %s (%lu) had a problem: %s", (char *) data, SDL_ThreadID(), "nevermind"); while (alive) { - printf("Thread '%s' is alive!\n", (char *) data); + SDL_Log("Thread '%s' is alive!\n", (char *) data); SDL_Delay(1 * 1000); } - printf("Child thread error string: %s\n", SDL_GetError()); + SDL_Log("Child thread error string: %s\n", SDL_GetError()); return (0); } @@ -48,9 +48,12 @@ main(int argc, char *argv[]) { SDL_Thread *thread; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -60,15 +63,15 @@ main(int argc, char *argv[]) alive = 1; thread = SDL_CreateThread(ThreadFunc, NULL, "#1"); if (thread == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } SDL_Delay(5 * 1000); - printf("Waiting for thread #1\n"); + SDL_Log("Waiting for thread #1\n"); alive = 0; SDL_WaitThread(thread, NULL); - printf("Main thread error string: %s\n", SDL_GetError()); + SDL_Log("Main thread error string: %s\n", SDL_GetError()); SDL_Quit(); return (0); diff --git a/test/testfile.c b/test/testfile.c index d82d0eb7c..efdc4155f 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -44,7 +44,6 @@ static void cleanup(void) { - unlink(FBASENAME1); unlink(FBASENAME2); } @@ -52,8 +51,7 @@ cleanup(void) static void rwops_error_quit(unsigned line, SDL_RWops * rwops) { - - printf("testfile.c(%d): failed\n", line); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line); if (rwops) { rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */ } @@ -71,6 +69,9 @@ main(int argc, char *argv[]) SDL_RWops *rwops = NULL; char test_buf[30]; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + cleanup(); /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */ @@ -90,7 +91,7 @@ main(int argc, char *argv[]) rwops = SDL_RWFromFile("something", NULL); if (rwops) RWOP_ERR_QUIT(rwops); - printf("test1 OK\n"); + SDL_Log("test1 OK\n"); /* test 2 : check that inexistent file is not successfully opened/created when required */ /* modes : r, r+ imply that file MUST exist @@ -123,7 +124,7 @@ main(int argc, char *argv[]) RWOP_ERR_QUIT(rwops); rwops->close(rwops); unlink(FBASENAME2); - printf("test2 OK\n"); + SDL_Log("test2 OK\n"); /* test 3 : creation, writing , reading, seeking, test : w mode, r mode, w+ mode @@ -201,7 +202,7 @@ main(int argc, char *argv[]) if (SDL_memcmp(test_buf, "12345678901234567890", 20)) RWOP_ERR_QUIT(rwops); rwops->close(rwops); - printf("test3 OK\n"); + SDL_Log("test3 OK\n"); /* test 4: same in r+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ @@ -236,7 +237,7 @@ main(int argc, char *argv[]) if (SDL_memcmp(test_buf, "12345678901234567890", 20)) RWOP_ERR_QUIT(rwops); rwops->close(rwops); - printf("test4 OK\n"); + SDL_Log("test4 OK\n"); /* test5 : append mode */ rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ @@ -277,7 +278,7 @@ main(int argc, char *argv[]) if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30)) RWOP_ERR_QUIT(rwops); rwops->close(rwops); - printf("test5 OK\n"); + SDL_Log("test5 OK\n"); cleanup(); return 0; /* all ok */ } diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index cd18aa5cc..419593dc4 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -91,7 +91,7 @@ WatchGameController(SDL_GameController * gamecontroller) const char *name = SDL_GameControllerName(gamecontroller); const char *basetitle = "Game Controller Test: "; const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1; - char *title = SDL_malloc(titlelen); + char *title = (char *)SDL_malloc(titlelen); SDL_Window *window = NULL; SDL_Renderer *screen = NULL; int done = 0; @@ -107,13 +107,13 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { - fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return; } screen = SDL_CreateRenderer(window, -1, 0); if (screen == NULL) { - fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return; } @@ -124,7 +124,7 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_RaiseWindow(window); /* Print info about the controller we are watching */ - printf("Watching controller %s\n", name ? name : "Unknown Controller"); + SDL_Log("Watching controller %s\n", name ? name : "Unknown Controller"); /* Loop, getting controller events! */ while (!done) { @@ -135,21 +135,21 @@ WatchGameController(SDL_GameController * gamecontroller) while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_CONTROLLERAXISMOTION: - printf("Controller %d axis %d ('%s') value: %d\n", + SDL_Log("Controller %d axis %d ('%s') value: %d\n", event.caxis.which, event.caxis.axis, - ControllerAxisName(event.caxis.axis), + ControllerAxisName((SDL_GameControllerAxis)event.caxis.axis), event.caxis.value); break; case SDL_CONTROLLERBUTTONDOWN: - printf("Controller %d button %d ('%s') down\n", + SDL_Log("Controller %d button %d ('%s') down\n", event.cbutton.which, event.cbutton.button, - ControllerButtonName(event.cbutton.button)); + ControllerButtonName((SDL_GameControllerButton)event.cbutton.button)); break; case SDL_CONTROLLERBUTTONUP: - printf("Controller %d button %d ('%s') up\n", + SDL_Log("Controller %d button %d ('%s') up\n", event.cbutton.which, event.cbutton.button, - ControllerButtonName(event.cbutton.button)); + ControllerButtonName((SDL_GameControllerButton)event.cbutton.button)); break; case SDL_KEYDOWN: if (event.key.keysym.sym != SDLK_ESCAPE) { @@ -167,7 +167,7 @@ WatchGameController(SDL_GameController * gamecontroller) /* Update visual controller state */ SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE); for (i = 0; i (SCREEN_WIDTH - 16)) { x = SCREEN_WIDTH - 16; } - y = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 1)) + 32768); + y = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 1))) + 32768); y *= SCREEN_HEIGHT; y /= 65535; if (y < 0) { @@ -217,9 +217,12 @@ main(int argc, char *argv[]) char guid[64]; SDL_GameController *gamecontroller; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL (Note: video is required to start event loop) */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; } @@ -238,22 +241,22 @@ main(int argc, char *argv[]) } else { name = SDL_JoystickNameForIndex(i); } - printf("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid); + SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid); } - printf("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks()); + SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks()); if (argv[1]) { int device = atoi(argv[1]); if (device >= SDL_NumJoysticks()) { - printf("%i is an invalid joystick index.\n", device); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%i is an invalid joystick index.\n", device); retcode = 1; } else { SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device), guid, sizeof (guid)); - printf("Attempting to open device %i, guid %s\n", device, guid); + SDL_Log("Attempting to open device %i, guid %s\n", device, guid); gamecontroller = SDL_GameControllerOpen(device); if (gamecontroller == NULL) { - printf("Couldn't open joystick %d: %s\n", device, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open joystick %d: %s\n", device, SDL_GetError()); retcode = 1; } else { WatchGameController(gamecontroller); @@ -272,7 +275,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Joystick support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); exit(1); } diff --git a/test/testgesture.c b/test/testgesture.c index e2a9694ae..7d4fe78cc 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -207,6 +207,9 @@ int main(int argc, char* argv[]) SDL_bool quitting = SDL_FALSE; SDL_RWops *src; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + //gesture variables knob.r = .1f; knob.ang = 0; diff --git a/test/testgl2.c b/test/testgl2.c index eb1a245e3..571a69d9a 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -181,6 +181,9 @@ main(int argc, char *argv[]) Uint32 then, now, frames; int status; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ fsaa = 0; accel = -1; @@ -206,7 +209,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, "Usage: %s %s [--fsaa n] [--accel n]\n", argv[0], + SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -235,7 +238,7 @@ main(int argc, char *argv[]) /* Create OpenGL context */ context = SDL_GL_CreateContext(state->windows[0]); if (!context) { - fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } @@ -249,63 +252,63 @@ main(int argc, char *argv[]) } SDL_GetCurrentDisplayMode(0, &mode); - printf("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format)); - printf("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); - printf("\n"); - printf("Vendor : %s\n", glGetString(GL_VENDOR)); - printf("Renderer : %s\n", glGetString(GL_RENDERER)); - printf("Version : %s\n", glGetString(GL_VERSION)); - printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); - printf("\n"); + SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format)); + SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); + SDL_Log("\n"); + SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); + SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); + SDL_Log("Version : %s\n", glGetString(GL_VERSION)); + SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS)); + SDL_Log("\n"); status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); if (!status) { - printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { - printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { - printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { - printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { - printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { - printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { - printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); + SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); } else { - printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); if (!status) { - printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); + SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { - printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { - printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, + SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } else { - printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } if (accel >= 0) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { - printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, + SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, value); } else { - printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } @@ -343,7 +346,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - printf("%2.2f frames per second\n", + SDL_Log("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } quit(0); @@ -355,7 +358,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - printf("No OpenGL support on this system\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; } diff --git a/test/testgles.c b/test/testgles.c index 41312a8bb..7a790bd9d 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -110,6 +110,9 @@ main(int argc, char *argv[]) Uint32 then, now, frames; int status; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ fsaa = 0; accel = 0; @@ -143,7 +146,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], + SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -169,7 +172,7 @@ main(int argc, char *argv[]) context = SDL_calloc(state->num_windows, sizeof(context)); if (context == NULL) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } @@ -177,7 +180,7 @@ main(int argc, char *argv[]) for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); if (!context[i]) { - fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } } @@ -189,65 +192,65 @@ main(int argc, char *argv[]) } SDL_GetCurrentDisplayMode(0, &mode); - printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); - printf("\n"); - printf("Vendor : %s\n", glGetString(GL_VENDOR)); - printf("Renderer : %s\n", glGetString(GL_RENDERER)); - printf("Version : %s\n", glGetString(GL_VERSION)); - printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); - printf("\n"); + SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); + SDL_Log("\n"); + SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); + SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); + SDL_Log("Version : %s\n", glGetString(GL_VERSION)); + SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS)); + SDL_Log("\n"); status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); if (!status) { - printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { - fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { - printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { - fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { - printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { - fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { - printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); + SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); } else { - fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); if (!status) { - printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); + SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { - fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { - printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, + SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } else { - fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } if (accel) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { - printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); + SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { - fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } @@ -258,7 +261,7 @@ main(int argc, char *argv[]) status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { - printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; @@ -292,7 +295,7 @@ main(int argc, char *argv[]) if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { - printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); break; } /* Change view port to the new window dimensions */ @@ -311,7 +314,7 @@ main(int argc, char *argv[]) for (i = 0; i < state->num_windows; ++i) { status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { - printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; @@ -324,7 +327,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - printf("%2.2f frames per second\n", + SDL_Log("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } quit(0); @@ -336,7 +339,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - printf("No OpenGL ES support on this system\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n"); return 1; } diff --git a/test/testhaptic.c b/test/testhaptic.c index 13dd19d67..c28d0df34 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -26,7 +26,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * includes */ #include -#include /* printf */ #include /* strstr */ #include /* isdigit */ @@ -62,12 +61,15 @@ main(int argc, char **argv) int nefx; unsigned int supported; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + name = NULL; index = -1; if (argc > 1) { name = argv[1]; if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { - printf("USAGE: %s [device]\n" + SDL_Log("USAGE: %s [device]\n" "If device is a two-digit number it'll use it as an index, otherwise\n" "it'll use it as if it were part of the device's name.\n", argv[0]); @@ -84,7 +86,7 @@ main(int argc, char **argv) /* Initialize the force feedbackness */ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC); - printf("%d Haptic devices detected.\n", SDL_NumHaptics()); + SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ if (name == NULL) { @@ -98,7 +100,7 @@ main(int argc, char **argv) } if (i >= SDL_NumHaptics()) { - printf("Unable to find device matching '%s', aborting.\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name); return 1; } @@ -106,14 +108,14 @@ main(int argc, char **argv) haptic = SDL_HapticOpen(i); if (haptic == NULL) { - printf("Unable to create the haptic device: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; } - printf("Device: %s\n", SDL_HapticName(i)); + SDL_Log("Device: %s\n", SDL_HapticName(i)); HapticPrintSupported(haptic); } else { - printf("No Haptic devices found!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n"); return 1; } @@ -125,10 +127,10 @@ main(int argc, char **argv) nefx = 0; supported = SDL_HapticQuery(haptic); - printf("\nUploading effects\n"); + SDL_Log("\nUploading effects\n"); /* First we'll try a SINE effect. */ if (supported & SDL_HAPTIC_SINE) { - printf(" effect %d: Sine Wave\n", nefx); + SDL_Log(" effect %d: Sine Wave\n", nefx); efx[nefx].type = SDL_HAPTIC_SINE; efx[nefx].periodic.period = 1000; efx[nefx].periodic.magnitude = 0x4000; @@ -137,14 +139,14 @@ main(int argc, char **argv) efx[nefx].periodic.fade_length = 1000; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* Now we'll try a SAWTOOTHUP */ if (supported & SDL_HAPTIC_SAWTOOTHUP) { - printf(" effect %d: Sawtooth Up\n", nefx); + SDL_Log(" effect %d: Sawtooth Up\n", nefx); efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP; efx[nefx].periodic.period = 500; efx[nefx].periodic.magnitude = 0x5000; @@ -153,14 +155,14 @@ main(int argc, char **argv) efx[nefx].periodic.fade_length = 1000; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* Now the classical constant effect. */ if (supported & SDL_HAPTIC_CONSTANT) { - printf(" effect %d: Constant Force\n", nefx); + SDL_Log(" effect %d: Constant Force\n", nefx); efx[nefx].type = SDL_HAPTIC_CONSTANT; efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR; efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */ @@ -170,14 +172,14 @@ main(int argc, char **argv) efx[nefx].constant.fade_length = 1000; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* The cute spring effect. */ if (supported & SDL_HAPTIC_SPRING) { - printf(" effect %d: Condition Spring\n", nefx); + SDL_Log(" effect %d: Condition Spring\n", nefx); efx[nefx].type = SDL_HAPTIC_SPRING; efx[nefx].condition.length = 5000; for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { @@ -189,14 +191,14 @@ main(int argc, char **argv) } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* The pretty awesome inertia effect. */ if (supported & SDL_HAPTIC_INERTIA) { - printf(" effect %d: Condition Inertia\n", nefx); + SDL_Log(" effect %d: Condition Inertia\n", nefx); efx[nefx].type = SDL_HAPTIC_SPRING; efx[nefx].condition.length = 5000; for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { @@ -207,7 +209,7 @@ main(int argc, char **argv) } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; @@ -215,24 +217,24 @@ main(int argc, char **argv) /* Finally we'll try a left/right effect. */ if (supported & SDL_HAPTIC_LEFTRIGHT) { - printf(" effect %d: Left/Right\n", nefx); + SDL_Log(" effect %d: Left/Right\n", nefx); efx[nefx].type = SDL_HAPTIC_LEFTRIGHT; efx[nefx].leftright.length = 5000; efx[nefx].leftright.large_magnitude = 0x3000; efx[nefx].leftright.small_magnitude = 0xFFFF; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } - printf + SDL_Log ("\nNow playing effects for 5 seconds each with 1 second delay between\n"); for (i = 0; i < nefx; i++) { - printf(" Playing effect %d\n", i); + SDL_Log(" Playing effect %d\n", i); SDL_HapticRunEffect(haptic, id[i], 1); SDL_Delay(6000); /* Effects only have length 5000 */ } @@ -252,7 +254,7 @@ main(int argc, char **argv) static void abort_execution(void) { - printf("\nAborting program execution.\n"); + SDL_Log("\nAborting program execution.\n"); SDL_HapticClose(haptic); SDL_Quit(); @@ -270,42 +272,42 @@ HapticPrintSupported(SDL_Haptic * haptic) unsigned int supported; supported = SDL_HapticQuery(haptic); - printf(" Supported effects [%d effects, %d playing]:\n", + SDL_Log(" Supported effects [%d effects, %d playing]:\n", SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic)); if (supported & SDL_HAPTIC_CONSTANT) - printf(" constant\n"); + SDL_Log(" constant\n"); if (supported & SDL_HAPTIC_SINE) - printf(" sine\n"); + SDL_Log(" sine\n"); /* !!! FIXME: put this back when we have more bits in 2.1 */ /*if (supported & SDL_HAPTIC_SQUARE) - printf(" square\n");*/ + SDL_Log(" square\n");*/ if (supported & SDL_HAPTIC_TRIANGLE) - printf(" triangle\n"); + SDL_Log(" triangle\n"); if (supported & SDL_HAPTIC_SAWTOOTHUP) - printf(" sawtoothup\n"); + SDL_Log(" sawtoothup\n"); if (supported & SDL_HAPTIC_SAWTOOTHDOWN) - printf(" sawtoothdown\n"); + SDL_Log(" sawtoothdown\n"); if (supported & SDL_HAPTIC_RAMP) - printf(" ramp\n"); + SDL_Log(" ramp\n"); if (supported & SDL_HAPTIC_FRICTION) - printf(" friction\n"); + SDL_Log(" friction\n"); if (supported & SDL_HAPTIC_SPRING) - printf(" spring\n"); + SDL_Log(" spring\n"); if (supported & SDL_HAPTIC_DAMPER) - printf(" damper\n"); + SDL_Log(" damper\n"); if (supported & SDL_HAPTIC_INERTIA) - printf(" intertia\n"); + SDL_Log(" inertia\n"); if (supported & SDL_HAPTIC_CUSTOM) - printf(" custom\n"); + SDL_Log(" custom\n"); if (supported & SDL_HAPTIC_LEFTRIGHT) - printf(" left/right\n"); - printf(" Supported capabilities:\n"); + SDL_Log(" left/right\n"); + SDL_Log(" Supported capabilities:\n"); if (supported & SDL_HAPTIC_GAIN) - printf(" gain\n"); + SDL_Log(" gain\n"); if (supported & SDL_HAPTIC_AUTOCENTER) - printf(" autocenter\n"); + SDL_Log(" autocenter\n"); if (supported & SDL_HAPTIC_STATUS) - printf(" status\n"); + SDL_Log(" status\n"); } #else @@ -313,7 +315,7 @@ HapticPrintSupported(SDL_Haptic * haptic) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Haptic support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n"); exit(1); } diff --git a/test/testiconv.c b/test/testiconv.c index d2081995d..435e2392f 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -49,12 +49,15 @@ main(int argc, char *argv[]) FILE *file; int errors = 0; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (!argv[1]) { argv[1] = "utf8.txt"; } file = fopen(argv[1], "rb"); if (!file) { - fprintf(stderr, "Unable to open %s\n", argv[1]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]); return (1); } @@ -69,7 +72,7 @@ main(int argc, char *argv[]) test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len); test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len); if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) { - fprintf(stderr, "FAIL: %s\n", formats[i]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]); ++errors; } if (test[0]) { diff --git a/test/testime.c b/test/testime.c index ce9f02b1f..44f1b1903 100644 --- a/test/testime.c +++ b/test/testime.c @@ -80,7 +80,7 @@ char *utf8_advance(char *p, size_t distance) void usage() { - printf("usage: testime [--font fontfile]\n"); + SDL_Log("usage: testime [--font fontfile]\n"); exit(0); } @@ -210,6 +210,9 @@ int main(int argc, char *argv[]) { SDL_Event event; const char *fontname = DEFAULT_FONT; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -251,12 +254,12 @@ int main(int argc, char *argv[]) { font = TTF_OpenFont(fontname, DEFAULT_PTSIZE); if (! font) { - fprintf(stderr, "Failed to find font: %s\n", TTF_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError()); exit(-1); } #endif - printf("Using font: %s\n", fontname); + SDL_Log("Using font: %s\n", fontname); atexit(SDL_Quit); InitInput(); @@ -321,8 +324,7 @@ int main(int argc, char *argv[]) { break; } - fprintf(stderr, - "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n", + SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n", event.key.keysym.scancode, SDL_GetScancodeName(event.key.keysym.scancode), event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym)); @@ -333,12 +335,12 @@ int main(int argc, char *argv[]) { markedRect.w < 0) break; - fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text); + SDL_Log("Keyboard: text input \"%s\"\n", event.text.text); if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) SDL_strlcat(text, event.text.text, sizeof(text)); - fprintf(stderr, "text inputed: %s\n", text); + SDL_Log("text inputed: %s\n", text); // After text inputed, we can clear up markedText because it // is committed @@ -347,7 +349,7 @@ int main(int argc, char *argv[]) { break; case SDL_TEXTEDITING: - fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n", + SDL_Log("text editing \"%s\", selected range (%d, %d)\n", event.edit.text, event.edit.start, event.edit.length); strcpy(markedText, event.edit.text); diff --git a/test/testintersections.c b/test/testintersections.c index d858717e5..237bd3511 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -84,7 +84,7 @@ add_line(int x1, int y1, int x2, int y2) if ((x1 == x2) && (y1 == y2)) return 0; - printf("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2); + SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2); lines[num_lines].x = x1; lines[num_lines].y = y1; lines[num_lines].w = x2; @@ -133,7 +133,7 @@ add_rect(int x1, int y1, int x2, int y2) if (y1 > y2) SWAP(int, y1, y2); - printf("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2, + SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2, x2 - x1, y2 - y1); rects[num_rects].x = x1; @@ -199,6 +199,9 @@ main(int argc, char *argv[]) SDL_Event event; Uint32 then, now, frames; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ num_objects = NUM_OBJECTS; @@ -241,8 +244,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", + SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", argv[0], SDLTest_CommonUsage(state)); return 1; } @@ -327,7 +329,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } return 0; } diff --git a/test/testjoystick.c b/test/testjoystick.c index da307ed29..7d3c573df 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -52,13 +52,13 @@ WatchJoystick(SDL_Joystick * joystick) SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { - fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } screen = SDL_CreateRenderer(window, -1, 0); if (screen == NULL) { - fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return SDL_FALSE; } @@ -70,9 +70,9 @@ WatchJoystick(SDL_Joystick * joystick) /* Print info about the joystick we are watching */ name = SDL_JoystickName(joystick); - printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), + SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), name ? name : "Unknown Joystick"); - printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", + SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); @@ -85,36 +85,36 @@ WatchJoystick(SDL_Joystick * joystick) while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_JOYAXISMOTION: - printf("Joystick %d axis %d value: %d\n", + SDL_Log("Joystick %d axis %d value: %d\n", event.jaxis.which, event.jaxis.axis, event.jaxis.value); break; case SDL_JOYHATMOTION: - printf("Joystick %d hat %d value:", + SDL_Log("Joystick %d hat %d value:", event.jhat.which, event.jhat.hat); if (event.jhat.value == SDL_HAT_CENTERED) - printf(" centered"); + SDL_Log(" centered"); if (event.jhat.value & SDL_HAT_UP) - printf(" up"); + SDL_Log(" up"); if (event.jhat.value & SDL_HAT_RIGHT) - printf(" right"); + SDL_Log(" right"); if (event.jhat.value & SDL_HAT_DOWN) - printf(" down"); + SDL_Log(" down"); if (event.jhat.value & SDL_HAT_LEFT) - printf(" left"); - printf("\n"); + SDL_Log(" left"); + SDL_Log("\n"); break; case SDL_JOYBALLMOTION: - printf("Joystick %d ball %d delta: (%d,%d)\n", + SDL_Log("Joystick %d ball %d delta: (%d,%d)\n", event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel); break; case SDL_JOYBUTTONDOWN: - printf("Joystick %d button %d down\n", + SDL_Log("Joystick %d button %d down\n", event.jbutton.which, event.jbutton.button); break; case SDL_JOYBUTTONUP: - printf("Joystick %d button %d up\n", + SDL_Log("Joystick %d button %d up\n", event.jbutton.which, event.jbutton.button); break; case SDL_KEYDOWN: @@ -211,31 +211,34 @@ main(int argc, char *argv[]) int i; SDL_Joystick *joystick; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL (Note: video is required to start event loop) */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Print information about the joysticks */ - printf("There are %d joysticks attached\n", SDL_NumJoysticks()); + SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks()); for (i = 0; i < SDL_NumJoysticks(); ++i) { name = SDL_JoystickNameForIndex(i); - printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); + SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); joystick = SDL_JoystickOpen(i); if (joystick == NULL) { - fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError()); } else { char guid[64]; SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), guid, sizeof (guid)); - printf(" axes: %d\n", SDL_JoystickNumAxes(joystick)); - printf(" balls: %d\n", SDL_JoystickNumBalls(joystick)); - printf(" hats: %d\n", SDL_JoystickNumHats(joystick)); - printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick)); - printf("instance id: %d\n", SDL_JoystickInstanceID(joystick)); - printf(" guid: %s\n", guid); + SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick)); + SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick)); + SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick)); + SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick)); + SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick)); + SDL_Log(" guid: %s\n", guid); SDL_JoystickClose(joystick); } } @@ -256,7 +259,7 @@ main(int argc, char *argv[]) while ( keepGoing ) { if (joystick == NULL) { if ( !reportederror ) { - printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError()); + SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError()); keepGoing = SDL_FALSE; reportederror = SDL_TRUE; } @@ -268,7 +271,7 @@ main(int argc, char *argv[]) joystick = NULL; if (keepGoing) { - printf("Waiting for attach\n"); + SDL_Log("Waiting for attach\n"); } while (keepGoing) { SDL_WaitEvent(&event); @@ -296,7 +299,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Joystick support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); exit(1); } diff --git a/test/testkeys.c b/test/testkeys.c index 71f895602..f4a35aba6 100644 --- a/test/testkeys.c +++ b/test/testkeys.c @@ -24,12 +24,15 @@ main(int argc, char *argv[]) { SDL_Scancode scancode; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { - printf("Scancode #%d, \"%s\"\n", scancode, + SDL_Log("Scancode #%d, \"%s\"\n", scancode, SDL_GetScancodeName(scancode)); } SDL_Quit(); diff --git a/test/testloadso.c b/test/testloadso.c index 4bf7bf654..946aafd20 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -33,14 +33,14 @@ main(int argc, char *argv[]) if (argc != 3) { const char *app = argv[0]; - fprintf(stderr, "USAGE: %s \n", app); - fprintf(stderr, " %s --hello \n", app); + SDL_Log("USAGE: %s \n", app); + SDL_Log(" %s --hello \n", app); return 1; } /* Initialize SDL */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 2; } @@ -55,23 +55,23 @@ main(int argc, char *argv[]) lib = SDL_LoadObject(libname); if (lib == NULL) { - fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", libname, SDL_GetError()); retval = 3; } else { fn = (fntype) SDL_LoadFunction(lib, symname); if (fn == NULL) { - fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", symname, SDL_GetError()); retval = 4; } else { - printf("Found %s in %s at %p\n", symname, libname, fn); + SDL_Log("Found %s in %s at %p\n", symname, libname, fn); if (hello) { - printf("Calling function...\n"); + SDL_Log("Calling function...\n"); fflush(stdout); fn(" HELLO, WORLD!\n"); - printf("...apparently, we survived. :)\n"); - printf("Unloading library...\n"); + SDL_Log("...apparently, we survived. :)\n"); + SDL_Log("Unloading library...\n"); fflush(stdout); } } diff --git a/test/testlock.c b/test/testlock.c index fcfeb8bc8..0414fe316 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -40,7 +40,7 @@ SDL_Quit_Wrapper(void) void printid(void) { - printf("Process %lu: exiting\n", SDL_ThreadID()); + SDL_Log("Process %lu: exiting\n", SDL_ThreadID()); } void @@ -55,7 +55,7 @@ closemutex(int sig) { SDL_threadID id = SDL_ThreadID(); int i; - printf("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id); + SDL_Log("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id); doterminate = 1; for (i = 0; i < 6; ++i) SDL_WaitThread(threads[i], NULL); @@ -69,23 +69,23 @@ Run(void *data) if (SDL_ThreadID() == mainthread) signal(SIGTERM, closemutex); while (!doterminate) { - printf("Process %lu ready to work\n", SDL_ThreadID()); + SDL_Log("Process %lu ready to work\n", SDL_ThreadID()); if (SDL_LockMutex(mutex) < 0) { - fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError()); exit(1); } - printf("Process %lu, working!\n", SDL_ThreadID()); + SDL_Log("Process %lu, working!\n", SDL_ThreadID()); SDL_Delay(1 * 1000); - printf("Process %lu, done!\n", SDL_ThreadID()); + SDL_Log("Process %lu, done!\n", SDL_ThreadID()); if (SDL_UnlockMutex(mutex) < 0) { - fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError()); exit(1); } /* If this sleep isn't done, then threads may starve */ SDL_Delay(10); } if (SDL_ThreadID() == mainthread && doterminate) { - printf("Process %lu: raising SIGTERM\n", SDL_ThreadID()); + SDL_Log("Process %lu: raising SIGTERM\n", SDL_ThreadID()); raise(SIGTERM); } return (0); @@ -97,26 +97,29 @@ main(int argc, char *argv[]) int i; int maxproc = 6; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "%s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit_Wrapper); if ((mutex = SDL_CreateMutex()) == NULL) { - fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError()); exit(1); } mainthread = SDL_ThreadID(); - printf("Main thread: %lu\n", mainthread); + SDL_Log("Main thread: %lu\n", mainthread); atexit(printid); for (i = 0; i < maxproc; ++i) { char name[64]; SDL_snprintf(name, sizeof (name), "Worker%d", i); if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL) - fprintf(stderr, "Couldn't create thread!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n"); } signal(SIGINT, terminate); Run(NULL); diff --git a/test/testmessage.c b/test/testmessage.c index f76b7ebac..330462362 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -62,7 +62,7 @@ button_messagebox(void *eventNumber) success = SDL_ShowMessageBox(&data, &button); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); if (eventNumber) { SDL_UserEvent event; event.type = (intptr_t)eventNumber; @@ -72,7 +72,7 @@ button_messagebox(void *eventNumber) quit(2); } } - printf("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK"); + SDL_Log("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK"); if (eventNumber) { SDL_UserEvent event; @@ -88,12 +88,15 @@ main(int argc, char *argv[]) { int success; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Simple MessageBox", "This is a simple error MessageBox", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -102,7 +105,7 @@ main(int argc, char *argv[]) "This is a simple MessageBox with a newline:\r\nHello world!", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -112,7 +115,7 @@ main(int argc, char *argv[]) "Unicode text: '牛肉西蘭花' ...", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -122,7 +125,7 @@ main(int argc, char *argv[]) "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -135,7 +138,7 @@ main(int argc, char *argv[]) subsystem on the main thread. */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError()); return (1); } { @@ -153,7 +156,7 @@ main(int argc, char *argv[]) SDL_WaitThread(thread, &status); - printf("Message box thread return %i\n", status); + SDL_Log("Message box thread return %i\n", status); } /* Test showing a message box with a parent window */ @@ -166,7 +169,7 @@ main(int argc, char *argv[]) "This is a simple error MessageBox with a parent window", window); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index 47a95e344..48d628ae3 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -10,7 +10,6 @@ freely. */ #include "SDL.h" -#include static SDL_AudioSpec spec; static Uint8 *sound = NULL; /* Pointer to wave data */ @@ -51,7 +50,7 @@ test_multi_audio(int devcount) int i; if (devcount > 64) { - fprintf(stderr, "Too many devices (%d), clamping to 64...\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n", devcount); devcount = 64; } @@ -60,33 +59,33 @@ test_multi_audio(int devcount) for (i = 0; i < devcount; i++) { const char *devname = SDL_GetAudioDeviceName(i, 0); - printf("playing on device #%d: ('%s')...", i, devname); + SDL_Log("playing on device #%d: ('%s')...", i, devname); fflush(stdout); SDL_memset(&cbd[0], '\0', sizeof(callback_data)); spec.userdata = &cbd[0]; cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0); if (cbd[0].dev == 0) { - printf("\nOpen device failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError()); } else { SDL_PauseAudioDevice(cbd[0].dev, 0); while (!cbd[0].done) SDL_Delay(100); SDL_PauseAudioDevice(cbd[0].dev, 1); - printf("done.\n"); + SDL_Log("done.\n"); SDL_CloseAudioDevice(cbd[0].dev); } } SDL_memset(cbd, '\0', sizeof(cbd)); - printf("playing on all devices...\n"); + SDL_Log("playing on all devices...\n"); for (i = 0; i < devcount; i++) { const char *devname = SDL_GetAudioDeviceName(i, 0); spec.userdata = &cbd[i]; cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0); if (cbd[i].dev == 0) { - printf("Open device %d failed: %s\n", i, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError()); } } @@ -113,7 +112,7 @@ test_multi_audio(int devcount) } } - printf("All done!\n"); + SDL_Log("All done!\n"); } @@ -122,17 +121,20 @@ main(int argc, char **argv) { int devcount = 0; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } - printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); + SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); devcount = SDL_GetNumAudioDevices(0); if (devcount < 1) { - fprintf(stderr, "Don't see any specific audio devices!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n"); } else { if (argv[1] == NULL) { argv[1] = "sample.wav"; @@ -140,7 +142,7 @@ main(int argc, char **argv) /* Load the wave file into memory */ if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) { - fprintf(stderr, "Couldn't load %s: %s\n", argv[1], + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); } else { test_multi_audio(devcount); diff --git a/test/testnative.c b/test/testnative.c index 63cba29c3..0ac99b2a3 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -58,7 +58,7 @@ LoadSprite(SDL_Renderer *renderer, char *file) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return 0; } @@ -70,7 +70,7 @@ LoadSprite(SDL_Renderer *renderer, char *file) /* Create textures from the image */ sprite = SDL_CreateTextureFromSurface(renderer, temp); if (!sprite) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return 0; } @@ -131,8 +131,11 @@ main(int argc, char *argv[]) int sprite_w, sprite_h; SDL_Event event; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_VideoInit(NULL) < 0) { - fprintf(stderr, "Couldn't initialize SDL video: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n", SDL_GetError()); exit(1); } @@ -146,19 +149,19 @@ main(int argc, char *argv[]) } } if (!factory) { - fprintf(stderr, "Couldn't find native window code for %s driver\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n", driver); quit(2); } - printf("Creating native window for %s driver\n", driver); + SDL_Log("Creating native window for %s driver\n", driver); native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H); if (!native_window) { - fprintf(stderr, "Couldn't create native window\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n"); quit(3); } window = SDL_CreateWindowFrom(native_window); if (!window) { - fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError()); quit(4); } SDL_SetWindowTitle(window, "SDL Native Window Test"); @@ -166,7 +169,7 @@ main(int argc, char *argv[]) /* Create the renderer */ renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { - fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(5); } @@ -185,7 +188,7 @@ main(int argc, char *argv[]) positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); if (!positions || !velocities) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } srand(time(NULL)); diff --git a/test/testoverlay2.c b/test/testoverlay2.c index e071614ad..23e1e1f17 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -209,19 +209,18 @@ ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h, static void PrintUsage(char *argv0) { - fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); - fprintf(stderr, "\n"); - fprintf(stderr, "Where 'arg' is any of the following options:\n"); - fprintf(stderr, "\n"); - fprintf(stderr, " -fps \n"); - fprintf(stderr, " -nodelay\n"); - fprintf(stderr, " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); - fprintf(stderr, " -scale (initial scale of the overlay)\n"); - fprintf(stderr, " -help (shows this help)\n"); - fprintf(stderr, "\n"); - fprintf(stderr, - "Press ESC to exit, or SPACE to freeze the movie while application running.\n"); - fprintf(stderr, "\n"); + SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0); + SDL_Log("\n"); + SDL_Log("Where 'arg' is any of the following options:\n"); + SDL_Log("\n"); + SDL_Log(" -fps \n"); + SDL_Log(" -nodelay\n"); + SDL_Log(" -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); + SDL_Log(" -scale (initial scale of the overlay)\n"); + SDL_Log(" -help (shows this help)\n"); + SDL_Log("\n"); + SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n"); + SDL_Log("\n"); } int @@ -246,8 +245,11 @@ main(int argc, char **argv) int scale = 5; SDL_bool done = SDL_FALSE; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 3; } @@ -256,19 +258,19 @@ main(int argc, char **argv) if (argv[2]) { fps = atoi(argv[2]); if (fps == 0) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } if ((fps < 0) || (fps > 1000)) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option must be in range from 1 to 1000, default is 12.\n"); quit(10); } argv += 2; argc -= 2; } else { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } @@ -280,19 +282,19 @@ main(int argc, char **argv) if (argv[2]) { scale = atoi(argv[2]); if (scale == 0) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -scale option requires an argument [from 1 to 50], default is 5.\n"); quit(10); } if ((scale < 0) || (scale > 50)) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -scale option must be in range from 1 to 50, default is 5.\n"); quit(10); } argv += 2; argc -= 2; } else { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } @@ -301,7 +303,7 @@ main(int argc, char **argv) PrintUsage(argv[0]); quit(0); } else { - fprintf(stderr, "Unrecognized option: %s.\n", argv[1]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]); quit(10); } break; @@ -309,7 +311,7 @@ main(int argc, char **argv) RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); if (RawMooseData == NULL) { - fprintf(stderr, "Can't allocate memory for movie !\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n"); free(RawMooseData); quit(1); } @@ -317,7 +319,7 @@ main(int argc, char **argv) /* load the trojan moose images */ handle = SDL_RWFromFile("moose.dat", "rb"); if (handle == NULL) { - fprintf(stderr, "Can't find the file moose.dat !\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); free(RawMooseData); quit(2); } @@ -335,21 +337,21 @@ main(int argc, char **argv) window_w, window_h, SDL_WINDOW_RESIZABLE); if (!window) { - fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); free(RawMooseData); quit(4); } renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { - fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); free(RawMooseData); quit(4); } MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); if (!MooseTexture) { - fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); free(RawMooseData); quit(5); } diff --git a/test/testplatform.c b/test/testplatform.c index 326b6f7e4..2f32e1f4e 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -35,30 +35,30 @@ TestTypes(SDL_bool verbose) if (badsize(sizeof(Uint8), 1)) { if (verbose) - printf("sizeof(Uint8) != 1, instead = %u\n", + SDL_Log("sizeof(Uint8) != 1, instead = %u\n", (unsigned int)sizeof(Uint8)); ++error; } if (badsize(sizeof(Uint16), 2)) { if (verbose) - printf("sizeof(Uint16) != 2, instead = %u\n", + SDL_Log("sizeof(Uint16) != 2, instead = %u\n", (unsigned int)sizeof(Uint16)); ++error; } if (badsize(sizeof(Uint32), 4)) { if (verbose) - printf("sizeof(Uint32) != 4, instead = %u\n", + SDL_Log("sizeof(Uint32) != 4, instead = %u\n", (unsigned int)sizeof(Uint32)); ++error; } if (badsize(sizeof(Uint64), 8)) { if (verbose) - printf("sizeof(Uint64) != 8, instead = %u\n", + SDL_Log("sizeof(Uint64) != 8, instead = %u\n", (unsigned int)sizeof(Uint64)); ++error; } if (verbose && !error) - printf("All data types are the expected size.\n"); + SDL_Log("All data types are the expected size.\n"); return (error ? 1 : 0); } @@ -83,7 +83,7 @@ TestEndian(SDL_bool verbose) swapped64 |= 0xDEADBEEF; if (verbose) { - printf("Detected a %s endian machine.\n", + SDL_Log("Detected a %s endian machine.\n", (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); } if ((*((char *) &value) >> 4) == 0x1) { @@ -93,44 +93,44 @@ TestEndian(SDL_bool verbose) } if (real_byteorder != SDL_BYTEORDER) { if (verbose) { - printf("Actually a %s endian machine!\n", + SDL_Log("Actually a %s endian machine!\n", (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); } ++error; } if (verbose) { - printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, + SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16)); } if (SDL_Swap16(value16) != swapped16) { if (verbose) { - printf("16 bit value swapped incorrectly!\n"); + SDL_Log("16 bit value swapped incorrectly!\n"); } ++error; } if (verbose) { - printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, + SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32)); } if (SDL_Swap32(value32) != swapped32) { if (verbose) { - printf("32 bit value swapped incorrectly!\n"); + SDL_Log("32 bit value swapped incorrectly!\n"); } ++error; } if (verbose) { #ifdef _MSC_VER - printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, + SDL_Log("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, SDL_Swap64(value64)); #else - printf("Value 64 = 0x%llX, swapped = 0x%llX\n", + SDL_Log("Value 64 = 0x%llX, swapped = 0x%llX\n", (unsigned long long) value64, (unsigned long long) SDL_Swap64(value64)); #endif } if (SDL_Swap64(value64) != swapped64) { if (verbose) { - printf("64 bit value swapped incorrectly!\n"); + SDL_Log("64 bit value swapped incorrectly!\n"); } ++error; } @@ -142,17 +142,17 @@ int TestCPUInfo(SDL_bool verbose) { if (verbose) { - printf("CPU count: %d\n", SDL_GetCPUCount()); - printf("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize()); - printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); - printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); - printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); - printf("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected"); - printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); - printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); - printf("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); - printf("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); - printf("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); + SDL_Log("CPU count: %d\n", SDL_GetCPUCount()); + SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize()); + SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); + SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); + SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); + SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected"); + SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); + SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); + SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); + SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); + SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); } return (0); } @@ -176,7 +176,7 @@ TestAssertions(SDL_bool verbose) { const SDL_assert_data *item = SDL_GetAssertionReport(); while (item) { - printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", + SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", item->condition, item->function, item->filename, item->linenum, item->trigger_count, item->always_ignore ? "yes" : "no"); @@ -192,11 +192,14 @@ main(int argc, char *argv[]) SDL_bool verbose = SDL_TRUE; int status = 0; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) { verbose = SDL_FALSE; } if (verbose) { - printf("This system is running %s\n", SDL_GetPlatform()); + SDL_Log("This system is running %s\n", SDL_GetPlatform()); } status += TestTypes(verbose); diff --git a/test/testpower.c b/test/testpower.c index 3e13d0ac1..1b3214393 100644 --- a/test/testpower.c +++ b/test/testpower.c @@ -21,7 +21,7 @@ report_power(void) const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent); char *statestr = NULL; - printf("SDL-reported power info...\n"); + SDL_Log("SDL-reported power info...\n"); switch (state) { case SDL_POWERSTATE_UNKNOWN: statestr = "Unknown"; @@ -43,18 +43,18 @@ report_power(void) break; } - printf("State: %s\n", statestr); + SDL_Log("State: %s\n", statestr); if (percent == -1) { - printf("Percent left: unknown\n"); + SDL_Log("Percent left: unknown\n"); } else { - printf("Percent left: %d%%\n", percent); + SDL_Log("Percent left: %d%%\n", percent); } if (seconds == -1) { - printf("Time left: unknown\n"); + SDL_Log("Time left: unknown\n"); } else { - printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), + SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), (int) (seconds % 60)); } } @@ -63,8 +63,11 @@ report_power(void) int main(int argc, char *argv[]) { + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(0) == -1) { - fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); return 1; } diff --git a/test/testrelative.c b/test/testrelative.c index fa5bda660..478d3bf77 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -35,6 +35,8 @@ main(int argc, char *argv[]) int i, done; SDL_Event event; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); @@ -74,10 +76,8 @@ main(int argc, char *argv[]) switch(event.type) { case SDL_MOUSEMOTION: { - /*printf("mouse motion ABS x %d y %d REL x %d y %d\n",event.motion.x,event.motion.y,event.motion.xrel,event.motion.yrel);*/ rect.x += event.motion.xrel; rect.y += event.motion.yrel; - } break; } diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 6dd59c0ac..a0221fe0f 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -46,7 +46,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return NULL; } @@ -77,7 +77,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Create textures from the image */ texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return NULL; } @@ -139,6 +139,9 @@ main(int argc, char *argv[]) int frames; Uint32 then, now; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -149,7 +152,7 @@ main(int argc, char *argv[]) consumed = SDLTest_CommonArg(state, i); if (consumed == 0) { - fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); return 1; } i += consumed; @@ -193,7 +196,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } SDL_stack_free(drawstates); diff --git a/test/testrendertarget.c b/test/testrendertarget.c index bc3104825..03e8df19e 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -46,7 +46,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return NULL; } @@ -77,7 +77,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Create textures from the image */ texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return NULL; } @@ -114,7 +114,7 @@ DrawComposite(DrawState *s) SDL_RenderCopy(s->renderer, A, NULL, NULL); SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P)); - printf("Blended pixel: 0x%8.8X\n", P); + SDL_Log("Blended pixel: 0x%8.8X\n", P); SDL_DestroyTexture(A); SDL_DestroyTexture(B); @@ -218,6 +218,9 @@ main(int argc, char *argv[]) Uint32 then, now; SDL_bool test_composite = SDL_FALSE; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -235,8 +238,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--composite]\n", + SDL_Log("Usage: %s %s [--composite]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -289,7 +291,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } SDL_stack_free(drawstates); diff --git a/test/testresample.c b/test/testresample.c index d79f1ac8a..177bd8413 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -9,7 +9,7 @@ including commercial applications, and to alter it and redistribute it freely. */ -#include + #include "SDL.h" int @@ -25,27 +25,30 @@ main(int argc, char **argv) int avgbytes = 0; SDL_RWops *io = NULL; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (argc != 4) { - fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]); + SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]); return 1; } cvtfreq = SDL_atoi(argv[3]); if (SDL_Init(SDL_INIT_AUDIO) == -1) { - fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); return 2; } if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) { - fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError()); SDL_Quit(); return 3; } if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq, spec.format, spec.channels, cvtfreq) == -1) { - fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError()); SDL_FreeWAV(data); SDL_Quit(); return 4; @@ -54,7 +57,7 @@ main(int argc, char **argv) cvt.len = len; cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult); if (cvt.buf == NULL) { - fprintf(stderr, "Out of memory.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n"); SDL_FreeWAV(data); SDL_Quit(); return 5; @@ -62,7 +65,7 @@ main(int argc, char **argv) SDL_memcpy(cvt.buf, data, len); if (SDL_ConvertAudio(&cvt) == -1) { - fprintf(stderr, "Conversion failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); @@ -72,7 +75,7 @@ main(int argc, char **argv) /* write out a WAV header... */ io = SDL_RWFromFile(argv[2], "wb"); if (io == NULL) { - fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); @@ -99,7 +102,7 @@ main(int argc, char **argv) SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1); if (SDL_RWclose(io) == -1) { - fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); diff --git a/test/testrumble.c b/test/testrumble.c index e5b5424d4..ffcaae4a8 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -26,7 +26,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * includes */ #include -#include /* printf */ #include /* strstr */ #include /* isdigit */ @@ -51,12 +50,15 @@ main(int argc, char **argv) char *name; int index; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + name = NULL; index = -1; if (argc > 1) { name = argv[1]; if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { - printf("USAGE: %s [device]\n" + SDL_Log("USAGE: %s [device]\n" "If device is a two-digit number it'll use it as an index, otherwise\n" "it'll use it as if it were part of the device's name.\n", argv[0]); @@ -73,7 +75,7 @@ main(int argc, char **argv) /* Initialize the force feedbackness */ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC); - printf("%d Haptic devices detected.\n", SDL_NumHaptics()); + SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ if (name == NULL) { @@ -87,7 +89,7 @@ main(int argc, char **argv) } if (i >= SDL_NumHaptics()) { - printf("Unable to find device matching '%s', aborting.\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name); return 1; } @@ -95,13 +97,13 @@ main(int argc, char **argv) haptic = SDL_HapticOpen(i); if (haptic == NULL) { - printf("Unable to create the haptic device: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; } - printf("Device: %s\n", SDL_HapticName(i)); + SDL_Log("Device: %s\n", SDL_HapticName(i)); } else { - printf("No Haptic devices found!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n"); return 1; } @@ -109,25 +111,25 @@ main(int argc, char **argv) SDL_ClearError(); if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) { - printf("\nRumble not supported!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n"); return 1; } if (SDL_HapticRumbleInit(haptic) != 0) { - printf("\nFailed to initialize rumble: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError()); return 1; } - printf("Playing 2 second rumble at 0.5 magnitude.\n"); + SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n"); if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) { - printf("\nFailed to play rumble: %s\n", SDL_GetError() ); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); return 1; } SDL_Delay(2000); - printf("Stopping rumble.\n"); + SDL_Log("Stopping rumble.\n"); SDL_HapticRumbleStop(haptic); SDL_Delay(2000); - printf("Playing 2 second rumble at 0.3 magnitude.\n"); + SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n"); if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) { - printf("\nFailed to play rumble: %s\n", SDL_GetError() ); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); return 1; } SDL_Delay(2000); @@ -145,7 +147,7 @@ main(int argc, char **argv) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Haptic support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n"); exit(1); } diff --git a/test/testscale.c b/test/testscale.c index 0f0096c6e..f81ccdc24 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -48,7 +48,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return NULL; } @@ -79,7 +79,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Create textures from the image */ texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return NULL; } @@ -129,6 +129,9 @@ main(int argc, char *argv[]) int frames; Uint32 then, now; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -139,7 +142,7 @@ main(int argc, char *argv[]) consumed = SDLTest_CommonArg(state, i); if (consumed == 0) { - fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); return 1; } i += consumed; @@ -183,7 +186,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } SDL_stack_free(drawstates); diff --git a/test/testsem.c b/test/testsem.c index eab280e1d..6a2a59e67 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -30,17 +30,15 @@ ThreadFunc(void *data) int threadnum = (int) (uintptr_t) data; while (alive) { SDL_SemWait(sem); - fprintf(stderr, - "Thread number %d has got the semaphore (value = %d)!\n", + SDL_Log("Thread number %d has got the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem)); SDL_Delay(200); SDL_SemPost(sem); - fprintf(stderr, - "Thread number %d has released the semaphore (value = %d)!\n", + SDL_Log("Thread number %d has released the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem)); SDL_Delay(1); /* For the scheduler */ } - printf("Thread number %d exiting.\n", threadnum); + SDL_Log("Thread number %d exiting.\n", threadnum); return 0; } @@ -59,7 +57,7 @@ TestWaitTimeout(void) int retval; sem = SDL_CreateSemaphore(0); - printf("Waiting 2 seconds on semaphore\n"); + SDL_Log("Waiting 2 seconds on semaphore\n"); start_ticks = SDL_GetTicks(); retval = SDL_SemWaitTimeout(sem, 2000); @@ -69,13 +67,13 @@ TestWaitTimeout(void) /* Accept a little offset in the effective wait */ if (duration > 1900 && duration < 2050) - printf("Wait done.\n"); + SDL_Log("Wait done.\n"); else - fprintf(stderr, "Wait took %d milliseconds\n", duration); + SDL_Log("Wait took %d milliseconds\n", duration); /* Check to make sure the return value indicates timed out */ if (retval != SDL_MUTEX_TIMEDOUT) - fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); } int @@ -85,14 +83,17 @@ main(int argc, char **argv) uintptr_t i; int init_sem; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (argc < 2) { - fprintf(stderr, "Usage: %s init_value\n", argv[0]); + SDL_Log("Usage: %s init_value\n", argv[0]); return (1); } /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } signal(SIGTERM, killed); @@ -101,7 +102,7 @@ main(int argc, char **argv) init_sem = atoi(argv[1]); sem = SDL_CreateSemaphore(init_sem); - printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, + SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS, init_sem); /* Create all the threads */ for (i = 0; i < NUM_THREADS; ++i) { @@ -114,12 +115,12 @@ main(int argc, char **argv) SDL_Delay(10 * 1000); /* Wait for all threads to finish */ - printf("Waiting for threads to finish\n"); + SDL_Log("Waiting for threads to finish\n"); alive = 0; for (i = 0; i < NUM_THREADS; ++i) { SDL_WaitThread(threads[i], NULL); } - printf("Finished waiting for threads\n"); + SDL_Log("Finished waiting for threads\n"); SDL_DestroySemaphore(sem); diff --git a/test/testshader.c b/test/testshader.c index 376b445e7..138dd45f8 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -11,7 +11,6 @@ */ /* This is a simple example of using GLSL shaders with SDL */ -#include /* for printf() */ #include "SDL.h" #ifdef HAVE_OPENGL @@ -139,7 +138,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source) glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); info = SDL_stack_alloc(char, length+1); glGetInfoLogARB(shader, length, NULL, info); - fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info); SDL_stack_free(info); return SDL_FALSE; @@ -245,7 +244,7 @@ static SDL_bool InitShaders() /* Compile all the shaders */ for (i = 0; i < NUM_SHADERS; ++i) { if (!CompileShaderProgram(&shaders[i])) { - fprintf(stderr, "Unable to compile shader!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n"); return SDL_FALSE; } } @@ -422,29 +421,32 @@ int main(int argc, char **argv) GLuint texture; GLfloat texcoords[4]; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL for video output */ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Create a 640x480 OpenGL screen */ window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL ); if ( !window ) { - fprintf(stderr, "Unable to create OpenGL window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } if ( !SDL_GL_CreateContext(window)) { - fprintf(stderr, "Unable to create OpenGL context: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } surface = SDL_LoadBMP("icon.bmp"); if ( ! surface ) { - fprintf(stderr, "Unable to load icon.bmp: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError()); SDL_Quit(); exit(3); } @@ -454,9 +456,9 @@ int main(int argc, char **argv) /* Loop, drawing and checking events */ InitGL(640, 480); if (InitShaders()) { - printf("Shaders supported, press SPACE to cycle them.\n"); + SDL_Log("Shaders supported, press SPACE to cycle them.\n"); } else { - printf("Shaders not supported!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n"); } done = 0; while ( ! done ) { @@ -489,7 +491,7 @@ int main(int argc, char **argv) int main(int argc, char *argv[]) { - printf("No OpenGL support on this system\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; } diff --git a/test/testshape.c b/test/testshape.c index 59dfb9fc2..5c969b30e 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -68,13 +68,16 @@ int main(int argc,char** argv) int access = 0; SDL_Rect texture_dimensions;; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if(argc < 2) { - printf("SDL_Shape requires at least one bitmap file as argument.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument."); exit(-1); } if(SDL_VideoInit(NULL) == -1) { - printf("Could not initialize SDL video.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video."); exit(-2); } @@ -91,7 +94,7 @@ int main(int argc,char** argv) SDL_FreeSurface(pictures[j].surface); SDL_free(pictures); SDL_VideoQuit(); - printf("Could not load surface from named bitmap file.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file."); exit(-3); } @@ -112,7 +115,7 @@ int main(int argc,char** argv) SDL_FreeSurface(pictures[i].surface); SDL_free(pictures); SDL_VideoQuit(); - printf("Could not create shaped window for SDL_Shape.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape."); exit(-4); } renderer = SDL_CreateRenderer(window,-1,0); @@ -122,7 +125,7 @@ int main(int argc,char** argv) SDL_FreeSurface(pictures[i].surface); SDL_free(pictures); SDL_VideoQuit(); - printf("Could not create rendering context for SDL_Shape window.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window."); exit(-5); } @@ -141,7 +144,7 @@ int main(int argc,char** argv) SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_VideoQuit(); - printf("Could not create texture for SDL_shape.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape."); exit(-6); } } diff --git a/test/testsprite2.c b/test/testsprite2.c index f77296960..26cc29f66 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -64,7 +64,7 @@ LoadSprite(const char *file) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return (-1); } sprite_w = temp->w; @@ -95,7 +95,7 @@ LoadSprite(const char *file) SDL_Renderer *renderer = state->renderers[i]; sprites[i] = SDL_CreateTextureFromSurface(renderer, temp); if (!sprites[i]) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return (-1); } @@ -299,8 +299,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n", + SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -314,7 +313,7 @@ main(int argc, char *argv[]) sprites = (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); if (!sprites) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } for (i = 0; i < state->num_windows; ++i) { @@ -330,7 +329,7 @@ main(int argc, char *argv[]) positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); if (!positions || !velocities) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } @@ -375,7 +374,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } quit(0); return 0; diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 6f3ac25c0..157293f30 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -42,7 +42,7 @@ LoadSprite(char *file, SDL_Renderer *renderer) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError()); return (-1); } sprite_w = temp->w; @@ -73,7 +73,7 @@ LoadSprite(char *file, SDL_Renderer *renderer) /* Create textures from the image */ sprite = SDL_CreateTextureFromSurface(renderer, temp); if (!sprite) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return (-1); } @@ -126,6 +126,9 @@ main(int argc, char *argv[]) int i, done; SDL_Event event; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) { quit(2); } diff --git a/test/teststreaming.c b/test/teststreaming.c index ea3ac2d61..1d3f68250 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -68,7 +68,7 @@ void UpdateTexture(SDL_Texture *texture, int frame) int pitch; if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) { - fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError()); quit(5); } src = MooseFrames[frame]; @@ -93,15 +93,18 @@ main(int argc, char **argv) SDL_bool done = SDL_FALSE; int frame; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; } /* load the moose images */ handle = SDL_RWFromFile("moose.dat", "rb"); if (handle == NULL) { - fprintf(stderr, "Can't find the file moose.dat !\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); quit(2); } SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); @@ -115,19 +118,19 @@ main(int argc, char **argv) MOOSEPIC_W*4, MOOSEPIC_H*4, SDL_WINDOW_RESIZABLE); if (!window) { - fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); quit(3); } renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { - fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); if (!MooseTexture) { - fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); quit(5); } diff --git a/test/testthread.c b/test/testthread.c index 949e44e3a..ed9f1f182 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -34,20 +34,20 @@ int SDLCALL ThreadFunc(void *data) { SDL_TLSSet(tls, "baby thread", NULL); - printf("Started thread %s: My thread id is %lu, thread data = %s\n", + SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n", (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls)); while (alive) { - printf("Thread '%s' is alive!\n", (char *) data); + SDL_Log("Thread '%s' is alive!\n", (char *) data); SDL_Delay(1 * 1000); } - printf("Thread '%s' exiting!\n", (char *) data); + SDL_Log("Thread '%s' exiting!\n", (char *) data); return (0); } static void killed(int sig) { - printf("Killed with SIGTERM, waiting 5 seconds to exit\n"); + SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n"); SDL_Delay(5 * 1000); alive = 0; quit(0); @@ -58,35 +58,38 @@ main(int argc, char *argv[]) { SDL_Thread *thread; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } tls = SDL_TLSCreate(); SDL_assert(tls); SDL_TLSSet(tls, "main thread", NULL); - printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls)); + SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls)); alive = 1; thread = SDL_CreateThread(ThreadFunc, "One", "#1"); if (thread == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } SDL_Delay(5 * 1000); - printf("Waiting for thread #1\n"); + SDL_Log("Waiting for thread #1\n"); alive = 0; SDL_WaitThread(thread, NULL); - printf("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls)); + SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls)); alive = 1; signal(SIGTERM, killed); thread = SDL_CreateThread(ThreadFunc, "Two", "#2"); if (thread == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } raise(SIGTERM); diff --git a/test/testtimer.c b/test/testtimer.c index ebc655d10..ea985e264 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -33,7 +33,7 @@ ticktock(Uint32 interval, void *param) static Uint32 SDLCALL callback(Uint32 interval, void *param) { - printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); + SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); return interval; } @@ -45,8 +45,11 @@ main(int argc, char *argv[]) Uint32 start32, now32; Uint64 start, now; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_TIMER) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -61,7 +64,7 @@ main(int argc, char *argv[]) t1 = SDL_AddTimer(desired, ticktock, NULL); /* Wait 10 seconds */ - printf("Waiting 10 seconds\n"); + SDL_Log("Waiting 10 seconds\n"); SDL_Delay(10 * 1000); /* Stop the timer */ @@ -69,28 +72,27 @@ main(int argc, char *argv[]) /* Print the results */ if (ticks) { - fprintf(stderr, - "Timer resolution: desired = %d ms, actual = %f ms\n", + SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n", desired, (double) (10 * 1000) / ticks); } /* Test multiple timers */ - printf("Testing multiple timers...\n"); + SDL_Log("Testing multiple timers...\n"); t1 = SDL_AddTimer(100, callback, (void *) 1); if (!t1) - fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError()); t2 = SDL_AddTimer(50, callback, (void *) 2); if (!t2) - fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError()); t3 = SDL_AddTimer(233, callback, (void *) 3); if (!t3) - fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError()); /* Wait 10 seconds */ - printf("Waiting 10 seconds\n"); + SDL_Log("Waiting 10 seconds\n"); SDL_Delay(10 * 1000); - printf("Removing timer 1 and waiting 5 more seconds\n"); + SDL_Log("Removing timer 1 and waiting 5 more seconds\n"); SDL_RemoveTimer(t1); SDL_Delay(5 * 1000); @@ -103,15 +105,15 @@ main(int argc, char *argv[]) ticktock(0, NULL); } now = SDL_GetPerformanceCounter(); - printf("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); + SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); - printf("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency()); + SDL_Log("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency()); start32 = SDL_GetTicks(); start = SDL_GetPerformanceCounter(); SDL_Delay(1000); now = SDL_GetPerformanceCounter(); now32 = SDL_GetTicks(); - printf("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); + SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); SDL_Quit(); return (0); diff --git a/test/testver.c b/test/testver.c index ecfcdf35e..cf3a54598 100644 --- a/test/testver.c +++ b/test/testver.c @@ -26,17 +26,20 @@ main(int argc, char *argv[]) SDL_version compiled; SDL_version linked; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + #if SDL_VERSION_ATLEAST(2, 0, 0) - printf("Compiled with SDL 2.0 or newer\n"); + SDL_Log("Compiled with SDL 2.0 or newer\n"); #else - printf("Compiled with SDL older than 2.0\n"); + SDL_Log("Compiled with SDL older than 2.0\n"); #endif SDL_VERSION(&compiled); - printf("Compiled version: %d.%d.%d.%d (%s)\n", + SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n", compiled.major, compiled.minor, compiled.patch, SDL_REVISION_NUMBER, SDL_REVISION); SDL_GetVersion(&linked); - printf("Linked version: %d.%d.%d.%d (%s)\n", + SDL_Log("Linked version: %d.%d.%d.%d (%s)\n", linked.major, linked.minor, linked.patch, SDL_GetRevisionNumber(), SDL_GetRevision()); SDL_Quit(); diff --git a/test/testwm2.c b/test/testwm2.c index efe6ea4dd..241f826f8 100644 --- a/test/testwm2.c +++ b/test/testwm2.c @@ -48,6 +48,9 @@ main(int argc, char *argv[]) int system_cursor = -1; SDL_Cursor *cursor = NULL; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS); /* Initialize test framework */ @@ -64,7 +67,7 @@ main(int argc, char *argv[]) consumed = -1; } if (consumed < 0) { - fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } i += consumed; @@ -84,7 +87,7 @@ main(int argc, char *argv[]) if (event.window.event == SDL_WINDOWEVENT_RESIZED) { SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); if (window) { - printf("Window %d resized to %dx%d\n", + SDL_Log("Window %d resized to %dx%d\n", event.window.windowID, event.window.data1, event.window.data2); @@ -93,7 +96,7 @@ main(int argc, char *argv[]) if (event.window.event == SDL_WINDOWEVENT_MOVED) { SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); if (window) { - printf("Window %d moved to %d,%d (display %s)\n", + SDL_Log("Window %d moved to %d,%d (display %s)\n", event.window.windowID, event.window.data1, event.window.data2, diff --git a/test/torturethread.c b/test/torturethread.c index 795b60b93..53a57a9b0 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -49,7 +49,7 @@ ThreadFunc(void *data) int i; int tid = (int) (uintptr_t) data; - fprintf(stderr, "Creating Thread %d\n", tid); + SDL_Log("Creating Thread %d\n", tid); for (i = 0; i < NUMTHREADS; i++) { char name[64]; @@ -58,18 +58,18 @@ ThreadFunc(void *data) sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]); } - printf("Thread '%d' waiting for signal\n", tid); + SDL_Log("Thread '%d' waiting for signal\n", tid); while (time_for_threads_to_die[tid] != 1) { ; /* do nothing */ } - printf("Thread '%d' sending signals to subthreads\n", tid); + SDL_Log("Thread '%d' sending signals to subthreads\n", tid); for (i = 0; i < NUMTHREADS; i++) { flags[i] = 1; SDL_WaitThread(sub_threads[i], NULL); } - printf("Thread '%d' exiting!\n", tid); + SDL_Log("Thread '%d' exiting!\n", tid); return 0; } @@ -80,9 +80,12 @@ main(int argc, char *argv[]) SDL_Thread *threads[NUMTHREADS]; int i; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -94,7 +97,7 @@ main(int argc, char *argv[]) threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i); if (threads[i] == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } } From 1873067816efadb0f2b3f0734dc2da76d6f7a39e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 16 Aug 2013 06:59:19 -0700 Subject: [PATCH 008/258] Fixed alpha blending for the MMX blit functions I see the Remarks of function SDL_BlitSurface shows that "when SDL_BLENDMODE_BLEND, we have dstA = srcA + (dstA * (1-srcA))". however, I tested some pictures but the result implies "dstA=arcA" actually. I stepped into the source code, and found after I set SDL_BLENDMODE_BLEND for the source surface, the final blit function is BlitRGBtoRGBPixelAlphaMMX when I use SDL_BlitSurface on my computer. And I found these codes: else if (alpha == amask) { /* opaque alpha -- copy RGB, keep dst alpha */ *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); The same code is used in BlitRGBtoRGBPixelAlphaMMX3DNOW and BlitRGBtoRGBPixelAlpha. So I think they still keep dst alpha. Best regards, Jianyu Guan --- src/video/SDL_blit_A.c | 74 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 3fb89c061..e53f99a83 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -337,15 +337,14 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; Uint32 amask = sf->Amask; Uint32 ashift = sf->Ashift; - Uint64 multmask; + Uint64 multmask, multmask2; - __m64 src1, dst1, mm_alpha, mm_zero, dmask; + __m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2; mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ - multmask = 0xFFFF; - multmask <<= (ashift * 2); - multmask = ~multmask; - dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ + multmask = 0x00FF; + multmask <<= (ashift * 2); + multmask2 = 0x00FF00FF00FF00FF; while (height--) { /* *INDENT-OFF* */ @@ -353,9 +352,8 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) Uint32 alpha = *srcp & amask; if (alpha == 0) { /* do nothing */ - } else if (alpha == amask) { - /* opaque alpha -- copy RGB, keep dst alpha */ - *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); + } else if (alpha == amask || (*dstp & amask) == 0) { + *dstp = *srcp; } else { src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ @@ -366,15 +364,17 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ - mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ + mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha*/ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha*/ /* blend */ - src1 = _mm_sub_pi16(src1, dst1);/* src1 - dst1 -> src1 */ - src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src1 - dst1) * alpha -> src1 */ - src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ - dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1 -> dst1(0A0R0G0B) */ - dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ + src1 = _mm_mullo_pi16(src1, mm_alpha); + src1 = _mm_srli_pi16(src1, 8); + dst1 = _mm_mullo_pi16(dst1, mm_alpha2); + dst1 = _mm_srli_pi16(dst1, 8); + dst1 = _mm_add_pi16(src1, dst1); + dst1 = _mm_packs_pu16(dst1, mm_zero); *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ } @@ -481,23 +481,24 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) compositioning used (>>8 instead of /255) doesn't handle it correctly. Also special-case alpha=0 for speed? Benchmark this! */ - if(alpha) { - if(alpha == SDL_ALPHA_OPAQUE) { - *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000); + if (alpha) { + if (alpha == SDL_ALPHA_OPAQUE) { + *dstp = *srcp; } else { /* * take out the middle component (green), and process * the other two in parallel. One multiply less. */ d = *dstp; - dalpha = d & 0xff000000; + dalpha = d >> 24; s1 = s & 0xff00ff; d1 = d & 0xff00ff; d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; s &= 0xff00; d &= 0xff00; d = (d + ((s - d) * alpha >> 8)) & 0xff00; - *dstp = d1 | d | dalpha; + dalpha = alpha + (dalpha * (alpha ^ 0xFF) >> 8); + *dstp = d1 | d | (dalpha << 24); } } ++srcp; @@ -524,15 +525,14 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; Uint32 amask = sf->Amask; Uint32 ashift = sf->Ashift; - Uint64 multmask; + Uint64 multmask, multmask2; - __m64 src1, dst1, mm_alpha, mm_zero, dmask; + __m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2; mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ - multmask = 0xFFFF; + multmask = 0x00FF; multmask <<= (ashift * 2); - multmask = ~multmask; - dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ + multmask2 = 0x00FF00FF00FF00FF; while (height--) { /* *INDENT-OFF* */ @@ -545,9 +545,8 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) alpha = *srcp & amask; if (alpha == 0) { /* do nothing */ - } else if (alpha == amask) { - /* copy RGB, keep dst alpha */ - *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); + } else if (alpha == amask || (*dstp & amask) == 0) { + *dstp = *srcp; } else { src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ @@ -558,15 +557,18 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ - mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ + mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha*/ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha*/ + /* blend */ - src1 = _mm_sub_pi16(src1, dst1);/* src - dst -> src1 */ - src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src - dst) * alpha -> src1 */ - src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ - dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst) -> dst1(0A0R0G0B) */ - dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ + src1 = _mm_mullo_pi16(src1, mm_alpha); + src1 = _mm_srli_pi16(src1, 8); + dst1 = _mm_mullo_pi16(dst1, mm_alpha2); + dst1 = _mm_srli_pi16(dst1, 8); + dst1 = _mm_add_pi16(src1, dst1); + dst1 = _mm_packs_pu16(dst1, mm_zero); *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ } From a460259e6bec96529994fdecf8da3f67dad6a7fb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 16 Aug 2013 09:20:33 -0700 Subject: [PATCH 009/258] Fixed alpha composition when destination alpha is transparent. Jianyu Guan I found I make a big mistake that when dstA==0, I just simply let *dstp=*srcp and forgot to make dstRGB = srcRGB*srcA. The if consition "(*dstp & amask) == 0" in BlitRGBtoRGBPixelAlphaMMX and BlitRGBtoRGBPixelAlphaMMX3dNow should be removed. --- src/video/SDL_blit_A.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index e53f99a83..9ef4a074b 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -352,7 +352,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) Uint32 alpha = *srcp & amask; if (alpha == 0) { /* do nothing */ - } else if (alpha == amask || (*dstp & amask) == 0) { + } else if (alpha == amask) { *dstp = *srcp; } else { src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ @@ -545,7 +545,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) alpha = *srcp & amask; if (alpha == 0) { /* do nothing */ - } else if (alpha == amask || (*dstp & amask) == 0) { + } else if (alpha == amask) { *dstp = *srcp; } else { src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ From 054cb844141fa4dc1aa2ed33a74a58824930c913 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Fri, 16 Aug 2013 13:37:27 -0300 Subject: [PATCH 010/258] [Bug 2042] OpenGL ES renderer tries to load OES functions unconditionally Also, fail more gracefully when creating texture to avoid double free errors. --- src/render/opengles/SDL_glesfuncs.h | 14 +++++++------- src/render/opengles/SDL_render_gles.c | 27 +++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/render/opengles/SDL_glesfuncs.h b/src/render/opengles/SDL_glesfuncs.h index 4a6384da6..ff5ce76be 100644 --- a/src/render/opengles/SDL_glesfuncs.h +++ b/src/render/opengles/SDL_glesfuncs.h @@ -1,6 +1,6 @@ SDL_PROC(void, glBindTexture, (GLenum, GLuint)) SDL_PROC(void, glBlendFunc, (GLenum, GLenum)) -SDL_PROC(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum)) +SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum)) SDL_PROC(void, glClear, (GLbitfield)) SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat)) @@ -8,11 +8,11 @@ SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *)) SDL_PROC(void, glDisable, (GLenum)) SDL_PROC(void, glDisableClientState, (GLenum array)) SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei)) -SDL_PROC(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC_OES(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glEnable, (GLenum)) SDL_PROC(void, glEnableClientState, (GLenum)) SDL_PROC(void, glFinish, (void)) -SDL_PROC(void, glGenFramebuffersOES, (GLsizei, GLuint *)) +SDL_PROC_OES(void, glGenFramebuffersOES, (GLsizei, GLuint *)) SDL_PROC(void, glGenTextures, (GLsizei, GLuint *)) SDL_PROC(GLenum, glGetError, (void)) SDL_PROC(void, glGetIntegerv, (GLenum, GLint *)) @@ -30,13 +30,13 @@ SDL_PROC(void, glTexParameteriv, (GLenum, GLenum, const GLint *)) SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) SDL_PROC(void, glVertexPointer, (GLint, GLenum, GLsizei, const GLvoid *)) SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei)) -SDL_PROC(void, glBindFramebufferOES, (GLenum, GLuint)) -SDL_PROC(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint)) -SDL_PROC(GLenum, glCheckFramebufferStatusOES, (GLenum)) +SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint)) +SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint)) +SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum)) SDL_PROC(void, glPushMatrix, (void)) SDL_PROC(void, glTranslatef, (GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glRotatef, (GLfloat, GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glPopMatrix, (void)) -SDL_PROC(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*)) +SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*)) /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index ab0f01d4e..940bcb137 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -96,7 +96,7 @@ SDL_RenderDriver GLES_RenderDriver = { GLES_CreateRenderer, { "opengles", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ), 1, {SDL_PIXELFORMAT_ABGR8888}, 0, @@ -113,8 +113,10 @@ typedef struct } current; #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC_OES SDL_PROC #include "SDL_glesfuncs.h" #undef SDL_PROC +#undef SDL_PROC_OES SDL_bool GL_OES_framebuffer_object_supported; GLES_FBOList *framebuffers; GLuint window_framebuffer; @@ -191,10 +193,15 @@ static int GLES_LoadFunctions(GLES_RenderData * data) return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \ } \ } while ( 0 ); +#define SDL_PROC_OES(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + } while ( 0 ); #endif /* _SDL_NOGETPROCADDR_ */ #include "SDL_glesfuncs.h" #undef SDL_PROC +#undef SDL_PROC_OES return 0; } @@ -465,12 +472,17 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } - texture->driverdata = data; + if (texture->access == SDL_TEXTUREACCESS_TARGET) { - data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h); + if (!renderdata->GL_OES_framebuffer_object_supported) { + SDL_free(data); + return SDL_SetError("GL_OES_framebuffer_object not supported"); + } + data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h); } else { - data->fbo = NULL; + data->fbo = NULL; } + renderdata->glGetError(); renderdata->glEnable(GL_TEXTURE_2D); @@ -503,8 +515,11 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) result = renderdata->glGetError(); if (result != GL_NO_ERROR) { + SDL_free(data); return GLES_SetError("glTexImage2D()", result); } + + texture->driverdata = data; return 0; } @@ -602,6 +617,10 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) GLenum status; GLES_ActivateRenderer(renderer); + + if (!data->GL_OES_framebuffer_object_supported) { + return SDL_SetError("Can't enable render target support in this renderer"); + } if (texture == NULL) { data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); From e5511f4ca0abc1191bb660223e998a650ea77234 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 16 Aug 2013 12:51:29 -0400 Subject: [PATCH 011/258] Patched to compile. --- src/render/opengles/SDL_render_gles.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 940bcb137..5ab3d7725 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -185,6 +185,7 @@ static int GLES_LoadFunctions(GLES_RenderData * data) #ifdef __SDL_NOGETPROCADDR__ #define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC_OES(ret,func,params) data->func=func; #else #define SDL_PROC(ret,func,params) \ do { \ From 140002c9314e71f4d0b6f586e98fdfebefef09ac Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Fri, 16 Aug 2013 14:38:04 -0300 Subject: [PATCH 012/258] Android quirk:Some devices don't report GL_OES_framebuffer_object but support it --- src/render/opengles/SDL_render_gles.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 5ab3d7725..64d3e8cd2 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -375,7 +375,8 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_height = value; - if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object")) { + /* Android does not report GL_OES_framebuffer_object but the functionality seems to be there anyway */ + if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object") || data->glGenFramebuffersOES) { data->GL_OES_framebuffer_object_supported = SDL_TRUE; renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE; From ec992b055885f0a964b102a99b9e023500ec752d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 16 Aug 2013 15:35:10 -0700 Subject: [PATCH 013/258] Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input Andreas The issue comes down to this line on MSDN: "TranslateMessage produces WM_CHAR messages only for keys that are mapped to ASCII characters by the keyboard driver." "WM_KEYDOWN and WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message. WM_SYSKEYDOWN and WM_SYSKEYUP combinations produce a WM_SYSCHAR or WM_SYSDEADCHAR message." Except for WM_CHAR, none of these messages are used in SDL. Hence TranslateMessage should be dropped entirely and proper handling be included in the WM_KEYDOWN event. Currently TranslateMessage is called for every message even if it must not be called in certain cases (like "An application should not call TranslateMessage if the TranslateAccelerator function returns a nonzero value."). WM_CHAR message handling should remain for external processes posting these messages - additionally, WM_UNICHAR should be added. I made a patch for src/video/windows/SDL_windowsevents.c that seems to work fine. It doesn't solve the "missing" composition for Khmer, but at least input for languages that cannot be mapped to ASCII characters (and for which IME is not used) will now work on Windows. --HG-- extra : rebase_source : 7024be6c3a874d0319ea4c65b7d43f105915288f --- src/video/windows/SDL_windowsevents.c | 70 ++++++++++++++++++++------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index acf8d5e51..eb57bcdb7 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -256,6 +256,33 @@ WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data ) } } +static SDL_FORCE_INLINE BOOL +WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) +{ + if (codepoint <= 0x7F) { + text[0] = (char) codepoint; + text[1] = '\0'; + } else if (codepoint <= 0x7FF) { + text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F); + text[1] = 0x80 | (char) (codepoint & 0x3F); + text[2] = '\0'; + } else if (codepoint <= 0xFFFF) { + text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F); + text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F); + text[2] = 0x80 | (char) (codepoint & 0x3F); + text[3] = '\0'; + } else if (codepoint <= 0x10FFFF) { + text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F); + text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F); + text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F); + text[3] = 0x80 | (char) (codepoint & 0x3F); + text[4] = '\0'; + } else { + return SDL_FALSE; + } + return SDL_TRUE; +} + LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -459,8 +486,23 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; #endif /* WM_MOUSELEAVE */ - case WM_SYSKEYDOWN: case WM_KEYDOWN: + { + BYTE keyboardState[256]; + char text[5]; + UINT32 utf32 = 0; + + GetKeyboardState(keyboardState); + if (ToUnicode(wParam, (lParam >> 16) & 0xff, keyboardState, (LPWSTR)&utf32, 1, 0) > 0) { + WORD repitition; + for (repitition = lParam & 0xffff; repitition > 0; repitition--) { + WIN_ConvertUTF32toUTF8(utf32, text); + SDL_SendKeyboardText(text); + } + } + } + // no break + case WM_SYSKEYDOWN: { SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam ); if ( code != SDL_SCANCODE_UNKNOWN ) { @@ -485,24 +527,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; + case WM_UNICHAR: + { + if (wParam == UNICODE_NOCHAR) { + returnCode = 1; + break; + } + } + // no break case WM_CHAR: { - char text[4]; + char text[5]; - /* Convert to UTF-8 and send it on... */ - if (wParam <= 0x7F) { - text[0] = (char) wParam; - text[1] = '\0'; - } else if (wParam <= 0x7FF) { - text[0] = 0xC0 | (char) ((wParam >> 6) & 0x1F); - text[1] = 0x80 | (char) (wParam & 0x3F); - text[2] = '\0'; - } else { - text[0] = 0xE0 | (char) ((wParam >> 12) & 0x0F); - text[1] = 0x80 | (char) ((wParam >> 6) & 0x3F); - text[2] = 0x80 | (char) (wParam & 0x3F); - text[3] = '\0'; - } + WIN_ConvertUTF32toUTF8(wParam, text); SDL_SendKeyboardText(text); } returnCode = 0; @@ -772,7 +809,6 @@ WIN_PumpEvents(_THIS) const Uint8 *keystate; MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); DispatchMessage(&msg); } From 8b93c73d0d4e03ac7ed708f5753298e0ee13a594 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 16 Aug 2013 15:38:06 -0700 Subject: [PATCH 014/258] The keyboard text events should be sent after the key down events --- src/video/windows/SDL_windowsevents.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index eb57bcdb7..a40be7b38 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -487,7 +487,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #endif /* WM_MOUSELEAVE */ case WM_KEYDOWN: + case WM_SYSKEYDOWN: { + SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam ); + if ( code != SDL_SCANCODE_UNKNOWN ) { + SDL_SendKeyboardKey(SDL_PRESSED, code ); + } + } + if (msg == WM_KEYDOWN) { BYTE keyboardState[256]; char text[5]; UINT32 utf32 = 0; @@ -501,14 +508,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } } - // no break - case WM_SYSKEYDOWN: - { - SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam ); - if ( code != SDL_SCANCODE_UNKNOWN ) { - SDL_SendKeyboardKey(SDL_PRESSED, code ); - } - } returnCode = 0; break; From 814d56a9cc27fef27f697deccb9debec5f8857cf Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 16 Aug 2013 17:50:44 -0700 Subject: [PATCH 015/258] Fixed windows build --- src/video/windows/SDL_windowsevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index a40be7b38..e9326b504 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -256,7 +256,7 @@ WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data ) } } -static SDL_FORCE_INLINE BOOL +SDL_FORCE_INLINE BOOL WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) { if (codepoint <= 0x7F) { From f2ddd7c8224d01c1961f6b59cc2811308d2f5b93 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Aug 2013 09:54:30 -0700 Subject: [PATCH 016/258] Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8. --- src/render/direct3d/SDL_render_d3d.c | 129 ++++++++++++++------------- 1 file changed, 69 insertions(+), 60 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index e9fc0ce04..4333bad36 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -395,6 +395,71 @@ D3DFMTToPixelFormat(D3DFORMAT format) } } +static void +D3D_InitRenderState(D3D_RenderData *data) +{ + Direct3DDevice9 *device = data->device; + + IDirect3DDevice9_SetVertexShader(device, NULL); + IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); + IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE); + IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE); + IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + + /* Enable color modulation by diffuse color */ + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, + D3DTOP_MODULATE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, + D3DTA_TEXTURE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, + D3DTA_DIFFUSE); + + /* Enable alpha modulation by diffuse alpha */ + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, + D3DTOP_MODULATE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, + D3DTA_TEXTURE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2, + D3DTA_DIFFUSE); + + /* Enable separate alpha blend function, if possible */ + if (data->enableSeparateAlphaBlend) { + IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE); + } + + /* Disable second texture stage, since we're done */ + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, + D3DTOP_DISABLE); + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP, + D3DTOP_DISABLE); + + /* Set an identity world and view matrix */ + matrix.m[0][0] = 1.0f; + matrix.m[0][1] = 0.0f; + matrix.m[0][2] = 0.0f; + matrix.m[0][3] = 0.0f; + matrix.m[1][0] = 0.0f; + matrix.m[1][1] = 1.0f; + matrix.m[1][2] = 0.0f; + matrix.m[1][3] = 0.0f; + matrix.m[2][0] = 0.0f; + matrix.m[2][1] = 0.0f; + matrix.m[2][2] = 1.0f; + matrix.m[2][3] = 0.0f; + matrix.m[3][0] = 0.0f; + matrix.m[3][1] = 0.0f; + matrix.m[3][2] = 0.0f; + matrix.m[3][3] = 1.0f; + IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix); + IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix); + + /* Reset our current scale mode */ + SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); + + /* Start the render with beginScene */ + data->beginScene = SDL_TRUE; +} + static int D3D_Reset(SDL_Renderer * renderer) { @@ -416,14 +481,9 @@ D3D_Reset(SDL_Renderer * renderer) return D3D_SetError("Reset()", result); } } - IDirect3DDevice9_SetVertexShader(data->device, NULL); - IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, - D3DCULL_NONE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); + IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); - SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); + D3D_InitRenderState(data); D3D_UpdateViewport(renderer); return 0; } @@ -624,8 +684,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) D3D_SetError("CreateDevice()", result); return NULL; } - data->beginScene = SDL_TRUE; - SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); /* Get presentation parameters to fill info */ result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain); @@ -658,61 +716,12 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) data->enableSeparateAlphaBlend = SDL_TRUE; } - /* Set up parameters for rendering */ - IDirect3DDevice9_SetVertexShader(data->device, NULL); - IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, - D3DCULL_NONE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); - /* Enable color modulation by diffuse color */ - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP, - D3DTOP_MODULATE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1, - D3DTA_TEXTURE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2, - D3DTA_DIFFUSE); - /* Enable alpha modulation by diffuse alpha */ - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP, - D3DTOP_MODULATE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1, - D3DTA_TEXTURE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2, - D3DTA_DIFFUSE); - /* Enable separate alpha blend function, if possible */ - if (data->enableSeparateAlphaBlend) { - IDirect3DDevice9_SetRenderState(data->device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE); - } - /* Disable second texture stage, since we're done */ - IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, - D3DTOP_DISABLE); - IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, - D3DTOP_DISABLE); - /* Store the default render target */ IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget ); data->currentRenderTarget = NULL; - /* Set an identity world and view matrix */ - matrix.m[0][0] = 1.0f; - matrix.m[0][1] = 0.0f; - matrix.m[0][2] = 0.0f; - matrix.m[0][3] = 0.0f; - matrix.m[1][0] = 0.0f; - matrix.m[1][1] = 1.0f; - matrix.m[1][2] = 0.0f; - matrix.m[1][3] = 0.0f; - matrix.m[2][0] = 0.0f; - matrix.m[2][1] = 0.0f; - matrix.m[2][2] = 1.0f; - matrix.m[2][3] = 0.0f; - matrix.m[3][0] = 0.0f; - matrix.m[3][1] = 0.0f; - matrix.m[3][2] = 0.0f; - matrix.m[3][3] = 1.0f; - IDirect3DDevice9_SetTransform(data->device, D3DTS_WORLD, &matrix); - IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, &matrix); + /* Set up parameters for rendering */ + D3D_InitRenderState(data); if (caps.MaxSimultaneousTextures >= 3) { From 508d844d448a95c3914875ca81750266aa4b40e1 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Sat, 17 Aug 2013 18:07:29 -0400 Subject: [PATCH 017/258] auto init the ticks if the GetTicks and the like methods are called before SDL_Init().. This prevents annoying game bugs such as caching SDL_GetPerformanceFrequency in a static initializer --- src/timer/SDL_timer.c | 13 ------------- src/timer/beos/SDL_systimer.c | 12 +++++++++++- src/timer/dummy/SDL_systimer.c | 12 +++++++++++- src/timer/psp/SDL_systimer.c | 12 +++++++++++- src/timer/unix/SDL_systimer.c | 20 +++++++++++++++++++- src/timer/windows/SDL_systimer.c | 10 +++++++++- 6 files changed, 61 insertions(+), 18 deletions(-) diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 5b6550c1c..2980f4dc7 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -26,8 +26,6 @@ #include "SDL_cpuinfo.h" #include "SDL_thread.h" -extern void SDL_StartTicks(void); - /* #define DEBUG_TIMERS */ typedef struct _SDL_Timer @@ -72,17 +70,6 @@ typedef struct { static SDL_TimerData SDL_timer_data; -static Uint32 ticks_started = 0; - -void -SDL_InitTicks(void) -{ - if (!ticks_started) { - SDL_StartTicks(); - ticks_started = 1; - } -} - /* The idea here is that any thread might add a timer, but a single * thread manages the active timer queue, sorted by scheduling time. * diff --git a/src/timer/beos/SDL_systimer.c b/src/timer/beos/SDL_systimer.c index edaf27501..fd22e4412 100644 --- a/src/timer/beos/SDL_systimer.c +++ b/src/timer/beos/SDL_systimer.c @@ -27,10 +27,16 @@ #include "SDL_timer.h" static bigtime_t start; +static SDL_bool ticks_started = SDL_FALSE; void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + /* Set first ticks value */ start = system_time(); } @@ -38,6 +44,10 @@ SDL_StartTicks(void) Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + return ((system_time() - start) / 1000); } diff --git a/src/timer/dummy/SDL_systimer.c b/src/timer/dummy/SDL_systimer.c index 2b5a9f8e3..387675db1 100644 --- a/src/timer/dummy/SDL_systimer.c +++ b/src/timer/dummy/SDL_systimer.c @@ -24,14 +24,24 @@ #include "SDL_timer.h" +static SDL_bool ticks_started = SDL_FALSE; + void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; } Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + SDL_Unsupported(); return 0; } diff --git a/src/timer/psp/SDL_systimer.c b/src/timer/psp/SDL_systimer.c index 59bb4df1c..61c4690aa 100644 --- a/src/timer/psp/SDL_systimer.c +++ b/src/timer/psp/SDL_systimer.c @@ -29,14 +29,24 @@ #include static struct timeval start; +static SDL_bool ticks_started = SDL_FALSE; -void SDL_StartTicks(void) +void SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + gettimeofday(&start, NULL); } Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + struct timeval now; Uint32 ticks; diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 596d749ab..793403297 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -56,10 +56,16 @@ mach_timebase_info_data_t mach_base_info; #endif static SDL_bool has_monotonic_time = SDL_FALSE; static struct timeval start_tv; +static SDL_bool ticks_started = SDL_FALSE; void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + /* Set first ticks value */ #if HAVE_CLOCK_GETTIME if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) { @@ -80,6 +86,10 @@ SDL_StartTicks(void) Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + Uint32 ticks; if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME @@ -105,6 +115,10 @@ SDL_GetTicks(void) Uint64 SDL_GetPerformanceCounter(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + Uint64 ticks; if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME @@ -131,6 +145,10 @@ SDL_GetPerformanceCounter(void) Uint64 SDL_GetPerformanceFrequency(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME return 1000000000; diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index ce6bd7a70..24a0c8cec 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -29,6 +29,7 @@ #include "SDL_hints.h" +static BOOL ticks_started = FALSE; /* The first (low-resolution) ticks value of the application */ static DWORD start; @@ -76,8 +77,13 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu } void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = TRUE; + /* Set first ticks value */ #ifdef USE_GETTICKCOUNT start = GetTickCount(); @@ -102,6 +108,8 @@ SDL_StartTicks(void) Uint32 SDL_GetTicks(void) { + if (!ticks_started) SDL_InitTicks(); + DWORD now; #ifndef USE_GETTICKCOUNT LARGE_INTEGER hires_now; From 458f93d7cb483f7ac65d34afd4b96c0b323a2219 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Aug 2013 17:04:14 -0700 Subject: [PATCH 018/258] Fixed for consistency with the other platforms --- src/timer/windows/SDL_systimer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 24a0c8cec..afa77c14a 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -29,9 +29,9 @@ #include "SDL_hints.h" -static BOOL ticks_started = FALSE; /* The first (low-resolution) ticks value of the application */ static DWORD start; +static BOOL ticks_started = FALSE; #ifndef USE_GETTICKCOUNT /* Store if a high-resolution performance counter exists on the system */ @@ -108,7 +108,9 @@ SDL_InitTicks(void) Uint32 SDL_GetTicks(void) { - if (!ticks_started) SDL_InitTicks(); + if (!ticks_started) { + SDL_InitTicks(); + } DWORD now; #ifndef USE_GETTICKCOUNT From f082b60d08e288dee12b5b4c433408952458425e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Aug 2013 17:14:15 -0700 Subject: [PATCH 019/258] Fixed Windows build --- src/render/direct3d/SDL_render_d3d.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 4333bad36..d1c0ac05b 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -398,7 +398,9 @@ D3DFMTToPixelFormat(D3DFORMAT format) static void D3D_InitRenderState(D3D_RenderData *data) { - Direct3DDevice9 *device = data->device; + D3DMATRIX matrix; + + IDirect3DDevice9 *device = data->device; IDirect3DDevice9_SetVertexShader(device, NULL); IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); @@ -542,7 +544,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) Uint32 window_flags; int w, h; SDL_DisplayMode fullscreen_mode; - D3DMATRIX matrix; int d3dxVersion; char d3dxDLLFile[50]; From 8cd0072f2d9a292d62b938e272eaf812d60c3cdb Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 17 Aug 2013 20:46:34 -0400 Subject: [PATCH 020/258] Patched to compile with Visual Studio. --- src/timer/windows/SDL_systimer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index afa77c14a..c3b54f5df 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -108,15 +108,15 @@ SDL_InitTicks(void) Uint32 SDL_GetTicks(void) { - if (!ticks_started) { - SDL_InitTicks(); - } - DWORD now; #ifndef USE_GETTICKCOUNT LARGE_INTEGER hires_now; #endif + if (!ticks_started) { + SDL_InitTicks(); + } + #ifdef USE_GETTICKCOUNT now = GetTickCount(); #else From 8900fb0a7eab7647ff2f357a7d5f256916c1755e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sun, 18 Aug 2013 11:08:52 +0200 Subject: [PATCH 021/258] Changed some documentation comments in header files to be used by doxygen. --- include/SDL_main.h | 2 +- include/SDL_thread.h | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/SDL_main.h b/include/SDL_main.h index bbb7e859b..b7e4a10e5 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -94,7 +94,7 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]); extern "C" { #endif -/* +/** * This is called by the real SDL main function to let the rest of the * library know that initialization was done properly. * diff --git a/include/SDL_thread.h b/include/SDL_thread.h index c878c3ab9..f248c3d69 100644 --- a/include/SDL_thread.h +++ b/include/SDL_thread.h @@ -51,9 +51,10 @@ typedef unsigned long SDL_threadID; /* Thread local storage ID, 0 is the invalid ID */ typedef unsigned int SDL_TLSID; -/* The SDL thread priority +/** + * The SDL thread priority. * - * Note: On many systems you require special privileges to set high priority. + * \note On many systems you require special privileges to set high priority. */ typedef enum { SDL_THREAD_PRIORITY_LOW, @@ -61,8 +62,9 @@ typedef enum { SDL_THREAD_PRIORITY_HIGH } SDL_ThreadPriority; -/* The function passed to SDL_CreateThread() - It is passed a void* user context parameter and returns an int. +/** + * The function passed to SDL_CreateThread(). + * It is passed a void* user context parameter and returns an int. */ typedef int (SDLCALL * SDL_ThreadFunction) (void *data); From dbd31e454adeb7a81d650a532113de9020960940 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sun, 18 Aug 2013 11:12:46 +0200 Subject: [PATCH 022/258] Corrected file names in header file comments. --- include/SDL_mutex.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h index 3efc4a890..4f2c50615 100644 --- a/include/SDL_mutex.h +++ b/include/SDL_mutex.h @@ -54,7 +54,7 @@ extern "C" { */ /*@{*/ -/* The SDL mutex structure, defined in SDL_mutex.c */ +/* The SDL mutex structure, defined in SDL_sysmutex.c */ struct SDL_mutex; typedef struct SDL_mutex SDL_mutex; @@ -102,7 +102,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); */ /*@{*/ -/* The SDL semaphore structure, defined in SDL_sem.c */ +/* The SDL semaphore structure, defined in SDL_syssem.c */ struct SDL_semaphore; typedef struct SDL_semaphore SDL_sem; @@ -162,7 +162,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); */ /*@{*/ -/* The SDL condition variable structure, defined in SDL_cond.c */ +/* The SDL condition variable structure, defined in SDL_syscond.c */ struct SDL_cond; typedef struct SDL_cond SDL_cond; From 7a4e8a102149c732578be21a3994f8f7d00aaf01 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sun, 18 Aug 2013 11:15:30 +0200 Subject: [PATCH 023/258] Replaced introduction in header file with more recent version from README.txt. --- include/SDL.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/include/SDL.h b/include/SDL.h index f2d760c2e..ca098ae6e 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -32,18 +32,20 @@ * * \section intro_sec Introduction * - * This is the Simple DirectMedia Layer, a general API that provides low - * level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, - * and 2D framebuffer across multiple platforms. + * Simple DirectMedia Layer is a cross-platform development library designed + * to provide low level access to audio, keyboard, mouse, joystick, and + * graphics hardware via OpenGL and Direct3D. It is used by video playback + * software, emulators, and popular games including Valve's award winning + * catalog and many Humble Bundle games. * - * SDL is written in C, but works with C++ natively, and has bindings to - * several other languages, including Ada, C#, Eiffel, Erlang, Euphoria, - * Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, - * Pike, Pliant, Python, Ruby, and Smalltalk. + * SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. + * Support for other platforms may be found in the source code. * - * This library is distributed under the zlib license, which can be - * found in the file "COPYING". This license allows you to use SDL - * freely for any purpose as long as you retain the copyright notice. + * SDL is written in C, works natively with C++, and there are bindings + * available for several other languages, including C# and Python. + * + * This library is distributed under the zlib license, which can be found + * in the file "COPYING.txt". * * The best way to learn how to use SDL is to check out the header files in * the "include" subdirectory and the programs in the "test" subdirectory. From 6af769d88741aede98e0105107bb4db873dfcd52 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Aug 2013 22:05:53 -0700 Subject: [PATCH 024/258] Fixed Haiku build (thanks Alexander!) --- src/main/beos/SDL_BApp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/beos/SDL_BApp.h b/src/main/beos/SDL_BApp.h index 2a64455b6..9b731e3e7 100644 --- a/src/main/beos/SDL_BApp.h +++ b/src/main/beos/SDL_BApp.h @@ -371,7 +371,7 @@ private: /* Members */ - vector _window_map; /* Keeps track of SDL_Windows by index-id*/ + std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ display_mode *_saved_mode; BGLView *_current_context; From 7960e55671eff8f324f355212737804047686c6b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Aug 2013 23:18:11 -0700 Subject: [PATCH 025/258] Fixed warnings building with gcc 2 and gcc 4 on Haiku --- include/begin_code.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/include/begin_code.h b/include/begin_code.h index dd1f0616d..bed798414 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -35,13 +35,7 @@ /* Some compilers use a special export keyword */ #ifndef DECLSPEC -# if defined(__BEOS__) || defined(__HAIKU__) -# if defined(__GNUC__) -# define DECLSPEC __declspec(dllexport) -# else -# define DECLSPEC __declspec(export) -# endif -# elif defined(__WIN32__) +# if defined(__WIN32__) # ifdef __BORLANDC__ # ifdef BUILD_SDL # define DECLSPEC @@ -54,6 +48,8 @@ # else # if defined(__GNUC__) && __GNUC__ >= 4 # define DECLSPEC __attribute__ ((visibility("default"))) +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define DECLSPEC __declspec(dllexport) # else # define DECLSPEC # endif From 29ea6509bcc55eac4862807c6911fe71244a547e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 19 Aug 2013 11:02:44 -0400 Subject: [PATCH 026/258] Fixed leaking of pixel shader object in D3D renderer (thanks, Peter!). Fixes Bugzilla #2047. --- src/render/direct3d/SDL_render_d3d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index d1c0ac05b..fb45f882f 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1835,7 +1835,9 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } - + if (data->ps_yuv) { + IDirect3DPixelShader9_Release(data->ps_yuv); + } if (data->device) { IDirect3DDevice9_Release(data->device); } From ef4a588d9971af2242fb18e829d442f5c7586c56 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Mon, 19 Aug 2013 16:29:46 -0300 Subject: [PATCH 027/258] Fixes bug #2037, common EGL code for Android and X11 --- Android.mk | 2 +- .../src/org/libsdl/app/SDLActivity.java | 201 +-------- configure | 55 +-- configure.in | 69 +-- include/SDL_config.h.in | 1 + include/SDL_config_android.h | 1 + include/SDL_video.h | 2 +- src/core/android/SDL_android.c | 117 +++-- src/core/android/SDL_android.h | 8 +- src/video/SDL_egl.c | 407 ++++++++++++++++++ src/video/SDL_egl.h | 132 ++++++ src/video/SDL_sysvideo.h | 6 +- src/video/SDL_video.c | 5 + src/video/android/SDL_androidevents.c | 39 +- src/video/android/SDL_androidgl.c | 95 +--- src/video/android/SDL_androidvideo.c | 38 +- src/video/android/SDL_androidwindow.c | 39 +- src/video/android/SDL_androidwindow.h | 11 + src/video/x11/SDL_x11opengl.c | 56 ++- src/video/x11/SDL_x11opengl.h | 1 + src/video/x11/SDL_x11opengles.c | 388 ++--------------- src/video/x11/SDL_x11opengles.h | 77 +--- src/video/x11/SDL_x11video.c | 4 +- src/video/x11/SDL_x11window.c | 44 +- src/video/x11/SDL_x11window.h | 7 + 25 files changed, 927 insertions(+), 878 deletions(-) create mode 100644 src/video/SDL_egl.c create mode 100644 src/video/SDL_egl.h diff --git a/Android.mk b/Android.mk index 3230f9fea..7338233c1 100755 --- a/Android.mk +++ b/Android.mk @@ -44,6 +44,6 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/video/android/*.c)) LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog +LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid include $(BUILD_SHARED_LIBRARY) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 7184a329c..f17365339 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -1,11 +1,5 @@ package org.libsdl.app; -import javax.microedition.khronos.egl.EGL10; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.egl.EGLContext; -import javax.microedition.khronos.egl.EGLDisplay; -import javax.microedition.khronos.egl.EGLSurface; - import android.app.*; import android.content.*; import android.view.*; @@ -43,13 +37,6 @@ public class SDLActivity extends Activity { protected static Thread mAudioThread; protected static AudioTrack mAudioTrack; - // EGL objects - protected static EGLContext mEGLContext; - protected static EGLSurface mEGLSurface; - protected static EGLDisplay mEGLDisplay; - protected static EGLConfig mEGLConfig; - protected static int mGLMajor, mGLMinor; - // Load the .so static { System.loadLibrary("SDL2"); @@ -70,9 +57,7 @@ public class SDLActivity extends Activity { mSingleton = this; // Set up the surface - mEGLSurface = EGL10.EGL_NO_SURFACE; mSurface = new SDLSurface(getApplication()); - mEGLContext = EGL10.EGL_NO_CONTEXT; mLayout = new AbsoluteLayout(this); mLayout.addView(mSurface); @@ -252,29 +237,12 @@ public class SDLActivity extends Activity { int action, float x, float y, float p); public static native void onNativeAccel(float x, float y, float z); - - // Java functions called from C - - public static boolean createGLContext(int majorVersion, int minorVersion, int[] attribs) { - return initEGL(majorVersion, minorVersion, attribs); - } - - public static void deleteGLContext() { - if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLContext != EGL10.EGL_NO_CONTEXT) { - EGL10 egl = (EGL10)EGLContext.getEGL(); - egl.eglMakeCurrent(SDLActivity.mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - egl.eglDestroyContext(SDLActivity.mEGLDisplay, SDLActivity.mEGLContext); - SDLActivity.mEGLContext = EGL10.EGL_NO_CONTEXT; - - if (SDLActivity.mEGLSurface != EGL10.EGL_NO_SURFACE) { - egl.eglDestroySurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface); - SDLActivity.mEGLSurface = EGL10.EGL_NO_SURFACE; - } - } - } + public static native void onNativeSurfaceChanged(); + public static native void onNativeSurfaceDestroyed(); + public static native void nativeFlipBuffers(); public static void flipBuffers() { - flipEGL(); + SDLActivity.nativeFlipBuffers(); } public static boolean setActivityTitle(String title) { @@ -332,147 +300,9 @@ public class SDLActivity extends Activity { // Transfer the task to the main thread as a Runnable return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h)); } - - - // EGL functions - public static boolean initEGL(int majorVersion, int minorVersion, int[] attribs) { - try { - EGL10 egl = (EGL10)EGLContext.getEGL(); - if (SDLActivity.mEGLDisplay == null) { - SDLActivity.mEGLDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - int[] version = new int[2]; - egl.eglInitialize(SDLActivity.mEGLDisplay, version); - } - - if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) { - // No current GL context exists, we will create a new one. - Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion); - EGLConfig[] configs = new EGLConfig[128]; - int[] num_config = new int[1]; - if (!egl.eglChooseConfig(SDLActivity.mEGLDisplay, attribs, configs, 1, num_config) || num_config[0] == 0) { - Log.e("SDL", "No EGL config available"); - return false; - } - EGLConfig config = null; - int bestdiff = -1, bitdiff; - int[] value = new int[1]; - - // eglChooseConfig returns a number of configurations that match or exceed the requested attribs. - // From those, we select the one that matches our requirements more closely - Log.v("SDL", "Got " + num_config[0] + " valid modes from egl"); - for(int i = 0; i < num_config[0]; i++) { - bitdiff = 0; - // Go through some of the attributes and compute the bit difference between what we want and what we get. - for (int j = 0; ; j += 2) { - if (attribs[j] == EGL10.EGL_NONE) - break; - - if (attribs[j+1] != EGL10.EGL_DONT_CARE && (attribs[j] == EGL10.EGL_RED_SIZE || - attribs[j] == EGL10.EGL_GREEN_SIZE || - attribs[j] == EGL10.EGL_BLUE_SIZE || - attribs[j] == EGL10.EGL_ALPHA_SIZE || - attribs[j] == EGL10.EGL_DEPTH_SIZE || - attribs[j] == EGL10.EGL_STENCIL_SIZE)) { - egl.eglGetConfigAttrib(SDLActivity.mEGLDisplay, configs[i], attribs[j], value); - bitdiff += value[0] - attribs[j + 1]; // value is always >= attrib - } - } - - if (bitdiff < bestdiff || bestdiff == -1) { - config = configs[i]; - bestdiff = bitdiff; - } - - if (bitdiff == 0) break; // we found an exact match! - } - - Log.d("SDL", "Selected mode with a total bit difference of " + bestdiff); - - SDLActivity.mEGLConfig = config; - SDLActivity.mGLMajor = majorVersion; - SDLActivity.mGLMinor = minorVersion; - } - - return SDLActivity.createEGLSurface(); - - } catch(Exception e) { - Log.v("SDL", e + ""); - for (StackTraceElement s : e.getStackTrace()) { - Log.v("SDL", s.toString()); - } - return false; - } - } - - public static boolean createEGLContext() { - EGL10 egl = (EGL10)EGLContext.getEGL(); - int EGL_CONTEXT_CLIENT_VERSION=0x3098; - int contextAttrs[] = new int[] { EGL_CONTEXT_CLIENT_VERSION, SDLActivity.mGLMajor, EGL10.EGL_NONE }; - SDLActivity.mEGLContext = egl.eglCreateContext(SDLActivity.mEGLDisplay, SDLActivity.mEGLConfig, EGL10.EGL_NO_CONTEXT, contextAttrs); - if (SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) { - Log.e("SDL", "Couldn't create context"); - return false; - } - return true; - } - - public static boolean createEGLSurface() { - if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLConfig != null) { - EGL10 egl = (EGL10)EGLContext.getEGL(); - if (SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) createEGLContext(); - - if (SDLActivity.mEGLSurface == EGL10.EGL_NO_SURFACE) { - Log.v("SDL", "Creating new EGL Surface"); - SDLActivity.mEGLSurface = egl.eglCreateWindowSurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLConfig, SDLActivity.mSurface, null); - if (SDLActivity.mEGLSurface == EGL10.EGL_NO_SURFACE) { - Log.e("SDL", "Couldn't create surface"); - return false; - } - } - else Log.v("SDL", "EGL Surface remains valid"); - - if (egl.eglGetCurrentContext() != SDLActivity.mEGLContext) { - if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface, SDLActivity.mEGLSurface, SDLActivity.mEGLContext)) { - Log.e("SDL", "Old EGL Context doesnt work, trying with a new one"); - // TODO: Notify the user via a message that the old context could not be restored, and that textures need to be manually restored. - createEGLContext(); - if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface, SDLActivity.mEGLSurface, SDLActivity.mEGLContext)) { - Log.e("SDL", "Failed making EGL Context current"); - return false; - } - } - else Log.v("SDL", "EGL Context made current"); - } - else Log.v("SDL", "EGL Context remains current"); - - return true; - } else { - Log.e("SDL", "Surface creation failed, display = " + SDLActivity.mEGLDisplay + ", config = " + SDLActivity.mEGLConfig); - return false; - } - } - - // EGL buffer flip - public static void flipEGL() { - try { - EGL10 egl = (EGL10)EGLContext.getEGL(); - - egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null); - - // drawing here - - egl.eglWaitGL(); - - egl.eglSwapBuffers(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface); - - - } catch(Exception e) { - Log.v("SDL", "flipEGL(): " + e); - for (StackTraceElement s : e.getStackTrace()) { - Log.v("SDL", s.toString()); - } - } + public static Surface getNativeSurface() { + return SDLActivity.mSurface.getNativeSurface(); } // Audio @@ -600,14 +430,16 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, mWidth = 1.0f; mHeight = 1.0f; } + + public Surface getNativeSurface() { + return getHolder().getSurface(); + } // Called when we have a valid drawing surface @Override public void surfaceCreated(SurfaceHolder holder) { Log.v("SDL", "surfaceCreated()"); holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); - // Set mIsSurfaceReady to 'true' *before* any call to handleResume - SDLActivity.mIsSurfaceReady = true; } // Called when we lose the surface @@ -617,16 +449,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // Call this *before* setting mIsSurfaceReady to 'false' SDLActivity.handlePause(); SDLActivity.mIsSurfaceReady = false; - - /* We have to clear the current context and destroy the egl surface here - * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume - * Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d - */ - - EGL10 egl = (EGL10)EGLContext.getEGL(); - egl.eglMakeCurrent(SDLActivity.mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - egl.eglDestroySurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface); - SDLActivity.mEGLSurface = EGL10.EGL_NO_SURFACE; + SDLActivity.onNativeSurfaceDestroyed(); } // Called when the surface is resized @@ -687,6 +510,8 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // Set mIsSurfaceReady to 'true' *before* making a call to handleResume SDLActivity.mIsSurfaceReady = true; + SDLActivity.onNativeSurfaceChanged(); + if (SDLActivity.mSDLThread == null) { // This is the entry point to the C app. diff --git a/configure b/configure index 38084c272..41adac4b0 100755 --- a/configure +++ b/configure @@ -20547,9 +20547,9 @@ fi CheckOpenGLESX11() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES (EGL) support" >&5 -$as_echo_n "checking for OpenGL ES (EGL) support... " >&6; } - video_opengles=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 +$as_echo_n "checking for EGL support... " >&6; } + video_opengl_egl=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -20566,21 +20566,26 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - video_opengles=yes + video_opengl_egl=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles" >&5 -$as_echo "$video_opengles" >&6; } - if test x$video_opengles = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 +$as_echo "$video_opengl_egl" >&6; } + if test x$video_opengl_egl = xyes; then + +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5 $as_echo_n "checking for OpenGL ES v1 headers... " >&6; } - video_opengles_v1=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + video_opengles_v1=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include + #include + #include int main () @@ -20593,28 +20598,29 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - video_opengles_v1=yes + video_opengles_v1=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 $as_echo "$video_opengles_v1" >&6; } - if test x$video_opengles_v1 = xyes; then + if test x$video_opengles_v1 = xyes; then $as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h $as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 $as_echo_n "checking for OpenGL ES v2 headers... " >&6; } - video_opengles_v2=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + video_opengles_v2=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include + #include + #include int main () @@ -20627,20 +20633,19 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - video_opengles_v2=yes + video_opengles_v2=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 $as_echo "$video_opengles_v2" >&6; } - if test x$video_opengles_v2 = xyes; then + if test x$video_opengles_v2 = xyes; then $as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h - fi fi fi } diff --git a/configure.in b/configure.in index 252efe4be..de32e6a12 100644 --- a/configure.in +++ b/configure.in @@ -1681,44 +1681,47 @@ dnl Find OpenGL ES CheckOpenGLESX11() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - AC_MSG_CHECKING(for OpenGL ES (EGL) support) - video_opengles=no + AC_MSG_CHECKING(for EGL support) + video_opengl_egl=no AC_TRY_COMPILE([ #include ],[ ],[ - video_opengles=yes + video_opengl_egl=yes ]) - AC_MSG_RESULT($video_opengles) - if test x$video_opengles = xyes; then - AC_MSG_CHECKING(for OpenGL ES v1 headers) - video_opengles_v1=no - AC_TRY_COMPILE([ - #include - #include - ],[ - ],[ - video_opengles_v1=yes - ]) - AC_MSG_RESULT($video_opengles_v1) - if test x$video_opengles_v1 = xyes; then - AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ]) - AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ]) - fi - AC_MSG_CHECKING(for OpenGL ES v2 headers) - video_opengles_v2=no - AC_TRY_COMPILE([ - #include - #include - ],[ - ],[ - video_opengles_v2=yes - ]) - AC_MSG_RESULT($video_opengles_v2) - if test x$video_opengles_v2 = xyes; then - AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ]) - AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ]) - fi + AC_MSG_RESULT($video_opengl_egl) + if test x$video_opengl_egl = xyes; then + AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ]) + fi + + AC_MSG_CHECKING(for OpenGL ES v1 headers) + video_opengles_v1=no + AC_TRY_COMPILE([ + #include + #include + ],[ + ],[ + video_opengles_v1=yes + ]) + AC_MSG_RESULT($video_opengles_v1) + if test x$video_opengles_v1 = xyes; then + AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ]) + AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ]) + fi + + AC_MSG_CHECKING(for OpenGL ES v2 headers) + video_opengles_v2=no + AC_TRY_COMPILE([ + #include + #include + ],[ + ],[ + video_opengles_v2=yes + ]) + AC_MSG_RESULT($video_opengles_v2) + if test x$video_opengles_v2 = xyes; then + AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ]) + AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ]) fi fi } diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 04ee11052..3f92d57b2 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -290,6 +290,7 @@ #undef SDL_VIDEO_OPENGL_ES #undef SDL_VIDEO_OPENGL_BGL #undef SDL_VIDEO_OPENGL_CGL +#undef SDL_VIDEO_OPENGL_EGL #undef SDL_VIDEO_OPENGL_GLX #undef SDL_VIDEO_OPENGL_WGL #undef SDL_VIDEO_OPENGL_OSMESA diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index e0c019f24..7c6b6cb51 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -129,6 +129,7 @@ /* Enable OpenGL ES */ #define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_OPENGL_EGL 1 #define SDL_VIDEO_RENDER_OGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES2 1 diff --git a/include/SDL_video.h b/include/SDL_video.h index f3a961977..30c7393f2 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -193,7 +193,7 @@ typedef enum { SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, - SDL_GL_CONTEXT_PROFILE_ES = 0x0004 + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /* GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ } SDL_GLprofile; typedef enum diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index b7d1ff6d1..7606859da 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -33,6 +33,7 @@ #include "../../video/android/SDL_androidkeyboard.h" #include "../../video/android/SDL_androidtouch.h" #include "../../video/android/SDL_androidvideo.h" +#include "../../video/android/SDL_androidwindow.h" #include #include @@ -67,8 +68,7 @@ static JavaVM* mJavaVM; static jclass mActivityClass; // method signatures -static jmethodID midCreateGLContext; -static jmethodID midDeleteGLContext; +static jmethodID midGetNativeSurface; static jmethodID midFlipBuffers; static jmethodID midAudioInit; static jmethodID midAudioWriteShortBuffer; @@ -116,10 +116,8 @@ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) mActivityClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls)); - midCreateGLContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, - "createGLContext","(II[I)Z"); - midDeleteGLContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, - "deleteGLContext","()V"); + midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, + "getNativeSurface","()Landroid/view/Surface;"); midFlipBuffers = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "flipBuffers","()V"); midAudioInit = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, @@ -133,7 +131,7 @@ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) bHasNewData = false; - if(!midCreateGLContext || !midFlipBuffers || !midAudioInit || + if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit || !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly"); } @@ -148,6 +146,65 @@ void Java_org_libsdl_app_SDLActivity_onNativeResize( Android_SetScreenResolution(width, height, format); } + +// Surface Created +void Java_org_libsdl_app_SDLActivity_onNativeSurfaceChanged(JNIEnv* env, jclass jcls) +{ + SDL_WindowData *data; + SDL_VideoDevice *_this; + + if (Android_Window == NULL || Android_Window->driverdata == NULL ) { + return; + } + + _this = SDL_GetVideoDevice(); + data = (SDL_WindowData *) Android_Window->driverdata; + + /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ + if (data->egl_surface == EGL_NO_SURFACE) { + if(data->native_window) { + ANativeWindow_release(data->native_window); + } + data->native_window = Android_JNI_GetNativeWindow(); + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); + } + + /* GL Context handling is done in the event loop because this function is run from the Java thread */ + +} + +// Surface Destroyed +void Java_org_libsdl_app_SDLActivity_onNativeSurfaceDestroyed(JNIEnv* env, jclass jcls) +{ + /* We have to clear the current context and destroy the egl surface here + * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume + * Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d + */ + SDL_WindowData *data; + SDL_VideoDevice *_this; + + if (Android_Window == NULL || Android_Window->driverdata == NULL ) { + return; + } + + _this = SDL_GetVideoDevice(); + data = (SDL_WindowData *) Android_Window->driverdata; + + if (data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + SDL_EGL_DestroySurface(_this, data->egl_surface); + data->egl_surface = EGL_NO_SURFACE; + } + + /* GL Context handling is done in the event loop because this function is run from the Java thread */ + +} + +void Java_org_libsdl_app_SDLActivity_nativeFlipBuffers(JNIEnv* env, jclass jcls) +{ + SDL_GL_SwapWindow(Android_Window); +} + // Keydown void Java_org_libsdl_app_SDLActivity_onNativeKeyDown( JNIEnv* env, jclass jcls, jint keycode) @@ -317,47 +374,17 @@ static SDL_bool LocalReferenceHolder_IsActive() return s_active > 0; } - -SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, - int red, int green, int blue, int alpha, - int buffer, int depth, int stencil, - int buffers, int samples) +ANativeWindow* Android_JNI_GetNativeWindow(void) { + ANativeWindow* anw; + jobject s; JNIEnv *env = Android_JNI_GetEnv(); - jint attribs[] = { - EGL_RED_SIZE, red, - EGL_GREEN_SIZE, green, - EGL_BLUE_SIZE, blue, - EGL_ALPHA_SIZE, alpha, - EGL_BUFFER_SIZE, buffer, - EGL_DEPTH_SIZE, depth, - EGL_STENCIL_SIZE, stencil, - EGL_SAMPLE_BUFFERS, buffers, - EGL_SAMPLES, samples, - EGL_RENDERABLE_TYPE, (majorVersion == 1 ? EGL_OPENGL_ES_BIT : EGL_OPENGL_ES2_BIT), - EGL_NONE - }; - int len = SDL_arraysize(attribs); - - jintArray array; - - array = (*env)->NewIntArray(env, len); - (*env)->SetIntArrayRegion(env, array, 0, len, attribs); - - jboolean success = (*env)->CallStaticBooleanMethod(env, mActivityClass, midCreateGLContext, majorVersion, minorVersion, array); - - (*env)->DeleteLocalRef(env, array); - - return success ? SDL_TRUE : SDL_FALSE; -} - -SDL_bool Android_JNI_DeleteContext(void) -{ - /* There's only one context, so no parameter for now */ - JNIEnv *env = Android_JNI_GetEnv(); - (*env)->CallStaticVoidMethod(env, mActivityClass, midDeleteGLContext); - return SDL_TRUE; + s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface); + anw = ANativeWindow_fromSurface(env, s); + (*env)->DeleteLocalRef(env, s); + + return anw; } void Android_JNI_SwapWindow() diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 973f5881f..e95fd4659 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -27,16 +27,20 @@ extern "C" { /* *INDENT-ON* */ #endif +#include +#include + #include "SDL_rect.h" /* Interface from the SDL library into the Android Java activity */ -extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); -extern SDL_bool Android_JNI_DeleteContext(void); +/*extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); +extern SDL_bool Android_JNI_DeleteContext(void);*/ extern void Android_JNI_SwapWindow(); extern void Android_JNI_SetActivityTitle(const char *title); extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]); extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect); extern void Android_JNI_HideTextInput(); +extern ANativeWindow* Android_JNI_GetNativeWindow(void); /* Audio support */ extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames); diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c new file mode 100644 index 000000000..da293743b --- /dev/null +++ b/src/video/SDL_egl.c @@ -0,0 +1,407 @@ +/* + * Simple DirectMedia Layer + * Copyright (C) 1997-2013 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 + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ +#include "SDL_config.h" + +#if SDL_VIDEO_OPENGL_EGL + +#include "SDL_sysvideo.h" +#include "SDL_egl.h" + +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" + +#define LOAD_FUNC(NAME) \ +*((void**)&_this->egl_data->NAME) = dlsym(handle, #NAME); \ +if (!_this->egl_data->NAME) \ +{ \ + return SDL_SetError("Could not retrieve EGL function " #NAME); \ +} + +/* EGL implementation of SDL OpenGL ES support */ + +void * +SDL_EGL_GetProcAddress(_THIS, const char *proc) +{ + static char procname[1024]; + void *handle; + void *retval; + + /* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */ +#if !defined(SDL_VIDEO_DRIVER_ANDROID) + handle = _this->egl_data->egl_dll_handle; + if (_this->egl_data->eglGetProcAddress) { + retval = _this->egl_data->eglGetProcAddress(proc); + if (retval) { + return retval; + } + } +#endif + + handle = _this->gl_config.dll_handle; + #if defined(__OpenBSD__) && !defined(__ELF__) + #undef dlsym(x,y); + #endif + retval = dlsym(handle, proc); + if (!retval && strlen(proc) <= 1022) { + procname[0] = '_'; + strcpy(procname + 1, proc); + retval = dlsym(handle, procname); + } + return retval; +} + +void +SDL_EGL_UnloadLibrary(_THIS) +{ + if ((_this->egl_data) && (_this->gl_config.driver_loaded)) { + _this->egl_data->eglTerminate(_this->egl_data->egl_display); + + dlclose(_this->gl_config.dll_handle); + dlclose(_this->egl_data->egl_dll_handle); + + SDL_free(_this->egl_data); + _this->egl_data = NULL; + + _this->gl_config.dll_handle = NULL; + _this->gl_config.driver_loaded = 0; + } +} + +int +SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display) +{ + void *handle; + int dlopen_flags; + + if (_this->egl_data) { + return SDL_SetError("OpenGL ES context already created"); + } + + /* Unload the old driver and reset the pointers */ + SDL_EGL_UnloadLibrary(_this); + + #ifdef RTLD_GLOBAL + dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; + #else + dlopen_flags = RTLD_LAZY; + #endif + handle = dlopen(path, dlopen_flags); + /* Catch the case where the application isn't linked with EGL */ + if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) { + + dlclose(handle); + path = getenv("SDL_VIDEO_EGL_DRIVER"); + if (path == NULL) { + path = DEFAULT_EGL; + } + handle = dlopen(path, dlopen_flags); + } + + if (handle == NULL) { + return SDL_SetError("Could not load OpenGL ES/EGL library"); + } + + _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData)); + if (!_this->egl_data) { + return SDL_OutOfMemory(); + } + + /* Load new function pointers */ + LOAD_FUNC(eglGetDisplay); + LOAD_FUNC(eglInitialize); + LOAD_FUNC(eglTerminate); + LOAD_FUNC(eglGetProcAddress); + LOAD_FUNC(eglChooseConfig); + LOAD_FUNC(eglGetConfigAttrib); + LOAD_FUNC(eglCreateContext); + LOAD_FUNC(eglDestroyContext); + LOAD_FUNC(eglCreateWindowSurface); + LOAD_FUNC(eglDestroySurface); + LOAD_FUNC(eglMakeCurrent); + LOAD_FUNC(eglSwapBuffers); + LOAD_FUNC(eglSwapInterval); + LOAD_FUNC(eglWaitNative); + LOAD_FUNC(eglWaitGL); + + _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); + + if (!_this->egl_data->egl_display) { + return SDL_SetError("Could not get EGL display"); + } + + if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { + return SDL_SetError("Could not initialize EGL"); + } + + _this->egl_data->egl_dll_handle = handle; + + path = getenv("SDL_VIDEO_GL_DRIVER"); + handle = dlopen(path, dlopen_flags); + if ((path == NULL) | (handle == NULL)) { + if (_this->gl_config.major_version > 1) { + path = DEFAULT_OGL_ES2; + handle = dlopen(path, dlopen_flags); + } else { + path = DEFAULT_OGL_ES; + handle = dlopen(path, dlopen_flags); + if (handle == NULL) { + path = DEFAULT_OGL_ES_PVR; + handle = dlopen(path, dlopen_flags); + } + } + } + + if (handle == NULL) { + return SDL_SetError("Could not initialize OpenGL ES library"); + } + + _this->gl_config.dll_handle = handle; + _this->gl_config.driver_loaded = 1; + + if (path) { + strncpy(_this->gl_config.driver_path, path, + sizeof(_this->gl_config.driver_path) - 1); + } else { + strcpy(_this->gl_config.driver_path, ""); + } + + /* We need to select a config here to satisfy some video backends such as X11 */ + SDL_EGL_ChooseConfig(_this); + + return 0; +} + +int +SDL_EGL_ChooseConfig(_THIS) +{ + /* 64 seems nice. */ + EGLint attribs[64]; + EGLint found_configs = 0; + int i; + + if (!_this->egl_data) { + /* The EGL library wasn't loaded, SDL_GetError() should have info */ + return -1; + } + + /* Get a valid EGL configuration */ + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + + if (_this->gl_config.alpha_size) { + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + + if (_this->gl_config.buffer_size) { + attribs[i++] = EGL_BUFFER_SIZE; + attribs[i++] = _this->gl_config.buffer_size; + } + + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.stencil_size) { + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + if (_this->gl_config.multisamplebuffers) { + attribs[i++] = EGL_SAMPLE_BUFFERS; + attribs[i++] = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + attribs[i++] = EGL_SAMPLES; + attribs[i++] = _this->gl_config.multisamplesamples; + } + + attribs[i++] = EGL_RENDERABLE_TYPE; + if (_this->gl_config.major_version == 2) { + attribs[i++] = EGL_OPENGL_ES2_BIT; + } else { + attribs[i++] = EGL_OPENGL_ES_BIT; + } + + attribs[i++] = EGL_NONE; + + if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display, + attribs, + &_this->egl_data->egl_config, 1, + &found_configs) == EGL_FALSE || + found_configs == 0) { + return SDL_SetError("Couldn't find matching EGL config"); + } + + return 0; +} + +SDL_GLContext +SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) +{ + EGLint context_attrib_list[] = { + EGL_CONTEXT_CLIENT_VERSION, + 1, + EGL_NONE + }; + + EGLContext egl_context; + + if (!_this->egl_data) { + /* The EGL library wasn't loaded, SDL_GetError() should have info */ + return NULL; + } + + if (_this->gl_config.major_version) { + context_attrib_list[1] = _this->gl_config.major_version; + } + + egl_context = + _this->egl_data->eglCreateContext(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NO_CONTEXT, context_attrib_list); + + if (egl_context == EGL_NO_CONTEXT) { + SDL_SetError("Could not create EGL context"); + return NULL; + } + + _this->egl_data->egl_swapinterval = 0; + + if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) { + SDL_EGL_DeleteContext(_this, egl_context); + SDL_SetError("Could not make EGL context current"); + return NULL; + } + + return (SDL_GLContext) egl_context; +} + +int +SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) +{ + if (!_this->egl_data) { + return SDL_SetError("OpenGL not initialized"); + } + + EGLContext egl_context = (EGLContext) context; + + /* The android emulator crashes badly if you try to eglMakeCurrent + * with a valid context and invalid surface, so we have to check for both here. + */ + if (!egl_context || !egl_surface) { + _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } + else { + if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, + egl_surface, egl_surface, egl_context)) { + return SDL_SetError("Unable to make EGL context current"); + } + } + + return 0; +} + +int +SDL_EGL_SetSwapInterval(_THIS, int interval) +{ + if (_this->egl_data) { + return SDL_SetError("OpenGL ES context not active"); + } + + EGLBoolean status; + status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); + if (status == EGL_TRUE) { + _this->egl_data->egl_swapinterval = interval; + return 0; + } + + return SDL_SetError("Unable to set the EGL swap interval"); +} + +int +SDL_EGL_GetSwapInterval(_THIS) +{ + if (_this->egl_data) { + return SDL_SetError("OpenGL ES context not active"); + } + + return _this->egl_data->egl_swapinterval; +} + +void +SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface) +{ + _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, egl_surface); +} + +void +SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) +{ + /* Clean up GLES and EGL */ + if (!_this->egl_data) { + return; + } + + EGLContext egl_context = (EGLContext) context; + + if (!egl_context && egl_context != EGL_NO_CONTEXT) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); + } + + /* FIXME: This "crappy fix" comes from the X11 code, + * it's required so you can create a GLX context, destroy it and create a EGL one */ + SDL_EGL_UnloadLibrary(_this); +} + +EGLSurface * +SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) +{ + return _this->egl_data->eglCreateWindowSurface( + _this->egl_data->egl_display, + _this->egl_data->egl_config, + nw, NULL); +} + +void +SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface) +{ + if (!_this->egl_data) { + return; + } + + if (egl_surface != EGL_NO_SURFACE) { + _this->egl_data->eglDestroySurface(_this->egl_data->egl_display, egl_surface); + } +} + +#endif /* SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + \ No newline at end of file diff --git a/src/video/SDL_egl.h b/src/video/SDL_egl.h new file mode 100644 index 000000000..d6139058d --- /dev/null +++ b/src/video/SDL_egl.h @@ -0,0 +1,132 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_egl_h +#define _SDL_egl_h + +#if SDL_VIDEO_OPENGL_EGL + +#include + +#include +#if defined(__OpenBSD__) && !defined(__ELF__) +#define dlsym(x,y) dlsym(x, "_" y) +#endif + +#include "SDL_sysvideo.h" + +typedef struct SDL_EGL_VideoData +{ + void *egl_dll_handle; + EGLDisplay egl_display; + EGLConfig egl_config; + int egl_swapinterval; + + EGLDisplay(*eglGetDisplay) (NativeDisplayType display); + EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major, + EGLint * minor); + EGLBoolean(*eglTerminate) (EGLDisplay dpy); + + void *(*eglGetProcAddress) (const char * procName); + + EGLBoolean(*eglChooseConfig) (EGLDisplay dpy, + const EGLint * attrib_list, + EGLConfig * configs, + EGLint config_size, EGLint * num_config); + + EGLContext(*eglCreateContext) (EGLDisplay dpy, + EGLConfig config, + EGLContext share_list, + const EGLint * attrib_list); + + EGLBoolean(*eglDestroyContext) (EGLDisplay dpy, EGLContext ctx); + + EGLSurface(*eglCreateWindowSurface) (EGLDisplay dpy, + EGLConfig config, + NativeWindowType window, + const EGLint * attrib_list); + EGLBoolean(*eglDestroySurface) (EGLDisplay dpy, EGLSurface surface); + + EGLBoolean(*eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw, + EGLSurface read, EGLContext ctx); + + EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw); + + EGLBoolean(*eglSwapInterval) (EGLDisplay dpy, EGLint interval); + + const char *(*eglQueryString) (EGLDisplay dpy, EGLint name); + + EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config, + EGLint attribute, EGLint * value); + + EGLBoolean(*eglWaitNative) (EGLint engine); + + EGLBoolean(*eglWaitGL)(void); +} SDL_EGL_VideoData; + +/* OpenGLES functions */ +extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern int SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display); +extern void *SDL_EGL_GetProcAddress(_THIS, const char *proc); +extern void SDL_EGL_UnloadLibrary(_THIS); +extern int SDL_EGL_ChooseConfig(_THIS); +extern int SDL_EGL_SetSwapInterval(_THIS, int interval); +extern int SDL_EGL_GetSwapInterval(_THIS); +extern void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context); +extern EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw); +extern void SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface); + +/* These need to be wrapped to get the surface for the window by the platform GLES implementation */ +extern SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface); +extern int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context); +extern void SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface); + +/* A few of useful macros */ + +#define SDL_EGL_SwapWindow_impl(BACKEND) void \ +BACKEND ## _GLES_SwapWindow(_THIS, SDL_Window * window) \ +{\ + SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\ +} + +#define SDL_EGL_MakeCurrent_impl(BACKEND) int \ +BACKEND ## _GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) \ +{\ + if (window && context) { \ + return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); \ + }\ + else {\ + return SDL_EGL_MakeCurrent(_this, NULL, NULL);\ + }\ +} + +#define SDL_EGL_CreateContext_impl(BACKEND) SDL_GLContext \ +BACKEND ## _GLES_CreateContext(_THIS, SDL_Window * window) \ +{\ + return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\ +} + +#endif /* SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_egl_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 4973648c7..084742fd8 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -313,7 +313,11 @@ struct SDL_VideoDevice /* Data private to this driver */ void *driverdata; struct SDL_GLDriverData *gl_data; - + +#if SDL_VIDEO_OPENGL_EGL + struct SDL_EGL_VideoData *egl_data; +#endif + #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 struct SDL_PrivateGLESData *gles_data; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index bab6c6cb9..b5c16e509 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -487,11 +487,16 @@ SDL_VideoInit(const char *driver_name) #elif SDL_VIDEO_OPENGL_ES _this->gl_config.major_version = 1; _this->gl_config.minor_version = 1; +#if SDL_VIDEO_OPENGL_EGL _this->gl_config.use_egl = 1; +#endif #elif SDL_VIDEO_OPENGL_ES2 _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; +#if SDL_VIDEO_OPENGL_EGL _this->gl_config.use_egl = 1; +#endif + #endif _this->gl_config.flags = 0; _this->gl_config.profile_mask = 0; diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index add86dfca..d0a16e1d7 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -27,6 +27,32 @@ #include "SDL_androidevents.h" #include "SDL_events.h" +#include "SDL_androidwindow.h" + +void android_egl_context_backup(); +void android_egl_context_restore(); + +void +android_egl_context_restore() +{ + SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + if (SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context) < 0) { + /* The context is no longer valid, create a new one */ + /* FIXME: Notify the user that the context changed and textures need to be re created*/ + data->egl_context = (EGLContext) SDL_GL_CreateContext(Android_Window); + SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context); + } +} + +void +android_egl_context_backup() +{ + /* Keep a copy of the EGL Context so we can try to restore it when we resume */ + SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + data->egl_context = SDL_GL_GetCurrentContext(); + /* We need to do this so the EGLSurface can be freed */ + SDL_GL_MakeCurrent(Android_Window, NULL); +} void Android_PumpEvents(_THIS) @@ -52,13 +78,9 @@ Android_PumpEvents(_THIS) if(SDL_SemTryWait(Android_ResumeSem) == 0) { #endif isPaused = 0; - /* TODO: Should we double check if we are on the same thread as the one that made the original GL context? - * This call will go through the following chain of calls in Java: - * SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext - * SDLActivity::createEGLContext will attempt to restore the GL context first, and if that fails it will create a new one - * If a new GL context is created, the user needs to restore the textures manually (TODO: notify the user that this happened with a message) - */ - SDL_GL_CreateContext(Android_Window); + + /* Restore the GL Context from here, as this operation is thread dependent */ + android_egl_context_restore(); } } else { @@ -70,13 +92,14 @@ Android_PumpEvents(_THIS) isPausing = 1; } else { + android_egl_context_backup(); isPausing = 0; isPaused = 1; } } #else if(SDL_SemTryWait(Android_PauseSem) == 0) { - /* If we fall in here, the system is/was paused */ + android_egl_context_backup(); isPaused = 1; } #endif diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index 6902bc1d0..1a3eb4c5f 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -25,6 +25,8 @@ /* Android SDL video driver implementation */ #include "SDL_video.h" +#include "../SDL_egl.h" +#include "SDL_androidwindow.h" #include "SDL_androidvideo.h" #include "../../core/android/SDL_android.h" @@ -33,95 +35,20 @@ #include -static void* Android_GLHandle = NULL; +SDL_EGL_CreateContext_impl(Android) +SDL_EGL_MakeCurrent_impl(Android) -/* GL functions */ -int -Android_GL_LoadLibrary(_THIS, const char *path) +Android_GLES_SwapWindow(_THIS, SDL_Window * window) { - if (!Android_GLHandle) { - Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL); - if (!Android_GLHandle) { - return SDL_SetError("Could not initialize GL ES library\n"); - } - } - return 0; -} - -void * -Android_GL_GetProcAddress(_THIS, const char *proc) -{ - /* - !!! FIXME: this _should_ use eglGetProcAddress(), but it appears to be - !!! FIXME: busted on Android at the moment... - !!! FIXME: http://code.google.com/p/android/issues/detail?id=7681 - !!! FIXME: ...so revisit this later. --ryan. - */ - return dlsym(Android_GLHandle, proc); -} - -void -Android_GL_UnloadLibrary(_THIS) -{ - if(Android_GLHandle) { - dlclose(Android_GLHandle); - Android_GLHandle = NULL; - } -} - -SDL_GLContext -Android_GL_CreateContext(_THIS, SDL_Window * window) -{ - if (!Android_JNI_CreateContext(_this->gl_config.major_version, - _this->gl_config.minor_version, - _this->gl_config.red_size, - _this->gl_config.green_size, - _this->gl_config.blue_size, - _this->gl_config.alpha_size, - _this->gl_config.buffer_size, - _this->gl_config.depth_size, - _this->gl_config.stencil_size, - _this->gl_config.multisamplebuffers, - _this->gl_config.multisamplesamples)) { - SDL_SetError("Couldn't create OpenGL context - see Android log for details"); - return NULL; - } - return (SDL_GLContext)1; + /* FIXME: These two functions were in the Java code, do we really need them? */ + _this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE); + _this->egl_data->eglWaitGL(); + SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); } int -Android_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ - /* There's only one context, nothing to do... */ - return 0; -} - -int -Android_GL_SetSwapInterval(_THIS, int interval) -{ - __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SetSwapInterval\n"); - return 0; -} - -int -Android_GL_GetSwapInterval(_THIS) -{ - __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetSwapInterval\n"); - return 0; -} - -void -Android_GL_SwapWindow(_THIS, SDL_Window * window) -{ - Android_JNI_SwapWindow(); -} - -void -Android_GL_DeleteContext(_THIS, SDL_GLContext context) -{ - if (context) { - Android_JNI_DeleteContext(); - } +Android_GLES_LoadLibrary(_THIS, const char *path) { + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0); } #endif /* SDL_VIDEO_DRIVER_ANDROID */ diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 6dcb81e70..0bf3a2ce9 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -44,17 +44,17 @@ static int Android_VideoInit(_THIS); static void Android_VideoQuit(_THIS); +#include "../SDL_egl.h" /* GL functions (SDL_androidgl.c) */ -extern int Android_GL_LoadLibrary(_THIS, const char *path); -extern void *Android_GL_GetProcAddress(_THIS, const char *proc); -extern void Android_GL_UnloadLibrary(_THIS); -extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window); -extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window, - SDL_GLContext context); -extern int Android_GL_SetSwapInterval(_THIS, int interval); -extern int Android_GL_GetSwapInterval(_THIS); -extern void Android_GL_SwapWindow(_THIS, SDL_Window * window); -extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context); +extern SDL_GLContext Android_GLES_CreateContext(_THIS, SDL_Window * window); +extern int Android_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern void Android_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int Android_GLES_LoadLibrary(_THIS, const char *path); +#define Android_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define Android_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define Android_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define Android_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define Android_GLES_DeleteContext SDL_EGL_DeleteContext /* Android driver bootstrap functions */ @@ -114,15 +114,15 @@ Android_CreateDevice(int devindex) device->free = Android_DeleteDevice; /* GL pointers */ - device->GL_LoadLibrary = Android_GL_LoadLibrary; - device->GL_GetProcAddress = Android_GL_GetProcAddress; - device->GL_UnloadLibrary = Android_GL_UnloadLibrary; - device->GL_CreateContext = Android_GL_CreateContext; - device->GL_MakeCurrent = Android_GL_MakeCurrent; - device->GL_SetSwapInterval = Android_GL_SetSwapInterval; - device->GL_GetSwapInterval = Android_GL_GetSwapInterval; - device->GL_SwapWindow = Android_GL_SwapWindow; - device->GL_DeleteContext = Android_GL_DeleteContext; + device->GL_LoadLibrary = Android_GLES_LoadLibrary; + device->GL_GetProcAddress = Android_GLES_GetProcAddress; + device->GL_UnloadLibrary = Android_GLES_UnloadLibrary; + device->GL_CreateContext = Android_GLES_CreateContext; + device->GL_MakeCurrent = Android_GLES_MakeCurrent; + device->GL_SetSwapInterval = Android_GLES_SetSwapInterval; + device->GL_GetSwapInterval = Android_GLES_GetSwapInterval; + device->GL_SwapWindow = Android_GLES_SwapWindow; + device->GL_DeleteContext = Android_GLES_DeleteContext; /* Text input */ device->StartTextInput = Android_StartTextInput; diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 70e244e1a..acc40dbee 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -29,15 +29,15 @@ #include "SDL_androidvideo.h" #include "SDL_androidwindow.h" -#include "../../core/android/SDL_android.h" - int Android_CreateWindow(_THIS, SDL_Window * window) { + SDL_WindowData *data; + if (Android_Window) { return SDL_SetError("Android only supports one window"); } - Android_Window = window; + Android_PauseSem = SDL_CreateSemaphore(0); Android_ResumeSem = SDL_CreateSemaphore(0); @@ -56,7 +56,29 @@ Android_CreateWindow(_THIS, SDL_Window * window) /* One window, it always has focus */ SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); + + data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + return SDL_OutOfMemory(); + } + + data->native_window = Android_JNI_GetNativeWindow(); + + if (!data->native_window) { + SDL_free(data); + return SDL_SetError("Could not fetch native window"); + } + + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); + if (data->egl_surface == EGL_NO_SURFACE) { + SDL_free(data); + return SDL_SetError("Could not create GLES window surface"); + } + + window->driverdata = data; + Android_Window = window; + return 0; } @@ -69,12 +91,23 @@ Android_SetWindowTitle(_THIS, SDL_Window * window) void Android_DestroyWindow(_THIS, SDL_Window * window) { + SDL_WindowData *data; + if (window == Android_Window) { Android_Window = NULL; if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem); if (Android_ResumeSem) SDL_DestroySemaphore(Android_ResumeSem); Android_PauseSem = NULL; Android_ResumeSem = NULL; + + if(window->driverdata) { + data = (SDL_WindowData *) window->driverdata; + if(data->native_window) { + ANativeWindow_release(data->native_window); + } + SDL_free(window->driverdata); + window->driverdata = NULL; + } } } diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index c0ef93bb0..4365cd414 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -23,10 +23,21 @@ #ifndef _SDL_androidwindow_h #define _SDL_androidwindow_h +#include "../../core/android/SDL_android.h" +#include "../SDL_egl.h" + extern int Android_CreateWindow(_THIS, SDL_Window * window); extern void Android_SetWindowTitle(_THIS, SDL_Window * window); extern void Android_DestroyWindow(_THIS, SDL_Window * window); +typedef struct +{ + EGLSurface egl_surface; + EGLContext egl_context; /* We use this to preserve the context when losing focus */ + ANativeWindow* native_window; + +} SDL_WindowData; + #endif /* _SDL_androidwindow_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 2eaed8698..6ddc0de7e 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -140,25 +140,6 @@ X11_GL_LoadLibrary(_THIS, const char *path) return SDL_SetError("OpenGL context already created"); } - /* If SDL_GL_CONTEXT_EGL has been changed to 1, switch over to X11_GLES functions */ - if (_this->gl_config.use_egl == 1) { -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - _this->GL_LoadLibrary = X11_GLES_LoadLibrary; - _this->GL_GetProcAddress = X11_GLES_GetProcAddress; - _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; - _this->GL_CreateContext = X11_GLES_CreateContext; - _this->GL_MakeCurrent = X11_GLES_MakeCurrent; - _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; - _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; - _this->GL_SwapWindow = X11_GLES_SwapWindow; - _this->GL_DeleteContext = X11_GLES_DeleteContext; - return X11_GLES_LoadLibrary(_this, path); -#else - return SDL_SetError("SDL not configured with OpenGL ES/EGL support"); -#endif - } - - /* Load the OpenGL library */ if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); @@ -228,6 +209,38 @@ X11_GL_LoadLibrary(_THIS, const char *path) /* Initialize extensions */ X11_GL_InitExtensions(_this); + + /* If SDL_GL_CONTEXT_EGL has been changed to 1, and there's + * no GLX_EXT_create_context_es2_profile extension switch over to X11_GLES functions */ + if (_this->gl_config.use_egl == 1) { + if (_this->gl_data->HAS_GLX_EXT_create_context_es2_profile) { + /* We cheat a little bit here by using GLX instead of EGL + * to improve our chances of getting hardware acceleration */ + _this->gl_config.use_egl = 0; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + } else { +#if SDL_VIDEO_OPENGL_EGL + X11_GL_UnloadLibrary(_this); + /* Better avoid conflicts! */ + if (_this->gl_config.dll_handle != NULL ) { + GL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + } + _this->GL_LoadLibrary = X11_GLES_LoadLibrary; + _this->GL_GetProcAddress = X11_GLES_GetProcAddress; + _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; + _this->GL_CreateContext = X11_GLES_CreateContext; + _this->GL_MakeCurrent = X11_GLES_MakeCurrent; + _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; + _this->GL_SwapWindow = X11_GLES_SwapWindow; + _this->GL_DeleteContext = X11_GLES_DeleteContext; + return X11_GLES_LoadLibrary(_this, NULL); +#else + return SDL_SetError("SDL not configured with EGL support"); +#endif + } + } return 0; } @@ -369,6 +382,11 @@ X11_GL_InitExtensions(_THIS) if (HasExtension("GLX_EXT_visual_info", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; } + + /* Check for GLX_EXT_create_context_es2_profile */ + if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { + _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE; + } if (context) { _this->gl_data->glXMakeCurrent(display, None, NULL); diff --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h index db1b3152e..27d7f9a2f 100644 --- a/src/video/x11/SDL_x11opengl.h +++ b/src/video/x11/SDL_x11opengl.h @@ -34,6 +34,7 @@ struct SDL_GLDriverData SDL_bool HAS_GLX_EXT_visual_rating; SDL_bool HAS_GLX_EXT_visual_info; SDL_bool HAS_GLX_EXT_swap_control_tear; + SDL_bool HAS_GLX_EXT_create_context_es2_profile; Bool (*glXQueryExtension) (Display*,int*,int*); void *(*glXGetProcAddress) (const GLubyte*); diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index ba72aff17..2d2054ae3 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -20,86 +20,22 @@ */ #include "SDL_config.h" -#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL #include "SDL_x11video.h" #include "SDL_x11opengles.h" #include "SDL_x11opengl.h" -#define DEFAULT_EGL "libEGL.so" -#define DEFAULT_OGL_ES2 "libGLESv2.so" -#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" -#define DEFAULT_OGL_ES "libGLESv1_CM.so" - -#define LOAD_FUNC(NAME) \ - *((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \ - if (!_this->gles_data->NAME) \ - { \ - return SDL_SetError("Could not retrieve EGL function " #NAME); \ - } - -/* GLES implementation of SDL OpenGL support */ - -void * -X11_GLES_GetProcAddress(_THIS, const char *proc) -{ - static char procname[1024]; - void *handle; - void *retval; - - handle = _this->gles_data->egl_dll_handle; - if (_this->gles_data->eglGetProcAddress) { - retval = _this->gles_data->eglGetProcAddress(proc); - if (retval) { - return retval; - } - } - - handle = _this->gl_config.dll_handle; -#if defined(__OpenBSD__) && !defined(__ELF__) -#undef dlsym(x,y); -#endif - retval = dlsym(handle, proc); - if (!retval && strlen(proc) <= 1022) { - procname[0] = '_'; - strcpy(procname + 1, proc); - retval = dlsym(handle, procname); - } - return retval; -} - -void -X11_GLES_UnloadLibrary(_THIS) -{ - if ((_this->gles_data) && (_this->gl_config.driver_loaded)) { - _this->gles_data->eglTerminate(_this->gles_data->egl_display); - - dlclose(_this->gl_config.dll_handle); - dlclose(_this->gles_data->egl_dll_handle); - - SDL_free(_this->gles_data); - _this->gles_data = NULL; - - _this->gl_config.dll_handle = NULL; - _this->gl_config.driver_loaded = 0; - } -} +/* EGL implementation of SDL OpenGL support */ int -X11_GLES_LoadLibrary(_THIS, const char *path) -{ - void *handle; - int dlopen_flags; - +X11_GLES_LoadLibrary(_THIS, const char *path) { + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - if (_this->gles_data) { - return SDL_SetError("OpenGL ES context already created"); - } - /* If SDL_GL_CONTEXT_EGL has been changed to 0, switch over to X11_GL functions */ if (_this->gl_config.use_egl == 0) { -#if SDL_VIDEO_OPENGL_GLX + #if SDL_VIDEO_OPENGL_GLX _this->GL_LoadLibrary = X11_GL_LoadLibrary; _this->GL_GetProcAddress = X11_GL_GetProcAddress; _this->GL_UnloadLibrary = X11_GL_UnloadLibrary; @@ -110,331 +46,63 @@ X11_GLES_LoadLibrary(_THIS, const char *path) _this->GL_SwapWindow = X11_GL_SwapWindow; _this->GL_DeleteContext = X11_GL_DeleteContext; return X11_GL_LoadLibrary(_this, path); -#else + #else return SDL_SetError("SDL not configured with OpenGL/GLX support"); -#endif + #endif } - -#ifdef RTLD_GLOBAL - dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; -#else - dlopen_flags = RTLD_LAZY; -#endif - handle = dlopen(path, dlopen_flags); - /* Catch the case where the application isn't linked with EGL */ - if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) { - - dlclose(handle); - path = getenv("SDL_VIDEO_EGL_DRIVER"); - if (path == NULL) { - path = DEFAULT_EGL; - } - handle = dlopen(path, dlopen_flags); - } - - if (handle == NULL) { - return SDL_SetError("Could not load OpenGL ES/EGL library"); - } - - /* Unload the old driver and reset the pointers */ - X11_GLES_UnloadLibrary(_this); - - _this->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData)); - if (!_this->gles_data) { - return SDL_OutOfMemory(); - } - - /* Load new function pointers */ - LOAD_FUNC(eglGetDisplay); - LOAD_FUNC(eglInitialize); - LOAD_FUNC(eglTerminate); - LOAD_FUNC(eglGetProcAddress); - LOAD_FUNC(eglChooseConfig); - LOAD_FUNC(eglGetConfigAttrib); - LOAD_FUNC(eglCreateContext); - LOAD_FUNC(eglDestroyContext); - LOAD_FUNC(eglCreateWindowSurface); - LOAD_FUNC(eglDestroySurface); - LOAD_FUNC(eglMakeCurrent); - LOAD_FUNC(eglSwapBuffers); - LOAD_FUNC(eglSwapInterval); - - _this->gles_data->egl_display = - _this->gles_data->eglGetDisplay((NativeDisplayType) data->display); - - if (!_this->gles_data->egl_display) { - return SDL_SetError("Could not get EGL display"); - } - - if (_this->gles_data-> - eglInitialize(_this->gles_data->egl_display, NULL, - NULL) != EGL_TRUE) { - return SDL_SetError("Could not initialize EGL"); - } - - _this->gles_data->egl_dll_handle = handle; - - path = getenv("SDL_VIDEO_GL_DRIVER"); - handle = dlopen(path, dlopen_flags); - if ((path == NULL) | (handle == NULL)) { - if (_this->gl_config.major_version > 1) { - path = DEFAULT_OGL_ES2; - handle = dlopen(path, dlopen_flags); - } else { - path = DEFAULT_OGL_ES; - handle = dlopen(path, dlopen_flags); - if (handle == NULL) { - path = DEFAULT_OGL_ES_PVR; - handle = dlopen(path, dlopen_flags); - } - } - } - - if (handle == NULL) { - return SDL_SetError("Could not initialize OpenGL ES library"); - } - - _this->gl_config.dll_handle = handle; - _this->gl_config.driver_loaded = 1; - - if (path) { - strncpy(_this->gl_config.driver_path, path, - sizeof(_this->gl_config.driver_path) - 1); - } else { - strcpy(_this->gl_config.driver_path, ""); - } - return 0; + + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) data->display); } XVisualInfo * X11_GLES_GetVisual(_THIS, Display * display, int screen) { - /* 64 seems nice. */ - EGLint attribs[64]; - EGLint found_configs = 0; + + XVisualInfo *egl_visualinfo = NULL; EGLint visual_id; - int i; + XVisualInfo vi_in; + int out_count; - if (!_this->gles_data) { + if (!_this->egl_data) { /* The EGL library wasn't loaded, SDL_GetError() should have info */ return NULL; } - i = 0; - attribs[i++] = EGL_RED_SIZE; - attribs[i++] = _this->gl_config.red_size; - attribs[i++] = EGL_GREEN_SIZE; - attribs[i++] = _this->gl_config.green_size; - attribs[i++] = EGL_BLUE_SIZE; - attribs[i++] = _this->gl_config.blue_size; - - if (_this->gl_config.alpha_size) { - attribs[i++] = EGL_ALPHA_SIZE; - attribs[i++] = _this->gl_config.alpha_size; - } - - if (_this->gl_config.buffer_size) { - attribs[i++] = EGL_BUFFER_SIZE; - attribs[i++] = _this->gl_config.buffer_size; - } - - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; - - if (_this->gl_config.stencil_size) { - attribs[i++] = EGL_STENCIL_SIZE; - attribs[i++] = _this->gl_config.stencil_size; - } - - if (_this->gl_config.multisamplebuffers) { - attribs[i++] = EGL_SAMPLE_BUFFERS; - attribs[i++] = _this->gl_config.multisamplebuffers; - } - - if (_this->gl_config.multisamplesamples) { - attribs[i++] = EGL_SAMPLES; - attribs[i++] = _this->gl_config.multisamplesamples; - } - - attribs[i++] = EGL_RENDERABLE_TYPE; - if (_this->gl_config.major_version == 2) { - attribs[i++] = EGL_OPENGL_ES2_BIT; - } else { - attribs[i++] = EGL_OPENGL_ES_BIT; - } - - attribs[i++] = EGL_NONE; - - if (_this->gles_data->eglChooseConfig(_this->gles_data->egl_display, - attribs, - &_this->gles_data->egl_config, 1, - &found_configs) == EGL_FALSE || - found_configs == 0) { - SDL_SetError("Couldn't find matching EGL config"); - return NULL; - } - - if (_this->gles_data->eglGetConfigAttrib(_this->gles_data->egl_display, - _this->gles_data->egl_config, - EGL_NATIVE_VISUAL_ID, - &visual_id) == - EGL_FALSE || !visual_id) { + if (_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NATIVE_VISUAL_ID, + &visual_id) == EGL_FALSE || !visual_id) { /* Use the default visual when all else fails */ - XVisualInfo vi_in; - int out_count; vi_in.screen = screen; - - _this->gles_data->egl_visualinfo = XGetVisualInfo(display, - VisualScreenMask, - &vi_in, &out_count); + egl_visualinfo = XGetVisualInfo(display, + VisualScreenMask, + &vi_in, &out_count); } else { - XVisualInfo vi_in; - int out_count; - vi_in.screen = screen; vi_in.visualid = visual_id; - _this->gles_data->egl_visualinfo = XGetVisualInfo(display, - VisualScreenMask | - VisualIDMask, - &vi_in, &out_count); + egl_visualinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); } - return _this->gles_data->egl_visualinfo; + return egl_visualinfo; } SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window) { - EGLint context_attrib_list[] = { - EGL_CONTEXT_CLIENT_VERSION, - 1, - EGL_NONE - }; - + SDL_GLContext context; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - SDL_GLContext context = (SDL_GLContext)1; XSync(display, False); - - if (_this->gl_config.major_version) { - context_attrib_list[1] = _this->gl_config.major_version; - } - - _this->gles_data->egl_context = - _this->gles_data->eglCreateContext(_this->gles_data->egl_display, - _this->gles_data->egl_config, - EGL_NO_CONTEXT, context_attrib_list); + context = SDL_EGL_CreateContext(_this, data->egl_surface); XSync(display, False); - if (_this->gles_data->egl_context == EGL_NO_CONTEXT) { - SDL_SetError("Could not create EGL context"); - return NULL; - } - - _this->gles_data->egl_swapinterval = 0; - - if (X11_GLES_MakeCurrent(_this, window, context) < 0) { - X11_GLES_DeleteContext(_this, context); - return NULL; - } - return context; } -int -X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ -/* - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - Display *display = data->videodata->display; -*/ +SDL_EGL_SwapWindow_impl(X11) +SDL_EGL_MakeCurrent_impl(X11) - if (!_this->gles_data) { - return SDL_SetError("OpenGL not initialized"); - } - - if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display, - _this->gles_data->egl_surface, - _this->gles_data->egl_surface, - _this->gles_data->egl_context)) { - return SDL_SetError("Unable to make EGL context current"); - } - -/* - XSync(display, False); -*/ - - return 1; -} - -int -X11_GLES_SetSwapInterval(_THIS, int interval) -{ - if (_this->gles_data) { - return SDL_SetError("OpenGL ES context not active"); - } - - EGLBoolean status; - status = _this->gles_data->eglSwapInterval(_this->gles_data->egl_display, interval); - if (status == EGL_TRUE) { - _this->gles_data->egl_swapinterval = interval; - return 0; - } - - return SDL_SetError("Unable to set the EGL swap interval"); -} - -int -X11_GLES_GetSwapInterval(_THIS) -{ - if (_this->gles_data) { - return SDL_SetError("OpenGL ES context not active"); - } - - return _this->gles_data->egl_swapinterval; -} - -void -X11_GLES_SwapWindow(_THIS, SDL_Window * window) -{ - _this->gles_data->eglSwapBuffers(_this->gles_data->egl_display, - _this->gles_data->egl_surface); -} - -void -X11_GLES_DeleteContext(_THIS, SDL_GLContext context) -{ - /* Clean up GLES and EGL */ - if (!_this->gles_data) { - return; - } - - if (_this->gles_data->egl_context != EGL_NO_CONTEXT || - _this->gles_data->egl_surface != EGL_NO_SURFACE) { - _this->gles_data->eglMakeCurrent(_this->gles_data->egl_display, - EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - - if (_this->gles_data->egl_context != EGL_NO_CONTEXT) { - _this->gles_data->eglDestroyContext(_this->gles_data->egl_display, - _this->gles_data-> - egl_context); - _this->gles_data->egl_context = EGL_NO_CONTEXT; - } - - if (_this->gles_data->egl_surface != EGL_NO_SURFACE) { - _this->gles_data->eglDestroySurface(_this->gles_data->egl_display, - _this->gles_data-> - egl_surface); - _this->gles_data->egl_surface = EGL_NO_SURFACE; - } - } - - /* crappy fix */ - X11_GLES_UnloadLibrary(_this); -} - -#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */ +#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11opengles.h b/src/video/x11/SDL_x11opengles.h index fa1506c76..978f91f3d 100644 --- a/src/video/x11/SDL_x11opengles.h +++ b/src/video/x11/SDL_x11opengles.h @@ -23,81 +23,30 @@ #ifndef _SDL_x11opengles_h #define _SDL_x11opengles_h -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 -#include -#include -#include -#if defined(__OpenBSD__) && !defined(__ELF__) -#define dlsym(x,y) dlsym(x, "_" y) -#endif +#if SDL_VIDEO_OPENGL_EGL #include "../SDL_sysvideo.h" +#include "../SDL_egl.h" typedef struct SDL_PrivateGLESData { - XVisualInfo *egl_visualinfo; - void *egl_dll_handle; - EGLDisplay egl_display; - EGLContext egl_context; /* Current GLES context */ - EGLSurface egl_surface; - EGLConfig egl_config; - int egl_swapinterval; - - EGLDisplay(*eglGetDisplay) (NativeDisplayType display); - EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major, - EGLint * minor); - EGLBoolean(*eglTerminate) (EGLDisplay dpy); - - void *(*eglGetProcAddress) (const char * procName); - - EGLBoolean(*eglChooseConfig) (EGLDisplay dpy, - const EGLint * attrib_list, - EGLConfig * configs, - EGLint config_size, EGLint * num_config); - - EGLContext(*eglCreateContext) (EGLDisplay dpy, - EGLConfig config, - EGLContext share_list, - const EGLint * attrib_list); - - EGLBoolean(*eglDestroyContext) (EGLDisplay dpy, EGLContext ctx); - - EGLSurface(*eglCreateWindowSurface) (EGLDisplay dpy, - EGLConfig config, - NativeWindowType window, - const EGLint * attrib_list); - EGLBoolean(*eglDestroySurface) (EGLDisplay dpy, EGLSurface surface); - - EGLBoolean(*eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw, - EGLSurface read, EGLContext ctx); - - EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw); - - EGLBoolean(*eglSwapInterval) (EGLDisplay dpy, EGLint interval); - - const char *(*eglQueryString) (EGLDisplay dpy, EGLint name); - - EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint * value); - } SDL_PrivateGLESData; /* OpenGLES functions */ -extern SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window); -extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen); -extern int X11_GLES_MakeCurrent(_THIS, SDL_Window * window, - SDL_GLContext context); -extern int X11_GLES_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +#define X11_GLES_GetAttribute SDL_EGL_GetAttribute +#define X11_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define X11_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define X11_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define X11_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define X11_GLES_DeleteContext SDL_EGL_DeleteContext + extern int X11_GLES_LoadLibrary(_THIS, const char *path); -extern void *X11_GLES_GetProcAddress(_THIS, const char *proc); -extern void X11_GLES_UnloadLibrary(_THIS); - -extern int X11_GLES_SetSwapInterval(_THIS, int interval); -extern int X11_GLES_GetSwapInterval(_THIS); +extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen); +extern SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window); extern void X11_GLES_SwapWindow(_THIS, SDL_Window * window); -extern void X11_GLES_DeleteContext(_THIS, SDL_GLContext context); +extern int X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -#endif /* SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 */ +#endif /* SDL_VIDEO_OPENGL_EGL */ #endif /* _SDL_x11opengles_h */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 86597ecf2..83224bcca 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -35,7 +35,7 @@ #include "SDL_x11touch.h" #include "SDL_x11xinput2.h" -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" #endif @@ -394,7 +394,7 @@ X11_CreateDevice(int devindex) device->GL_GetSwapInterval = X11_GL_GetSwapInterval; device->GL_SwapWindow = X11_GL_SwapWindow; device->GL_DeleteContext = X11_GL_DeleteContext; -#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#elif SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = X11_GLES_LoadLibrary; device->GL_GetProcAddress = X11_GLES_GetProcAddress; device->GL_UnloadLibrary = X11_GLES_UnloadLibrary; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 02529e08a..60acd706c 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -34,7 +34,7 @@ #include "SDL_x11shape.h" #include "SDL_x11xinput2.h" -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" #endif @@ -363,11 +363,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) Atom XdndAware, xdnd_version = 5; Uint32 fevent = 0; -#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { XVisualInfo *vinfo; -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_EGL if (_this->gl_config.use_egl == 1) { vinfo = X11_GLES_GetVisual(_this, display, screen); } else @@ -481,26 +481,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) if (!w) { return SDL_SetError("Couldn't create window"); } -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) { - if (!_this->gles_data) { - XDestroyWindow(display, w); - return -1; - } - - /* Create the GLES window surface */ - _this->gles_data->egl_surface = - _this->gles_data->eglCreateWindowSurface(_this->gles_data-> - egl_display, - _this->gles_data->egl_config, - (NativeWindowType) w, NULL); - - if (_this->gles_data->egl_surface == EGL_NO_SURFACE) { - XDestroyWindow(display, w); - return SDL_SetError("Could not create GLES window surface"); - } - } -#endif SetWindowBordered(display, screen, w, (window->flags & SDL_WINDOW_BORDERLESS) == 0); @@ -568,6 +548,24 @@ X11_CreateWindow(_THIS, SDL_Window * window) return -1; } +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 + if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) { + if (!_this->egl_data) { + XDestroyWindow(display, w); + return -1; + } + + /* Create the GLES window surface */ + ((SDL_WindowData *) window->driverdata)->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); + + if (((SDL_WindowData *) window->driverdata)->egl_surface == EGL_NO_SURFACE) { + XDestroyWindow(display, w); + return SDL_SetError("Could not create GLES window surface"); + } + } +#endif + + #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index f53fd8aa2..b0eff5cf4 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -30,6 +30,10 @@ #define PENDING_FOCUS_IN_TIME 200 #define PENDING_FOCUS_OUT_TIME 200 +#if SDL_VIDEO_OPENGL_EGL +#include +#endif + typedef enum { PENDING_FOCUS_NONE, @@ -59,6 +63,9 @@ typedef struct struct SDL_VideoData *videodata; Atom xdnd_req; Window xdnd_source; +#if SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif } SDL_WindowData; extern void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags); From 824641c0ccae5e0b90b274a9725db95c6b34b921 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 12:43:06 -0400 Subject: [PATCH 028/258] Added some FIXMEs for later. --HG-- extra : rebase_source : a82aef2d5065d03cb0a14f9020f9fcc82fb16f12 --- src/core/windows/SDL_windows.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 440c387d3..91a7f4614 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -35,10 +35,13 @@ #include /* Routines to convert from UTF8 to native Windows text */ +/* !!! FIXME: should we force Unicode at this point? */ #if UNICODE +/* !!! FIXME: UCS-2 should be UTF-16 on Windows. */ #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) #define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", (char *)(S), SDL_strlen(S)+1) #else +/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) #endif From 4aff1bfc47ebfb75261cba273498b1fb2d116e2a Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Tue, 20 Aug 2013 15:56:08 -0400 Subject: [PATCH 029/258] add missing SDL_bits.h from OS X framework - also add in headers to static and shared targets (for completeness) --- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 424 ++++++++++++------------ 1 file changed, 214 insertions(+), 210 deletions(-) diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 3757efde0..eec42cb08 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -392,7 +392,7 @@ 566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */; }; 566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; }; A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; }; + A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; }; AA0F8491178D5ECC00823F9D /* SDL_systls.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0F8490178D5ECC00823F9D /* SDL_systls.c */; }; AA0F8492178D5ECC00823F9D /* SDL_systls.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0F8490178D5ECC00823F9D /* SDL_systls.c */; }; @@ -407,105 +407,105 @@ AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AD0159367F2005138DD /* SDL_x11xinput2.h */; }; AA628AD4159367F2005138DD /* SDL_x11xinput2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AD0159367F2005138DD /* SDL_x11xinput2.h */; }; AA7557FA1595D4D800BBD41B /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; }; + AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7557FC1595D4D800BBD41B /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7557FD1595D4D800BBD41B /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; }; + AA7557FD1595D4D800BBD41B /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7557FE1595D4D800BBD41B /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; }; + AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558001595D4D800BBD41B /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; }; + AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558021595D4D800BBD41B /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; }; + AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558041595D4D800BBD41B /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; }; + AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558061595D4D800BBD41B /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; }; + AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558081595D4D800BBD41B /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; }; + AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75580A1595D4D800BBD41B /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; }; + AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75580C1595D4D800BBD41B /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; }; + AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75580E1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; }; + AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558101595D4D800BBD41B /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; }; + AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558121595D4D800BBD41B /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558131595D4D800BBD41B /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; }; + AA7558131595D4D800BBD41B /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558141595D4D800BBD41B /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558151595D4D800BBD41B /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; }; + AA7558151595D4D800BBD41B /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558161595D4D800BBD41B /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; }; + AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; }; + AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75581A1595D4D800BBD41B /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; }; + AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75581E1595D4D800BBD41B /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; }; + AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558201595D4D800BBD41B /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; }; + AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558221595D4D800BBD41B /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; }; + AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558241595D4D800BBD41B /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; }; + AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558261595D4D800BBD41B /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558271595D4D800BBD41B /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; }; + AA7558271595D4D800BBD41B /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558281595D4D800BBD41B /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558291595D4D800BBD41B /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; }; + AA7558291595D4D800BBD41B /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75582A1595D4D800BBD41B /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; }; + AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75582C1595D4D800BBD41B /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; }; + AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75582E1595D4D800BBD41B /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; }; + AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558301595D4D800BBD41B /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; }; + AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558321595D4D800BBD41B /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; }; + AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558341595D4D800BBD41B /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; }; + AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558361595D4D800BBD41B /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; }; + AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558381595D4D800BBD41B /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; }; + AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75583A1595D4D800BBD41B /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; }; + AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75583C1595D4D800BBD41B /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; }; + AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75583E1595D4D800BBD41B /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; }; + AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558401595D4D800BBD41B /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558411595D4D800BBD41B /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; }; + AA7558411595D4D800BBD41B /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558421595D4D800BBD41B /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; }; + AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558441595D4D800BBD41B /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; }; + AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558461595D4D800BBD41B /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; }; + AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558481595D4D800BBD41B /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; }; + AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75584A1595D4D800BBD41B /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; }; + AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75584C1595D4D800BBD41B /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; }; + AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75584E1595D4D800BBD41B /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; }; + AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558501595D4D800BBD41B /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; }; + AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558521595D4D800BBD41B /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; }; + AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558541595D4D800BBD41B /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; }; + AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558561595D4D800BBD41B /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; }; + AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558581595D4D800BBD41B /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558591595D4D800BBD41B /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; }; + AA7558591595D4D800BBD41B /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75585A1595D4D800BBD41B /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; }; + AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75585C1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; }; + AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75585E1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75585F1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; }; + AA75585F1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; }; AA9E4094163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; }; AA9FF95A1637CBF9000DF050 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -513,8 +513,8 @@ AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; }; AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; }; AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; }; - AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; }; - AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; }; + AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; BBFC088D164C6647003E6A99 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; }; D55A1B81179F262300625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; D55A1B82179F262300625D7C /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = D55A1B80179F262300625D7C /* SDL_cocoamousetap.m */; }; @@ -522,6 +522,8 @@ D55A1B84179F263600625D7C /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = D55A1B80179F262300625D7C /* SDL_cocoamousetap.m */; }; D55A1B85179F278E00625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; + DB0F489317C400E6008798C5 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB0F489417C400ED008798C5 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313F7417554B71006C0E22 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; }; DB313F7517554B71006C0E22 /* SDL_dummyaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD9512E6671700899322 /* SDL_dummyaudio.h */; }; DB313F7617554B71006C0E22 /* SDL_coreaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDA112E6671700899322 /* SDL_coreaudio.h */; }; @@ -605,59 +607,59 @@ DB313FC517554B71006C0E22 /* SDL_shaders_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0435673D1303160F00BA5428 /* SDL_shaders_gl.h */; }; DB313FC617554B71006C0E22 /* SDL_rotate.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AC9159367B7005138DD /* SDL_rotate.h */; }; DB313FC717554B71006C0E22 /* SDL_x11xinput2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AD0159367F2005138DD /* SDL_x11xinput2.h */; }; - DB313FC817554B71006C0E22 /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; }; - DB313FC917554B71006C0E22 /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; }; - DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; }; - DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; }; - DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; }; - DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; }; - DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; }; - DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; }; - DB313FD017554B71006C0E22 /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; }; - DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; }; - DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; }; - DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; }; - DB313FD417554B71006C0E22 /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; }; - DB313FD517554B71006C0E22 /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; }; - DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; }; - DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; }; - DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; }; - DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; }; - DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; }; - DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; }; - DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; }; - DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; }; - DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; }; - DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; }; - DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; }; - DB313FE117554B71006C0E22 /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; }; - DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; }; - DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; }; - DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; }; - DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; }; - DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; }; - DB313FE717554B71006C0E22 /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; }; - DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; }; - DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; }; - DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; }; - DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; }; - DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; }; - DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; }; - DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; }; - DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; }; - DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; }; - DB313FF117554B71006C0E22 /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; }; - DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; }; - DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; }; - DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; }; - DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; }; - DB313FF617554B71006C0E22 /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; }; - DB313FF717554B71006C0E22 /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; }; - DB313FF817554B71006C0E22 /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; }; - DB313FF917554B71006C0E22 /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; }; + DB313FC817554B71006C0E22 /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FC917554B71006C0E22 /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD017554B71006C0E22 /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD417554B71006C0E22 /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD517554B71006C0E22 /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE117554B71006C0E22 /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE717554B71006C0E22 /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF117554B71006C0E22 /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF617554B71006C0E22 /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF717554B71006C0E22 /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF817554B71006C0E22 /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF917554B71006C0E22 /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313FFA17554B71006C0E22 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; }; - DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; }; - DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; }; + DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313FFE17554B71006C0E22 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD7412E6671700899322 /* SDL_atomic.c */; }; DB313FFF17554B71006C0E22 /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD7512E6671700899322 /* SDL_spinlock.c */; }; DB31400017554B71006C0E22 /* SDL_diskaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD8812E6671700899322 /* SDL_diskaudio.c */; }; @@ -1722,6 +1724,7 @@ AA7557FE1595D4D800BBD41B /* SDL_assert.h in Headers */, AA7558001595D4D800BBD41B /* SDL_atomic.h in Headers */, AA7558021595D4D800BBD41B /* SDL_audio.h in Headers */, + AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */, AA7558041595D4D800BBD41B /* SDL_blendmode.h in Headers */, AA7558061595D4D800BBD41B /* SDL_clipboard.h in Headers */, AA7558081595D4D800BBD41B /* SDL_config_macosx.h in Headers */, @@ -1854,7 +1857,6 @@ AA628ACC159367B7005138DD /* SDL_rotate.h in Headers */, AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */, AABCC38D164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, - AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */, D55A1B81179F262300625D7C /* SDL_cocoamousetap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1863,6 +1865,59 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */, + AA7557FD1595D4D800BBD41B /* close_code.h in Headers */, + AA75585F1595D4D800BBD41B /* SDL.h in Headers */, + AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */, + AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */, + AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */, + AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */, + AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */, + AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */, + AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */, + AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */, + AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */, + AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */, + AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */, + AA7558131595D4D800BBD41B /* SDL_error.h in Headers */, + AA7558151595D4D800BBD41B /* SDL_events.h in Headers */, + A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */, + AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */, + AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */, + AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */, + AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */, + AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */, + AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */, + AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */, + AA7558271595D4D800BBD41B /* SDL_log.h in Headers */, + AA7558291595D4D800BBD41B /* SDL_main.h in Headers */, + DB0F489417C400ED008798C5 /* SDL_messagebox.h in Headers */, + AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */, + AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */, + AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */, + AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */, + AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */, + AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */, + AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */, + AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */, + AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */, + AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */, + AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */, + AA7558411595D4D800BBD41B /* SDL_render.h in Headers */, + AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */, + AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */, + AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */, + AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */, + AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */, + AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */, + AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */, + AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */, + AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */, + AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */, + AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */, + AA7558591595D4D800BBD41B /* SDL_types.h in Headers */, + AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */, + AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */, 04BD022512E6671800899322 /* SDL_diskaudio.h in Headers */, 04BD022D12E6671800899322 /* SDL_dummyaudio.h in Headers */, 04BD023512E6671800899322 /* SDL_coreaudio.h in Headers */, @@ -1946,59 +2001,7 @@ 043567411303160F00BA5428 /* SDL_shaders_gl.h in Headers */, AA628ACD159367B7005138DD /* SDL_rotate.h in Headers */, AA628AD4159367F2005138DD /* SDL_x11xinput2.h in Headers */, - AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */, - AA7557FD1595D4D800BBD41B /* close_code.h in Headers */, - AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */, - AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */, - AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */, - AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */, - AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */, - AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */, - AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */, - AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */, - AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */, - AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */, - AA7558131595D4D800BBD41B /* SDL_error.h in Headers */, - AA7558151595D4D800BBD41B /* SDL_events.h in Headers */, - AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */, - AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */, - AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */, - AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */, - AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */, - AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */, - AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */, - AA7558271595D4D800BBD41B /* SDL_log.h in Headers */, - AA7558291595D4D800BBD41B /* SDL_main.h in Headers */, - AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */, - AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */, - AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */, - AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */, - AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */, - AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */, - AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */, - AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */, - AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */, - AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */, - AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */, - AA7558411595D4D800BBD41B /* SDL_render.h in Headers */, - AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */, - AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */, - AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */, - AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */, - AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */, - AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */, - AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */, - AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */, - AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */, - AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */, - AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */, - AA7558591595D4D800BBD41B /* SDL_types.h in Headers */, - AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */, - AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */, - AA75585F1595D4D800BBD41B /* SDL.h in Headers */, AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, - A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */, - AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */, D55A1B85179F278E00625D7C /* SDL_cocoamousetap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2007,6 +2010,59 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + DB313FC817554B71006C0E22 /* begin_code.h in Headers */, + DB313FC917554B71006C0E22 /* close_code.h in Headers */, + DB313FF917554B71006C0E22 /* SDL.h in Headers */, + DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */, + DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */, + DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */, + DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */, + DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */, + DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */, + DB313FD017554B71006C0E22 /* SDL_config.h in Headers */, + DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */, + DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */, + DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */, + DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */, + DB313FD417554B71006C0E22 /* SDL_error.h in Headers */, + DB313FD517554B71006C0E22 /* SDL_events.h in Headers */, + DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */, + DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */, + DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */, + DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */, + DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */, + DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */, + DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */, + DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */, + DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */, + DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */, + DB0F489317C400E6008798C5 /* SDL_messagebox.h in Headers */, + DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */, + DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */, + DB313FE117554B71006C0E22 /* SDL_name.h in Headers */, + DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */, + DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */, + DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */, + DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */, + DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */, + DB313FE717554B71006C0E22 /* SDL_power.h in Headers */, + DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */, + DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */, + DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */, + DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */, + DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */, + DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */, + DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */, + DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */, + DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */, + DB313FF117554B71006C0E22 /* SDL_system.h in Headers */, + DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */, + DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */, + DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */, + DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */, + DB313FF617554B71006C0E22 /* SDL_types.h in Headers */, + DB313FF717554B71006C0E22 /* SDL_version.h in Headers */, + DB313FF817554B71006C0E22 /* SDL_video.h in Headers */, DB313F7417554B71006C0E22 /* SDL_diskaudio.h in Headers */, DB313F7517554B71006C0E22 /* SDL_dummyaudio.h in Headers */, DB313F7617554B71006C0E22 /* SDL_coreaudio.h in Headers */, @@ -2090,59 +2146,7 @@ DB313FC517554B71006C0E22 /* SDL_shaders_gl.h in Headers */, DB313FC617554B71006C0E22 /* SDL_rotate.h in Headers */, DB313FC717554B71006C0E22 /* SDL_x11xinput2.h in Headers */, - DB313FC817554B71006C0E22 /* begin_code.h in Headers */, - DB313FC917554B71006C0E22 /* close_code.h in Headers */, - DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */, - DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */, - DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */, - DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */, - DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */, - DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */, - DB313FD017554B71006C0E22 /* SDL_config.h in Headers */, - DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */, - DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */, - DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */, - DB313FD417554B71006C0E22 /* SDL_error.h in Headers */, - DB313FD517554B71006C0E22 /* SDL_events.h in Headers */, - DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */, - DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */, - DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */, - DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */, - DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */, - DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */, - DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */, - DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */, - DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */, - DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */, - DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */, - DB313FE117554B71006C0E22 /* SDL_name.h in Headers */, - DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */, - DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */, - DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */, - DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */, - DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */, - DB313FE717554B71006C0E22 /* SDL_power.h in Headers */, - DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */, - DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */, - DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */, - DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */, - DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */, - DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */, - DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */, - DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */, - DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */, - DB313FF117554B71006C0E22 /* SDL_system.h in Headers */, - DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */, - DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */, - DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */, - DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */, - DB313FF617554B71006C0E22 /* SDL_types.h in Headers */, - DB313FF717554B71006C0E22 /* SDL_version.h in Headers */, - DB313FF817554B71006C0E22 /* SDL_video.h in Headers */, - DB313FF917554B71006C0E22 /* SDL.h in Headers */, DB313FFA17554B71006C0E22 /* SDL_cocoamessagebox.h in Headers */, - DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */, - DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */, D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; From 25c9f2cd30d0a2e2e27b1036fd9da60e2dbb99ee Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Tue, 20 Aug 2013 19:49:24 -0300 Subject: [PATCH 030/258] Fixes a few non C89 compliant comments --- src/events/SDL_gesture.c | 119 ++++++++++++++++++------------------ src/joystick/SDL_joystick.c | 4 +- src/video/SDL_video.c | 2 +- 3 files changed, 63 insertions(+), 62 deletions(-) diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index e987fcfbf..617ea0b4f 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -121,8 +121,8 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) if (src == NULL) return 0; - //No Longer storing the Hash, rehash on load - //if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; + /*No Longer storing the Hash, rehash on load*/ + /*if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;*/ if (SDL_RWwrite(src,templ->path, sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) @@ -158,8 +158,8 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) return SDL_SetError("Unknown gestureId"); } -//path is an already sampled set of points -//Returns the index of the gesture on success, or -1 +/*path is an already sampled set of points +Returns the index of the gesture on success, or -1*/ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) { SDL_DollarTemplate* dollarTemplate; @@ -196,7 +196,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) if (index < 0) return -1; } - // Use the index of the last one added. + /* Use the index of the last one added.*/ return index; } else { return SDL_AddDollarGesture_one(inTouch, path); @@ -223,16 +223,16 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) DOLLARNPOINTS) break; if (touchId >= 0) { - //printf("Adding loaded gesture to 1 touch\n"); + /*printf("Adding loaded gesture to 1 touch\n");*/ if (SDL_AddDollarGesture(touch, templ.path) >= 0) loaded++; } else { - //printf("Adding to: %i touches\n",SDL_numGestureTouches); + /*printf("Adding to: %i touches\n",SDL_numGestureTouches);*/ for (i = 0; i < SDL_numGestureTouches; i++) { touch = &SDL_gestureTouch[i]; - //printf("Adding loaded gesture to + touches\n"); - //TODO: What if this fails? + /*printf("Adding loaded gesture to + touches\n");*/ + /*TODO: What if this fails?*/ SDL_AddDollarGesture(touch,templ.path); } loaded++; @@ -245,7 +245,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { - // SDL_FloatPoint p[DOLLARNPOINTS]; + /* SDL_FloatPoint p[DOLLARNPOINTS];*/ float dist = 0; SDL_FloatPoint p; int i; @@ -261,9 +261,10 @@ static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { - //------------BEGIN DOLLAR BLACKBOX----------------// - //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-// - //-"http://depts.washington.edu/aimgroup/proj/dollar/"-// + /*------------BEGIN DOLLAR BLACKBOX------------------ + -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT- + -"http://depts.washington.edu/aimgroup/proj/dollar/" + */ double ta = -M_PI/4; double tb = M_PI/4; double dt = M_PI/90; @@ -296,7 +297,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) return SDL_min(f1,f2); } -//DollarPath contains raw points, plus (possibly) the calculated length +/*DollarPath contains raw points, plus (possibly) the calculated length*/ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { int i; @@ -309,7 +310,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) float w,h; float length = path->length; - //Calculate length if it hasn't already been done + /*Calculate length if it hasn't already been done*/ if (length <= 0) { for (i=1;i < path->numPoints; i++) { float dx = path->p[i ].x - path->p[i-1].x; @@ -318,17 +319,17 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) } } - //Resample + /*Resample*/ interval = length/(DOLLARNPOINTS - 1); dist = interval; centroid.x = 0;centroid.y = 0; - //printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); + /*printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y);*/ for (i = 1; i < path->numPoints; i++) { float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); - //printf("d = %f dist = %f/%f\n",d,dist,interval); + /*printf("d = %f dist = %f/%f\n",d,dist,interval);*/ while (dist + d > interval) { points[numPoints].x = path->p[i-1].x + ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); @@ -346,15 +347,15 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) SDL_SetError("ERROR: NumPoints = %i\n",numPoints); return 0; } - //copy the last point + /*copy the last point*/ points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; numPoints = DOLLARNPOINTS; centroid.x /= numPoints; centroid.y /= numPoints; - //printf("Centroid (%f,%f)",centroid.x,centroid.y); - //Rotate Points so point 0 is left of centroid and solve for the bounding box + /*printf("Centroid (%f,%f)",centroid.x,centroid.y);*/ + /*Rotate Points so point 0 is left of centroid and solve for the bounding box*/ xmin = centroid.x; xmax = centroid.x; ymin = centroid.y; @@ -378,7 +379,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) if (points[i].y > ymax) ymax = points[i].y; } - //Scale points to DOLLARSIZE, and translate to the origin + /*Scale points to DOLLARSIZE, and translate to the origin*/ w = xmax-xmin; h = ymax-ymin; @@ -399,7 +400,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu dollarNormalize(path,points); - //PrintPath(points); + /*PrintPath(points);*/ *bestTempl = -1; for (i = 0; i < touch->numDollarTemplates; i++) { float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); @@ -435,7 +436,7 @@ static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { - //printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); + /*printf("%i ?= %i\n",SDL_gestureTouch[i].id,id);*/ if (SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i]; } @@ -465,7 +466,7 @@ static int SDL_SendGestureDollar(SDL_GestureTouch* touch, event.mgesture.y = touch->centroid.y; event.dgesture.gestureId = gestureId; event.dgesture.error = error; - //A finger came up to trigger this event. + /*A finger came up to trigger this event.*/ event.dgesture.numFingers = touch->numDownFingers + 1; return SDL_PushEvent(&event) > 0; } @@ -500,13 +501,13 @@ void SDL_GestureProcessEvent(SDL_Event* event) event->type == SDL_FINGERUP) { SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); - //Shouldn't be possible + /*Shouldn't be possible*/ if (inTouch == NULL) return; x = event->tfinger.x; y = event->tfinger.y; - //Finger Up + /*Finger Up*/ if (event->type == SDL_FINGERUP) { inTouch->numDownFingers--; @@ -514,7 +515,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) if (inTouch->recording) { inTouch->recording = SDL_FALSE; dollarNormalize(&inTouch->dollarPath,path); - //PrintPath(path); + /*PrintPath(path);*/ if (recordAll) { index = SDL_AddDollarGesture(NULL,path); for (i = 0; i < SDL_numGestureTouches; i++) @@ -537,14 +538,14 @@ void SDL_GestureProcessEvent(SDL_Event* event) error = dollarRecognize(&inTouch->dollarPath, &bestTempl,inTouch); if (bestTempl >= 0){ - //Send Event + /*Send Event*/ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch,gestureId,error); - //printf ("%s\n",);("Dollar error: %f\n",error); + /*printf ("%s\n",);("Dollar error: %f\n",error);*/ } } #endif - //inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; + /*inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];*/ if (inTouch->numDownFingers > 0) { inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- x)/inTouch->numDownFingers; @@ -574,22 +575,22 @@ void SDL_GestureProcessEvent(SDL_Event* event) inTouch->centroid.x += dx/inTouch->numDownFingers; inTouch->centroid.y += dy/inTouch->numDownFingers; - //printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); + /*printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y);*/ if (inTouch->numDownFingers > 1) { - SDL_FloatPoint lv; //Vector from centroid to last x,y position - SDL_FloatPoint v; //Vector from centroid to current x,y position - //lv = inTouch->gestureLast[j].cv; + SDL_FloatPoint lv; /*Vector from centroid to last x,y position*/ + SDL_FloatPoint v; /*Vector from centroid to current x,y position*/ + /*lv = inTouch->gestureLast[j].cv;*/ lv.x = lastP.x - lastCentroid.x; lv.y = lastP.y - lastCentroid.y; lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); - //printf("lDist = %f\n",lDist); + /*printf("lDist = %f\n",lDist);*/ v.x = x - inTouch->centroid.x; v.y = y - inTouch->centroid.y; - //inTouch->gestureLast[j].cv = v; + /*inTouch->gestureLast[j].cv = v;*/ Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); - // SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) + /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)*/ - //Normalize Vectors to simplify angle calculation + /*Normalize Vectors to simplify angle calculation*/ lv.x/=lDist; lv.y/=lDist; v.x/=Dist; @@ -597,30 +598,30 @@ void SDL_GestureProcessEvent(SDL_Event* event) dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); dDist = (Dist - lDist); - if (lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values + if (lDist == 0) {dDist = 0;dtheta = 0;} /*To avoid impossible values*/ - //inTouch->gestureLast[j].dDist = dDist; - //inTouch->gestureLast[j].dtheta = dtheta; + /*inTouch->gestureLast[j].dDist = dDist; + inTouch->gestureLast[j].dtheta = dtheta; - //printf("dDist = %f, dTheta = %f\n",dDist,dtheta); - //gdtheta = gdtheta*.9 + dtheta*.1; - //gdDist = gdDist*.9 + dDist*.1 - //knob.r += dDist/numDownFingers; - //knob.ang += dtheta; - //printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); - //printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); + printf("dDist = %f, dTheta = %f\n",dDist,dtheta); + gdtheta = gdtheta*.9 + dtheta*.1; + gdDist = gdDist*.9 + dDist*.1 + knob.r += dDist/numDownFingers; + knob.ang += dtheta; + printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); + printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);*/ SDL_SendGestureMulti(inTouch,dtheta,dDist); } else { - //inTouch->gestureLast[j].dDist = 0; - //inTouch->gestureLast[j].dtheta = 0; - //inTouch->gestureLast[j].cv.x = 0; - //inTouch->gestureLast[j].cv.y = 0; + /*inTouch->gestureLast[j].dDist = 0; + inTouch->gestureLast[j].dtheta = 0; + inTouch->gestureLast[j].cv.x = 0; + inTouch->gestureLast[j].cv.y = 0;*/ } - //inTouch->gestureLast[j].f.p.x = x; - //inTouch->gestureLast[j].f.p.y = y; - //break; - //pressure? + /*inTouch->gestureLast[j].f.p.x = x; + inTouch->gestureLast[j].f.p.y = y; + break; + pressure?*/ } if (event->type == SDL_FINGERDOWN) { @@ -630,8 +631,8 @@ void SDL_GestureProcessEvent(SDL_Event* event) x)/inTouch->numDownFingers; inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ y)/inTouch->numDownFingers; - //printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, - // inTouch->centroid.x,inTouch->centroid.y); + /*printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, + inTouch->centroid.x,inTouch->centroid.y);*/ #ifdef ENABLE_DOLLAR inTouch->dollarPath.length = 0; diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index bb8652f4d..b1197093e 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -488,14 +488,14 @@ SDL_PrivateJoystickShouldIgnoreEvent() if (SDL_WasInit(SDL_INIT_VIDEO)) { if (SDL_GetKeyboardFocus() == NULL) { - // Video is initialized and we don't have focus, ignore the event. + /* Video is initialized and we don't have focus, ignore the event.*/ return SDL_TRUE; } else { return SDL_FALSE; } } - // Video subsystem wasn't initialized, always allow the event + /* Video subsystem wasn't initialized, always allow the event*/ return SDL_FALSE; } diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b5c16e509..77abae9f2 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1761,7 +1761,7 @@ SDL_MaximizeWindow(SDL_Window * window) return; } - // !!! FIXME: should this check if the window is resizable? + /* !!! FIXME: should this check if the window is resizable? */ if (_this->MaximizeWindow) { _this->MaximizeWindow(_this, window); From 5e78879e762bbaf092998f03c52350c008b1a883 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Tue, 20 Aug 2013 20:34:40 -0300 Subject: [PATCH 031/258] More non C89 compliant comments --- include/SDL_config_psp.h | 4 +- include/SDL_test_harness.h | 12 +- src/audio/directsound/SDL_directsound.c | 2 +- src/audio/psp/SDL_pspaudio.c | 8 +- src/core/android/SDL_android.c | 148 ++++++++++++------------ src/events/scancodes_windows.h | 36 +++--- src/joystick/windows/SDL_dxjoystick.c | 4 +- src/main/android/SDL_android_main.c | 6 +- src/render/direct3d/SDL_render_d3d.c | 2 +- src/render/psp/SDL_render_psp.c | 18 +-- src/video/bwindow/SDL_BWin.h | 8 +- src/video/bwindow/SDL_bopengl.h | 10 +- src/video/windows/SDL_windowsevents.c | 2 +- src/video/windows/SDL_windowswindow.c | 2 +- test/testautomation_main.c | 16 +-- test/testautomation_platform.c | 18 +-- test/testautomation_rect.c | 86 +++++++------- test/testautomation_rwops.c | 6 +- test/testautomation_suites.h | 4 +- test/testfile.c | 2 +- test/testgesture.c | 16 +-- test/testime.c | 6 +- test/testmessage.c | 4 +- test/testrendercopyex.c | 2 +- test/testresample.c | 6 +- test/testshader.c | 58 +++++----- test/testshape.c | 12 +- test/testwm2.c | 2 +- 28 files changed, 252 insertions(+), 248 deletions(-) diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index bf456f688..85cf53c27 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -99,8 +99,8 @@ #define HAVE_SQRT 1 #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 -//#define HAVE_SYSCONF 1 -//#define HAVE_SIGACTION 1 +/*#define HAVE_SYSCONF 1*/ +/*#define HAVE_SIGACTION 1*/ /* PSP isn't that sophisticated */ diff --git a/include/SDL_test_harness.h b/include/SDL_test_harness.h index d2da04f1e..00381aa6d 100644 --- a/include/SDL_test_harness.h +++ b/include/SDL_test_harness.h @@ -43,30 +43,30 @@ extern "C" { #endif -//! Definitions for test case structures +/*! Definitions for test case structures*/ #define TEST_ENABLED 1 #define TEST_DISABLED 0 -//! Definition of all the possible test return values of the test case method +/*! Definition of all the possible test return values of the test case method*/ #define TEST_ABORTED -1 #define TEST_STARTED 0 #define TEST_COMPLETED 1 #define TEST_SKIPPED 2 -//! Definition of all the possible test results for the harness +/*! Definition of all the possible test results for the harness*/ #define TEST_RESULT_PASSED 0 #define TEST_RESULT_FAILED 1 #define TEST_RESULT_NO_ASSERT 2 #define TEST_RESULT_SKIPPED 3 #define TEST_RESULT_SETUP_FAILURE 4 -//!< Function pointer to a test case setup function (run before every test) +/*!< Function pointer to a test case setup function (run before every test)*/ typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); -//!< Function pointer to a test case function +/*!< Function pointer to a test case function*/ typedef int (*SDLTest_TestCaseFp)(void *arg); -//!< Function pointer to a test case teardown function (run after every test) +/*!< Function pointer to a test case teardown function (run after every test)*/ typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); /** diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 686d46615..23167bf1b 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -510,7 +510,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) if (!valid_format) { DSOUND_CloseDevice(this); if (tried_format) { - return -1; // CreateSecondary() should have called SDL_SetError(). + return -1; /* CreateSecondary() should have called SDL_SetError(). */ } return SDL_SetError("DirectSound: Unsupported audio format"); } diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 4b5534a3c..6e0a283be 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -63,7 +63,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.freq = 44100; /* Update the fragment size as size in bytes. */ -// SDL_CalculateAudioSpec(this->spec); MOD +/* SDL_CalculateAudioSpec(this->spec); MOD*/ switch (this->spec.format) { case AUDIO_U8: this->spec.silence = 0x80; @@ -76,7 +76,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.size *= this->spec.channels; this->spec.size *= this->spec.samples; -//========================================== +/*==========================================*/ /* Allocate the mixing buffer. Its size and starting address must be a multiple of 64 bytes. Our sample count is already a multiple of @@ -162,7 +162,7 @@ static int PSPAUD_Init(SDL_AudioDriverImpl * impl) { - // Set the function pointers + /* Set the function pointers*/ impl->OpenDevice = PSPAUD_OpenDevice; impl->PlayDevice = PSPAUD_PlayDevice; impl->WaitDevice = PSPAUD_WaitDevice; @@ -171,7 +171,7 @@ PSPAUD_Init(SDL_AudioDriverImpl * impl) impl->CloseDevice = PSPAUD_CloseDevice; impl->ThreadInit = PSPAUD_ThreadInit; - //PSP audio device + /*PSP audio device*/ impl->OnlyHasDefaultOutputDevice = 1; /* impl->HasCaptureSupport = 1; diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 7606859da..8af2926d3 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -40,13 +40,13 @@ #include #include #define LOG_TAG "SDL_android" -//#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) -//#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) +/*#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)*/ +/*#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)*/ #define LOGI(...) do {} while (false) #define LOGE(...) do {} while (false) /* Uncomment this to log messages entering and exiting methods in this file */ -//#define DEBUG_JNI +/*#define DEBUG_JNI */ static void Android_JNI_ThreadDestroyed(void*); @@ -64,10 +64,10 @@ static void Android_JNI_ThreadDestroyed(void*); static pthread_key_t mThreadKey; static JavaVM* mJavaVM; -// Main activity +/* Main activity */ static jclass mActivityClass; -// method signatures +/* method signatures */ static jmethodID midGetNativeSurface; static jmethodID midFlipBuffers; static jmethodID midAudioInit; @@ -75,7 +75,7 @@ static jmethodID midAudioWriteShortBuffer; static jmethodID midAudioWriteByteBuffer; static jmethodID midAudioQuit; -// Accelerometer data storage +/* Accelerometer data storage */ static float fLastAccelerometer[3]; static bool bHasNewData; @@ -83,7 +83,7 @@ static bool bHasNewData; Functions called by JNI *******************************************************************************/ -// Library init +/* Library init */ jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv *env; @@ -107,7 +107,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) return JNI_VERSION_1_4; } -// Called before SDL_main() to initialize JNI bindings +/* Called before SDL_main() to initialize JNI bindings */ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) { __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()"); @@ -138,7 +138,7 @@ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init() finished!"); } -// Resize +/* Resize */ void Java_org_libsdl_app_SDLActivity_onNativeResize( JNIEnv* env, jclass jcls, jint width, jint height, jint format) @@ -147,7 +147,7 @@ void Java_org_libsdl_app_SDLActivity_onNativeResize( } -// Surface Created +/* Surface Created */ void Java_org_libsdl_app_SDLActivity_onNativeSurfaceChanged(JNIEnv* env, jclass jcls) { SDL_WindowData *data; @@ -173,7 +173,7 @@ void Java_org_libsdl_app_SDLActivity_onNativeSurfaceChanged(JNIEnv* env, jclass } -// Surface Destroyed +/* Surface Destroyed */ void Java_org_libsdl_app_SDLActivity_onNativeSurfaceDestroyed(JNIEnv* env, jclass jcls) { /* We have to clear the current context and destroy the egl surface here @@ -205,21 +205,21 @@ void Java_org_libsdl_app_SDLActivity_nativeFlipBuffers(JNIEnv* env, jclass jcls) SDL_GL_SwapWindow(Android_Window); } -// Keydown +/* Keydown */ void Java_org_libsdl_app_SDLActivity_onNativeKeyDown( JNIEnv* env, jclass jcls, jint keycode) { Android_OnKeyDown(keycode); } -// Keyup +/* Keyup */ void Java_org_libsdl_app_SDLActivity_onNativeKeyUp( JNIEnv* env, jclass jcls, jint keycode) { Android_OnKeyUp(keycode); } -// Keyboard Focus Lost +/* Keyboard Focus Lost */ void Java_org_libsdl_app_SDLActivity_onNativeKeyboardFocusLost( JNIEnv* env, jclass jcls) { @@ -228,7 +228,7 @@ void Java_org_libsdl_app_SDLActivity_onNativeKeyboardFocusLost( } -// Touch +/* Touch */ void Java_org_libsdl_app_SDLActivity_onNativeTouch( JNIEnv* env, jclass jcls, jint touch_device_id_in, jint pointer_finger_id_in, @@ -237,7 +237,7 @@ void Java_org_libsdl_app_SDLActivity_onNativeTouch( Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p); } -// Accelerometer +/* Accelerometer */ void Java_org_libsdl_app_SDLActivity_onNativeAccel( JNIEnv* env, jclass jcls, jfloat x, jfloat y, jfloat z) @@ -248,23 +248,23 @@ void Java_org_libsdl_app_SDLActivity_onNativeAccel( bHasNewData = true; } -// Low memory +/* Low memory */ void Java_org_libsdl_app_SDLActivity_nativeLowMemory( JNIEnv* env, jclass cls) { SDL_SendAppEvent(SDL_APP_LOWMEMORY); } -// Quit +/* Quit */ void Java_org_libsdl_app_SDLActivity_nativeQuit( JNIEnv* env, jclass cls) { - // Inject a SDL_QUIT event + /* Inject a SDL_QUIT event */ SDL_SendQuit(); SDL_SendAppEvent(SDL_APP_TERMINATING); } -// Pause +/* Pause */ void Java_org_libsdl_app_SDLActivity_nativePause( JNIEnv* env, jclass cls) { @@ -280,7 +280,7 @@ void Java_org_libsdl_app_SDLActivity_nativePause( SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND); } -// Resume +/* Resume */ void Java_org_libsdl_app_SDLActivity_nativeResume( JNIEnv* env, jclass cls) { @@ -468,9 +468,9 @@ int Android_JNI_SetupThread(void) { return 1; } -// -// Audio support -// +/* + * Audio support + */ static jboolean audioBuffer16Bit = JNI_FALSE; static jboolean audioBufferStereo = JNI_FALSE; static jobject audioBuffer = NULL; @@ -568,8 +568,8 @@ void Android_JNI_CloseAudioDevice() } } -// Test for an exception and call SDL_SetError with its detail if one occurs -// If the parameter silent is truthy then SDL_SetError() will not be called. +/* Test for an exception and call SDL_SetError with its detail if one occurs */ +/* If the parameter silent is truthy then SDL_SetError() will not be called. */ static bool Android_JNI_ExceptionOccurred(bool silent) { SDL_assert(LocalReferenceHolder_IsActive()); @@ -579,7 +579,7 @@ static bool Android_JNI_ExceptionOccurred(bool silent) if (exception != NULL) { jmethodID mid; - // Until this happens most JNI operations have undefined behaviour + /* Until this happens most JNI operations have undefined behaviour */ (*mEnv)->ExceptionClear(mEnv); if (!silent) { @@ -635,13 +635,13 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) fileNameJString = (jstring)ctx->hidden.androidio.fileNameRef; ctx->hidden.androidio.position = 0; - // context = SDLActivity.getContext(); + /* context = SDLActivity.getContext(); */ mid = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getContext","()Landroid/content/Context;"); context = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, mid); - // assetManager = context.getAssets(); + /* assetManager = context.getAssets(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context), "getAssets", "()Landroid/content/res/AssetManager;"); assetManager = (*mEnv)->CallObjectMethod(mEnv, context, mid); @@ -674,18 +674,18 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) ctx->hidden.androidio.fd = (*mEnv)->GetIntField(mEnv, fd, descriptor); ctx->hidden.androidio.assetFileDescriptorRef = (*mEnv)->NewGlobalRef(mEnv, inputStream); - // Seek to the correct offset in the file. + /* Seek to the correct offset in the file. */ lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET); if (false) { fallback: - // Disabled log message because of spam on the Nexus 7 - //__android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); + /* Disabled log message because of spam on the Nexus 7 */ + /*__android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file");*/ /* Try the old method using InputStream */ ctx->hidden.androidio.assetFileDescriptorRef = NULL; - // inputStream = assetManager.open(); + /* inputStream = assetManager.open(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "open", "(Ljava/lang/String;I)Ljava/io/InputStream;"); inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /*ACCESS_RANDOM*/); @@ -695,13 +695,14 @@ fallback: ctx->hidden.androidio.inputStreamRef = (*mEnv)->NewGlobalRef(mEnv, inputStream); - // Despite all the visible documentation on [Asset]InputStream claiming - // that the .available() method is not guaranteed to return the entire file - // size, comments in /samples//ApiDemos/src/com/example/ ... - // android/apis/content/ReadAsset.java imply that Android's - // AssetInputStream.available() /will/ always return the total file size - - // size = inputStream.available(); + /* Despite all the visible documentation on [Asset]InputStream claiming + * that the .available() method is not guaranteed to return the entire file + * size, comments in /samples//ApiDemos/src/com/example/ ... + * android/apis/content/ReadAsset.java imply that Android's + * AssetInputStream.available() /will/ always return the total file size + */ + + /* size = inputStream.available(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "available", "()I"); ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid); @@ -709,7 +710,7 @@ fallback: goto failure; } - // readableByteChannel = Channels.newChannel(inputStream); + /* readableByteChannel = Channels.newChannel(inputStream); */ channels = (*mEnv)->FindClass(mEnv, "java/nio/channels/Channels"); mid = (*mEnv)->GetStaticMethodID(mEnv, channels, "newChannel", @@ -723,7 +724,7 @@ fallback: ctx->hidden.androidio.readableByteChannelRef = (*mEnv)->NewGlobalRef(mEnv, readableByteChannel); - // Store .read id for reading purposes + /* Store .read id for reading purposes */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, readableByteChannel), "read", "(Ljava/nio/ByteBuffer;)I"); ctx->hidden.androidio.readMethod = mid; @@ -819,7 +820,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, jobject byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining); while (bytesRemaining > 0) { - // result = readableByteChannel.read(...); + /* result = readableByteChannel.read(...); */ int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer); if (Android_JNI_ExceptionOccurred(false)) { @@ -877,7 +878,7 @@ static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release) else { jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef; - // inputStream.close(); + /* inputStream.close();*/ jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "close", "()V"); (*mEnv)->CallVoidMethod(mEnv, inputStream, mid); @@ -956,7 +957,7 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) if (movement > 0) { unsigned char buffer[4096]; - // The easy case where we're seeking forwards + /* The easy case where we're seeking forwards */ while (movement > 0) { Sint64 amount = sizeof (buffer); if (amount > movement) { @@ -964,7 +965,7 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) } size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount); if (result <= 0) { - // Failed to read/skip the required amount, so fail + /* Failed to read/skip the required amount, so fail */ return -1; } @@ -972,8 +973,8 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) } } else if (movement < 0) { - // We can't seek backwards so we have to reopen the file and seek - // forwards which obviously isn't very efficient + /* We can't seek backwards so we have to reopen the file and seek */ + /* forwards which obviously isn't very efficient */ Internal_Android_JNI_FileClose(ctx, false); Internal_Android_JNI_FileOpen(ctx); Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET); @@ -989,7 +990,7 @@ int Android_JNI_FileClose(SDL_RWops* ctx) return Internal_Android_JNI_FileClose(ctx, true); } -// returns a new global reference which needs to be released later +/* returns a new global reference which needs to be released later */ static jobject Android_JNI_GetSystemServiceObject(const char* name) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); @@ -1089,9 +1090,10 @@ SDL_bool Android_JNI_HasClipboardText() } -// returns 0 on success or -1 on error (others undefined then) -// returns truthy or falsy value in plugged, charged and battery -// returns the value in seconds and percent or -1 if not available +/* returns 0 on success or -1 on error (others undefined then) + * returns truthy or falsy value in plugged, charged and battery + * returns the value in seconds and percent or -1 if not available + */ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); @@ -1139,38 +1141,38 @@ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seco (*env)->DeleteLocalRef(env, bname); if (plugged) { - GET_INT_EXTRA(plug, "plugged") // == BatteryManager.EXTRA_PLUGGED (API 5) + GET_INT_EXTRA(plug, "plugged") /* == BatteryManager.EXTRA_PLUGGED (API 5) */ if (plug == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } - // 1 == BatteryManager.BATTERY_PLUGGED_AC - // 2 == BatteryManager.BATTERY_PLUGGED_USB + /* 1 == BatteryManager.BATTERY_PLUGGED_AC */ + /* 2 == BatteryManager.BATTERY_PLUGGED_USB */ *plugged = (0 < plug) ? 1 : 0; } if (charged) { - GET_INT_EXTRA(status, "status") // == BatteryManager.EXTRA_STATUS (API 5) + GET_INT_EXTRA(status, "status") /* == BatteryManager.EXTRA_STATUS (API 5) */ if (status == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } - // 5 == BatteryManager.BATTERY_STATUS_FULL + /* 5 == BatteryManager.BATTERY_STATUS_FULL */ *charged = (status == 5) ? 1 : 0; } if (battery) { - GET_BOOL_EXTRA(present, "present") // == BatteryManager.EXTRA_PRESENT (API 5) + GET_BOOL_EXTRA(present, "present") /* == BatteryManager.EXTRA_PRESENT (API 5) */ *battery = present ? 1 : 0; } if (seconds) { - *seconds = -1; // not possible + *seconds = -1; /* not possible */ } if (percent) { - GET_INT_EXTRA(level, "level") // == BatteryManager.EXTRA_LEVEL (API 5) - GET_INT_EXTRA(scale, "scale") // == BatteryManager.EXTRA_SCALE (API 5) + GET_INT_EXTRA(level, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */ + GET_INT_EXTRA(scale, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */ if ((level == -1) || (scale == -1)) { LocalReferenceHolder_Cleanup(&refs); return -1; @@ -1184,7 +1186,7 @@ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seco return 0; } -// sends message to be handled on the UI event dispatch thread +/* sends message to be handled on the UI event dispatch thread */ int Android_JNI_SendMessage(int command, int param) { JNIEnv *env = Android_JNI_GetEnv(); @@ -1219,15 +1221,17 @@ void Android_JNI_ShowTextInput(SDL_Rect *inputRect) void Android_JNI_HideTextInput() { - // has to match Activity constant + /* has to match Activity constant */ const int COMMAND_TEXTEDIT_HIDE = 3; Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0); } +/* ////////////////////////////////////////////////////////////////////////////// // // Functions exposed to SDL applications in SDL_system.h -// +////////////////////////////////////////////////////////////////////////////// +*/ void *SDL_AndroidGetJNIEnv() { @@ -1247,7 +1251,7 @@ void *SDL_AndroidGetActivity() return NULL; } - // return SDLActivity.getContext(); + /* return SDLActivity.getContext(); */ mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); return (*env)->CallStaticObjectMethod(env, mActivityClass, mid); @@ -1271,12 +1275,12 @@ const char * SDL_AndroidGetInternalStoragePath() return NULL; } - // context = SDLActivity.getContext(); + /* context = SDLActivity.getContext(); */ mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid); - // fileObj = context.getFilesDir(); + /* fileObj = context.getFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getFilesDir", "()Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid); @@ -1286,7 +1290,7 @@ const char * SDL_AndroidGetInternalStoragePath() return NULL; } - // path = fileObject.getAbsolutePath(); + /* path = fileObject.getAbsolutePath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); @@ -1322,7 +1326,7 @@ int SDL_AndroidGetExternalStorageState() state = (*env)->GetStringUTFChars(env, stateString, NULL); - // Print an info message so people debugging know the storage state + /* Print an info message so people debugging know the storage state */ __android_log_print(ANDROID_LOG_INFO, "SDL", "external storage state: %s", state); if (SDL_strcmp(state, "mounted") == 0) { @@ -1357,12 +1361,12 @@ const char * SDL_AndroidGetExternalStoragePath() return NULL; } - // context = SDLActivity.getContext(); + /* context = SDLActivity.getContext(); */ mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid); - // fileObj = context.getExternalFilesDir(); + /* fileObj = context.getExternalFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid, NULL); @@ -1372,7 +1376,7 @@ const char * SDL_AndroidGetExternalStoragePath() return NULL; } - // path = fileObject.getAbsolutePath(); + /* path = fileObject.getAbsolutePath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); diff --git a/src/events/scancodes_windows.h b/src/events/scancodes_windows.h index 1034b1b57..3462e14ef 100644 --- a/src/events/scancodes_windows.h +++ b/src/events/scancodes_windows.h @@ -26,30 +26,30 @@ /* *INDENT-OFF* */ static const SDL_Scancode windows_scancode_table[] = { - // 0 1 2 3 4 5 6 7 - // 8 9 A B C D E F - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, // 0 - SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9, SDL_SCANCODE_0, SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_TAB, // 0 + /* 0 1 2 3 4 5 6 7 */ + /* 8 9 A B C D E F */ + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, /* 0 */ + SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9, SDL_SCANCODE_0, SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_TAB, /* 0 */ - SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_E, SDL_SCANCODE_R, SDL_SCANCODE_T, SDL_SCANCODE_Y, SDL_SCANCODE_U, SDL_SCANCODE_I, // 1 - SDL_SCANCODE_O, SDL_SCANCODE_P, SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_RETURN, SDL_SCANCODE_LCTRL, SDL_SCANCODE_A, SDL_SCANCODE_S, // 1 + SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_E, SDL_SCANCODE_R, SDL_SCANCODE_T, SDL_SCANCODE_Y, SDL_SCANCODE_U, SDL_SCANCODE_I, /* 1 */ + SDL_SCANCODE_O, SDL_SCANCODE_P, SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_RETURN, SDL_SCANCODE_LCTRL, SDL_SCANCODE_A, SDL_SCANCODE_S, /* 1 */ - SDL_SCANCODE_D, SDL_SCANCODE_F, SDL_SCANCODE_G, SDL_SCANCODE_H, SDL_SCANCODE_J, SDL_SCANCODE_K, SDL_SCANCODE_L, SDL_SCANCODE_SEMICOLON, // 2 - SDL_SCANCODE_APOSTROPHE, SDL_SCANCODE_GRAVE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C, SDL_SCANCODE_V, // 2 + SDL_SCANCODE_D, SDL_SCANCODE_F, SDL_SCANCODE_G, SDL_SCANCODE_H, SDL_SCANCODE_J, SDL_SCANCODE_K, SDL_SCANCODE_L, SDL_SCANCODE_SEMICOLON, /* 2 */ + SDL_SCANCODE_APOSTROPHE, SDL_SCANCODE_GRAVE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C, SDL_SCANCODE_V, /* 2 */ - SDL_SCANCODE_B, SDL_SCANCODE_N, SDL_SCANCODE_M, SDL_SCANCODE_COMMA, SDL_SCANCODE_PERIOD, SDL_SCANCODE_SLASH, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_PRINTSCREEN,// 3 - SDL_SCANCODE_LALT, SDL_SCANCODE_SPACE, SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_F1, SDL_SCANCODE_F2, SDL_SCANCODE_F3, SDL_SCANCODE_F4, SDL_SCANCODE_F5, // 3 + SDL_SCANCODE_B, SDL_SCANCODE_N, SDL_SCANCODE_M, SDL_SCANCODE_COMMA, SDL_SCANCODE_PERIOD, SDL_SCANCODE_SLASH, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_PRINTSCREEN,/* 3 */ + SDL_SCANCODE_LALT, SDL_SCANCODE_SPACE, SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_F1, SDL_SCANCODE_F2, SDL_SCANCODE_F3, SDL_SCANCODE_F4, SDL_SCANCODE_F5, /* 3 */ - SDL_SCANCODE_F6, SDL_SCANCODE_F7, SDL_SCANCODE_F8, SDL_SCANCODE_F9, SDL_SCANCODE_F10, SDL_SCANCODE_NUMLOCKCLEAR, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_HOME, // 4 - SDL_SCANCODE_UP, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_5, SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_END, // 4 + SDL_SCANCODE_F6, SDL_SCANCODE_F7, SDL_SCANCODE_F8, SDL_SCANCODE_F9, SDL_SCANCODE_F10, SDL_SCANCODE_NUMLOCKCLEAR, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_HOME, /* 4 */ + SDL_SCANCODE_UP, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_5, SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_END, /* 4 */ - SDL_SCANCODE_DOWN, SDL_SCANCODE_PAGEDOWN, SDL_SCANCODE_INSERT, SDL_SCANCODE_DELETE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_NONUSBACKSLASH,SDL_SCANCODE_F11, // 5 - SDL_SCANCODE_F12, SDL_SCANCODE_PAUSE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_LGUI, SDL_SCANCODE_RGUI, SDL_SCANCODE_APPLICATION, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 5 + SDL_SCANCODE_DOWN, SDL_SCANCODE_PAGEDOWN, SDL_SCANCODE_INSERT, SDL_SCANCODE_DELETE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_NONUSBACKSLASH,SDL_SCANCODE_F11, /* 5 */ + SDL_SCANCODE_F12, SDL_SCANCODE_PAUSE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_LGUI, SDL_SCANCODE_RGUI, SDL_SCANCODE_APPLICATION, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 5 */ - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, // 6 - SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 6 + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, /* 6 */ + SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 6 */ - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 7 - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN // 7 + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 7 */ + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */ }; /* *INDENT-ON* */ diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 5a832abd8..0c915a96d 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -433,8 +433,8 @@ BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) return SDL_FALSE; } - // Check for well known XInput device GUIDs - // We need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list. + /* Check for well known XInput device GUIDs */ + /* We need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list. */ for ( iDevice = 0; iDevice < SDL_arraysize(s_XInputProductGUID); ++iDevice ) { if (SDL_memcmp(pGuidProductFromDirectInput, s_XInputProductGUID[iDevice], sizeof(GUID)) == 0) { return SDL_TRUE; diff --git a/src/main/android/SDL_android_main.c b/src/main/android/SDL_android_main.c index 0622a12c4..649bd4ffa 100644 --- a/src/main/android/SDL_android_main.c +++ b/src/main/android/SDL_android_main.c @@ -11,10 +11,10 @@ *******************************************************************************/ #include -// Called before SDL_main() to initialize JNI bindings in SDL library +/* Called before SDL_main() to initialize JNI bindings in SDL library */ extern void SDL_Android_Init(JNIEnv* env, jclass cls); -// Start up the SDL app +/* Start up the SDL app */ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) { /* This interface could expand with ABI negotiation, calbacks, etc. */ @@ -30,7 +30,7 @@ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject status = SDL_main(1, argv); /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ - //exit(status); + /*exit(status);*/ } #endif /* __ANDROID__ */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index fb45f882f..b51cb012b 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1033,7 +1033,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, HRESULT result; if (data->yuv) { - // It's more efficient to upload directly... + /* It's more efficient to upload directly... */ if (!data->pixels) { data->pitch = texture->w; data->pixels = (Uint8 *)SDL_malloc((texture->h * data->pitch * 3) / 2); diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 7ea536d14..3b7666c18 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -458,7 +458,7 @@ PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { -// PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; +/* PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata;*/ PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture));; if(!psp_texture) @@ -528,7 +528,7 @@ static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { -// PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; +/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata;*/ const Uint8 *src; Uint8 *dst; int row, length,dpitch; @@ -895,8 +895,8 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, sceGuColor(0xFFFFFFFF); } -// x += width * 0.5f; -// y += height * 0.5f; +/* x += width * 0.5f;*/ +/* y += height * 0.5f;*/ x += centerx; y += centery; @@ -904,8 +904,8 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, MathSincos(degToRad(angle), &s, &c); -// width *= 0.5f; -// height *= 0.5f; +/* width *= 0.5f;*/ +/* height *= 0.5f;*/ width -= centerx; height -= centery; @@ -968,7 +968,7 @@ PSP_RenderPresent(SDL_Renderer * renderer) sceGuFinish(); sceGuSync(0,0); -// if(data->vsync) +/* if(data->vsync)*/ sceDisplayWaitVblankStart(); data->backbuffer = data->frontbuffer; @@ -1007,8 +1007,8 @@ PSP_DestroyRenderer(SDL_Renderer * renderer) StartDrawing(renderer); sceGuTerm(); -// vfree(data->backbuffer); -// vfree(data->frontbuffer); +/* vfree(data->backbuffer);*/ +/* vfree(data->frontbuffer);*/ data->initialized = SDL_FALSE; data->displayListAvail = SDL_FALSE; diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index fb576da68..9540bd323 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -353,7 +353,7 @@ class SDL_BWin:public BDirectWindow - CTRL+Q to close window (and other shortcuts) - PrintScreen to make screenshot into /boot/home - etc.. */ - //BDirectWindow::DispatchMessage(msg, target); + /*BDirectWindow::DispatchMessage(msg, target);*/ break; } @@ -461,9 +461,9 @@ private: msg.AddBool("focusGained", focusGained); _PostWindowEvent(msg); -//FIXME: Why were these here? -// if false: be_app->SetCursor(B_HAND_CURSOR); -// if true: SDL_SetCursor(NULL); +/*FIXME: Why were these here? + if false: be_app->SetCursor(B_HAND_CURSOR); + if true: SDL_SetCursor(NULL);*/ } void _MouseButtonEvent(int32 buttons) { diff --git a/src/video/bwindow/SDL_bopengl.h b/src/video/bwindow/SDL_bopengl.h index f0279ba66..a7e924bce 100644 --- a/src/video/bwindow/SDL_bopengl.h +++ b/src/video/bwindow/SDL_bopengl.h @@ -29,13 +29,13 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int BE_GL_LoadLibrary(_THIS, const char *path); //FIXME -extern void *BE_GL_GetProcAddress(_THIS, const char *proc); //FIXME -extern void BE_GL_UnloadLibrary(_THIS); //TODO +extern int BE_GL_LoadLibrary(_THIS, const char *path); /*FIXME*/ +extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /*FIXME*/ +extern void BE_GL_UnloadLibrary(_THIS); /*TODO*/ extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern int BE_GL_SetSwapInterval(_THIS, int interval); //TODO -extern int BE_GL_GetSwapInterval(_THIS); //TODO +extern int BE_GL_SetSwapInterval(_THIS, int interval); /*TODO*/ +extern int BE_GL_GetSwapInterval(_THIS); /*TODO*/ extern void BE_GL_SwapWindow(_THIS, SDL_Window * window); extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window); extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context); diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index e9326b504..bf7d0117f 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -533,7 +533,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; } } - // no break + /* no break */ case WM_CHAR: { char text[5]; diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index e83115f00..94f555baf 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -157,7 +157,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) int w = rect.right; int h = rect.bottom; if ((window->w && window->w != w) || (window->h && window->h != h)) { - // We tried to create a window larger than the desktop and Windows didn't allow it. Override! + /* We tried to create a window larger than the desktop and Windows didn't allow it. Override! */ WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE); } else { window->w = w; diff --git a/test/testautomation_main.c b/test/testautomation_main.c index f695903c2..481e3daae 100644 --- a/test/testautomation_main.c +++ b/test/testautomation_main.c @@ -79,16 +79,16 @@ static int main_testImpliedJoystickInit (void *arg) #else int initialized_system; - // First initialize the controller + /* First initialize the controller */ SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); - // Then make sure this implicitly initialized the joystick subsystem + /* Then make sure this implicitly initialized the joystick subsystem */ initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); - // Then quit the controller, and make sure that implicitly also quits the - // joystick subsystem + /* Then quit the controller, and make sure that implicitly also quits the */ + /* joystick subsystem */ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); @@ -104,17 +104,17 @@ static int main_testImpliedJoystickQuit (void *arg) #else int initialized_system; - // First initialize the controller and the joystick (explicitly) + /* First initialize the controller and the joystick (explicitly) */ SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)" ); SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); - // Then make sure they're both initialized properly + /* Then make sure they're both initialized properly */ initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); - // Then quit the controller, and make sure that it does NOT quit the - // explicitly initialized joystick subsystem. + /* Then quit the controller, and make sure that it does NOT quit the */ + /* explicitly initialized joystick subsystem. */ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); diff --git a/test/testautomation_platform.c b/test/testautomation_platform.c index 5ed2abad1..06699ad96 100644 --- a/test/testautomation_platform.c +++ b/test/testautomation_platform.c @@ -168,7 +168,7 @@ int platform_testHasFunctions (void *arg) { int ret; - // TODO: independently determine and compare values as well + /* TODO: independently determine and compare values as well */ ret = SDL_HasRDTSC(); SDLTest_AssertPass("SDL_HasRDTSC()"); @@ -315,7 +315,7 @@ int platform_testGetSetClearError(void *arg) lastError); } - // Clean up + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); @@ -351,7 +351,7 @@ int platform_testSetErrorEmptyInput(void *arg) lastError); } - // Clean up + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); @@ -370,11 +370,11 @@ int platform_testSetErrorInvalidInput(void *arg) char *lastError; int len; - // Reset + /* Reset */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); - // Check for no-op + /* Check for no-op */ SDL_SetError(testError); SDLTest_AssertPass("SDL_SetError()"); lastError = (char *)SDL_GetError(); @@ -392,11 +392,11 @@ int platform_testSetErrorInvalidInput(void *arg) lastError); } - // Set + /* Set */ SDL_SetError(probeError); SDLTest_AssertPass("SDL_SetError()"); - // Check for no-op + /* Check for no-op */ SDL_SetError(testError); SDLTest_AssertPass("SDL_SetError()"); lastError = (char *)SDL_GetError(); @@ -415,7 +415,7 @@ int platform_testSetErrorInvalidInput(void *arg) lastError); } - // Clean up + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); @@ -472,7 +472,7 @@ int platform_testGetPowerInfo(void *arg) pct); } - // Partial return value variations + /* Partial return value variations */ stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); SDLTest_AssertCheck( state==stateAgain, diff --git a/test/testautomation_rect.c b/test/testautomation_rect.c index 77a7347e6..7d80f8927 100644 --- a/test/testautomation_rect.c +++ b/test/testautomation_rect.c @@ -423,7 +423,7 @@ int rect_testIntersectRectInside (void *arg) SDL_Rect result; SDL_bool intersection; - // rectB fully contained in rectA + /* rectB fully contained in rectA */ refRectB.x = 0; refRectB.y = 0; refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); @@ -451,7 +451,7 @@ int rect_testIntersectRectOutside (void *arg) SDL_Rect result; SDL_bool intersection; - // rectB fully outside of rectA + /* rectB fully outside of rectA */ refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10); refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10); refRectB.w = refRectA.w; @@ -480,7 +480,7 @@ int rect_testIntersectRectPartial (void *arg) SDL_Rect expectedResult; SDL_bool intersection; - // rectB partially contained in rectA + /* rectB partially contained in rectA */ refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); refRectB.w = refRectA.w; @@ -494,7 +494,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB right edge + /* rectB right edge */ refRectB.x = rectA.w - 1; refRectB.y = rectA.y; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -508,7 +508,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB left edge + /* rectB left edge */ refRectB.x = 1 - rectA.w; refRectB.y = rectA.y; refRectB.w = refRectA.w; @@ -522,7 +522,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB bottom edge + /* rectB bottom edge */ refRectB.x = rectA.x; refRectB.y = rectA.h - 1; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -536,7 +536,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB top edge + /* rectB top edge */ refRectB.x = rectA.x; refRectB.y = 1 - rectA.h; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -569,7 +569,7 @@ int rect_testIntersectRectPoint (void *arg) SDL_bool intersection; int offsetX, offsetY; - // intersecting pixels + /* intersecting pixels */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; @@ -579,7 +579,7 @@ int rect_testIntersectRectPoint (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA); - // non-intersecting pixels cases + /* non-intersecting pixels cases */ for (offsetX = -1; offsetX <= 1; offsetX++) { for (offsetY = -1; offsetY <= 1; offsetY++) { if (offsetX != 0 || offsetY != 0) { @@ -616,7 +616,7 @@ int rect_testIntersectRectEmpty (void *arg) SDL_bool intersection; SDL_bool empty; - // Rect A empty + /* Rect A empty */ result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100); @@ -633,7 +633,7 @@ int rect_testIntersectRectEmpty (void *arg) empty = (SDL_bool)SDL_RectEmpty(&result); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - // Rect B empty + /* Rect B empty */ result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100); @@ -650,7 +650,7 @@ int rect_testIntersectRectEmpty (void *arg) empty = (SDL_bool)SDL_RectEmpty(&result); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - // Rect A and B empty + /* Rect A and B empty */ result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100); @@ -685,7 +685,7 @@ int rect_testIntersectRectParam(void *arg) SDL_Rect result; SDL_bool intersection; - // invalid parameter combinations + /* invalid parameter combinations */ intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result); SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result); @@ -716,7 +716,7 @@ int rect_testHasIntersectionInside (void *arg) SDL_Rect rectB; SDL_bool intersection; - // rectB fully contained in rectA + /* rectB fully contained in rectA */ refRectB.x = 0; refRectB.y = 0; refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); @@ -743,7 +743,7 @@ int rect_testHasIntersectionOutside (void *arg) SDL_Rect rectB; SDL_bool intersection; - // rectB fully outside of rectA + /* rectB fully outside of rectA */ refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10); refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10); refRectB.w = refRectA.w; @@ -770,7 +770,7 @@ int rect_testHasIntersectionPartial (void *arg) SDL_Rect rectB; SDL_bool intersection; - // rectB partially contained in rectA + /* rectB partially contained in rectA */ refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); refRectB.w = refRectA.w; @@ -780,7 +780,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB right edge + /* rectB right edge */ refRectB.x = rectA.w - 1; refRectB.y = rectA.y; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -790,7 +790,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB left edge + /* rectB left edge */ refRectB.x = 1 - rectA.w; refRectB.y = rectA.y; refRectB.w = refRectA.w; @@ -800,7 +800,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB bottom edge + /* rectB bottom edge */ refRectB.x = rectA.x; refRectB.y = rectA.h - 1; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -810,7 +810,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB top edge + /* rectB top edge */ refRectB.x = rectA.x; refRectB.y = 1 - rectA.h; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -838,7 +838,7 @@ int rect_testHasIntersectionPoint (void *arg) SDL_bool intersection; int offsetX, offsetY; - // intersecting pixels + /* intersecting pixels */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; @@ -848,7 +848,7 @@ int rect_testHasIntersectionPoint (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // non-intersecting pixels cases + /* non-intersecting pixels cases */ for (offsetX = -1; offsetX <= 1; offsetX++) { for (offsetY = -1; offsetY <= 1; offsetY++) { if (offsetX != 0 || offsetY != 0) { @@ -883,7 +883,7 @@ int rect_testHasIntersectionEmpty (void *arg) SDL_Rect rectB; SDL_bool intersection; - // Rect A empty + /* Rect A empty */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectA.w = SDLTest_RandomIntegerInRange(1, 100); @@ -896,7 +896,7 @@ int rect_testHasIntersectionEmpty (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - // Rect B empty + /* Rect B empty */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectA.w = SDLTest_RandomIntegerInRange(1, 100); @@ -909,7 +909,7 @@ int rect_testHasIntersectionEmpty (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - // Rect A and B empty + /* Rect A and B empty */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectA.w = SDLTest_RandomIntegerInRange(1, 100); @@ -939,7 +939,7 @@ int rect_testHasIntersectionParam(void *arg) SDL_Rect rectB; SDL_bool intersection; - // invalid parameter combinations + /* invalid parameter combinations */ intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB); SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL); @@ -969,7 +969,7 @@ int rect_testEnclosePoints(void *arg) int minx = 0, maxx = 0, miny = 0, maxy = 0; int i; - // Create input data, tracking result + /* Create input data, tracking result */ for (i=0; i diff --git a/test/testgesture.c b/test/testgesture.c index 7d4fe78cc..3e0fc9dd4 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -49,7 +49,7 @@ #define BPP 4 #define DEPTH 32 -//MUST BE A POWER OF 2! +/*MUST BE A POWER OF 2!*/ #define EVENT_BUF_SIZE 256 @@ -102,9 +102,9 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); SDL_GetRGB(colour,screen->format,&r,&g,&b); - //r = 0;g = 0; b = 0; + /*r = 0;g = 0; b = 0;*/ a = (float)((col>>24)&0xFF); - if(a == 0) a = 0xFF; //Hack, to make things easier. + if(a == 0) a = 0xFF; /*Hack, to make things easier.*/ a /= 0xFF; r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a)); g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); @@ -127,7 +127,7 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) float xr; for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) { xr = (float)sqrt(r*r - ty*ty); - if(r > 0) { //r > 0 ==> filled circle + if(r > 0) { /*r > 0 ==> filled circle*/ for(tx=-xr+.5f;tx<=xr-.5;tx++) { setpix(screen,x+tx,y+ty,c); } @@ -157,7 +157,7 @@ void DrawScreen(SDL_Surface* screen) setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); #endif - //draw Touch History + /*draw Touch History*/ for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; @@ -170,7 +170,7 @@ void DrawScreen(SDL_Surface* screen) x = event->tfinger.x; y = event->tfinger.y; - //draw the touch: + /*draw the touch:*/ c = colors[event->tfinger.fingerId%7]; col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - //gesture variables + /*gesture variables*/ knob.r = .1f; knob.ang = 0; @@ -225,7 +225,7 @@ int main(int argc, char* argv[]) while(!quitting) { while(SDL_PollEvent(&event)) { - //Record _all_ events + /*Record _all_ events*/ events[eventWrite & (EVENT_BUF_SIZE-1)] = event; eventWrite++; diff --git a/test/testime.c b/test/testime.c index 44f1b1903..2975e84b9 100644 --- a/test/testime.c +++ b/test/testime.c @@ -135,7 +135,7 @@ void _Redraw(SDL_Renderer * renderer) { markedRect.w = textRect.w - w; if (markedRect.w < 0) { - // Stop text input because we cannot hold any more characters + /* Stop text input because we cannot hold any more characters */ SDL_StopTextInput(); return; } @@ -342,8 +342,8 @@ int main(int argc, char *argv[]) { SDL_Log("text inputed: %s\n", text); - // After text inputed, we can clear up markedText because it - // is committed + /* After text inputed, we can clear up markedText because it */ + /* is committed*/ markedText[0] = 0; Redraw(); break; diff --git a/test/testmessage.c b/test/testmessage.c index 330462362..9faa39007 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -46,12 +46,12 @@ button_messagebox(void *eventNumber) SDL_MessageBoxData data = { SDL_MESSAGEBOX_INFORMATION, - NULL, // no parent window + NULL, /* no parent window */ "Custom MessageBox", "This is a custom messagebox", 2, buttons, - NULL // Default color scheme + NULL /* Default color scheme */ }; int button = -1; diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index a0221fe0f..2ba739e09 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -127,7 +127,7 @@ Draw(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); - //SDL_Delay(10); + /*SDL_Delay(10);*/ } int diff --git a/test/testresample.c b/test/testresample.c index 177bd8413..a6e859d36 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -107,12 +107,12 @@ main(int argc, char **argv) SDL_FreeWAV(data); SDL_Quit(); return 8; - } // if + } /* if */ SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); return 0; -} // main +} /* main */ -// end of resample_test.c ... +/* end of resample_test.c ... */ diff --git a/test/testshader.c b/test/testshader.c index 138dd45f8..04467709e 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -332,19 +332,19 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) } /* A general OpenGL initialization function. Sets all of the initial parameters. */ -void InitGL(int Width, int Height) // We call this right after our OpenGL window is created. +void InitGL(int Width, int Height) /* We call this right after our OpenGL window is created. */ { GLdouble aspect; glViewport(0, 0, Width, Height); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black - glClearDepth(1.0); // Enables Clearing Of The Depth Buffer - glDepthFunc(GL_LESS); // The Type Of Depth Test To Do - glEnable(GL_DEPTH_TEST); // Enables Depth Testing - glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); /* This Will Clear The Background Color To Black */ + glClearDepth(1.0); /* Enables Clearing Of The Depth Buffer */ + glDepthFunc(GL_LESS); /* The Type Of Depth Test To Do */ + glEnable(GL_DEPTH_TEST); /* Enables Depth Testing */ + glShadeModel(GL_SMOOTH); /* Enables Smooth Color Shading */ glMatrixMode(GL_PROJECTION); - glLoadIdentity(); // Reset The Projection Matrix + glLoadIdentity(); /* Reset The Projection Matrix */ aspect = (GLdouble)Width / Height; glOrtho(-3.0, 3.0, -3.0 / aspect, 3.0 / aspect, 0.0, 1.0); @@ -363,29 +363,29 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) MAXY }; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer - glLoadIdentity(); // Reset The View + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Clear The Screen And The Depth Buffer */ + glLoadIdentity(); /* Reset The View */ - glTranslatef(-1.5f,0.0f,0.0f); // Move Left 1.5 Units + glTranslatef(-1.5f,0.0f,0.0f); /* Move Left 1.5 Units */ - // draw a triangle (in smooth coloring mode) - glBegin(GL_POLYGON); // start drawing a polygon - glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red - glVertex3f( 0.0f, 1.0f, 0.0f); // Top - glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green - glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right - glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue - glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left - glEnd(); // we're done with the polygon (smooth color interpolation) + /* draw a triangle (in smooth coloring mode) */ + glBegin(GL_POLYGON); /* start drawing a polygon */ + glColor3f(1.0f,0.0f,0.0f); /* Set The Color To Red */ + glVertex3f( 0.0f, 1.0f, 0.0f); /* Top */ + glColor3f(0.0f,1.0f,0.0f); /* Set The Color To Green */ + glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ + glColor3f(0.0f,0.0f,1.0f); /* Set The Color To Blue */ + glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ + glEnd(); /* we're done with the polygon (smooth color interpolation) */ - glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units + glTranslatef(3.0f,0.0f,0.0f); /* Move Right 3 Units */ - // Enable blending + /* Enable blending */ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // draw a textured square (quadrilateral) + /* draw a textured square (quadrilateral) */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glColor3f(1.0f,1.0f,1.0f); @@ -393,23 +393,23 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) glUseProgramObjectARB(shaders[current_shader].program); } - glBegin(GL_QUADS); // start drawing a polygon (4 sided) + glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */ glTexCoord2f(texcoord[MINX], texcoord[MINY]); - glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left + glVertex3f(-1.0f, 1.0f, 0.0f); /* Top Left */ glTexCoord2f(texcoord[MAXX], texcoord[MINY]); - glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right + glVertex3f( 1.0f, 1.0f, 0.0f); /* Top Right */ glTexCoord2f(texcoord[MAXX], texcoord[MAXY]); - glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right + glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ glTexCoord2f(texcoord[MINX], texcoord[MAXY]); - glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left - glEnd(); // done with the polygon + glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ + glEnd(); /* done with the polygon */ if (shaders_supported) { glUseProgramObjectARB(0); } glDisable(GL_TEXTURE_2D); - // swap buffers to display, since we're double buffered. + /* swap buffers to display, since we're double buffered. */ SDL_GL_SwapWindow(window); } diff --git a/test/testshape.c b/test/testshape.c index 5c969b30e..6a117953f 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -29,11 +29,11 @@ typedef struct LoadedPicture { void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions) { - //Clear render-target to blue. + /*Clear render-target to blue.*/ SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); SDL_RenderClear(renderer); - //Render the texture. + /*Render the texture.*/ SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); SDL_RenderPresent(renderer); @@ -188,17 +188,17 @@ int main(int argc,char** argv) next_time += TICK_INTERVAL; } - //Free the textures. + /*Free the textures.*/ for(i=0;i Date: Tue, 20 Aug 2013 14:17:48 -0400 Subject: [PATCH 032/258] Added SDL_assert_always (never disabled). --HG-- extra : rebase_source : ff08944ae7b6f86458840f29a3bf82ccb89b0307 --- include/SDL_assert.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/SDL_assert.h b/include/SDL_assert.h index 5a6afc5e2..53ee9ba74 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -165,6 +165,9 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, # error Unknown assertion level. #endif +/* this assertion is never disabled at any level. */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)( const SDL_assert_data* data, void* userdata); From 5b99be4382092b2b9f044f02fa8114467d7d5f71 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 14:21:35 -0400 Subject: [PATCH 033/258] Added SDL_DEPRECATED #define. --HG-- extra : rebase_source : 865047af634b49c9f5101656e1055d0278720633 --- include/begin_code.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/begin_code.h b/include/begin_code.h index bed798414..902aeb114 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -33,6 +33,14 @@ #endif #define _begin_code_h +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + /* Some compilers use a special export keyword */ #ifndef DECLSPEC # if defined(__WIN32__) From a001caf9027a21c20f3ff7ce66912d509571ef17 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 15:28:14 -0400 Subject: [PATCH 034/258] Fixed cut-and-paste error. --HG-- extra : rebase_source : 95c9c82bc324e35b10e4f3a5199c792d06d71f5b --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 925392ebb..d79b84bb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1008,7 +1008,7 @@ endif(NOT HAVE_SDL_HAPTIC) if(NOT HAVE_SDL_LOADSO) set(SDL_LOADSO_DISABLED 1) file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c) - set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) + set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES}) endif(NOT HAVE_SDL_LOADSO) # We always need to have threads and timers around From 2b9a2802b2a5d4163496b656c09e4ce0c1a35a06 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 19:57:11 -0400 Subject: [PATCH 035/258] Added SDL_GetBasePath() and SDL_GetPrefPath() in new filesystem module. --HG-- extra : rebase_source : c1fac232063443a2880e64f1abda85e0bdb2e710 --- .hgignore | 1 + Android.mk | 1 + CMakeLists.txt | 33 ++++- Makefile.in | 1 + Makefile.minimal | 1 + Makefile.pandora | 2 +- Makefile.psp | 1 + VisualC/SDL/SDL_VS2008.vcproj | 8 + VisualC/SDL/SDL_VS2010.vcxproj | 2 + VisualC/SDL/SDL_VS2012.vcxproj | 4 +- configure | 62 +++++++- configure.in | 41 ++++++ include/SDL.h | 1 + include/SDL_config.h.cmake | 8 + include/SDL_config.h.in | 8 + include/SDL_config_android.h | 3 + include/SDL_config_iphoneos.h | 3 + include/SDL_config_macosx.h | 3 + include/SDL_config_minimal.h | 3 + include/SDL_config_pandora.h | 1 + include/SDL_config_psp.h | 3 + include/SDL_config_windows.h | 3 + include/SDL_filesystem.h | 136 +++++++++++++++++ src/filesystem/beos/SDL_sysfilesystem.cc | 92 ++++++++++++ src/filesystem/cocoa/SDL_sysfilesystem.m | 93 ++++++++++++ src/filesystem/dummy/SDL_sysfilesystem.c | 47 ++++++ src/filesystem/unix/SDL_sysfilesystem.c | 161 +++++++++++++++++++++ src/filesystem/windows/SDL_sysfilesystem.c | 96 ++++++++++++ test/Makefile.in | 4 + test/testfilesystem.c | 33 +++++ 30 files changed, 848 insertions(+), 7 deletions(-) create mode 100644 include/SDL_filesystem.h create mode 100644 src/filesystem/beos/SDL_sysfilesystem.cc create mode 100644 src/filesystem/cocoa/SDL_sysfilesystem.m create mode 100644 src/filesystem/dummy/SDL_sysfilesystem.c create mode 100644 src/filesystem/unix/SDL_sysfilesystem.c create mode 100644 src/filesystem/windows/SDL_sysfilesystem.c create mode 100644 test/testfilesystem.c diff --git a/.hgignore b/.hgignore index b6c427f82..c4b118779 100644 --- a/.hgignore +++ b/.hgignore @@ -76,6 +76,7 @@ test/testnative test/testoverlay2 test/testplatform test/testpower +test/testfilesystem test/testrelative test/testrendercopyex test/testrendertarget diff --git a/Android.mk b/Android.mk index 7338233c1..f3fcb3a19 100755 --- a/Android.mk +++ b/Android.mk @@ -33,6 +33,7 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/android/*.c) \ + $(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \ $(wildcard $(LOCAL_PATH)/src/render/*.c) \ $(wildcard $(LOCAL_PATH)/src/render/*/*.c) \ $(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \ diff --git a/CMakeLists.txt b/CMakeLists.txt index d79b84bb1..8eca0c6b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,7 @@ include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include) set(SDL_SUBSYSTEMS Atomic Audio Video Render Events Joystick Haptic Power Threads Timers - File Loadso CPUinfo) + File Loadso CPUinfo Filesystem) foreach(_SUB ${SDL_SUBSYSTEMS}) string(TOUPPER ${_SUB} _OPT) option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON) @@ -714,6 +714,13 @@ if(UNIX AND NOT APPLE) endif(LINUX) endif(SDL_POWER) + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_UNIX 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/unix/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif(SDL_FILESYSTEM) + if(SDL_TIMERS) set(SDL_TIMER_UNIX 1) file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c) @@ -814,6 +821,13 @@ elseif(WINDOWS) set(HAVE_SDL_POWER TRUE) endif(SDL_POWER) + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_WINDOWS 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesytem/windows/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif(SDL_FILESYSTEM) + # Libraries for Win32 native and MinGW list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid) @@ -924,6 +938,13 @@ elseif(APPLE) set(SDL_FRAMEWORK_IOKIT 1) endif() + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_COCOA 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif() + # Actually load the frameworks at the end so we don't duplicate include. if(SDL_FRAMEWORK_COCOA) find_library(COCOA_LIBRARY Cocoa) @@ -973,6 +994,11 @@ elseif(BEOS) set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES}) set(HAVE_SDL_VIDEO TRUE) + set(SDL_FILESYSTEM_BEOS 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/beos/*.cc) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + if(VIDEO_OPENGL) # TODO: Use FIND_PACKAGE(OpenGL) instead set(SDL_VIDEO_OPENGL 1) @@ -1010,6 +1036,11 @@ if(NOT HAVE_SDL_LOADSO) file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES}) endif(NOT HAVE_SDL_LOADSO) +if(NOT HAVE_SDL_FILESYSTEM) + set(SDL_FILESYSTEM_DISABLED 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) +endif(NOT HAVE_SDL_FILESYSTEM) # We always need to have threads and timers around if(NOT HAVE_SDL_THREADS) diff --git a/Makefile.in b/Makefile.in index ae6293e7d..da42661c5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -54,6 +54,7 @@ HDRS = \ SDL_endian.h \ SDL_error.h \ SDL_events.h \ + SDL_filesystem.h \ SDL_gamecontroller.h \ SDL_gesture.h \ SDL_haptic.h \ diff --git a/Makefile.minimal b/Makefile.minimal index a06083230..6ec1ce81c 100644 --- a/Makefile.minimal +++ b/Makefile.minimal @@ -19,6 +19,7 @@ SOURCES = \ src/joystick/dummy/*.c \ src/loadso/dummy/*.c \ src/power/*.c \ + src/filesystem/dummy/*.c \ src/render/*.c \ src/render/software/*.c \ src/stdlib/*.c \ diff --git a/Makefile.pandora b/Makefile.pandora index de15c846b..bb89d52a6 100644 --- a/Makefile.pandora +++ b/Makefile.pandora @@ -19,7 +19,7 @@ SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \ ./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \ ./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \ ./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \ - ./src/atomic/linux/*.c \ + ./src/atomic/linux/*.c ./src/filesystem/unix/*.c \ ./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o ./src/video/x11/*.c diff --git a/Makefile.psp b/Makefile.psp index 8bcdcb927..5e7dcd29a 100644 --- a/Makefile.psp +++ b/Makefile.psp @@ -31,6 +31,7 @@ OBJS= src/SDL.o \ src/joystick/psp/SDL_sysjoystick.o \ src/power/SDL_power.o \ src/power/psp/SDL_syspower.o \ + src/filesystem/dummy/SDL_sysfilesystem.o \ src/render/SDL_render.o \ src/render/SDL_yuv_sw.o \ src/render/psp/SDL_render_psp.o \ diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj index 72eb2d4c9..1e7db21a3 100644 --- a/VisualC/SDL/SDL_VS2008.vcproj +++ b/VisualC/SDL/SDL_VS2008.vcproj @@ -427,6 +427,10 @@ RelativePath="..\..\include\SDL_events.h" > + + @@ -1088,6 +1092,10 @@ RelativePath="..\..\src\events\SDL_sysevents.h" > + + diff --git a/VisualC/SDL/SDL_VS2010.vcxproj b/VisualC/SDL/SDL_VS2010.vcxproj index 4fa9111d2..58807a5af 100644 --- a/VisualC/SDL/SDL_VS2010.vcxproj +++ b/VisualC/SDL/SDL_VS2010.vcxproj @@ -229,6 +229,7 @@ + @@ -430,6 +431,7 @@ + diff --git a/VisualC/SDL/SDL_VS2012.vcxproj b/VisualC/SDL/SDL_VS2012.vcxproj index 213c10cef..141bc6481 100644 --- a/VisualC/SDL/SDL_VS2012.vcxproj +++ b/VisualC/SDL/SDL_VS2012.vcxproj @@ -19,7 +19,7 @@ - SDL2 + SDL2 {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} SDL @@ -233,6 +233,7 @@ + @@ -433,6 +434,7 @@ + diff --git a/configure b/configure index 41adac4b0..f4c3f6ae4 100755 --- a/configure +++ b/configure @@ -783,6 +783,7 @@ enable_events enable_joystick enable_haptic enable_power +enable_filesystem enable_threads enable_timers enable_file @@ -1496,6 +1497,7 @@ Optional Features: --enable-haptic Enable the haptic (force feedback) subsystem [[default=yes]] --enable-power Enable the power subsystem [[default=yes]] + --enable-filesystem Enable the filesystem subsystem [[default=yes]] --enable-threads Enable the threading subsystem [[default=yes]] --enable-timers Enable the timer subsystem [[default=yes]] --enable-file Enable the file subsystem [[default=yes]] @@ -16767,6 +16769,7 @@ SOURCES="$SOURCES $srcdir/src/haptic/*.c" SOURCES="$SOURCES $srcdir/src/joystick/*.c" SOURCES="$SOURCES $srcdir/src/libm/*.c" SOURCES="$SOURCES $srcdir/src/power/*.c" +#SOURCES="$SOURCES $srcdir/src/filesystem/*.c" SOURCES="$SOURCES $srcdir/src/render/*.c" SOURCES="$SOURCES $srcdir/src/render/*/*.c" SOURCES="$SOURCES $srcdir/src/stdlib/*.c" @@ -16870,6 +16873,18 @@ if test x$enable_power != xyes; then $as_echo "#define SDL_POWER_DISABLED 1" >>confdefs.h +fi +# Check whether --enable-filesystem was given. +if test "${enable_filesystem+set}" = set; then : + enableval=$enable_filesystem; +else + enable_filesystem=yes +fi + +if test x$enable_filesystem != xyes; then + +$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h + fi # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then : @@ -22120,6 +22135,14 @@ $as_echo "#define SDL_POWER_LINUX 1" >>confdefs.h ;; esac fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then @@ -22222,6 +22245,13 @@ $as_echo "#define SDL_POWER_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c" have_power=yes fi + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c" + have_filesystem=yes + fi # Set up files for the thread library if test x$enable_threads = xyes; then @@ -22355,6 +22385,14 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/beos/*.c" have_power=yes fi + # Set up files for the system filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_BEOS 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/power/beos/*.cc" + have_filesystem=yes + fi # The BeOS platform requires special setup. SOURCES="$srcdir/src/main/beos/*.cc $SOURCES" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding" @@ -22389,10 +22427,10 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h # have_haptic=yes # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback" #fi - # Set up files for the power library - if test x$enable_power = xyes; then - SOURCES="$SOURCES $srcdir/src/power/uikit/*.m" - have_power=yes + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes fi # Set up files for the timer library if test x$enable_timers = xyes; then @@ -22475,6 +22513,14 @@ $as_echo "#define SDL_POWER_MACOSX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/macosx/*.c" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then @@ -22541,6 +22587,14 @@ $as_echo "#define SDL_TIMERS_DISABLED 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c" fi +if test x$have_filesystem != xyes; then + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h + + fi + SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c" +fi if test x$have_loadso != xyes; then if test x$enable_loadso = xyes; then diff --git a/configure.in b/configure.in index de32e6a12..f9d0bf2ed 100644 --- a/configure.in +++ b/configure.in @@ -325,6 +325,7 @@ SOURCES="$SOURCES $srcdir/src/haptic/*.c" SOURCES="$SOURCES $srcdir/src/joystick/*.c" SOURCES="$SOURCES $srcdir/src/libm/*.c" SOURCES="$SOURCES $srcdir/src/power/*.c" +#SOURCES="$SOURCES $srcdir/src/filesystem/*.c" SOURCES="$SOURCES $srcdir/src/render/*.c" SOURCES="$SOURCES $srcdir/src/render/*/*.c" SOURCES="$SOURCES $srcdir/src/stdlib/*.c" @@ -382,6 +383,12 @@ AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]), if test x$enable_power != xyes; then AC_DEFINE(SDL_POWER_DISABLED, 1, [ ]) fi +AC_ARG_ENABLE(filesystem, +AC_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]), + , enable_filesystem=yes) +if test x$enable_filesystem != xyes; then + AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ]) +fi AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]), , enable_threads=yes) @@ -2431,6 +2438,12 @@ case "$host" in ;; esac fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then AC_DEFINE(SDL_TIMER_UNIX, 1, [ ]) @@ -2509,6 +2522,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c" have_power=yes fi + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c" + have_filesystem=yes + fi # Set up files for the thread library if test x$enable_threads = xyes; then AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ]) @@ -2591,6 +2609,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/beos/*.c" have_power=yes fi + # Set up files for the system filesystem library + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_BEOS, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/power/beos/*.cc" + have_filesystem=yes + fi # The BeOS platform requires special setup. SOURCES="$srcdir/src/main/beos/*.cc $SOURCES" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding" @@ -2630,6 +2654,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/uikit/*.m" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" @@ -2703,6 +2732,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/macosx/*.c" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then AC_DEFINE(SDL_TIMER_UNIX, 1, [ ]) @@ -2760,6 +2795,12 @@ if test x$have_timers != xyes; then fi SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c" fi +if test x$have_filesystem != xyes; then + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ]) + fi + SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c" +fi if test x$have_loadso != xyes; then if test x$enable_loadso = xyes; then AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ]) diff --git a/include/SDL.h b/include/SDL.h index ca098ae6e..8b8a61c14 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -74,6 +74,7 @@ #include "SDL_endian.h" #include "SDL_error.h" #include "SDL_events.h" +#include "SDL_filesystem.h" #include "SDL_joystick.h" #include "SDL_gamecontroller.h" #include "SDL_haptic.h" diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 12c14fa24..500e72a2d 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -182,6 +182,7 @@ #cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@ #cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@ #cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@ +#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@ /* Enable various audio drivers */ #cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@ @@ -301,6 +302,13 @@ #cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@ #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ +/* Enable system filesystem support */ +#cmakedefine SDL_FILESYSTEM_BEOS @SDL_FILESYSTEM_BEOS@ +#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@ +#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@ +#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@ +#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@ + /* Enable assembly routines */ #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ #cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 3f92d57b2..7bb12832f 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -184,6 +184,7 @@ #undef SDL_TIMERS_DISABLED #undef SDL_VIDEO_DISABLED #undef SDL_POWER_DISABLED +#undef SDL_FILESYSTEM_DISABLED /* Enable various audio drivers */ #undef SDL_AUDIO_DRIVER_ALSA @@ -303,6 +304,13 @@ #undef SDL_POWER_BEOS #undef SDL_POWER_HARDWIRED +/* Enable system filesystem support */ +#undef SDL_FILESYSTEM_BEOS +#undef SDL_FILESYSTEM_COCOA +#undef SDL_FILESYSTEM_DUMMY +#undef SDL_FILESYSTEM_UNIX +#undef SDL_FILESYSTEM_WINDOWS + /* Enable assembly routines */ #undef SDL_ASSEMBLY_ROUTINES #undef SDL_ALTIVEC_BLITTERS diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index 7c6b6cb51..0826415c6 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -136,4 +136,7 @@ /* Enable system power support */ #define SDL_POWER_ANDROID 1 +/* !!! FIXME: what does Android do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + #endif /* _SDL_config_android_h */ diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index b27b18973..ade296614 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -148,4 +148,7 @@ */ #define SDL_IPHONE_MAX_GFORCE 5.0 +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + #endif /* _SDL_config_iphoneos_h */ diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index 68a0ebb9b..9f2f76e3f 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -171,6 +171,9 @@ /* Enable system power support */ #define SDL_POWER_MACOSX 1 +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + /* Enable assembly routines */ #define SDL_ASSEMBLY_ROUTINES 1 #ifdef __ppc__ diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h index fe3cebc7e..3248bdda1 100644 --- a/include/SDL_config_minimal.h +++ b/include/SDL_config_minimal.h @@ -75,4 +75,7 @@ typedef unsigned long uintptr_t; /* Enable the dummy video driver (src/video/dummy/\*.c) */ #define SDL_VIDEO_DRIVER_DUMMY 1 +/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ +#define SDL_FILESYSTEM_DUMMY 1 + #endif /* _SDL_config_minimal_h */ diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index b93a1bc1a..4bfad4861 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -114,6 +114,7 @@ #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 #define SDL_TIMER_UNIX 1 +#define SDL_FILESYSTEM_UNIX 1 #define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_X11 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 85cf53c27..09eef29d9 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -126,6 +126,9 @@ #define SDL_POWER_PSP 1 +/* !!! FIXME: what does PSP do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + /* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ #define SDL_HAPTIC_DISABLED 1 diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 0b7621564..9f3448ec3 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -181,6 +181,9 @@ typedef unsigned int uintptr_t; /* Enable system power support */ #define SDL_POWER_WINDOWS 1 +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + /* Enable assembly routines (Win64 doesn't have inline asm) */ #ifndef _WIN64 #define SDL_ASSEMBLY_ROUTINES 1 diff --git a/include/SDL_filesystem.h b/include/SDL_filesystem.h new file mode 100644 index 000000000..71ced94fd --- /dev/null +++ b/include/SDL_filesystem.h @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_filesystem.h + * + * \brief Include file for filesystem SDL API functions + */ + +#ifndef _SDL_filesystem_h +#define _SDL_filesystem_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the path where the application resides. + * + * Get the "base path". This is the directory where the application was run + * from, which is probably the installation directory, and may or may not + * be the process's current working directory. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * Some platforms can't determine the application's path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \return String of base dir in UTF-8 encoding, or NULL on error. + * + * \sa SDL_GetPrefPath + */ +extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); + +/** + * \brief Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native filesystem, + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name" + * + * On Linux, the string might look like: + * "/home/bob/.local/share/My Program Name" + * + * On Mac OS X, the string might look like: + * "/Users/bob/Library/Application Support/My Program Name" + * + * (etc.) + * + * You specify the name of your organization (if it's not a real organization, + * your name or an Internet domain you own might do) and the name of your + * application. These should be untranslated proper names. + * + * Both the org and app strings may become part of a directory name, so + * please follow these rules: + * + * - Try to use the same org string (including case-sensitivity) for + * all your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like + * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * You should assume the path returned by this function is the only safe + * place to write files (and that SDL_GetBasePath(), while it might be + * writable, or even the parent of the returned path, aren't where you + * should be writing things). + * + * Some platforms can't determine the pref path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \param org The name of your organization. + * \param app The name of your application. + * \return UTF-8 string of user dir in platform-dependent notation. NULL + * if there's a problem (creating directory failed, etc). + * + * \sa SDL_GetBasePath + */ +extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/beos/SDL_sysfilesystem.cc b/src/filesystem/beos/SDL_sysfilesystem.cc new file mode 100644 index 000000000..7b63fab34 --- /dev/null +++ b/src/filesystem/beos/SDL_sysfilesystem.cc @@ -0,0 +1,92 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_BEOS + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_assert.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + image_info info; + int32 cookie = 0; + + while (get_next_image_info(0, &cookie, &info) == B_OK) { + if (info.type == B_APP_IMAGE) { + break; + } + } + + BEntry entry(info.name, true); + BPath path; + status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */ + SDL_assert(rc == B_OK); + rc = path.GetParent(&path); /* chop filename, keep directory. */ + SDL_assert(rc == B_OK); + const char *str = path.Path(); + SDL_assert(str != NULL); + + const size_t len = SDL_strlen(str); + char *retval = (char *) SDL_malloc(len + 2); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_strcpy(retval, str); + retval[len] = '/'; + retval[len+1] = '\0'; + return retval; +} + + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + // !!! FIXME: is there a better way to do this? + const char *home = SDL_getenv("HOME"); + const char *append = "config/settings/"; + const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) + 2; + char *retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_OutOfMemory(); + } else { + SDL_snprintf(retval, len, "%s%s%s/", home, append, app); + create_directory(retval, 0700); // BeOS api: creates missing dirs + } + + return retval; +} + +#endif /* SDL_FILESYSTEM_BEOS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m new file mode 100644 index 000000000..3c4597455 --- /dev/null +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -0,0 +1,93 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_COCOA + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + const char *base = [[[NSBundle mainBundle] bundlePath] UTF8String]; + char *retval = NULL; + if (base) { + const size_t len = SDL_strlen(base) + 2; + retval = (char *) SDL_malloc(len); + if (retval == NULL) { + SDL_OutOfMemory(); + } else { + SDL_snprintf(retval, len, "%s/", base); + } + } + + [pool release]; + return retval; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + char *retval = NULL; + + (void) org; // unused on Mac OS X and iOS. + + if ([array count] > 0) { // we only want the first item in the list. + NSString *str = [array objectAtIndex:0]; + const char *base = [str UTF8String]; + if (base) { + const size_t len = SDL_strlen(base) + SDL_strlen(app) + 3; + retval = (char *) SDL_malloc(len); + if (retval == NULL) { + SDL_OutOfMemory(); + } else { + char *ptr; + SDL_snprintf(retval, len, "%s/%s/", base, app); + for (ptr = retval+1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + mkdir(retval, 0700); + *ptr = '/'; + } + } + mkdir(retval, 0700); + } + } + } + + [pool release]; + return retval; +} + +#endif /* SDL_FILESYSTEM_COCOA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/dummy/SDL_sysfilesystem.c b/src/filesystem/dummy/SDL_sysfilesystem.c new file mode 100644 index 000000000..a6bd57767 --- /dev/null +++ b/src/filesystem/dummy/SDL_sysfilesystem.c @@ -0,0 +1,47 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_DUMMY + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include "SDL_error.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + SDL_Unsupported(); + return NULL; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + SDL_Unsupported(); + return NULL; +} + +#endif /* SDL_FILESYSTEM_DUMMY */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c new file mode 100644 index 000000000..326637e78 --- /dev/null +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -0,0 +1,161 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_UNIX + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +static char *readSymLink(const char *path) +{ + char *retval = NULL; + ssize_t len = 64; + ssize_t rc = -1; + + while (1) + { + char *ptr = (char *) SDL_realloc(retval, (size_t) len); + if (ptr == NULL) { + SDL_OutOfMemory(); + break; + } + + retval = ptr; + + rc = readlink(path, retval, len); + if (rc == -1) { + break; /* not a symlink, i/o error, etc. */ + } else if (rc < len) { + retval[rc] = '\0'; /* readlink doesn't null-terminate. */ + return retval; /* we're good to go. */ + } + + len *= 2; /* grow buffer, try again. */ + } + + if (retval != NULL) { + SDL_free(retval); + } + return NULL; +} + + +char * +SDL_GetBasePath(void) +{ + char *retval = NULL; + + /* is a Linux-style /proc filesystem available? */ + if (access("/proc", F_OK) { + retval = readSymLink("/proc/self/exe"); + if (retval == NULL) { + /* older kernels don't have /proc/self ... try PID version... */ + char path[64]; + const int rc = (int) SDL_snprintf(path, sizeof(path), + "/proc/%llu/exe", + (unsigned long long) getpid()); + if ( (rc > 0) && (rc < sizeof(path)) ) { + retval = readSymLink(path); + } + } + } + + /* If we had access to argv[0] here, we could check it for a path, + or troll through $PATH looking for it, too. */ + + if (retval != NULL) { /* chop off filename. */ + char *ptr = SDL_strrchr(retval, '/'); + if (ptr != NULL) { + *(ptr+1) = '\0'; + } else { /* shouldn't happen, but just in case... */ + SDL_free(retval); + retval = NULL; + } + } + + if (retval != NULL) { + /* try to shrink buffer... */ + char *ptr = (char *) SDL_realloc(retval, strlen(retval) + 1); + if (ptr != NULL) + retval = ptr; /* oh well if it failed. */ + } + + return retval; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + /* + * We use XDG's base directory spec, even if you're not on Linux. + * This isn't strictly correct, but the results are relatively sane + * in any case. + * + * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html + */ + const char *envr = SDL_getenv("XDG_DATA_HOME"); + const char *append = "/"; + char *retval = NULL; + char *ptr = NULL; + size_t len = 0; + + if (!envr) { + /* You end up with "$HOME/.local/share/Game Name 2" */ + envr = SDL_getenv("HOME"); + if (!envr) { + /* we could take heroic measures with /etc/passwd, but oh well. */ + SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); + return NULL; + } + append = ".local/share/"; + } /* if */ + + len = SDL_strlen(envr) + SDL_strlen(append) + SDL_strlen(app) + 2; + retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_snprintf(retval, len, "%s%s%s/", envr, append, app); + + for (ptr = retval+1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + mkdir(retval, 0700); + *ptr = '/'; + } + } + mkdir(retval, 0700); + + return retval; +} + +#endif /* SDL_FILESYSTEM_UNIX */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c new file mode 100644 index 000000000..fc17d5e0f --- /dev/null +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -0,0 +1,96 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_WINDOWS + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include "SDL_error.h" +#include "SDL_windows.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + TCHAR path[MAX_PATH]; + const DWORD len = GetModuleFileName(NULL, path, SDL_arraysize(path)); + size_t i; + + SDL_assert(len < SDL_arraysize(path)); + + if (len == 0) { + WIN_SetError("Couldn't locate our .exe"); + return NULL; + } + + for (i = len-1; i > 0; i--) { + if (path[i] == '\\') { + break; + } + } + + SDL_assert(i > 0); /* Should have been an absolute path. */ + path[i+1] = '\0'; /* chop off filename. */ + return WIN_StringToUTF8(path); +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + /* + * Vista and later has a new API for this, but SHGetFolderPath works there, + * and apparently just wraps the new API. This is the new way to do it: + * + * SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, + * NULL, &wszPath); + */ + + TCHAR path[MAX_PATH]; + char *utf8 = NULL; + char *retval = NULL; + + if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) { + WIN_SetError("Couldn't locate our prefpath"); + return NULL; + } + + utf8 = WIN_StringToUTF8(path); + if (utf8) { + const size_t len = SDL_strlen(utf8) + SDL_strlen(org) + SDL_strlen(app) + 4; + retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_free(utf8); + SDL_OutOfMemory(); + return NULL; + } + SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app); + SDL_free(utf8); + } + + return retval; +} + +#endif /* SDL_FILESYSTEM_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/Makefile.in b/test/Makefile.in index 2a39afc6b..ed0fce36a 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -36,6 +36,7 @@ TARGETS = \ testoverlay2$(EXE) \ testplatform$(EXE) \ testpower$(EXE) \ + testfilesystem$(EXE) \ testrendertarget$(EXE) \ testresample$(EXE) \ testscale$(EXE) \ @@ -180,6 +181,9 @@ testplatform$(EXE): $(srcdir)/testplatform.c testpower$(EXE): $(srcdir)/testpower.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +testfilesystem$(EXE): $(srcdir)/testfilesystem.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + testrendertarget$(EXE): $(srcdir)/testrendertarget.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/test/testfilesystem.c b/test/testfilesystem.c new file mode 100644 index 000000000..e1f251371 --- /dev/null +++ b/test/testfilesystem.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely. +*/ +/* Simple test of power subsystem. */ + +#include +#include "SDL.h" + +int +main(int argc, char *argv[]) +{ + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + if (SDL_Init(0) == -1) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); + return 1; + } + + SDL_Log("base path: '%s'\n", SDL_GetBasePath()); + SDL_Log("pref path: '%s'\n", SDL_GetPrefPath("libsdl", "testfilesystem")); + + SDL_Quit(); + return 0; +} From 4fef316c65c0b6aeaf737d267ed03597d0cb1801 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 20:15:15 -0400 Subject: [PATCH 036/258] Patched new filesystem code to compile. --- src/filesystem/cocoa/SDL_sysfilesystem.m | 1 + src/filesystem/unix/SDL_sysfilesystem.c | 7 +++++-- src/filesystem/windows/SDL_sysfilesystem.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 3c4597455..3cf8878dd 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -27,6 +27,7 @@ #include #include +#include #include "SDL_error.h" #include "SDL_stdinc.h" diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 326637e78..09db1e55c 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -26,12 +26,15 @@ /* System dependent filesystem routines */ #include +#include +#include #include "SDL_error.h" #include "SDL_stdinc.h" #include "SDL_filesystem.h" -static char *readSymLink(const char *path) +static char * +readSymLink(const char *path) { char *retval = NULL; ssize_t len = 64; @@ -71,7 +74,7 @@ SDL_GetBasePath(void) char *retval = NULL; /* is a Linux-style /proc filesystem available? */ - if (access("/proc", F_OK) { + if (access("/proc", F_OK) == 0) { retval = readSymLink("/proc/self/exe"); if (retval == NULL) { /* older kernels don't have /proc/self ... try PID version... */ diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index fc17d5e0f..e55be7e6f 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -26,7 +26,7 @@ /* System dependent filesystem routines */ #include "SDL_error.h" -#include "SDL_windows.h" +#include "../../core/windows/SDL_windows.h" #include "SDL_stdinc.h" #include "SDL_filesystem.h" From 708d2720cd4c5f71f21c0e544d9d94b7124709c1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 20:16:15 -0400 Subject: [PATCH 037/258] Corrected Haiku build. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index f9d0bf2ed..a1fc311fd 100644 --- a/configure.in +++ b/configure.in @@ -2612,7 +2612,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau # Set up files for the system filesystem library if test x$enable_filesystem = xyes; then AC_DEFINE(SDL_FILESYSTEM_BEOS, 1, [ ]) - SOURCES="$SOURCES $srcdir/src/power/beos/*.cc" + SOURCES="$SOURCES $srcdir/src/filesystem/beos/*.cc" have_filesystem=yes fi # The BeOS platform requires special setup. From 8fe6c7fae69ed13f5c575b59b5211410b63e0259 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 20:27:42 -0400 Subject: [PATCH 038/258] Regenerate configure script. --- configure | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index f4c3f6ae4..dffecba4e 100755 --- a/configure +++ b/configure @@ -22390,7 +22390,7 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h $as_echo "#define SDL_FILESYSTEM_BEOS 1" >>confdefs.h - SOURCES="$SOURCES $srcdir/src/power/beos/*.cc" + SOURCES="$SOURCES $srcdir/src/filesystem/beos/*.cc" have_filesystem=yes fi # The BeOS platform requires special setup. @@ -22427,6 +22427,11 @@ $as_echo "#define SDL_FILESYSTEM_BEOS 1" >>confdefs.h # have_haptic=yes # EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback" #fi + # Set up files for the power library + if test x$enable_power = xyes; then + SOURCES="$SOURCES $srcdir/src/power/uikit/*.m" + have_power=yes + fi # Set up files for the filesystem library if test x$enable_filesystem = xyes; then SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" From 56176b1b4b22348b06ee23d9f5b25a8b8e4f3624 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 20:29:30 -0400 Subject: [PATCH 039/258] More Windows fixes for filesystem code. --- src/filesystem/windows/SDL_sysfilesystem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index e55be7e6f..7b101ffed 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -25,8 +25,11 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ -#include "SDL_error.h" #include "../../core/windows/SDL_windows.h" +#include + +#include "SDL_assert.h" +#include "SDL_error.h" #include "SDL_stdinc.h" #include "SDL_filesystem.h" From 26992a5a9f2c95186f70e459fe0f9c773c2a0ef7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 20:31:57 -0400 Subject: [PATCH 040/258] Fixed compiler warning. --- src/video/x11/SDL_x11keyboard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 81d64b2df..5c5f5bcf1 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -197,7 +197,8 @@ int X11_InitKeyboard(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - int i, j; + int i = 0; + int j = 0; int min_keycode, max_keycode; struct { SDL_Scancode scancode; From aa07924132393cff1f59f45fbf95ea32b8861a41 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 20:39:22 -0400 Subject: [PATCH 041/258] More Haiku fixes. --- src/filesystem/beos/SDL_sysfilesystem.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filesystem/beos/SDL_sysfilesystem.cc b/src/filesystem/beos/SDL_sysfilesystem.cc index 7b63fab34..06b1880d5 100644 --- a/src/filesystem/beos/SDL_sysfilesystem.cc +++ b/src/filesystem/beos/SDL_sysfilesystem.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include "SDL_error.h" @@ -62,7 +63,7 @@ SDL_GetBasePath(void) return NULL; } - SDL_strcpy(retval, str); + strcpy(retval, str); retval[len] = '/'; retval[len+1] = '\0'; return retval; From 0d45b5b9868035d90c5c39bdaa86151e0402713f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 21:21:57 -0400 Subject: [PATCH 042/258] Patched to compile on iOS. --- src/filesystem/cocoa/SDL_sysfilesystem.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 3cf8878dd..298c1f75a 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -25,7 +25,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ -#include +#include #include #include From a03a7f7745e0801b341d7c6365e9f3807afee398 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 21:29:40 -0400 Subject: [PATCH 043/258] Added filesystem code to Mac and iOS Xcode projects. --- Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj | 16 ++++++++++++++++ Xcode/SDL/SDL.xcodeproj/project.pbxproj | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj index f3122ecba..78d1c0b8d 100755 --- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj @@ -67,6 +67,8 @@ 04F7808512FB753F00FC43C0 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */; }; 04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; }; 04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */; }; + 56C181DF17C44D5E00406AE3 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 56C181DE17C44D5E00406AE3 /* SDL_filesystem.h */; }; + 56C181E217C44D7A00406AE3 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C181E117C44D7A00406AE3 /* SDL_sysfilesystem.m */; }; 56EA86FB13E9EC2B002E47EB /* SDL_coreaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 56EA86F913E9EC2B002E47EB /* SDL_coreaudio.c */; }; 56EA86FC13E9EC2B002E47EB /* SDL_coreaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 56EA86FA13E9EC2B002E47EB /* SDL_coreaudio.h */; }; 56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E0118A8EE200A56AA6 /* SDL_power.c */; }; @@ -258,6 +260,8 @@ 04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullframebuffer.c; sourceTree = ""; }; 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = ""; }; 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = ""; }; + 56C181DE17C44D5E00406AE3 /* SDL_filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_filesystem.h; sourceTree = ""; }; + 56C181E117C44D7A00406AE3 /* SDL_sysfilesystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_sysfilesystem.m; path = ../../src/filesystem/cocoa/SDL_sysfilesystem.m; sourceTree = ""; }; 56EA86F913E9EC2B002E47EB /* SDL_coreaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_coreaudio.c; path = coreaudio/SDL_coreaudio.c; sourceTree = ""; }; 56EA86FA13E9EC2B002E47EB /* SDL_coreaudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_coreaudio.h; path = coreaudio/SDL_coreaudio.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; }; @@ -548,6 +552,14 @@ name = CustomTemplate; sourceTree = ""; }; + 56C181E017C44D6900406AE3 /* filesystem */ = { + isa = PBXGroup; + children = ( + 56C181E117C44D7A00406AE3 /* SDL_sysfilesystem.m */, + ); + name = filesystem; + sourceTree = ""; + }; 56EA86F813E9EBF9002E47EB /* coreaudio */ = { isa = PBXGroup; children = ( @@ -676,6 +688,7 @@ AA7558701595D55500BBD41B /* SDL_endian.h */, AA7558711595D55500BBD41B /* SDL_error.h */, AA7558721595D55500BBD41B /* SDL_events.h */, + 56C181DE17C44D5E00406AE3 /* SDL_filesystem.h */, AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */, AA7558731595D55500BBD41B /* SDL_gesture.h */, AA7558741595D55500BBD41B /* SDL_haptic.h */, @@ -726,6 +739,7 @@ FD99B98A0DD52EDC00FB1D6B /* cpuinfo */, FD99B98C0DD52EDC00FB1D6B /* events */, FD99B99D0DD52EDC00FB1D6B /* file */, + 56C181E017C44D6900406AE3 /* filesystem */, 047677B60EA769DF008ABAF1 /* haptic */, FD5F9D080E0E08B3008E885B /* joystick */, FD8BD8150E27E25900B52CD5 /* loadso */, @@ -1018,6 +1032,7 @@ AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */, AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */, AADA5B8F16CCAB7C00107CF7 /* SDL_bits.h in Headers */, + 56C181DF17C44D5E00406AE3 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1183,6 +1198,7 @@ AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */, AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */, AA0F8495178D5F1A00823F9D /* SDL_systls.c in Sources */, + 56C181E217C44D7A00406AE3 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index eec42cb08..c190cbf4d 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -391,6 +391,8 @@ 04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; }; 566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */; }; 566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; }; + 567E2F1C17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; + 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; }; A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; }; @@ -986,6 +988,8 @@ 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = ""; }; 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dropevents_c.h; sourceTree = ""; }; 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_dropevents.c; sourceTree = ""; }; + 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_sysfilesystem.m; path = ../../src/filesystem/cocoa/SDL_sysfilesystem.m; sourceTree = ""; }; + 567E2F2017C44C35005F1892 /* SDL_filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_filesystem.h; sourceTree = ""; }; A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = ""; }; AA0F8490178D5ECC00823F9D /* SDL_systls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systls.c; sourceTree = ""; }; AA628AC8159367B7005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = ""; }; @@ -1135,6 +1139,7 @@ AA7557D21595D4D800BBD41B /* SDL_endian.h */, AA7557D31595D4D800BBD41B /* SDL_error.h */, AA7557D41595D4D800BBD41B /* SDL_events.h */, + 567E2F2017C44C35005F1892 /* SDL_filesystem.h */, A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */, AA7557D51595D4D800BBD41B /* SDL_gesture.h */, AA7557D61595D4D800BBD41B /* SDL_haptic.h */, @@ -1643,6 +1648,7 @@ 04BDFD7612E6671700899322 /* audio */, 04BDFDD312E6671700899322 /* cpuinfo */, 04BDFDD512E6671700899322 /* events */, + 567E2F1F17C44BBB005F1892 /* filesystem */, 04BDFDEC12E6671700899322 /* file */, 04BDFDF112E6671700899322 /* haptic */, 04BDFDFF12E6671700899322 /* joystick */, @@ -1664,6 +1670,14 @@ name = "Library Source"; sourceTree = ""; }; + 567E2F1F17C44BBB005F1892 /* filesystem */ = { + isa = PBXGroup; + children = ( + 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */, + ); + name = filesystem; + sourceTree = ""; + }; BEC562FE0761C0E800A33029 /* Linked Frameworks */ = { isa = PBXGroup; children = ( @@ -1858,6 +1872,7 @@ AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */, AABCC38D164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, D55A1B81179F262300625D7C /* SDL_cocoamousetap.h in Headers */, + 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2003,6 +2018,7 @@ AA628AD4159367F2005138DD /* SDL_x11xinput2.h in Headers */, AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, D55A1B85179F278E00625D7C /* SDL_cocoamousetap.h in Headers */, + 567E2F2217C44C35005F1892 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2148,6 +2164,7 @@ DB313FC717554B71006C0E22 /* SDL_x11xinput2.h in Headers */, DB313FFA17554B71006C0E22 /* SDL_cocoamessagebox.h in Headers */, D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */, + 567E2F2317C44C35005F1892 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2431,6 +2448,7 @@ AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */, AA0F8491178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B82179F262300625D7C /* SDL_cocoamousetap.m in Sources */, + 567E2F1C17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2548,6 +2566,7 @@ AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */, AA0F8492178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B84179F263600625D7C /* SDL_cocoamousetap.m in Sources */, + 567E2F1D17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2665,6 +2684,7 @@ DB31406A17554B71006C0E22 /* SDL_cocoamessagebox.m in Sources */, AA0F8493178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B83179F263500625D7C /* SDL_cocoamousetap.m in Sources */, + 567E2F1E17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 0f758bdbfdfeaee2c3a9aca7aa548a73a91ac10c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 20 Aug 2013 23:20:32 -0400 Subject: [PATCH 044/258] Actually, this should be a memcpy(). We already know the exact length we just allocated, and we plan to append our own null terminator to the end of the copy, so this makes more sense. --- src/filesystem/beos/SDL_sysfilesystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/beos/SDL_sysfilesystem.cc b/src/filesystem/beos/SDL_sysfilesystem.cc index 06b1880d5..decf84cc0 100644 --- a/src/filesystem/beos/SDL_sysfilesystem.cc +++ b/src/filesystem/beos/SDL_sysfilesystem.cc @@ -63,7 +63,7 @@ SDL_GetBasePath(void) return NULL; } - strcpy(retval, str); + SDL_memcpy(retval, str, len); retval[len] = '/'; retval[len+1] = '\0'; return retval; From 271e0d67c4028a54f34cc37cc739591d7cde6534 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 21 Aug 2013 09:43:09 -0300 Subject: [PATCH 045/258] OCD fixes: Adds a space before */ --- Xcode-iOS/Demos/src/rectangles.c | 2 +- include/SDL.h | 4 +- include/SDL_atomic.h | 4 +- include/SDL_audio.h | 44 ++++++------- include/SDL_config_psp.h | 4 +- include/SDL_endian.h | 8 +-- include/SDL_error.h | 4 +- include/SDL_events.h | 8 +-- include/SDL_haptic.h | 14 ++--- include/SDL_joystick.h | 4 +- include/SDL_mutex.h | 12 ++-- include/SDL_pixels.h | 4 +- include/SDL_platform.h | 2 +- include/SDL_rwops.h | 16 ++--- include/SDL_scancode.h | 12 ++-- include/SDL_stdinc.h | 8 +-- include/SDL_surface.h | 4 +- include/SDL_test_harness.h | 12 ++-- include/SDL_video.h | 4 +- src/audio/SDL_wave.c | 4 +- src/audio/alsa/SDL_alsa_audio.c | 2 +- src/audio/psp/SDL_pspaudio.c | 10 +-- src/core/android/SDL_android.c | 16 ++--- src/core/android/SDL_android.h | 2 +- src/events/SDL_gesture.c | 80 ++++++++++++------------ src/events/SDL_keyboard.c | 2 +- src/events/SDL_mouse.c | 2 +- src/haptic/darwin/SDL_syshaptic.c | 6 +- src/haptic/linux/SDL_syshaptic.c | 6 +- src/haptic/windows/SDL_syshaptic.c | 6 +- src/joystick/SDL_gamecontroller.c | 2 +- src/joystick/SDL_joystick.c | 4 +- src/joystick/darwin/SDL_sysjoystick.c | 2 +- src/libm/e_atan2.c | 4 +- src/libm/math_private.h | 4 +- src/main/android/SDL_android_main.c | 2 +- src/render/SDL_yuv_sw.c | 8 +-- src/render/direct3d/SDL_render_d3d.c | 2 +- src/render/opengl/SDL_render_gl.c | 4 +- src/render/opengl/SDL_shaders_gl.c | 2 +- src/render/psp/SDL_render_psp.c | 18 +++--- src/render/software/SDL_rotate.c | 10 +-- src/video/SDL_blit_A.c | 16 ++--- src/video/SDL_bmp.c | 34 +++++----- src/video/SDL_fillrect.c | 4 +- src/video/SDL_shape.c | 2 +- src/video/SDL_stretch.c | 2 +- src/video/SDL_surface.c | 2 +- src/video/android/SDL_androidevents.c | 2 +- src/video/bwindow/SDL_BWin.h | 4 +- src/video/bwindow/SDL_bopengl.h | 10 +-- src/video/directfb/SDL_DirectFB_WM.c | 2 +- src/video/directfb/SDL_DirectFB_events.c | 4 +- src/video/directfb/SDL_DirectFB_render.c | 4 +- src/video/psp/SDL_pspevents.c | 2 +- src/video/psp/SDL_pspvideo.c | 2 +- src/video/windows/SDL_windowsevents.c | 2 +- src/video/x11/SDL_x11events.c | 4 +- src/video/x11/SDL_x11modes.c | 4 +- src/video/x11/SDL_x11window.c | 6 +- src/video/x11/SDL_x11xinput2.c | 10 +-- src/video/x11/SDL_x11xinput2.h | 2 +- test/testautomation_audio.c | 2 +- test/testautomation_events.c | 10 +-- test/testautomation_pixels.c | 2 +- test/testautomation_video.c | 2 +- test/testgesture.c | 16 ++--- test/testhaptic.c | 2 +- test/testime.c | 2 +- test/testmessage.c | 2 +- test/testoverlay2.c | 2 +- test/testrendercopyex.c | 2 +- test/testshape.c | 12 ++-- 73 files changed, 270 insertions(+), 270 deletions(-) diff --git a/Xcode-iOS/Demos/src/rectangles.c b/Xcode-iOS/Demos/src/rectangles.c index 035e4f982..86fce49fe 100644 --- a/Xcode-iOS/Demos/src/rectangles.c +++ b/Xcode-iOS/Demos/src/rectangles.c @@ -37,7 +37,7 @@ render(SDL_Renderer *renderer) int main(int argc, char *argv[]) { - if (SDL_Init(SDL_INIT_VIDEO/* | SDL_INIT_AUDIO*/) < 0) + if (SDL_Init(SDL_INIT_VIDEO/* | SDL_INIT_AUDIO */) < 0) { printf("Unable to initialize SDL"); } diff --git a/include/SDL.h b/include/SDL.h index 8b8a61c14..67dd30f50 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -106,7 +106,7 @@ extern "C" { * These are the flags which may be passed to SDL_Init(). You should * specify the subsystems which you will be using in your application. */ -/*@{*/ +/*@{ */ #define SDL_INIT_TIMER 0x00000001 #define SDL_INIT_AUDIO 0x00000010 #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ @@ -119,7 +119,7 @@ extern "C" { SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ ) -/*@}*/ +/*@} */ /** * This function initializes the subsystems specified by \c flags diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index 7bd669d1a..ae51dfc12 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -91,7 +91,7 @@ extern "C" { * The spin lock functions and type are required and can not be * emulated because they are used in the atomic emulation code. */ -/*@{*/ +/*@{ */ typedef int SDL_SpinLock; @@ -118,7 +118,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); */ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); -/*@}*//*SDL AtomicLock*/ +/*@} *//*SDL AtomicLock */ /** diff --git a/include/SDL_audio.h b/include/SDL_audio.h index 0b6f28af6..bf57852e4 100644 --- a/include/SDL_audio.h +++ b/include/SDL_audio.h @@ -66,7 +66,7 @@ typedef Uint16 SDL_AudioFormat; /** * \name Audio flags */ -/*@{*/ +/*@{ */ #define SDL_AUDIO_MASK_BITSIZE (0xFF) #define SDL_AUDIO_MASK_DATATYPE (1<<8) @@ -85,7 +85,7 @@ typedef Uint16 SDL_AudioFormat; * * Defaults to LSB byte order. */ -/*@{*/ +/*@{ */ #define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ #define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ #define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ @@ -94,30 +94,30 @@ typedef Uint16 SDL_AudioFormat; #define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ #define AUDIO_U16 AUDIO_U16LSB #define AUDIO_S16 AUDIO_S16LSB -/*@}*/ +/*@} */ /** * \name int32 support */ -/*@{*/ +/*@{ */ #define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ #define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ #define AUDIO_S32 AUDIO_S32LSB -/*@}*/ +/*@} */ /** * \name float32 support */ -/*@{*/ +/*@{ */ #define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ #define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ #define AUDIO_F32 AUDIO_F32LSB -/*@}*/ +/*@} */ /** * \name Native audio byte ordering */ -/*@{*/ +/*@{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define AUDIO_U16SYS AUDIO_U16LSB #define AUDIO_S16SYS AUDIO_S16LSB @@ -129,21 +129,21 @@ typedef Uint16 SDL_AudioFormat; #define AUDIO_S32SYS AUDIO_S32MSB #define AUDIO_F32SYS AUDIO_F32MSB #endif -/*@}*/ +/*@} */ /** * \name Allow change flags * * Which audio format changes are allowed when opening a device. */ -/*@{*/ +/*@{ */ #define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 #define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 #define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 #define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE) -/*@}*/ +/*@} */ -/*@}*//*Audio flags*/ +/*@} *//*Audio flags */ /** * This function is called when the audio device needs more data. @@ -218,10 +218,10 @@ typedef struct SDL_AudioCVT * These functions return the list of built in audio drivers, in the * order that they are normally initialized by default. */ -/*@{*/ +/*@{ */ extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); -/*@}*/ +/*@} */ /** * \name Initialization and cleanup @@ -230,10 +230,10 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); * you have a specific need to specify the audio driver you want to * use. You should normally use SDL_Init() or SDL_InitSubSystem(). */ -/*@{*/ +/*@{ */ extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); extern DECLSPEC void SDLCALL SDL_AudioQuit(void); -/*@}*/ +/*@} */ /** * This function returns the name of the current audio driver, or NULL @@ -359,7 +359,7 @@ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char * * Get the current audio state. */ -/*@{*/ +/*@{ */ typedef enum { SDL_AUDIO_STOPPED = 0, @@ -370,7 +370,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); -/*@}*//*Audio State*/ +/*@} *//*Audio State */ /** * \name Pause audio functions @@ -381,11 +381,11 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); * data for your callback function after opening the audio device. * Silence will be written to the audio device during the pause. */ -/*@{*/ +/*@{ */ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on); -/*@}*//*Pause audio functions*/ +/*@} *//*Pause audio functions */ /** * This function loads a WAVE from the data source, automatically freeing @@ -482,12 +482,12 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, * the callback function is not running. Do not call these from the callback * function or you will cause deadlock. */ -/*@{*/ +/*@{ */ extern DECLSPEC void SDLCALL SDL_LockAudio(void); extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); -/*@}*//*Audio lock functions*/ +/*@} *//*Audio lock functions */ /** * This function shuts down audio processing and closes the audio device. diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 09eef29d9..921920db5 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -99,8 +99,8 @@ #define HAVE_SQRT 1 #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 -/*#define HAVE_SYSCONF 1*/ -/*#define HAVE_SIGACTION 1*/ +/*#define HAVE_SYSCONF 1 */ +/*#define HAVE_SIGACTION 1 */ /* PSP isn't that sophisticated */ diff --git a/include/SDL_endian.h b/include/SDL_endian.h index c58edcca0..81e8c70e7 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -33,10 +33,10 @@ /** * \name The two types of endianness */ -/*@{*/ +/*@{ */ #define SDL_LIL_ENDIAN 1234 #define SDL_BIG_ENDIAN 4321 -/*@}*/ +/*@} */ #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ #ifdef __linux__ @@ -206,7 +206,7 @@ SDL_SwapFloat(float x) * \name Swap to native * Byteswap item from the specified endianness to the native endianness. */ -/*@{*/ +/*@{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define SDL_SwapLE16(X) (X) #define SDL_SwapLE32(X) (X) @@ -226,7 +226,7 @@ SDL_SwapFloat(float x) #define SDL_SwapBE64(X) (X) #define SDL_SwapFloatBE(X) (X) #endif -/*@}*//*Swap to native*/ +/*@} *//*Swap to native */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_error.h b/include/SDL_error.h index 229b26802..11285633f 100644 --- a/include/SDL_error.h +++ b/include/SDL_error.h @@ -48,7 +48,7 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void); * \internal * Private error reporting function - used internally. */ -/*@{*/ +/*@{ */ #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) @@ -63,7 +63,7 @@ typedef enum } SDL_errorcode; /* SDL_Error() unconditionally returns -1. */ extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); -/*@}*//*Internal error functions*/ +/*@} *//*Internal error functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_events.h b/include/SDL_events.h index b997b5ec8..77d5fde23 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -541,7 +541,7 @@ typedef union SDL_Event */ extern DECLSPEC void SDLCALL SDL_PumpEvents(void); -/*@{*/ +/*@{ */ typedef enum { SDL_ADDEVENT, @@ -570,7 +570,7 @@ typedef enum extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType); -/*@}*/ +/*@} */ /** * Checks to see if certain event types are in the event queue. @@ -681,7 +681,7 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); -/*@{*/ +/*@{ */ #define SDL_QUERY -1 #define SDL_IGNORE 0 #define SDL_DISABLE 0 @@ -697,7 +697,7 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, * current processing state of the specified event. */ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); -/*@}*/ +/*@} */ #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) /** diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index da555c9c3..c2a025ef2 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -140,12 +140,12 @@ typedef struct _SDL_Haptic SDL_Haptic; * * Different haptic features a device can have. */ -/*@{*/ +/*@{ */ /** * \name Haptic effects */ -/*@{*/ +/*@{ */ /** * \brief Constant effect supported. @@ -177,7 +177,7 @@ typedef struct _SDL_Haptic SDL_Haptic; #define SDL_HAPTIC_LEFTRIGHT (1<<2) /* !!! FIXME: put this back when we have more bits in 2.1 */ -/*#define SDL_HAPTIC_SQUARE (1<<2)*/ +/*#define SDL_HAPTIC_SQUARE (1<<2) */ /** * \brief Triangle wave effect supported. @@ -262,7 +262,7 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_CUSTOM (1<<11) -/*@}*//*Haptic effects*/ +/*@} *//*Haptic effects */ /* These last few are features the device has, not effects */ @@ -305,7 +305,7 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \name Direction encodings */ -/*@{*/ +/*@{ */ /** * \brief Uses polar coordinates for the direction. @@ -328,9 +328,9 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_SPHERICAL 2 -/*@}*//*Direction encodings*/ +/*@} *//*Direction encodings */ -/*@}*//*Haptic features*/ +/*@} *//*Haptic features */ /* * Misc defines. diff --git a/include/SDL_joystick.h b/include/SDL_joystick.h index 266740348..5b91f04ce 100644 --- a/include/SDL_joystick.h +++ b/include/SDL_joystick.h @@ -187,7 +187,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, /** * \name Hat positions */ -/*@{*/ +/*@{ */ #define SDL_HAT_CENTERED 0x00 #define SDL_HAT_UP 0x01 #define SDL_HAT_RIGHT 0x02 @@ -197,7 +197,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) -/*@}*/ +/*@} */ /** * Get the current state of a POV hat on a joystick. diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h index 4f2c50615..57274fa15 100644 --- a/include/SDL_mutex.h +++ b/include/SDL_mutex.h @@ -52,7 +52,7 @@ extern "C" { /** * \name Mutex functions */ -/*@{*/ +/*@{ */ /* The SDL mutex structure, defined in SDL_sysmutex.c */ struct SDL_mutex; @@ -94,13 +94,13 @@ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); */ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); -/*@}*//*Mutex functions*/ +/*@} *//*Mutex functions */ /** * \name Semaphore functions */ -/*@{*/ +/*@{ */ /* The SDL semaphore structure, defined in SDL_syssem.c */ struct SDL_semaphore; @@ -154,13 +154,13 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); */ extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); -/*@}*//*Semaphore functions*/ +/*@} *//*Semaphore functions */ /** * \name Condition variable functions */ -/*@{*/ +/*@{ */ /* The SDL condition variable structure, defined in SDL_syscond.c */ struct SDL_cond; @@ -237,7 +237,7 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms); -/*@}*//*Condition variable functions*/ +/*@} *//*Condition variable functions */ /* Ends C function definitions when using C++ */ diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index 5e17cba53..5b6d9c4f7 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -39,10 +39,10 @@ extern "C" { * * These define alpha as the opacity of a surface. */ -/*@{*/ +/*@{ */ #define SDL_ALPHA_OPAQUE 255 #define SDL_ALPHA_TRANSPARENT 0 -/*@}*/ +/*@} */ /** Pixel type. */ enum diff --git a/include/SDL_platform.h b/include/SDL_platform.h index 1e8e0d9f4..bf520ba6d 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -66,7 +66,7 @@ #endif #if defined(ANDROID) #undef __ANDROID__ -#undef __LINUX__ /*do we need to do this?*/ +#undef __LINUX__ /*do we need to do this? */ #define __ANDROID__ 1 #endif diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h index 0461ff782..e2f116166 100644 --- a/include/SDL_rwops.h +++ b/include/SDL_rwops.h @@ -148,7 +148,7 @@ typedef struct SDL_RWops * * Functions to create SDL_RWops structures from various data streams. */ -/*@{*/ +/*@{ */ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode); @@ -165,7 +165,7 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, int size); -/*@}*//*RWFrom functions*/ +/*@} *//*RWFrom functions */ extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); @@ -180,14 +180,14 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); * * Macros to easily read and write from an SDL_RWops structure. */ -/*@{*/ +/*@{ */ #define SDL_RWsize(ctx) (ctx)->size(ctx) #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) #define SDL_RWclose(ctx) (ctx)->close(ctx) -/*@}*//*Read/write macros*/ +/*@} *//*Read/write macros */ /** @@ -195,7 +195,7 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); * * Read an item of the specified endianness and return in native format. */ -/*@{*/ +/*@{ */ extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); @@ -203,14 +203,14 @@ extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); -/*@}*//*Read endian functions*/ +/*@} *//*Read endian functions */ /** * \name Write endian functions * * Write an item of native format to the specified endianness. */ -/*@{*/ +/*@{ */ extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); @@ -218,7 +218,7 @@ extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); -/*@}*//*Write endian functions*/ +/*@} *//*Write endian functions */ /* Ends C function definitions when using C++ */ diff --git a/include/SDL_scancode.h b/include/SDL_scancode.h index d3f874811..7c7cf4322 100644 --- a/include/SDL_scancode.h +++ b/include/SDL_scancode.h @@ -49,7 +49,7 @@ typedef enum * * These values are from usage page 0x07 (USB keyboard page). */ - /*@{*/ + /*@{ */ SDL_SCANCODE_A = 4, SDL_SCANCODE_B = 5, @@ -339,14 +339,14 @@ typedef enum * special KMOD_MODE for it I'm adding it here */ - /*@}*//*Usage page 0x07*/ + /*@} *//*Usage page 0x07 */ /** * \name Usage page 0x0C * * These values are mapped from usage page 0x0C (USB consumer page). */ - /*@{*/ + /*@{ */ SDL_SCANCODE_AUDIONEXT = 258, SDL_SCANCODE_AUDIOPREV = 259, @@ -366,14 +366,14 @@ typedef enum SDL_SCANCODE_AC_REFRESH = 273, SDL_SCANCODE_AC_BOOKMARKS = 274, - /*@}*//*Usage page 0x0C*/ + /*@} *//*Usage page 0x0C */ /** * \name Walther keys * * These are values that Christian Walther added (for mac keyboard?). */ - /*@{*/ + /*@{ */ SDL_SCANCODE_BRIGHTNESSDOWN = 275, SDL_SCANCODE_BRIGHTNESSUP = 276, @@ -388,7 +388,7 @@ typedef enum SDL_SCANCODE_APP1 = 283, SDL_SCANCODE_APP2 = 284, - /*@}*//*Walther keys*/ + /*@} *//*Walther keys */ /* Add any other keys here. */ diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 7fa9c1049..6f9c23cac 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -89,7 +89,7 @@ * Use proper C++ casts when compiled as C++ to be compatible with the option * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). */ -/*@{*/ +/*@{ */ #ifdef __cplusplus #define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) #define SDL_static_cast(type, expression) static_cast(expression) @@ -99,7 +99,7 @@ #define SDL_static_cast(type, expression) ((type)(expression)) #define SDL_const_cast(type, expression) ((type)(expression)) #endif -/*@}*//*Cast operators*/ +/*@} *//*Cast operators */ /* Define a four character code as a Uint32 */ #define SDL_FOURCC(A, B, C, D) \ @@ -111,7 +111,7 @@ /** * \name Basic data types */ -/*@{*/ +/*@{ */ typedef enum { @@ -153,7 +153,7 @@ typedef int64_t Sint64; */ typedef uint64_t Uint64; -/*@}*//*Basic data types*/ +/*@} *//*Basic data types */ #define SDL_COMPILE_TIME_ASSERT(name, x) \ diff --git a/include/SDL_surface.h b/include/SDL_surface.h index fece79743..4b9628c72 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -48,12 +48,12 @@ extern "C" { * \internal * Used internally (read-only). */ -/*@{*/ +/*@{ */ #define SDL_SWSURFACE 0 /**< Just here for compatibility */ #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ -/*@}*//*Surface flags*/ +/*@} *//*Surface flags */ /** * Evaluates to true if the surface needs to be locked before access. diff --git a/include/SDL_test_harness.h b/include/SDL_test_harness.h index 00381aa6d..d22c9fcbc 100644 --- a/include/SDL_test_harness.h +++ b/include/SDL_test_harness.h @@ -43,30 +43,30 @@ extern "C" { #endif -/*! Definitions for test case structures*/ +/*! Definitions for test case structures */ #define TEST_ENABLED 1 #define TEST_DISABLED 0 -/*! Definition of all the possible test return values of the test case method*/ +/*! Definition of all the possible test return values of the test case method */ #define TEST_ABORTED -1 #define TEST_STARTED 0 #define TEST_COMPLETED 1 #define TEST_SKIPPED 2 -/*! Definition of all the possible test results for the harness*/ +/*! Definition of all the possible test results for the harness */ #define TEST_RESULT_PASSED 0 #define TEST_RESULT_FAILED 1 #define TEST_RESULT_NO_ASSERT 2 #define TEST_RESULT_SKIPPED 3 #define TEST_RESULT_SETUP_FAILURE 4 -/*!< Function pointer to a test case setup function (run before every test)*/ +/*!< Function pointer to a test case setup function (run before every test) */ typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); -/*!< Function pointer to a test case function*/ +/*!< Function pointer to a test case function */ typedef int (*SDLTest_TestCaseFp)(void *arg); -/*!< Function pointer to a test case teardown function (run after every test)*/ +/*!< Function pointer to a test case teardown function (run after every test) */ typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); /** diff --git a/include/SDL_video.h b/include/SDL_video.h index 30c7393f2..3a2ac83ae 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -821,7 +821,7 @@ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); /** * \name OpenGL support functions */ -/*@{*/ +/*@{ */ /** * \brief Dynamically load an OpenGL library. @@ -939,7 +939,7 @@ extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); */ extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); -/*@}*//*OpenGL support functions*/ +/*@} *//*OpenGL support functions */ /* Ends C function definitions when using C++ */ diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 18fdcacd3..4956f1f41 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -61,7 +61,7 @@ InitMS_ADPCM(WaveFMT * format) SDL_SwapLE16(format->bitspersample); rogue_feel = (Uint8 *) format + sizeof(*format); if (sizeof(*format) == 16) { - /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);*/ + /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ rogue_feel += sizeof(Uint16); } MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); @@ -242,7 +242,7 @@ InitIMA_ADPCM(WaveFMT * format) SDL_SwapLE16(format->bitspersample); rogue_feel = (Uint8 *) format + sizeof(*format); if (sizeof(*format) == 16) { - /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);*/ + /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ rogue_feel += sizeof(Uint16); } IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 13cc77bf6..93de9d7e4 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -304,7 +304,7 @@ ALSA_PlayDevice(_THIS) while ( frames_left > 0 && this->enabled ) { /* !!! FIXME: This works, but needs more testing before going live */ - /*ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1);*/ + /*ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1); */ status = ALSA_snd_pcm_writei(this->hidden->pcm_handle, sample_buf, frames_left); diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 6e0a283be..f5cf1a01e 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -63,7 +63,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.freq = 44100; /* Update the fragment size as size in bytes. */ -/* SDL_CalculateAudioSpec(this->spec); MOD*/ +/* SDL_CalculateAudioSpec(this->spec); MOD */ switch (this->spec.format) { case AUDIO_U8: this->spec.silence = 0x80; @@ -76,7 +76,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.size *= this->spec.channels; this->spec.size *= this->spec.samples; -/*==========================================*/ +/*========================================== */ /* Allocate the mixing buffer. Its size and starting address must be a multiple of 64 bytes. Our sample count is already a multiple of @@ -162,7 +162,7 @@ static int PSPAUD_Init(SDL_AudioDriverImpl * impl) { - /* Set the function pointers*/ + /* Set the function pointers */ impl->OpenDevice = PSPAUD_OpenDevice; impl->PlayDevice = PSPAUD_PlayDevice; impl->WaitDevice = PSPAUD_WaitDevice; @@ -171,7 +171,7 @@ PSPAUD_Init(SDL_AudioDriverImpl * impl) impl->CloseDevice = PSPAUD_CloseDevice; impl->ThreadInit = PSPAUD_ThreadInit; - /*PSP audio device*/ + /*PSP audio device */ impl->OnlyHasDefaultOutputDevice = 1; /* impl->HasCaptureSupport = 1; @@ -189,7 +189,7 @@ AudioBootStrap PSPAUD_bootstrap = { "psp", "PSP audio driver", PSPAUD_Init, 0 }; - /* SDL_AUDI*/ + /* SDL_AUDI */ diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 8af2926d3..df963fdaa 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -40,8 +40,8 @@ #include #include #define LOG_TAG "SDL_android" -/*#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)*/ -/*#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)*/ +/*#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */ +/*#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */ #define LOGI(...) do {} while (false) #define LOGE(...) do {} while (false) @@ -680,7 +680,7 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) if (false) { fallback: /* Disabled log message because of spam on the Nexus 7 */ - /*__android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file");*/ + /*__android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */ /* Try the old method using InputStream */ ctx->hidden.androidio.assetFileDescriptorRef = NULL; @@ -688,7 +688,7 @@ fallback: /* inputStream = assetManager.open(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "open", "(Ljava/lang/String;I)Ljava/io/InputStream;"); - inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /*ACCESS_RANDOM*/); + inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /*ACCESS_RANDOM */); if (Android_JNI_ExceptionOccurred(false)) { goto failure; } @@ -790,7 +790,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, if (ctx->hidden.androidio.assetFileDescriptorRef) { size_t bytesMax = size * maxnum; - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { + if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH */ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { bytesMax = ctx->hidden.androidio.size - ctx->hidden.androidio.position; } size_t result = read(ctx->hidden.androidio.fd, buffer, bytesMax ); @@ -878,7 +878,7 @@ static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release) else { jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef; - /* inputStream.close();*/ + /* inputStream.close(); */ jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "close", "()V"); (*mEnv)->CallVoidMethod(mEnv, inputStream, mid); @@ -909,12 +909,12 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) if (ctx->hidden.androidio.assetFileDescriptorRef) { switch (whence) { case RW_SEEK_SET: - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; + if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_CUR: offset += ctx->hidden.androidio.position; - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; + if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_END: diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index e95fd4659..3ce0f496d 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -34,7 +34,7 @@ extern "C" { /* Interface from the SDL library into the Android Java activity */ /*extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); -extern SDL_bool Android_JNI_DeleteContext(void);*/ +extern SDL_bool Android_JNI_DeleteContext(void); */ extern void Android_JNI_SwapWindow(); extern void Android_JNI_SetActivityTitle(const char *title); extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]); diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 617ea0b4f..908c030cc 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -121,8 +121,8 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) if (src == NULL) return 0; - /*No Longer storing the Hash, rehash on load*/ - /*if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;*/ + /*No Longer storing the Hash, rehash on load */ + /*if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */ if (SDL_RWwrite(src,templ->path, sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) @@ -159,7 +159,7 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) } /*path is an already sampled set of points -Returns the index of the gesture on success, or -1*/ +Returns the index of the gesture on success, or -1 */ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) { SDL_DollarTemplate* dollarTemplate; @@ -196,7 +196,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) if (index < 0) return -1; } - /* Use the index of the last one added.*/ + /* Use the index of the last one added. */ return index; } else { return SDL_AddDollarGesture_one(inTouch, path); @@ -223,16 +223,16 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) DOLLARNPOINTS) break; if (touchId >= 0) { - /*printf("Adding loaded gesture to 1 touch\n");*/ + /*printf("Adding loaded gesture to 1 touch\n"); */ if (SDL_AddDollarGesture(touch, templ.path) >= 0) loaded++; } else { - /*printf("Adding to: %i touches\n",SDL_numGestureTouches);*/ + /*printf("Adding to: %i touches\n",SDL_numGestureTouches); */ for (i = 0; i < SDL_numGestureTouches; i++) { touch = &SDL_gestureTouch[i]; - /*printf("Adding loaded gesture to + touches\n");*/ - /*TODO: What if this fails?*/ + /*printf("Adding loaded gesture to + touches\n"); */ + /*TODO: What if this fails? */ SDL_AddDollarGesture(touch,templ.path); } loaded++; @@ -245,7 +245,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { - /* SDL_FloatPoint p[DOLLARNPOINTS];*/ + /* SDL_FloatPoint p[DOLLARNPOINTS]; */ float dist = 0; SDL_FloatPoint p; int i; @@ -297,7 +297,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) return SDL_min(f1,f2); } -/*DollarPath contains raw points, plus (possibly) the calculated length*/ +/*DollarPath contains raw points, plus (possibly) the calculated length */ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { int i; @@ -310,7 +310,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) float w,h; float length = path->length; - /*Calculate length if it hasn't already been done*/ + /*Calculate length if it hasn't already been done */ if (length <= 0) { for (i=1;i < path->numPoints; i++) { float dx = path->p[i ].x - path->p[i-1].x; @@ -319,17 +319,17 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) } } - /*Resample*/ + /*Resample */ interval = length/(DOLLARNPOINTS - 1); dist = interval; centroid.x = 0;centroid.y = 0; - /*printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y);*/ + /*printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ for (i = 1; i < path->numPoints; i++) { float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); - /*printf("d = %f dist = %f/%f\n",d,dist,interval);*/ + /*printf("d = %f dist = %f/%f\n",d,dist,interval); */ while (dist + d > interval) { points[numPoints].x = path->p[i-1].x + ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); @@ -347,15 +347,15 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) SDL_SetError("ERROR: NumPoints = %i\n",numPoints); return 0; } - /*copy the last point*/ + /*copy the last point */ points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; numPoints = DOLLARNPOINTS; centroid.x /= numPoints; centroid.y /= numPoints; - /*printf("Centroid (%f,%f)",centroid.x,centroid.y);*/ - /*Rotate Points so point 0 is left of centroid and solve for the bounding box*/ + /*printf("Centroid (%f,%f)",centroid.x,centroid.y); */ + /*Rotate Points so point 0 is left of centroid and solve for the bounding box */ xmin = centroid.x; xmax = centroid.x; ymin = centroid.y; @@ -379,7 +379,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) if (points[i].y > ymax) ymax = points[i].y; } - /*Scale points to DOLLARSIZE, and translate to the origin*/ + /*Scale points to DOLLARSIZE, and translate to the origin */ w = xmax-xmin; h = ymax-ymin; @@ -400,7 +400,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu dollarNormalize(path,points); - /*PrintPath(points);*/ + /*PrintPath(points); */ *bestTempl = -1; for (i = 0; i < touch->numDollarTemplates; i++) { float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); @@ -436,7 +436,7 @@ static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { - /*printf("%i ?= %i\n",SDL_gestureTouch[i].id,id);*/ + /*printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */ if (SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i]; } @@ -466,7 +466,7 @@ static int SDL_SendGestureDollar(SDL_GestureTouch* touch, event.mgesture.y = touch->centroid.y; event.dgesture.gestureId = gestureId; event.dgesture.error = error; - /*A finger came up to trigger this event.*/ + /*A finger came up to trigger this event. */ event.dgesture.numFingers = touch->numDownFingers + 1; return SDL_PushEvent(&event) > 0; } @@ -501,13 +501,13 @@ void SDL_GestureProcessEvent(SDL_Event* event) event->type == SDL_FINGERUP) { SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); - /*Shouldn't be possible*/ + /*Shouldn't be possible */ if (inTouch == NULL) return; x = event->tfinger.x; y = event->tfinger.y; - /*Finger Up*/ + /*Finger Up */ if (event->type == SDL_FINGERUP) { inTouch->numDownFingers--; @@ -515,7 +515,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) if (inTouch->recording) { inTouch->recording = SDL_FALSE; dollarNormalize(&inTouch->dollarPath,path); - /*PrintPath(path);*/ + /*PrintPath(path); */ if (recordAll) { index = SDL_AddDollarGesture(NULL,path); for (i = 0; i < SDL_numGestureTouches; i++) @@ -538,14 +538,14 @@ void SDL_GestureProcessEvent(SDL_Event* event) error = dollarRecognize(&inTouch->dollarPath, &bestTempl,inTouch); if (bestTempl >= 0){ - /*Send Event*/ + /*Send Event */ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch,gestureId,error); - /*printf ("%s\n",);("Dollar error: %f\n",error);*/ + /*printf ("%s\n",);("Dollar error: %f\n",error); */ } } #endif - /*inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];*/ + /*inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ if (inTouch->numDownFingers > 0) { inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- x)/inTouch->numDownFingers; @@ -575,22 +575,22 @@ void SDL_GestureProcessEvent(SDL_Event* event) inTouch->centroid.x += dx/inTouch->numDownFingers; inTouch->centroid.y += dy/inTouch->numDownFingers; - /*printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y);*/ + /*printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */ if (inTouch->numDownFingers > 1) { - SDL_FloatPoint lv; /*Vector from centroid to last x,y position*/ - SDL_FloatPoint v; /*Vector from centroid to current x,y position*/ - /*lv = inTouch->gestureLast[j].cv;*/ + SDL_FloatPoint lv; /*Vector from centroid to last x,y position */ + SDL_FloatPoint v; /*Vector from centroid to current x,y position */ + /*lv = inTouch->gestureLast[j].cv; */ lv.x = lastP.x - lastCentroid.x; lv.y = lastP.y - lastCentroid.y; lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); - /*printf("lDist = %f\n",lDist);*/ + /*printf("lDist = %f\n",lDist); */ v.x = x - inTouch->centroid.x; v.y = y - inTouch->centroid.y; - /*inTouch->gestureLast[j].cv = v;*/ + /*inTouch->gestureLast[j].cv = v; */ Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); - /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)*/ + /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */ - /*Normalize Vectors to simplify angle calculation*/ + /*Normalize Vectors to simplify angle calculation */ lv.x/=lDist; lv.y/=lDist; v.x/=Dist; @@ -598,7 +598,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); dDist = (Dist - lDist); - if (lDist == 0) {dDist = 0;dtheta = 0;} /*To avoid impossible values*/ + if (lDist == 0) {dDist = 0;dtheta = 0;} /*To avoid impossible values */ /*inTouch->gestureLast[j].dDist = dDist; inTouch->gestureLast[j].dtheta = dtheta; @@ -609,19 +609,19 @@ void SDL_GestureProcessEvent(SDL_Event* event) knob.r += dDist/numDownFingers; knob.ang += dtheta; printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); - printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);*/ + printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); */ SDL_SendGestureMulti(inTouch,dtheta,dDist); } else { /*inTouch->gestureLast[j].dDist = 0; inTouch->gestureLast[j].dtheta = 0; inTouch->gestureLast[j].cv.x = 0; - inTouch->gestureLast[j].cv.y = 0;*/ + inTouch->gestureLast[j].cv.y = 0; */ } /*inTouch->gestureLast[j].f.p.x = x; inTouch->gestureLast[j].f.p.y = y; break; - pressure?*/ + pressure? */ } if (event->type == SDL_FINGERDOWN) { @@ -632,7 +632,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ y)/inTouch->numDownFingers; /*printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, - inTouch->centroid.x,inTouch->centroid.y);*/ + inTouch->centroid.x,inTouch->centroid.y); */ #ifdef ENABLE_DOLLAR inTouch->dollarPath.length = 0; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index a3ed16869..4577857fa 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -28,7 +28,7 @@ #include "../video/SDL_sysvideo.h" -/*#define DEBUG_KEYBOARD*/ +/*#define DEBUG_KEYBOARD */ /* Global keyboard information */ diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index e9404f057..fa30361b7 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -28,7 +28,7 @@ #include "default_cursor.h" #include "../video/SDL_sysvideo.h" -/*#define DEBUG_MOUSE*/ +/*#define DEBUG_MOUSE */ /* The mouse state */ static SDL_Mouse SDL_mouse; diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index ec889041c..72a336dec 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -343,7 +343,7 @@ GetSupportedFeatures(SDL_Haptic * haptic) FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE);*/ + /*FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); */ FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE); FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE); FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP); @@ -752,7 +752,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE:*/ + /*case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -982,7 +982,7 @@ SDL_SYS_HapticEffectType(Uint16 type) /* !!! FIXME: put this back when we have more bits in 2.1 */ /*case SDL_HAPTIC_SQUARE: - return kFFEffectType_Square_ID;*/ + return kFFEffectType_Square_ID; */ case SDL_HAPTIC_SINE: return kFFEffectType_Sine_ID; diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index ad34fc27f..1c2500c1e 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -100,7 +100,7 @@ EV_IsHaptic(int fd) EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); EV_TEST(FF_SINE, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE);*/ + /*EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); */ EV_TEST(FF_TRIANGLE, SDL_HAPTIC_TRIANGLE); EV_TEST(FF_SAW_UP, SDL_HAPTIC_SAWTOOTHUP); EV_TEST(FF_SAW_DOWN, SDL_HAPTIC_SAWTOOTHDOWN); @@ -600,7 +600,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE:*/ + /*case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -626,7 +626,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) dest->u.periodic.waveform = FF_SINE; /* !!! FIXME: put this back when we have more bits in 2.1 */ /*else if (periodic->type == SDL_HAPTIC_SQUARE) - dest->u.periodic.waveform = FF_SQUARE;*/ + dest->u.periodic.waveform = FF_SQUARE; */ else if (periodic->type == SDL_HAPTIC_TRIANGLE) dest->u.periodic.waveform = FF_TRIANGLE; else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 9b1349644..6d77973a6 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -304,7 +304,7 @@ DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM); EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);*/ + /*EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); */ EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE); EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP); EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); @@ -936,7 +936,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE:*/ + /*case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -1166,7 +1166,7 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) /* !!! FIXME: put this back when we have more bits in 2.1 */ /*case SDL_HAPTIC_SQUARE: - return &GUID_Square;*/ + return &GUID_Square; */ case SDL_HAPTIC_SINE: return &GUID_Sine; diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 912be0524..0a4ad6b0d 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -52,7 +52,7 @@ struct _SDL_HatMapping */ #define k_nMaxHatEntries 0x3f + 1 -/* our in memory mapping db between joystick objects and controller mappings*/ +/* our in memory mapping db between joystick objects and controller mappings */ struct _SDL_ControllerMapping { SDL_JoystickGUID guid; diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index b1197093e..4e086248d 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -488,14 +488,14 @@ SDL_PrivateJoystickShouldIgnoreEvent() if (SDL_WasInit(SDL_INIT_VIDEO)) { if (SDL_GetKeyboardFocus() == NULL) { - /* Video is initialized and we don't have focus, ignore the event.*/ + /* Video is initialized and we don't have focus, ignore the event. */ return SDL_TRUE; } else { return SDL_FALSE; } } - /* Video subsystem wasn't initialized, always allow the event*/ + /* Video subsystem wasn't initialized, always allow the event */ return SDL_FALSE; } diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index 4e50e4dd6..2251d0d33 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -771,7 +771,7 @@ SDL_SYS_JoystickInit(void) ("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching."); } - /*/ Now search I/O Registry for matching devices. */ + / */ Now search I/O Registry for matching devices. */ result = IOServiceGetMatchingServices(masterPort, hidMatchDictionary, &hidObjectIterator); diff --git a/src/libm/e_atan2.c b/src/libm/e_atan2.c index 3f1ee5771..f2aa23600 100644 --- a/src/libm/e_atan2.c +++ b/src/libm/e_atan2.c @@ -81,8 +81,8 @@ double attribute_hidden __ieee754_atan2(double y, double x) switch(m) { case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ - case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ - case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ + case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF) */ + case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF) */ } } else { switch(m) { diff --git a/src/libm/math_private.h b/src/libm/math_private.h index c5ab63d7c..9a08b103b 100644 --- a/src/libm/math_private.h +++ b/src/libm/math_private.h @@ -17,9 +17,9 @@ #ifndef _MATH_PRIVATE_H_ #define _MATH_PRIVATE_H_ -/*#include */ +/*#include */ #include "SDL_endian.h" -/*#include */ +/*#include */ #define attribute_hidden #define libm_hidden_proto(x) diff --git a/src/main/android/SDL_android_main.c b/src/main/android/SDL_android_main.c index 649bd4ffa..e2889dbc9 100644 --- a/src/main/android/SDL_android_main.c +++ b/src/main/android/SDL_android_main.c @@ -30,7 +30,7 @@ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject status = SDL_main(1, argv); /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ - /*exit(status);*/ + /*exit(status); */ } #endif /* __ANDROID__ */ diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index bb235b0a2..257704524 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -958,10 +958,10 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) if (SDL_HasMMX() && (Rmask == 0xF800) && (Gmask == 0x07E0) && (Bmask == 0x001F) && (swdata->w & 15) == 0) { -/*printf("Using MMX 16-bit 565 dither\n");*/ +/*printf("Using MMX 16-bit 565 dither\n"); */ swdata->Display1X = Color565DitherYV12MMX1X; } else { -/*printf("Using C 16-bit dither\n");*/ +/*printf("Using C 16-bit dither\n"); */ swdata->Display1X = Color16DitherYV12Mod1X; } #else @@ -979,10 +979,10 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) if (SDL_HasMMX() && (Rmask == 0x00FF0000) && (Gmask == 0x0000FF00) && (Bmask == 0x000000FF) && (swdata->w & 15) == 0) { -/*printf("Using MMX 32-bit dither\n");*/ +/*printf("Using MMX 32-bit dither\n"); */ swdata->Display1X = ColorRGBDitherYV12MMX1X; } else { -/*printf("Using C 32-bit dither\n");*/ +/*printf("Using C 32-bit dither\n"); */ swdata->Display1X = Color32DitherYV12Mod1X; } #else diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index b51cb012b..a09894494 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -874,7 +874,7 @@ GetScaleQuality(void) if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { return D3DTEXF_POINT; - } else /*if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0)*/ { + } else /*if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ { return D3DTEXF_LINEAR; } } diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 697a974c5..facb89e98 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -310,7 +310,7 @@ GL_ResetState(SDL_Renderer *renderer) data->glDisable(GL_DEPTH_TEST); data->glDisable(GL_CULL_FACE); /* This ended up causing video discrepancies between OpenGL and Direct3D */ - /*data->glEnable(GL_LINE_SMOOTH);*/ + /*data->glEnable(GL_LINE_SMOOTH); */ data->glMatrixMode(GL_MODELVIEW); data->glLoadIdentity(); @@ -638,7 +638,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return -1; } if ((renderdata->GL_ARB_texture_rectangle_supported) - /*&& texture->access != SDL_TEXTUREACCESS_TARGET*/){ + /*&& texture->access != SDL_TEXTUREACCESS_TARGET */){ data->type = GL_TEXTURE_RECTANGLE_ARB; texture_w = texture->w; texture_h = texture->h; diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 1e6262191..162713ea7 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -30,7 +30,7 @@ /* OpenGL shader implementation */ -/*#define DEBUG_SHADERS*/ +/*#define DEBUG_SHADERS */ typedef struct { diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 3b7666c18..5b104373c 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -458,7 +458,7 @@ PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { -/* PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata;*/ +/* PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; */ PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture));; if(!psp_texture) @@ -528,7 +528,7 @@ static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { -/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata;*/ +/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; */ const Uint8 *src; Uint8 *dst; int row, length,dpitch; @@ -895,8 +895,8 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, sceGuColor(0xFFFFFFFF); } -/* x += width * 0.5f;*/ -/* y += height * 0.5f;*/ +/* x += width * 0.5f; */ +/* y += height * 0.5f; */ x += centerx; y += centery; @@ -904,8 +904,8 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, MathSincos(degToRad(angle), &s, &c); -/* width *= 0.5f;*/ -/* height *= 0.5f;*/ +/* width *= 0.5f; */ +/* height *= 0.5f; */ width -= centerx; height -= centery; @@ -968,7 +968,7 @@ PSP_RenderPresent(SDL_Renderer * renderer) sceGuFinish(); sceGuSync(0,0); -/* if(data->vsync)*/ +/* if(data->vsync) */ sceDisplayWaitVblankStart(); data->backbuffer = data->frontbuffer; @@ -1007,8 +1007,8 @@ PSP_DestroyRenderer(SDL_Renderer * renderer) StartDrawing(renderer); sceGuTerm(); -/* vfree(data->backbuffer);*/ -/* vfree(data->frontbuffer);*/ +/* vfree(data->backbuffer); */ +/* vfree(data->frontbuffer); */ data->initialized = SDL_FALSE; data->displayListAvail = SDL_FALSE; diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index b31553587..538d10c5c 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -357,7 +357,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce if (src == NULL) return (NULL); - if (src->flags & SDL_TRUE/*SDL_SRCCOLORKEY*/) + if (src->flags & SDL_TRUE/*SDL_SRCCOLORKEY */) { colorkey = _colorkey(src); SDL_GetRGB(colorkey, src->format, &r, &g, &b); @@ -391,7 +391,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce SDL_BlitSurface(src, NULL, rz_src, NULL); if(colorKeyAvailable) - SDL_SetColorKey(src, SDL_TRUE /*SDL_SRCCOLORKEY*/, colorkey); + SDL_SetColorKey(src, SDL_TRUE /*SDL_SRCCOLORKEY */, colorkey); src_converted = 1; is32bit = 1; } @@ -459,8 +459,8 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce /* * Turn on source-alpha support */ - /*SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);*/ - SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + /*SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */ + SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } else { /* * Copy palette and colorkey info @@ -475,7 +475,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce transformSurfaceY(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy); - SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } /* * Unlock source surface diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 9ef4a074b..ca08876e3 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -355,18 +355,18 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) } else if (alpha == amask) { *dstp = *srcp; } else { - src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ + src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ - mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha*/ - mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha*/ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ /* blend */ src1 = _mm_mullo_pi16(src1, mm_alpha); @@ -548,18 +548,18 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) } else if (alpha == amask) { *dstp = *srcp; } else { - src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ + src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ - mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha*/ - mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha*/ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ /* blend */ diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index df43ed0ce..81d93f7ab 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -97,23 +97,23 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) /* The Win32 BMP file header (14 bytes) */ char magic[2]; - /*Uint32 bfSize = 0;*/ - /*Uint16 bfReserved1 = 0;*/ - /*Uint16 bfReserved2 = 0;*/ + /*Uint32 bfSize = 0; */ + /*Uint16 bfReserved1 = 0; */ + /*Uint16 bfReserved2 = 0; */ Uint32 bfOffBits = 0; /* The Win32 BITMAPINFOHEADER struct (40 bytes) */ Uint32 biSize = 0; Sint32 biWidth = 0; Sint32 biHeight = 0; - /*Uint16 biPlanes = 0;*/ + /*Uint16 biPlanes = 0; */ Uint16 biBitCount = 0; Uint32 biCompression = 0; - /*Uint32 biSizeImage = 0;*/ - /*Sint32 biXPelsPerMeter = 0;*/ - /*Sint32 biYPelsPerMeter = 0;*/ + /*Uint32 biSizeImage = 0; */ + /*Sint32 biXPelsPerMeter = 0; */ + /*Sint32 biYPelsPerMeter = 0; */ Uint32 biClrUsed = 0; - /*Uint32 biClrImportant = 0;*/ + /*Uint32 biClrImportant = 0; */ /* Make sure we are passed a valid data source */ surface = NULL; @@ -136,9 +136,9 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) was_error = SDL_TRUE; goto done; } - /*bfSize =*/ SDL_ReadLE32(src); - /*bfReserved1 =*/ SDL_ReadLE16(src); - /*bfReserved2 =*/ SDL_ReadLE16(src); + /*bfSize = */ SDL_ReadLE32(src); + /*bfReserved1 = */ SDL_ReadLE16(src); + /*bfReserved2 = */ SDL_ReadLE16(src); bfOffBits = SDL_ReadLE32(src); /* Read the Win32 BITMAPINFOHEADER */ @@ -146,20 +146,20 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (biSize == 12) { biWidth = (Uint32) SDL_ReadLE16(src); biHeight = (Uint32) SDL_ReadLE16(src); - /*biPlanes =*/ SDL_ReadLE16(src); + /*biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = BI_RGB; } else { biWidth = SDL_ReadLE32(src); biHeight = SDL_ReadLE32(src); - /*biPlanes =*/ SDL_ReadLE16(src); + /*biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = SDL_ReadLE32(src); - /*biSizeImage =*/ SDL_ReadLE32(src); - /*biXPelsPerMeter =*/ SDL_ReadLE32(src); - /*biYPelsPerMeter =*/ SDL_ReadLE32(src); + /*biSizeImage = */ SDL_ReadLE32(src); + /*biXPelsPerMeter = */ SDL_ReadLE32(src); + /*biYPelsPerMeter = */ SDL_ReadLE32(src); biClrUsed = SDL_ReadLE32(src); - /*biClrImportant =*/ SDL_ReadLE32(src); + /*biClrImportant = */ SDL_ReadLE32(src); } if (biHeight < 0) { topDown = SDL_TRUE; diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index a99371e05..6e9b8e796 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -119,7 +119,7 @@ SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) SSE_END; } -/*DEFINE_SSE_FILLRECT(1, Uint8)*/ +/*DEFINE_SSE_FILLRECT(1, Uint8) */ DEFINE_SSE_FILLRECT(2, Uint16) DEFINE_SSE_FILLRECT(4, Uint32) @@ -212,7 +212,7 @@ SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) MMX_END; } -/*DEFINE_MMX_FILLRECT(1, Uint8)*/ +/*DEFINE_MMX_FILLRECT(1, Uint8) */ DEFINE_MMX_FILLRECT(2, Uint16) DEFINE_MMX_FILLRECT(4, Uint32) diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index e9876e410..490714de0 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -33,7 +33,7 @@ SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { SDL_Window *result = NULL; - result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/); + result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN) */); if(result != NULL) { result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); if(result->shaper != NULL) { diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 69980d076..b01d2f35e 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -38,7 +38,7 @@ (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES /* There's a bug with gcc 4.4.1 and -O2 where srcp doesn't get the correct * value after the first scanline. FIXME? */ -/*#define USE_ASM_STRETCH*/ +/*#define USE_ASM_STRETCH */ #endif #ifdef USE_ASM_STRETCH diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 460d53bc3..9b144cb96 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -963,7 +963,7 @@ SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, surface->h = height; surface->pitch = pitch; /* We don't actually need to set up the clip rect for our purposes */ - /*SDL_SetClipRect(surface, NULL);*/ + /*SDL_SetClipRect(surface, NULL); */ /* Allocate an empty mapping */ SDL_zerop(blitmap); diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index d0a16e1d7..03573973e 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -38,7 +38,7 @@ android_egl_context_restore() SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; if (SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context) < 0) { /* The context is no longer valid, create a new one */ - /* FIXME: Notify the user that the context changed and textures need to be re created*/ + /* FIXME: Notify the user that the context changed and textures need to be re created */ data->egl_context = (EGLContext) SDL_GL_CreateContext(Android_Window); SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context); } diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index 9540bd323..d61b5c225 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -353,7 +353,7 @@ class SDL_BWin:public BDirectWindow - CTRL+Q to close window (and other shortcuts) - PrintScreen to make screenshot into /boot/home - etc.. */ - /*BDirectWindow::DispatchMessage(msg, target);*/ + /*BDirectWindow::DispatchMessage(msg, target); */ break; } @@ -463,7 +463,7 @@ private: /*FIXME: Why were these here? if false: be_app->SetCursor(B_HAND_CURSOR); - if true: SDL_SetCursor(NULL);*/ + if true: SDL_SetCursor(NULL); */ } void _MouseButtonEvent(int32 buttons) { diff --git a/src/video/bwindow/SDL_bopengl.h b/src/video/bwindow/SDL_bopengl.h index a7e924bce..4e1a5cf7c 100644 --- a/src/video/bwindow/SDL_bopengl.h +++ b/src/video/bwindow/SDL_bopengl.h @@ -29,13 +29,13 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int BE_GL_LoadLibrary(_THIS, const char *path); /*FIXME*/ -extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /*FIXME*/ -extern void BE_GL_UnloadLibrary(_THIS); /*TODO*/ +extern int BE_GL_LoadLibrary(_THIS, const char *path); /*FIXME */ +extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /*FIXME */ +extern void BE_GL_UnloadLibrary(_THIS); /*TODO */ extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern int BE_GL_SetSwapInterval(_THIS, int interval); /*TODO*/ -extern int BE_GL_GetSwapInterval(_THIS); /*TODO*/ +extern int BE_GL_SetSwapInterval(_THIS, int interval); /*TODO */ +extern int BE_GL_GetSwapInterval(_THIS); /*TODO */ extern void BE_GL_SwapWindow(_THIS, SDL_Window * window); extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window); extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context); diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index 8241d9b3d..c9f683cce 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -351,7 +351,7 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) dy = 0; SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); - /* necessary to trigger an event - ugly*/ + /* necessary to trigger an event - ugly */ SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy)); SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 483ba9cb1..9c34754fd 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -132,7 +132,7 @@ MotionAllMice(_THIS, int x, int y) SDL_Mouse *mouse = SDL_GetMouse(index); mouse->x = mouse->last_x = x; mouse->y = mouse->last_y = y; - /*SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0);*/ + /*SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0); */ } #endif } @@ -233,7 +233,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) case DWET_KEYDOWN: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym, &unicode); - /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id);*/ + /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_zero(text); diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 958793db7..e40dcbeba 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -131,7 +131,7 @@ SDL_RenderDriver DirectFB_RenderDriver = { (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | - SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),*/ + SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST), */ 0, { /* formats filled in later */ @@ -450,7 +450,7 @@ DirectFB_ActivateRenderer(SDL_Renderer * renderer) SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); - if (renddata->size_changed /*|| windata->wm_needs_redraw*/) { + if (renddata->size_changed /*|| windata->wm_needs_redraw */) { renddata->size_changed = SDL_FALSE; } } diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index 54cd4e7d8..e2746c628 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -118,7 +118,7 @@ void PSP_PumpEvents(_THIS) pressed = scanData->pressed; sym.scancode = raw; sym.sym = keymap[raw]; - /* not tested*/ + /* not tested */ /*SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]); diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index ed5ab1c96..64b48eb5e 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -306,7 +306,7 @@ PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) } -/* TO Write Me*/ +/* TO Write Me */ SDL_bool PSP_HasScreenKeyboardSupport(_THIS) { return SDL_FALSE; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index bf7d0117f..516d4e22d 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -36,7 +36,7 @@ /* For GET_X_LPARAM, GET_Y_LPARAM. */ #include -/*#define WMMSG_DEBUG*/ +/*#define WMMSG_DEBUG */ #ifdef WMMSG_DEBUG #include #include "wmmsg.h" diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 4bdfd1c6e..385039f7e 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -97,7 +97,7 @@ static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) if (a2 != None) atom[count++] = a2; return X11_PickTarget(disp, atom, count); } -/*#define DEBUG_XEVENTS*/ +/*#define DEBUG_XEVENTS */ struct KeyRepeatCheckData { @@ -384,7 +384,7 @@ X11_DispatchEvent(_THIS) I think it's better to think the ALT key is held down when it's not, then always lose the ALT modifier on Unity. */ - /*SDL_ResetKeyboard();*/ + /*SDL_ResetKeyboard(); */ } data->pending_focus = PENDING_FOCUS_IN; data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_IN_TIME; diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index b66b94b1a..be3383227 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -26,7 +26,7 @@ #include "SDL_x11video.h" #include "edid.h" -/*#define X11MODES_DEBUG*/ +/*#define X11MODES_DEBUG */ /* I'm becoming more and more convinced that the application should never * use XRandR, and it's the window manager's responsibility to track and @@ -38,7 +38,7 @@ * * However, many people swear by it, so let them swear at it. :) */ -/*#define XRANDR_DISABLED_BY_DEFAULT*/ +/*#define XRANDR_DISABLED_BY_DEFAULT */ static int diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 60acd706c..4b70f6602 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -131,7 +131,7 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; Display *display = videodata->display; Atom _NET_WM_STATE = videodata->_NET_WM_STATE; - /*Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;*/ + /*Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; */ Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED; Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT; Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ; @@ -213,7 +213,7 @@ X11_GetNetWMState(_THIS, Window xwindow) } /* FIXME, check the size hints for resizable */ - /*flags |= SDL_WINDOW_RESIZABLE;*/ + /*flags |= SDL_WINDOW_RESIZABLE; */ return flags; } @@ -823,7 +823,7 @@ X11_SetWindowSize(_THIS, SDL_Window * window) } if (!(window->flags & SDL_WINDOW_RESIZABLE)) { /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus - we must set the size hints to adjust the window size.*/ + we must set the size hints to adjust the window size. */ XSizeHints *sizehints = XAllocSizeHints(); long userhints; diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 1b86c6774..01b4da34f 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -95,20 +95,20 @@ X11_InitXinput2(_THIS) return; } - /*Check supported version*/ + /*Check supported version */ if(outmajor * 1000 + outminor < major * 1000 + minor) { - /*X server does not support the version we want*/ + /*X server does not support the version we want */ return; } xinput2_initialized = 1; #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - /*XInput 2.2*/ + /*XInput 2.2 */ if(outmajor * 1000 + outminor >= major * 1000 + minor) { xinput2_multitouch_supported = 1; } #endif - /*Enable Raw motion events for this display*/ + /*Enable Raw motion events for this display */ eventmask.deviceid = XIAllMasterDevices; eventmask.mask_len = sizeof(mask); eventmask.mask = mask; @@ -188,7 +188,7 @@ X11_InitXinput2Multitouch(_THIS) XIAnyClassInfo *class = dev->classes[j]; XITouchClassInfo *t = (XITouchClassInfo*)class; - /*Only touch devices*/ + /*Only touch devices */ if (class->type != XITouchClass) continue; diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index 56a4b906c..ff42f7477 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -25,7 +25,7 @@ #ifndef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS /*Define XGenericEventCookie as forward declaration when - *xinput2 is not available in order to compile*/ + *xinput2 is not available in order to compile */ struct XGenericEventCookie; typedef struct XGenericEventCookie XGenericEventCookie; #endif diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index 90b08acbd..50c16144b 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -643,7 +643,7 @@ int audio_lockUnlockOpenAudioDevice() SDL_Delay(10); SDLTest_Log("Simulate callback processing - delay"); - /* Unlock again*/ + /* Unlock again */ SDL_UnlockAudioDevice(id); SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id); diff --git a/test/testautomation_events.c b/test/testautomation_events.c index 638607e76..f9eb5bb9e 100644 --- a/test/testautomation_events.c +++ b/test/testautomation_events.c @@ -58,7 +58,7 @@ events_pushPumpAndPollUserevent(void *arg) event1.user.data1 = (void *)&_userdataValue1; event1.user.data2 = (void *)&_userdataValue2; - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ SDL_PushEvent(&event1); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); @@ -101,7 +101,7 @@ events_addDelEventWatch(void *arg) SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); @@ -112,7 +112,7 @@ events_addDelEventWatch(void *arg) SDL_DelEventWatch(_events_sampleNullEventFilter, NULL); SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ _eventFilterCalled = 0; SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); @@ -152,7 +152,7 @@ events_addDelEventWatchWithUserdata(void *arg) SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); @@ -163,7 +163,7 @@ events_addDelEventWatchWithUserdata(void *arg) SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ _eventFilterCalled = 0; SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c index 48f9838c8..3c0f63b57 100644 --- a/test/testautomation_pixels.c +++ b/test/testautomation_pixels.c @@ -411,7 +411,7 @@ pixels_calcGammaRamp(void *arg) int changed; Uint16 magic = 0xbeef; - /* Allocate temp ramp array and fill with some value*/ + /* Allocate temp ramp array and fill with some value */ ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16)); SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated"); if (ramp == NULL) return TEST_ABORTED; diff --git a/test/testautomation_video.c b/test/testautomation_video.c index 46061090e..350f0d0d3 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -876,7 +876,7 @@ video_getWindowId(void *arg) /* Clean up */ _destroyVideoSuiteTestWindow(window); - /* Get window from ID for closed window*/ + /* Get window from ID for closed window */ result = SDL_GetWindowFromID(id); SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id); SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); diff --git a/test/testgesture.c b/test/testgesture.c index 3e0fc9dd4..9c1959b52 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -49,7 +49,7 @@ #define BPP 4 #define DEPTH 32 -/*MUST BE A POWER OF 2!*/ +/*MUST BE A POWER OF 2! */ #define EVENT_BUF_SIZE 256 @@ -102,9 +102,9 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); SDL_GetRGB(colour,screen->format,&r,&g,&b); - /*r = 0;g = 0; b = 0;*/ + /*r = 0;g = 0; b = 0; */ a = (float)((col>>24)&0xFF); - if(a == 0) a = 0xFF; /*Hack, to make things easier.*/ + if(a == 0) a = 0xFF; /*Hack, to make things easier. */ a /= 0xFF; r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a)); g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); @@ -127,7 +127,7 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) float xr; for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) { xr = (float)sqrt(r*r - ty*ty); - if(r > 0) { /*r > 0 ==> filled circle*/ + if(r > 0) { /*r > 0 ==> filled circle */ for(tx=-xr+.5f;tx<=xr-.5;tx++) { setpix(screen,x+tx,y+ty,c); } @@ -157,7 +157,7 @@ void DrawScreen(SDL_Surface* screen) setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); #endif - /*draw Touch History*/ + /*draw Touch History */ for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; @@ -170,7 +170,7 @@ void DrawScreen(SDL_Surface* screen) x = event->tfinger.x; y = event->tfinger.y; - /*draw the touch:*/ + /*draw the touch: */ c = colors[event->tfinger.fingerId%7]; col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /*gesture variables*/ + /*gesture variables */ knob.r = .1f; knob.ang = 0; @@ -225,7 +225,7 @@ int main(int argc, char* argv[]) while(!quitting) { while(SDL_PollEvent(&event)) { - /*Record _all_ events*/ + /*Record _all_ events */ events[eventWrite & (EVENT_BUF_SIZE-1)] = event; eventWrite++; diff --git a/test/testhaptic.c b/test/testhaptic.c index c28d0df34..6f523c565 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -280,7 +280,7 @@ HapticPrintSupported(SDL_Haptic * haptic) SDL_Log(" sine\n"); /* !!! FIXME: put this back when we have more bits in 2.1 */ /*if (supported & SDL_HAPTIC_SQUARE) - SDL_Log(" square\n");*/ + SDL_Log(" square\n"); */ if (supported & SDL_HAPTIC_TRIANGLE) SDL_Log(" triangle\n"); if (supported & SDL_HAPTIC_SAWTOOTHUP) diff --git a/test/testime.c b/test/testime.c index 2975e84b9..0baf43733 100644 --- a/test/testime.c +++ b/test/testime.c @@ -343,7 +343,7 @@ int main(int argc, char *argv[]) { SDL_Log("text inputed: %s\n", text); /* After text inputed, we can clear up markedText because it */ - /* is committed*/ + /* is committed */ markedText[0] = 0; Redraw(); break; diff --git a/test/testmessage.c b/test/testmessage.c index 9faa39007..254bd9b3d 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -10,7 +10,7 @@ freely. */ -/* Simple test of the SDL MessageBox API*/ +/* Simple test of the SDL MessageBox API */ #include #include diff --git a/test/testoverlay2.c b/test/testoverlay2.c index 23e1e1f17..addbc27b8 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -356,7 +356,7 @@ main(int argc, char **argv) quit(5); } /* Uncomment this to check vertex color with a YUV texture */ - /*SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80);*/ + /*SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ for (i = 0; i < MOOSEFRAMES_COUNT; i++) { Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3]; diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 2ba739e09..6c26a7a51 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -127,7 +127,7 @@ Draw(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); - /*SDL_Delay(10);*/ + /*SDL_Delay(10); */ } int diff --git a/test/testshape.c b/test/testshape.c index 6a117953f..7c987fe49 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -29,11 +29,11 @@ typedef struct LoadedPicture { void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions) { - /*Clear render-target to blue.*/ + /*Clear render-target to blue. */ SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); SDL_RenderClear(renderer); - /*Render the texture.*/ + /*Render the texture. */ SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); SDL_RenderPresent(renderer); @@ -188,17 +188,17 @@ int main(int argc,char** argv) next_time += TICK_INTERVAL; } - /*Free the textures.*/ + /*Free the textures. */ for(i=0;i Date: Wed, 21 Aug 2013 09:47:10 -0300 Subject: [PATCH 046/258] OCD fixes: Adds a space after /* (glory to regular expressions!) --- Xcode-iOS/Demos/src/fireworks.c | 2 +- Xcode-iOS/Demos/src/keyboard.c | 2 +- Xcode-iOS/Demos/src/touch.c | 2 +- include/SDL.h | 4 +- include/SDL_atomic.h | 4 +- include/SDL_audio.h | 44 ++-- include/SDL_config_psp.h | 4 +- include/SDL_endian.h | 8 +- include/SDL_error.h | 4 +- include/SDL_events.h | 8 +- include/SDL_haptic.h | 14 +- include/SDL_joystick.h | 4 +- include/SDL_mutex.h | 12 +- include/SDL_pixels.h | 4 +- include/SDL_platform.h | 2 +- include/SDL_rwops.h | 16 +- include/SDL_scancode.h | 12 +- include/SDL_stdinc.h | 8 +- include/SDL_surface.h | 4 +- include/SDL_test_harness.h | 28 +-- include/SDL_video.h | 4 +- src/audio/SDL_audio.c | 2 +- src/audio/SDL_wave.c | 4 +- src/audio/alsa/SDL_alsa_audio.c | 2 +- src/audio/psp/SDL_pspaudio.c | 4 +- src/core/android/SDL_android.c | 16 +- src/core/android/SDL_android.h | 2 +- src/events/SDL_gesture.c | 74 +++---- src/events/SDL_keyboard.c | 2 +- src/events/SDL_mouse.c | 2 +- src/haptic/darwin/SDL_syshaptic.c | 8 +- src/haptic/linux/SDL_syshaptic.c | 6 +- src/haptic/windows/SDL_syshaptic.c | 6 +- src/libm/e_atan2.c | 4 +- src/libm/e_pow.c | 2 +- src/libm/math_private.h | 4 +- src/libm/s_scalbn.c | 6 +- src/main/android/SDL_android_main.c | 2 +- src/render/SDL_yuv_sw.c | 8 +- src/render/direct3d/SDL_render_d3d.c | 2 +- src/render/opengl/SDL_render_gl.c | 4 +- src/render/opengl/SDL_shaders_gl.c | 2 +- src/render/software/SDL_rotate.c | 32 +-- src/test/SDL_test_assert.c | 4 +- src/test/SDL_test_font.c | 256 +++++++++++------------ src/test/SDL_test_fuzzer.c | 4 +- src/test/SDL_test_harness.c | 2 +- src/test/SDL_test_log.c | 2 +- src/video/SDL_bmp.c | 34 +-- src/video/SDL_fillrect.c | 4 +- src/video/SDL_shape.c | 2 +- src/video/SDL_stretch.c | 2 +- src/video/SDL_surface.c | 2 +- src/video/bwindow/SDL_BWin.h | 4 +- src/video/bwindow/SDL_bopengl.h | 10 +- src/video/directfb/SDL_DirectFB_WM.c | 4 +- src/video/directfb/SDL_DirectFB_events.c | 8 +- src/video/directfb/SDL_DirectFB_render.c | 14 +- src/video/directfb/SDL_DirectFB_shape.c | 2 +- src/video/directfb/SDL_DirectFB_video.c | 2 +- src/video/directfb/SDL_DirectFB_window.c | 2 +- src/video/directfb/SDL_DirectFB_window.h | 2 +- src/video/psp/SDL_pspevents.c | 2 +- src/video/psp/SDL_pspvideo.h | 2 +- src/video/windows/SDL_windowsevents.c | 2 +- src/video/x11/SDL_x11events.c | 4 +- src/video/x11/SDL_x11modes.c | 4 +- src/video/x11/SDL_x11sym.h | 4 +- src/video/x11/SDL_x11window.c | 4 +- src/video/x11/SDL_x11xinput2.c | 10 +- src/video/x11/SDL_x11xinput2.h | 2 +- src/video/x11/imKStoUCS.h | 2 +- test/testautomation_main.c | 6 +- test/testautomation_platform.c | 18 +- test/testautomation_rect.c | 72 +++---- test/testautomation_rwops.c | 2 +- test/testautomation_surface.c | 4 +- test/testgesture.c | 16 +- test/testhaptic.c | 2 +- test/testoverlay2.c | 2 +- test/testrendercopyex.c | 2 +- test/testshape.c | 12 +- test/torturethread.c | 2 +- 83 files changed, 459 insertions(+), 459 deletions(-) diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c index b2a4d095d..6c60dd125 100644 --- a/Xcode-iOS/Demos/src/fireworks.c +++ b/Xcode-iOS/Demos/src/fireworks.c @@ -196,7 +196,7 @@ explodeEmitter(struct particle *emitter) float speed = randomFloat(0.00, powf(0.17, exponent)); speed = powf(speed, 1.0f / exponent); - /*select the particle at the end of our array */ + /* select the particle at the end of our array */ struct particle *p = &particles[num_active_particles]; /* set the particles properties */ diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c index fd903ff86..4fb45b94a 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -80,7 +80,7 @@ fontMapping map[TABLE_SIZE] = { {SDL_SCANCODE_7, 1, 0, 23}, /* 7 */ {SDL_SCANCODE_8, 1, 0, 24}, /* 8 */ {SDL_SCANCODE_9, 1, 0, 25}, /* 9 */ - {SDL_SCANCODE_SPACE, 1, 0, 0}, /*' ' */ + {SDL_SCANCODE_SPACE, 1, 0, 0}, /* ' ' */ {SDL_SCANCODE_1, 0, KMOD_SHIFT, 1}, /* ! */ {SDL_SCANCODE_SLASH, 0, KMOD_SHIFT, 31}, /* ? */ {SDL_SCANCODE_SLASH, 1, 0, 15}, /* / */ diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index e811967b1..c81dcbc22 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -92,7 +92,7 @@ main(int argc, char *argv[]) SDL_WINDOW_BORDERLESS); renderer = SDL_CreateRenderer(window, 0, 0); - /*load brush texture */ + /* load brush texture */ initializeTexture(renderer); /* fill canvass initially with all black */ diff --git a/include/SDL.h b/include/SDL.h index 67dd30f50..c0c067ca5 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -106,7 +106,7 @@ extern "C" { * These are the flags which may be passed to SDL_Init(). You should * specify the subsystems which you will be using in your application. */ -/*@{ */ +/* @{ */ #define SDL_INIT_TIMER 0x00000001 #define SDL_INIT_AUDIO 0x00000010 #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ @@ -119,7 +119,7 @@ extern "C" { SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ ) -/*@} */ +/* @} */ /** * This function initializes the subsystems specified by \c flags diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index ae51dfc12..48b0053a0 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -91,7 +91,7 @@ extern "C" { * The spin lock functions and type are required and can not be * emulated because they are used in the atomic emulation code. */ -/*@{ */ +/* @{ */ typedef int SDL_SpinLock; @@ -118,7 +118,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); */ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); -/*@} *//*SDL AtomicLock */ +/* @} *//* SDL AtomicLock */ /** diff --git a/include/SDL_audio.h b/include/SDL_audio.h index bf57852e4..b9da236fc 100644 --- a/include/SDL_audio.h +++ b/include/SDL_audio.h @@ -66,7 +66,7 @@ typedef Uint16 SDL_AudioFormat; /** * \name Audio flags */ -/*@{ */ +/* @{ */ #define SDL_AUDIO_MASK_BITSIZE (0xFF) #define SDL_AUDIO_MASK_DATATYPE (1<<8) @@ -85,7 +85,7 @@ typedef Uint16 SDL_AudioFormat; * * Defaults to LSB byte order. */ -/*@{ */ +/* @{ */ #define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ #define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ #define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ @@ -94,30 +94,30 @@ typedef Uint16 SDL_AudioFormat; #define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ #define AUDIO_U16 AUDIO_U16LSB #define AUDIO_S16 AUDIO_S16LSB -/*@} */ +/* @} */ /** * \name int32 support */ -/*@{ */ +/* @{ */ #define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ #define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ #define AUDIO_S32 AUDIO_S32LSB -/*@} */ +/* @} */ /** * \name float32 support */ -/*@{ */ +/* @{ */ #define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ #define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ #define AUDIO_F32 AUDIO_F32LSB -/*@} */ +/* @} */ /** * \name Native audio byte ordering */ -/*@{ */ +/* @{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define AUDIO_U16SYS AUDIO_U16LSB #define AUDIO_S16SYS AUDIO_S16LSB @@ -129,21 +129,21 @@ typedef Uint16 SDL_AudioFormat; #define AUDIO_S32SYS AUDIO_S32MSB #define AUDIO_F32SYS AUDIO_F32MSB #endif -/*@} */ +/* @} */ /** * \name Allow change flags * * Which audio format changes are allowed when opening a device. */ -/*@{ */ +/* @{ */ #define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 #define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 #define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 #define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE) -/*@} */ +/* @} */ -/*@} *//*Audio flags */ +/* @} *//* Audio flags */ /** * This function is called when the audio device needs more data. @@ -218,10 +218,10 @@ typedef struct SDL_AudioCVT * These functions return the list of built in audio drivers, in the * order that they are normally initialized by default. */ -/*@{ */ +/* @{ */ extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); -/*@} */ +/* @} */ /** * \name Initialization and cleanup @@ -230,10 +230,10 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); * you have a specific need to specify the audio driver you want to * use. You should normally use SDL_Init() or SDL_InitSubSystem(). */ -/*@{ */ +/* @{ */ extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); extern DECLSPEC void SDLCALL SDL_AudioQuit(void); -/*@} */ +/* @} */ /** * This function returns the name of the current audio driver, or NULL @@ -359,7 +359,7 @@ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char * * Get the current audio state. */ -/*@{ */ +/* @{ */ typedef enum { SDL_AUDIO_STOPPED = 0, @@ -370,7 +370,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); -/*@} *//*Audio State */ +/* @} *//* Audio State */ /** * \name Pause audio functions @@ -381,11 +381,11 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); * data for your callback function after opening the audio device. * Silence will be written to the audio device during the pause. */ -/*@{ */ +/* @{ */ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on); -/*@} *//*Pause audio functions */ +/* @} *//* Pause audio functions */ /** * This function loads a WAVE from the data source, automatically freeing @@ -482,12 +482,12 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, * the callback function is not running. Do not call these from the callback * function or you will cause deadlock. */ -/*@{ */ +/* @{ */ extern DECLSPEC void SDLCALL SDL_LockAudio(void); extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); -/*@} *//*Audio lock functions */ +/* @} *//* Audio lock functions */ /** * This function shuts down audio processing and closes the audio device. diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 921920db5..31ac2b2b7 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -99,8 +99,8 @@ #define HAVE_SQRT 1 #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 -/*#define HAVE_SYSCONF 1 */ -/*#define HAVE_SIGACTION 1 */ +/* #define HAVE_SYSCONF 1 */ +/* #define HAVE_SIGACTION 1 */ /* PSP isn't that sophisticated */ diff --git a/include/SDL_endian.h b/include/SDL_endian.h index 81e8c70e7..3450316c0 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -33,10 +33,10 @@ /** * \name The two types of endianness */ -/*@{ */ +/* @{ */ #define SDL_LIL_ENDIAN 1234 #define SDL_BIG_ENDIAN 4321 -/*@} */ +/* @} */ #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ #ifdef __linux__ @@ -206,7 +206,7 @@ SDL_SwapFloat(float x) * \name Swap to native * Byteswap item from the specified endianness to the native endianness. */ -/*@{ */ +/* @{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define SDL_SwapLE16(X) (X) #define SDL_SwapLE32(X) (X) @@ -226,7 +226,7 @@ SDL_SwapFloat(float x) #define SDL_SwapBE64(X) (X) #define SDL_SwapFloatBE(X) (X) #endif -/*@} *//*Swap to native */ +/* @} *//* Swap to native */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_error.h b/include/SDL_error.h index 11285633f..2b8bb4165 100644 --- a/include/SDL_error.h +++ b/include/SDL_error.h @@ -48,7 +48,7 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void); * \internal * Private error reporting function - used internally. */ -/*@{ */ +/* @{ */ #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) @@ -63,7 +63,7 @@ typedef enum } SDL_errorcode; /* SDL_Error() unconditionally returns -1. */ extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); -/*@} *//*Internal error functions */ +/* @} *//* Internal error functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_events.h b/include/SDL_events.h index 77d5fde23..c08903073 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -541,7 +541,7 @@ typedef union SDL_Event */ extern DECLSPEC void SDLCALL SDL_PumpEvents(void); -/*@{ */ +/* @{ */ typedef enum { SDL_ADDEVENT, @@ -570,7 +570,7 @@ typedef enum extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType); -/*@} */ +/* @} */ /** * Checks to see if certain event types are in the event queue. @@ -681,7 +681,7 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); -/*@{ */ +/* @{ */ #define SDL_QUERY -1 #define SDL_IGNORE 0 #define SDL_DISABLE 0 @@ -697,7 +697,7 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, * current processing state of the specified event. */ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); -/*@} */ +/* @} */ #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) /** diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index c2a025ef2..a029eb996 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -140,12 +140,12 @@ typedef struct _SDL_Haptic SDL_Haptic; * * Different haptic features a device can have. */ -/*@{ */ +/* @{ */ /** * \name Haptic effects */ -/*@{ */ +/* @{ */ /** * \brief Constant effect supported. @@ -177,7 +177,7 @@ typedef struct _SDL_Haptic SDL_Haptic; #define SDL_HAPTIC_LEFTRIGHT (1<<2) /* !!! FIXME: put this back when we have more bits in 2.1 */ -/*#define SDL_HAPTIC_SQUARE (1<<2) */ +/* #define SDL_HAPTIC_SQUARE (1<<2) */ /** * \brief Triangle wave effect supported. @@ -262,7 +262,7 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_CUSTOM (1<<11) -/*@} *//*Haptic effects */ +/* @} *//* Haptic effects */ /* These last few are features the device has, not effects */ @@ -305,7 +305,7 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \name Direction encodings */ -/*@{ */ +/* @{ */ /** * \brief Uses polar coordinates for the direction. @@ -328,9 +328,9 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_SPHERICAL 2 -/*@} *//*Direction encodings */ +/* @} *//* Direction encodings */ -/*@} *//*Haptic features */ +/* @} *//* Haptic features */ /* * Misc defines. diff --git a/include/SDL_joystick.h b/include/SDL_joystick.h index 5b91f04ce..b0e4b5dab 100644 --- a/include/SDL_joystick.h +++ b/include/SDL_joystick.h @@ -187,7 +187,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, /** * \name Hat positions */ -/*@{ */ +/* @{ */ #define SDL_HAT_CENTERED 0x00 #define SDL_HAT_UP 0x01 #define SDL_HAT_RIGHT 0x02 @@ -197,7 +197,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) -/*@} */ +/* @} */ /** * Get the current state of a POV hat on a joystick. diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h index 57274fa15..2b5df0ec3 100644 --- a/include/SDL_mutex.h +++ b/include/SDL_mutex.h @@ -52,7 +52,7 @@ extern "C" { /** * \name Mutex functions */ -/*@{ */ +/* @{ */ /* The SDL mutex structure, defined in SDL_sysmutex.c */ struct SDL_mutex; @@ -94,13 +94,13 @@ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); */ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); -/*@} *//*Mutex functions */ +/* @} *//* Mutex functions */ /** * \name Semaphore functions */ -/*@{ */ +/* @{ */ /* The SDL semaphore structure, defined in SDL_syssem.c */ struct SDL_semaphore; @@ -154,13 +154,13 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); */ extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); -/*@} *//*Semaphore functions */ +/* @} *//* Semaphore functions */ /** * \name Condition variable functions */ -/*@{ */ +/* @{ */ /* The SDL condition variable structure, defined in SDL_syscond.c */ struct SDL_cond; @@ -237,7 +237,7 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms); -/*@} *//*Condition variable functions */ +/* @} *//* Condition variable functions */ /* Ends C function definitions when using C++ */ diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index 5b6d9c4f7..99fcd9aac 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -39,10 +39,10 @@ extern "C" { * * These define alpha as the opacity of a surface. */ -/*@{ */ +/* @{ */ #define SDL_ALPHA_OPAQUE 255 #define SDL_ALPHA_TRANSPARENT 0 -/*@} */ +/* @} */ /** Pixel type. */ enum diff --git a/include/SDL_platform.h b/include/SDL_platform.h index bf520ba6d..b4849afec 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -66,7 +66,7 @@ #endif #if defined(ANDROID) #undef __ANDROID__ -#undef __LINUX__ /*do we need to do this? */ +#undef __LINUX__ /* do we need to do this? */ #define __ANDROID__ 1 #endif diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h index e2f116166..d25744238 100644 --- a/include/SDL_rwops.h +++ b/include/SDL_rwops.h @@ -148,7 +148,7 @@ typedef struct SDL_RWops * * Functions to create SDL_RWops structures from various data streams. */ -/*@{ */ +/* @{ */ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode); @@ -165,7 +165,7 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, int size); -/*@} *//*RWFrom functions */ +/* @} *//* RWFrom functions */ extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); @@ -180,14 +180,14 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); * * Macros to easily read and write from an SDL_RWops structure. */ -/*@{ */ +/* @{ */ #define SDL_RWsize(ctx) (ctx)->size(ctx) #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) #define SDL_RWclose(ctx) (ctx)->close(ctx) -/*@} *//*Read/write macros */ +/* @} *//* Read/write macros */ /** @@ -195,7 +195,7 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); * * Read an item of the specified endianness and return in native format. */ -/*@{ */ +/* @{ */ extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); @@ -203,14 +203,14 @@ extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); -/*@} *//*Read endian functions */ +/* @} *//* Read endian functions */ /** * \name Write endian functions * * Write an item of native format to the specified endianness. */ -/*@{ */ +/* @{ */ extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); @@ -218,7 +218,7 @@ extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); -/*@} *//*Write endian functions */ +/* @} *//* Write endian functions */ /* Ends C function definitions when using C++ */ diff --git a/include/SDL_scancode.h b/include/SDL_scancode.h index 7c7cf4322..00b47a3b8 100644 --- a/include/SDL_scancode.h +++ b/include/SDL_scancode.h @@ -49,7 +49,7 @@ typedef enum * * These values are from usage page 0x07 (USB keyboard page). */ - /*@{ */ + /* @{ */ SDL_SCANCODE_A = 4, SDL_SCANCODE_B = 5, @@ -339,14 +339,14 @@ typedef enum * special KMOD_MODE for it I'm adding it here */ - /*@} *//*Usage page 0x07 */ + /* @} *//* Usage page 0x07 */ /** * \name Usage page 0x0C * * These values are mapped from usage page 0x0C (USB consumer page). */ - /*@{ */ + /* @{ */ SDL_SCANCODE_AUDIONEXT = 258, SDL_SCANCODE_AUDIOPREV = 259, @@ -366,14 +366,14 @@ typedef enum SDL_SCANCODE_AC_REFRESH = 273, SDL_SCANCODE_AC_BOOKMARKS = 274, - /*@} *//*Usage page 0x0C */ + /* @} *//* Usage page 0x0C */ /** * \name Walther keys * * These are values that Christian Walther added (for mac keyboard?). */ - /*@{ */ + /* @{ */ SDL_SCANCODE_BRIGHTNESSDOWN = 275, SDL_SCANCODE_BRIGHTNESSUP = 276, @@ -388,7 +388,7 @@ typedef enum SDL_SCANCODE_APP1 = 283, SDL_SCANCODE_APP2 = 284, - /*@} *//*Walther keys */ + /* @} *//* Walther keys */ /* Add any other keys here. */ diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 6f9c23cac..8f17d5519 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -89,7 +89,7 @@ * Use proper C++ casts when compiled as C++ to be compatible with the option * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). */ -/*@{ */ +/* @{ */ #ifdef __cplusplus #define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) #define SDL_static_cast(type, expression) static_cast(expression) @@ -99,7 +99,7 @@ #define SDL_static_cast(type, expression) ((type)(expression)) #define SDL_const_cast(type, expression) ((type)(expression)) #endif -/*@} *//*Cast operators */ +/* @} *//* Cast operators */ /* Define a four character code as a Uint32 */ #define SDL_FOURCC(A, B, C, D) \ @@ -111,7 +111,7 @@ /** * \name Basic data types */ -/*@{ */ +/* @{ */ typedef enum { @@ -153,7 +153,7 @@ typedef int64_t Sint64; */ typedef uint64_t Uint64; -/*@} *//*Basic data types */ +/* @} *//* Basic data types */ #define SDL_COMPILE_TIME_ASSERT(name, x) \ diff --git a/include/SDL_surface.h b/include/SDL_surface.h index 4b9628c72..4062012df 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -48,12 +48,12 @@ extern "C" { * \internal * Used internally (read-only). */ -/*@{ */ +/* @{ */ #define SDL_SWSURFACE 0 /**< Just here for compatibility */ #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ -/*@} *//*Surface flags */ +/* @} *//* Surface flags */ /** * Evaluates to true if the surface needs to be locked before access. diff --git a/include/SDL_test_harness.h b/include/SDL_test_harness.h index d22c9fcbc..935038e90 100644 --- a/include/SDL_test_harness.h +++ b/include/SDL_test_harness.h @@ -43,43 +43,43 @@ extern "C" { #endif -/*! Definitions for test case structures */ +/* ! Definitions for test case structures */ #define TEST_ENABLED 1 #define TEST_DISABLED 0 -/*! Definition of all the possible test return values of the test case method */ +/* ! Definition of all the possible test return values of the test case method */ #define TEST_ABORTED -1 #define TEST_STARTED 0 #define TEST_COMPLETED 1 #define TEST_SKIPPED 2 -/*! Definition of all the possible test results for the harness */ +/* ! Definition of all the possible test results for the harness */ #define TEST_RESULT_PASSED 0 #define TEST_RESULT_FAILED 1 #define TEST_RESULT_NO_ASSERT 2 #define TEST_RESULT_SKIPPED 3 #define TEST_RESULT_SETUP_FAILURE 4 -/*!< Function pointer to a test case setup function (run before every test) */ +/* !< Function pointer to a test case setup function (run before every test) */ typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); -/*!< Function pointer to a test case function */ +/* !< Function pointer to a test case function */ typedef int (*SDLTest_TestCaseFp)(void *arg); -/*!< Function pointer to a test case teardown function (run after every test) */ +/* !< Function pointer to a test case teardown function (run after every test) */ typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); /** * Holds information about a single test case. */ typedef struct SDLTest_TestCaseReference { - /*!< Func2Stress */ + /* !< Func2Stress */ SDLTest_TestCaseFp testCase; - /*!< Short name (or function name) "Func2Stress" */ + /* !< Short name (or function name) "Func2Stress" */ char *name; - /*!< Long name or full description "This test pushes func2() to the limit." */ + /* !< Long name or full description "This test pushes func2() to the limit." */ char *description; - /*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ int enabled; } SDLTest_TestCaseReference; @@ -87,13 +87,13 @@ typedef struct SDLTest_TestCaseReference { * Holds information about a test suite (multiple test cases). */ typedef struct SDLTest_TestSuiteReference { - /*!< "PlatformSuite" */ + /* !< "PlatformSuite" */ char *name; - /*!< The function that is run before each test. NULL skips. */ + /* !< The function that is run before each test. NULL skips. */ SDLTest_TestCaseSetUpFp testSetUp; - /*!< The test cases that are run as part of the suite. Last item should be NULL. */ + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ const SDLTest_TestCaseReference **testCases; - /*!< The function that is run after each test. NULL skips. */ + /* !< The function that is run after each test. NULL skips. */ SDLTest_TestCaseTearDownFp testTearDown; } SDLTest_TestSuiteReference; diff --git a/include/SDL_video.h b/include/SDL_video.h index 3a2ac83ae..d4133b026 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -821,7 +821,7 @@ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); /** * \name OpenGL support functions */ -/*@{ */ +/* @{ */ /** * \brief Dynamically load an OpenGL library. @@ -939,7 +939,7 @@ extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); */ extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); -/*@} *//*OpenGL support functions */ +/* @} *//* OpenGL support functions */ /* Ends C function definitions when using C++ */ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 4d53e82b1..69e6bf138 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -419,7 +419,7 @@ SDL_RunAudio(void *devicep) if (istream == NULL) { istream = device->fake_stream; } - /*SDL_memcpy(istream, device->convert.buf, device->convert.len_cvt); */ + /* SDL_memcpy(istream, device->convert.buf, device->convert.len_cvt); */ SDL_StreamWrite(&device->streamer, device->convert.buf, device->convert.len_cvt); } else { diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 4956f1f41..d9ff16536 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -61,7 +61,7 @@ InitMS_ADPCM(WaveFMT * format) SDL_SwapLE16(format->bitspersample); rogue_feel = (Uint8 *) format + sizeof(*format); if (sizeof(*format) == 16) { - /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ + /* const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ rogue_feel += sizeof(Uint16); } MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); @@ -242,7 +242,7 @@ InitIMA_ADPCM(WaveFMT * format) SDL_SwapLE16(format->bitspersample); rogue_feel = (Uint8 *) format + sizeof(*format); if (sizeof(*format) == 16) { - /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ + /* const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ rogue_feel += sizeof(Uint16); } IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 93de9d7e4..7c5792416 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -304,7 +304,7 @@ ALSA_PlayDevice(_THIS) while ( frames_left > 0 && this->enabled ) { /* !!! FIXME: This works, but needs more testing before going live */ - /*ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1); */ + /* ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1); */ status = ALSA_snd_pcm_writei(this->hidden->pcm_handle, sample_buf, frames_left); diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index f5cf1a01e..8576d95e1 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -76,7 +76,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.size *= this->spec.channels; this->spec.size *= this->spec.samples; -/*========================================== */ +/* ========================================== */ /* Allocate the mixing buffer. Its size and starting address must be a multiple of 64 bytes. Our sample count is already a multiple of @@ -171,7 +171,7 @@ PSPAUD_Init(SDL_AudioDriverImpl * impl) impl->CloseDevice = PSPAUD_CloseDevice; impl->ThreadInit = PSPAUD_ThreadInit; - /*PSP audio device */ + /* PSP audio device */ impl->OnlyHasDefaultOutputDevice = 1; /* impl->HasCaptureSupport = 1; diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index df963fdaa..00592e87a 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -40,13 +40,13 @@ #include #include #define LOG_TAG "SDL_android" -/*#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */ -/*#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */ +/* #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */ +/* #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */ #define LOGI(...) do {} while (false) #define LOGE(...) do {} while (false) /* Uncomment this to log messages entering and exiting methods in this file */ -/*#define DEBUG_JNI */ +/* #define DEBUG_JNI */ static void Android_JNI_ThreadDestroyed(void*); @@ -680,7 +680,7 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) if (false) { fallback: /* Disabled log message because of spam on the Nexus 7 */ - /*__android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */ + /* __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */ /* Try the old method using InputStream */ ctx->hidden.androidio.assetFileDescriptorRef = NULL; @@ -688,7 +688,7 @@ fallback: /* inputStream = assetManager.open(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "open", "(Ljava/lang/String;I)Ljava/io/InputStream;"); - inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /*ACCESS_RANDOM */); + inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */); if (Android_JNI_ExceptionOccurred(false)) { goto failure; } @@ -790,7 +790,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, if (ctx->hidden.androidio.assetFileDescriptorRef) { size_t bytesMax = size * maxnum; - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH */ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { + if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { bytesMax = ctx->hidden.androidio.size - ctx->hidden.androidio.position; } size_t result = read(ctx->hidden.androidio.fd, buffer, bytesMax ); @@ -909,12 +909,12 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) if (ctx->hidden.androidio.assetFileDescriptorRef) { switch (whence) { case RW_SEEK_SET: - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; + if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_CUR: offset += ctx->hidden.androidio.position; - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; + if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_END: diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 3ce0f496d..feb7a6023 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -33,7 +33,7 @@ extern "C" { #include "SDL_rect.h" /* Interface from the SDL library into the Android Java activity */ -/*extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); +/* extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); extern SDL_bool Android_JNI_DeleteContext(void); */ extern void Android_JNI_SwapWindow(); extern void Android_JNI_SetActivityTitle(const char *title); diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 908c030cc..20ce57b57 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -121,8 +121,8 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) if (src == NULL) return 0; - /*No Longer storing the Hash, rehash on load */ - /*if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */ + /* No Longer storing the Hash, rehash on load */ + /* if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */ if (SDL_RWwrite(src,templ->path, sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) @@ -158,7 +158,7 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) return SDL_SetError("Unknown gestureId"); } -/*path is an already sampled set of points +/* path is an already sampled set of points Returns the index of the gesture on success, or -1 */ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) { @@ -223,16 +223,16 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) DOLLARNPOINTS) break; if (touchId >= 0) { - /*printf("Adding loaded gesture to 1 touch\n"); */ + /* printf("Adding loaded gesture to 1 touch\n"); */ if (SDL_AddDollarGesture(touch, templ.path) >= 0) loaded++; } else { - /*printf("Adding to: %i touches\n",SDL_numGestureTouches); */ + /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */ for (i = 0; i < SDL_numGestureTouches; i++) { touch = &SDL_gestureTouch[i]; - /*printf("Adding loaded gesture to + touches\n"); */ - /*TODO: What if this fails? */ + /* printf("Adding loaded gesture to + touches\n"); */ + /* TODO: What if this fails? */ SDL_AddDollarGesture(touch,templ.path); } loaded++; @@ -297,7 +297,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) return SDL_min(f1,f2); } -/*DollarPath contains raw points, plus (possibly) the calculated length */ +/* DollarPath contains raw points, plus (possibly) the calculated length */ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { int i; @@ -310,7 +310,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) float w,h; float length = path->length; - /*Calculate length if it hasn't already been done */ + /* Calculate length if it hasn't already been done */ if (length <= 0) { for (i=1;i < path->numPoints; i++) { float dx = path->p[i ].x - path->p[i-1].x; @@ -319,17 +319,17 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) } } - /*Resample */ + /* Resample */ interval = length/(DOLLARNPOINTS - 1); dist = interval; centroid.x = 0;centroid.y = 0; - /*printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ + /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ for (i = 1; i < path->numPoints; i++) { float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); - /*printf("d = %f dist = %f/%f\n",d,dist,interval); */ + /* printf("d = %f dist = %f/%f\n",d,dist,interval); */ while (dist + d > interval) { points[numPoints].x = path->p[i-1].x + ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); @@ -347,15 +347,15 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) SDL_SetError("ERROR: NumPoints = %i\n",numPoints); return 0; } - /*copy the last point */ + /* copy the last point */ points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; numPoints = DOLLARNPOINTS; centroid.x /= numPoints; centroid.y /= numPoints; - /*printf("Centroid (%f,%f)",centroid.x,centroid.y); */ - /*Rotate Points so point 0 is left of centroid and solve for the bounding box */ + /* printf("Centroid (%f,%f)",centroid.x,centroid.y); */ + /* Rotate Points so point 0 is left of centroid and solve for the bounding box */ xmin = centroid.x; xmax = centroid.x; ymin = centroid.y; @@ -379,7 +379,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) if (points[i].y > ymax) ymax = points[i].y; } - /*Scale points to DOLLARSIZE, and translate to the origin */ + /* Scale points to DOLLARSIZE, and translate to the origin */ w = xmax-xmin; h = ymax-ymin; @@ -400,7 +400,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu dollarNormalize(path,points); - /*PrintPath(points); */ + /* PrintPath(points); */ *bestTempl = -1; for (i = 0; i < touch->numDollarTemplates; i++) { float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); @@ -436,7 +436,7 @@ static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { - /*printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */ + /* printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */ if (SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i]; } @@ -466,7 +466,7 @@ static int SDL_SendGestureDollar(SDL_GestureTouch* touch, event.mgesture.y = touch->centroid.y; event.dgesture.gestureId = gestureId; event.dgesture.error = error; - /*A finger came up to trigger this event. */ + /* A finger came up to trigger this event. */ event.dgesture.numFingers = touch->numDownFingers + 1; return SDL_PushEvent(&event) > 0; } @@ -501,13 +501,13 @@ void SDL_GestureProcessEvent(SDL_Event* event) event->type == SDL_FINGERUP) { SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); - /*Shouldn't be possible */ + /* Shouldn't be possible */ if (inTouch == NULL) return; x = event->tfinger.x; y = event->tfinger.y; - /*Finger Up */ + /* Finger Up */ if (event->type == SDL_FINGERUP) { inTouch->numDownFingers--; @@ -515,7 +515,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) if (inTouch->recording) { inTouch->recording = SDL_FALSE; dollarNormalize(&inTouch->dollarPath,path); - /*PrintPath(path); */ + /* PrintPath(path); */ if (recordAll) { index = SDL_AddDollarGesture(NULL,path); for (i = 0; i < SDL_numGestureTouches; i++) @@ -538,14 +538,14 @@ void SDL_GestureProcessEvent(SDL_Event* event) error = dollarRecognize(&inTouch->dollarPath, &bestTempl,inTouch); if (bestTempl >= 0){ - /*Send Event */ + /* Send Event */ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch,gestureId,error); - /*printf ("%s\n",);("Dollar error: %f\n",error); */ + /* printf ("%s\n",);("Dollar error: %f\n",error); */ } } #endif - /*inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ + /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ if (inTouch->numDownFingers > 0) { inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- x)/inTouch->numDownFingers; @@ -575,22 +575,22 @@ void SDL_GestureProcessEvent(SDL_Event* event) inTouch->centroid.x += dx/inTouch->numDownFingers; inTouch->centroid.y += dy/inTouch->numDownFingers; - /*printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */ + /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */ if (inTouch->numDownFingers > 1) { - SDL_FloatPoint lv; /*Vector from centroid to last x,y position */ - SDL_FloatPoint v; /*Vector from centroid to current x,y position */ - /*lv = inTouch->gestureLast[j].cv; */ + SDL_FloatPoint lv; /* Vector from centroid to last x,y position */ + SDL_FloatPoint v; /* Vector from centroid to current x,y position */ + /* lv = inTouch->gestureLast[j].cv; */ lv.x = lastP.x - lastCentroid.x; lv.y = lastP.y - lastCentroid.y; lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); - /*printf("lDist = %f\n",lDist); */ + /* printf("lDist = %f\n",lDist); */ v.x = x - inTouch->centroid.x; v.y = y - inTouch->centroid.y; - /*inTouch->gestureLast[j].cv = v; */ + /* inTouch->gestureLast[j].cv = v; */ Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */ - /*Normalize Vectors to simplify angle calculation */ + /* Normalize Vectors to simplify angle calculation */ lv.x/=lDist; lv.y/=lDist; v.x/=Dist; @@ -598,9 +598,9 @@ void SDL_GestureProcessEvent(SDL_Event* event) dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); dDist = (Dist - lDist); - if (lDist == 0) {dDist = 0;dtheta = 0;} /*To avoid impossible values */ + if (lDist == 0) {dDist = 0;dtheta = 0;} /* To avoid impossible values */ - /*inTouch->gestureLast[j].dDist = dDist; + /* inTouch->gestureLast[j].dDist = dDist; inTouch->gestureLast[j].dtheta = dtheta; printf("dDist = %f, dTheta = %f\n",dDist,dtheta); @@ -613,12 +613,12 @@ void SDL_GestureProcessEvent(SDL_Event* event) SDL_SendGestureMulti(inTouch,dtheta,dDist); } else { - /*inTouch->gestureLast[j].dDist = 0; + /* inTouch->gestureLast[j].dDist = 0; inTouch->gestureLast[j].dtheta = 0; inTouch->gestureLast[j].cv.x = 0; inTouch->gestureLast[j].cv.y = 0; */ } - /*inTouch->gestureLast[j].f.p.x = x; + /* inTouch->gestureLast[j].f.p.x = x; inTouch->gestureLast[j].f.p.y = y; break; pressure? */ @@ -631,7 +631,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) x)/inTouch->numDownFingers; inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ y)/inTouch->numDownFingers; - /*printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, + /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, inTouch->centroid.x,inTouch->centroid.y); */ #ifdef ENABLE_DOLLAR diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 4577857fa..607046e0e 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -28,7 +28,7 @@ #include "../video/SDL_sysvideo.h" -/*#define DEBUG_KEYBOARD */ +/* #define DEBUG_KEYBOARD */ /* Global keyboard information */ diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index fa30361b7..dd6049af0 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -28,7 +28,7 @@ #include "default_cursor.h" #include "../video/SDL_sysvideo.h" -/*#define DEBUG_MOUSE */ +/* #define DEBUG_MOUSE */ /* The mouse state */ static SDL_Mouse SDL_mouse; diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 72a336dec..124cc41af 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -93,7 +93,7 @@ FFStrError(HRESULT err) case FFERR_DEVICEFULL: return "device full"; /* This should be valid, but for some reason isn't defined... */ - /*case FFERR_DEVICENOTREG: + /* case FFERR_DEVICENOTREG: return "device not registered"; */ case FFERR_DEVICEPAUSED: return "device paused"; @@ -343,7 +343,7 @@ GetSupportedFeatures(SDL_Haptic * haptic) FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); */ + /* FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); */ FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE); FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE); FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP); @@ -752,7 +752,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: */ + /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -981,7 +981,7 @@ SDL_SYS_HapticEffectType(Uint16 type) return kFFEffectType_RampForce_ID; /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: + /* case SDL_HAPTIC_SQUARE: return kFFEffectType_Square_ID; */ case SDL_HAPTIC_SINE: diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 1c2500c1e..401249196 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -100,7 +100,7 @@ EV_IsHaptic(int fd) EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); EV_TEST(FF_SINE, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); */ + /* EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); */ EV_TEST(FF_TRIANGLE, SDL_HAPTIC_TRIANGLE); EV_TEST(FF_SAW_UP, SDL_HAPTIC_SAWTOOTHUP); EV_TEST(FF_SAW_DOWN, SDL_HAPTIC_SAWTOOTHDOWN); @@ -600,7 +600,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: */ + /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -625,7 +625,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) if (periodic->type == SDL_HAPTIC_SINE) dest->u.periodic.waveform = FF_SINE; /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*else if (periodic->type == SDL_HAPTIC_SQUARE) + /* else if (periodic->type == SDL_HAPTIC_SQUARE) dest->u.periodic.waveform = FF_SQUARE; */ else if (periodic->type == SDL_HAPTIC_TRIANGLE) dest->u.periodic.waveform = FF_TRIANGLE; diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 6d77973a6..9ba020a88 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -304,7 +304,7 @@ DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM); EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); */ + /* EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); */ EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE); EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP); EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); @@ -936,7 +936,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: */ + /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -1165,7 +1165,7 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) return &GUID_RampForce; /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: + /* case SDL_HAPTIC_SQUARE: return &GUID_Square; */ case SDL_HAPTIC_SINE: diff --git a/src/libm/e_atan2.c b/src/libm/e_atan2.c index f2aa23600..f7b91a3e1 100644 --- a/src/libm/e_atan2.c +++ b/src/libm/e_atan2.c @@ -81,8 +81,8 @@ double attribute_hidden __ieee754_atan2(double y, double x) switch(m) { case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ - case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF) */ - case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF) */ + case 2: return 3.0*pi_o_4+tiny;/* atan(+INF,-INF) */ + case 3: return -3.0*pi_o_4-tiny;/* atan(-INF,-INF) */ } } else { switch(m) { diff --git a/src/libm/e_pow.c b/src/libm/e_pow.c index 9145c4b57..686da2e55 100644 --- a/src/libm/e_pow.c +++ b/src/libm/e_pow.c @@ -178,7 +178,7 @@ libm_hidden_proto(scalbn) /* special value of x */ if (lx == 0) { if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) { - z = ax; /*x is +-0,+-inf,+-1 */ + z = ax; /* x is +-0,+-inf,+-1 */ if (hy < 0) z = one / z; /* z = (1/|x|) */ if (hx < 0) { diff --git a/src/libm/math_private.h b/src/libm/math_private.h index 9a08b103b..6ab0f35fd 100644 --- a/src/libm/math_private.h +++ b/src/libm/math_private.h @@ -17,9 +17,9 @@ #ifndef _MATH_PRIVATE_H_ #define _MATH_PRIVATE_H_ -/*#include */ +/* #include */ #include "SDL_endian.h" -/*#include */ +/* #include */ #define attribute_hidden #define libm_hidden_proto(x) diff --git a/src/libm/s_scalbn.c b/src/libm/s_scalbn.c index 74b979445..f824e926d 100644 --- a/src/libm/s_scalbn.c +++ b/src/libm/s_scalbn.c @@ -54,7 +54,7 @@ libm_hidden_proto(scalbn) GET_HIGH_WORD(hx, x); k = ((hx & 0x7ff00000) >> 20) - 54; if (n < -50000) - return tiny * x; /*underflow */ + return tiny * x; /* underflow */ } if (k == 0x7ff) return x + x; /* NaN or Inf */ @@ -67,9 +67,9 @@ libm_hidden_proto(scalbn) } if (k <= -54) { if (n > 50000) /* in case integer overflow in n+k */ - return huge_val * copysign(huge_val, x); /*overflow */ + return huge_val * copysign(huge_val, x); /* overflow */ else - return tiny * copysign(tiny, x); /*underflow */ + return tiny * copysign(tiny, x); /* underflow */ } k += 54; /* subnormal result */ SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); diff --git a/src/main/android/SDL_android_main.c b/src/main/android/SDL_android_main.c index e2889dbc9..8f00f39d9 100644 --- a/src/main/android/SDL_android_main.c +++ b/src/main/android/SDL_android_main.c @@ -30,7 +30,7 @@ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject status = SDL_main(1, argv); /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ - /*exit(status); */ + /* exit(status); */ } #endif /* __ANDROID__ */ diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 257704524..46b680cd8 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -958,10 +958,10 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) if (SDL_HasMMX() && (Rmask == 0xF800) && (Gmask == 0x07E0) && (Bmask == 0x001F) && (swdata->w & 15) == 0) { -/*printf("Using MMX 16-bit 565 dither\n"); */ +/* printf("Using MMX 16-bit 565 dither\n"); */ swdata->Display1X = Color565DitherYV12MMX1X; } else { -/*printf("Using C 16-bit dither\n"); */ +/* printf("Using C 16-bit dither\n"); */ swdata->Display1X = Color16DitherYV12Mod1X; } #else @@ -979,10 +979,10 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) if (SDL_HasMMX() && (Rmask == 0x00FF0000) && (Gmask == 0x0000FF00) && (Bmask == 0x000000FF) && (swdata->w & 15) == 0) { -/*printf("Using MMX 32-bit dither\n"); */ +/* printf("Using MMX 32-bit dither\n"); */ swdata->Display1X = ColorRGBDitherYV12MMX1X; } else { -/*printf("Using C 32-bit dither\n"); */ +/* printf("Using C 32-bit dither\n"); */ swdata->Display1X = Color32DitherYV12Mod1X; } #else diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index a09894494..6e72b30d3 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -874,7 +874,7 @@ GetScaleQuality(void) if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { return D3DTEXF_POINT; - } else /*if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ { + } else /* if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ { return D3DTEXF_LINEAR; } } diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index facb89e98..b1473b07b 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -310,7 +310,7 @@ GL_ResetState(SDL_Renderer *renderer) data->glDisable(GL_DEPTH_TEST); data->glDisable(GL_CULL_FACE); /* This ended up causing video discrepancies between OpenGL and Direct3D */ - /*data->glEnable(GL_LINE_SMOOTH); */ + /* data->glEnable(GL_LINE_SMOOTH); */ data->glMatrixMode(GL_MODELVIEW); data->glLoadIdentity(); @@ -638,7 +638,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return -1; } if ((renderdata->GL_ARB_texture_rectangle_supported) - /*&& texture->access != SDL_TEXTUREACCESS_TARGET */){ + /* && texture->access != SDL_TEXTUREACCESS_TARGET */){ data->type = GL_TEXTURE_RECTANGLE_ARB; texture_w = texture->w; texture_h = texture->h; diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 162713ea7..ebf641bb2 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -30,7 +30,7 @@ /* OpenGL shader implementation */ -/*#define DEBUG_SHADERS */ +/* #define DEBUG_SHADERS */ typedef struct { diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 538d10c5c..628c8d534 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -42,7 +42,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net /* ---- Internally used structures */ -/*! +/* ! \brief A 32 bit RGBA pixel. */ typedef struct tColorRGBA { @@ -52,19 +52,19 @@ typedef struct tColorRGBA { Uint8 a; } tColorRGBA; -/*! +/* ! \brief A 8bit Y/palette pixel. */ typedef struct tColorY { Uint8 y; } tColorY; -/*! +/* ! \brief Returns maximum of two numbers a and b. */ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) -/*! +/* ! \brief Number of guard rows added to destination surfaces. This is a simple but effective workaround for observed issues. @@ -76,12 +76,12 @@ to a situation where the program can segfault. */ #define GUARD_ROWS (2) -/*! +/* ! \brief Lower limit of absolute zoom factor or rotation degrees. */ #define VALUE_LIMIT 0.001 -/*! +/* ! \brief Returns colorkey info for a surface */ Uint32 _colorkey(SDL_Surface *src) @@ -92,7 +92,7 @@ Uint32 _colorkey(SDL_Surface *src) } -/*! +/* ! \brief Internal target surface sizing function for rotations with trig result return. \param width The source surface width. @@ -134,7 +134,7 @@ void _rotozoomSurfaceSizeTrig(int width, int height, double angle, } -/*! +/* ! \brief Internal 32 bit rotozoomer with optional anti-aliasing. Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control @@ -252,7 +252,7 @@ void _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, } } -/*! +/* ! \brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing. @@ -317,7 +317,7 @@ void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int -/*! +/* ! \brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing. Rotates a 32bit or 8bit 'src' surface to newly created 'dst' surface. @@ -357,7 +357,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce if (src == NULL) return (NULL); - if (src->flags & SDL_TRUE/*SDL_SRCCOLORKEY */) + if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */) { colorkey = _colorkey(src); SDL_GetRGB(colorkey, src->format, &r, &g, &b); @@ -391,14 +391,14 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce SDL_BlitSurface(src, NULL, rz_src, NULL); if(colorKeyAvailable) - SDL_SetColorKey(src, SDL_TRUE /*SDL_SRCCOLORKEY */, colorkey); + SDL_SetColorKey(src, SDL_TRUE /* SDL_SRCCOLORKEY */, colorkey); src_converted = 1; is32bit = 1; } /* Determine target size */ - /*_rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */ + /* _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */ /* * Calculate target factors from sin/cos and zoom @@ -459,8 +459,8 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce /* * Turn on source-alpha support */ - /*SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */ - SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + /* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */ + SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } else { /* * Copy palette and colorkey info @@ -475,7 +475,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce transformSurfaceY(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy); - SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } /* * Unlock source surface diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c index 41a3df68f..6f08d1f5b 100644 --- a/src/test/SDL_test_assert.c +++ b/src/test/SDL_test_assert.c @@ -35,10 +35,10 @@ const char *SDLTest_AssertCheckFormat = "Assert '%s': %s"; /* Assert summary message format */ const char *SDLTest_AssertSummaryFormat = "Assert Summary: Total=%d Passed=%d Failed=%d"; -/*! \brief counts the failed asserts */ +/* ! \brief counts the failed asserts */ static Uint32 SDLTest_AssertsFailed = 0; -/*! \brief counts the passed asserts */ +/* ! \brief counts the passed asserts */ static Uint32 SDLTest_AssertsPassed = 0; /* diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index 144bcad02..b7d2caa2d 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -1569,7 +1569,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 128 0x80 '' + * 128 0x80 '�' */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ @@ -1581,7 +1581,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x78, /* 01111000 */ /* - * 129 0x81 '' + * 129 0x81 '�' */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ @@ -1593,7 +1593,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 130 0x82 '' + * 130 0x82 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1605,7 +1605,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 131 0x83 '' + * 131 0x83 '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1617,7 +1617,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 132 0x84 '' + * 132 0x84 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1629,7 +1629,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 133 0x85 '' + * 133 0x85 '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1641,7 +1641,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 134 0x86 '' + * 134 0x86 '�' */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ @@ -1653,7 +1653,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 135 0x87 '' + * 135 0x87 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -1665,7 +1665,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x38, /* 00111000 */ /* - * 136 0x88 '' + * 136 0x88 '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1677,7 +1677,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 137 0x89 '' + * 137 0x89 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1689,7 +1689,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 138 0x8a '' + * 138 0x8a '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1701,7 +1701,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 139 0x8b '' + * 139 0x8b '�' */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ @@ -1713,7 +1713,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 140 0x8c '' + * 140 0x8c '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1725,7 +1725,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 141 0x8d '' + * 141 0x8d '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1737,7 +1737,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 142 0x8e '' + * 142 0x8e '�' */ 0xc6, /* 11000110 */ 0x38, /* 00111000 */ @@ -1749,7 +1749,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 143 0x8f '' + * 143 0x8f '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -1761,7 +1761,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 144 0x90 '' + * 144 0x90 '�' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -1773,7 +1773,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 145 0x91 '' + * 145 0x91 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -1785,7 +1785,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 146 0x92 '' + * 146 0x92 '�' */ 0x3e, /* 00111110 */ 0x6c, /* 01101100 */ @@ -1797,7 +1797,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 147 0x93 '' + * 147 0x93 '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1809,7 +1809,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 148 0x94 '' + * 148 0x94 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1821,7 +1821,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 149 0x95 '' + * 149 0x95 '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1833,7 +1833,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 150 0x96 '' + * 150 0x96 '�' */ 0x78, /* 01111000 */ 0x84, /* 10000100 */ @@ -1845,7 +1845,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 151 0x97 '' + * 151 0x97 '�' */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ @@ -1857,7 +1857,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 152 0x98 '' + * 152 0x98 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1869,7 +1869,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xfc, /* 11111100 */ /* - * 153 0x99 '' + * 153 0x99 '�' */ 0xc6, /* 11000110 */ 0x38, /* 00111000 */ @@ -1881,7 +1881,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 154 0x9a '' + * 154 0x9a '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1893,7 +1893,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 155 0x9b '' + * 155 0x9b '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -1905,7 +1905,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 156 0x9c '' + * 156 0x9c '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -1917,7 +1917,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 157 0x9d '' + * 157 0x9d '�' */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ @@ -1929,7 +1929,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 158 0x9e '' + * 158 0x9e '�' */ 0xf8, /* 11111000 */ 0xcc, /* 11001100 */ @@ -1941,7 +1941,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc7, /* 11000111 */ /* - * 159 0x9f '' + * 159 0x9f '�' */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ @@ -1953,7 +1953,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 160 0xa0 '' + * 160 0xa0 '�' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -1965,7 +1965,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 161 0xa1 '' + * 161 0xa1 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1977,7 +1977,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 162 0xa2 '' + * 162 0xa2 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1989,7 +1989,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 163 0xa3 '' + * 163 0xa3 '�' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -2001,7 +2001,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 164 0xa4 '' + * 164 0xa4 '�' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ @@ -2013,7 +2013,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 165 0xa5 '' + * 165 0xa5 '�' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ @@ -2025,7 +2025,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 166 0xa6 '' + * 166 0xa6 '�' */ 0x3c, /* 00111100 */ 0x6c, /* 01101100 */ @@ -2037,7 +2037,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 167 0xa7 '' + * 167 0xa7 '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2049,7 +2049,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 168 0xa8 '' + * 168 0xa8 '�' */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ @@ -2061,7 +2061,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 169 0xa9 '' + * 169 0xa9 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2073,7 +2073,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 170 0xaa '' + * 170 0xaa '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2085,7 +2085,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 171 0xab '' + * 171 0xab '�' */ 0x63, /* 01100011 */ 0xe6, /* 11100110 */ @@ -2097,7 +2097,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x0f, /* 00001111 */ /* - * 172 0xac '' + * 172 0xac '�' */ 0x63, /* 01100011 */ 0xe6, /* 11100110 */ @@ -2109,7 +2109,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x06, /* 00000110 */ /* - * 173 0xad '' + * 173 0xad '�' */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ @@ -2121,7 +2121,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 174 0xae '' + * 174 0xae '�' */ 0x00, /* 00000000 */ 0x33, /* 00110011 */ @@ -2133,7 +2133,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 175 0xaf '' + * 175 0xaf '�' */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ @@ -2145,7 +2145,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 176 0xb0 '' + * 176 0xb0 '�' */ 0x22, /* 00100010 */ 0x88, /* 10001000 */ @@ -2157,7 +2157,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x88, /* 10001000 */ /* - * 177 0xb1 '' + * 177 0xb1 '�' */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ @@ -2169,7 +2169,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xaa, /* 10101010 */ /* - * 178 0xb2 '' + * 178 0xb2 '�' */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ @@ -2181,7 +2181,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xdd, /* 11011101 */ /* - * 179 0xb3 '' + * 179 0xb3 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2193,7 +2193,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 180 0xb4 '' + * 180 0xb4 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2205,7 +2205,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 181 0xb5 '' + * 181 0xb5 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2217,7 +2217,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 182 0xb6 '' + * 182 0xb6 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2229,7 +2229,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 183 0xb7 '' + * 183 0xb7 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2241,7 +2241,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 184 0xb8 '' + * 184 0xb8 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2253,7 +2253,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 185 0xb9 '' + * 185 0xb9 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2265,7 +2265,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 186 0xba '' + * 186 0xba '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2277,7 +2277,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 187 0xbb '' + * 187 0xbb '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2289,7 +2289,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 188 0xbc '' + * 188 0xbc '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2301,7 +2301,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 189 0xbd '' + * 189 0xbd '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2313,7 +2313,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 190 0xbe '' + * 190 0xbe '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2325,7 +2325,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 191 0xbf '' + * 191 0xbf '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2337,7 +2337,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 192 0xc0 '' + * 192 0xc0 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2349,7 +2349,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 193 0xc1 '' + * 193 0xc1 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2361,7 +2361,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 194 0xc2 '' + * 194 0xc2 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2373,7 +2373,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 195 0xc3 '' + * 195 0xc3 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2385,7 +2385,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 196 0xc4 '' + * 196 0xc4 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2397,7 +2397,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 197 0xc5 '' + * 197 0xc5 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2409,7 +2409,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 198 0xc6 '' + * 198 0xc6 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2421,7 +2421,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 199 0xc7 '' + * 199 0xc7 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2433,7 +2433,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 200 0xc8 '' + * 200 0xc8 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2445,7 +2445,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 201 0xc9 '' + * 201 0xc9 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2457,7 +2457,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 202 0xca '' + * 202 0xca '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2469,7 +2469,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 203 0xcb '' + * 203 0xcb '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2481,7 +2481,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 204 0xcc '' + * 204 0xcc '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2493,7 +2493,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 205 0xcd '' + * 205 0xcd '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2505,7 +2505,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 206 0xce '' + * 206 0xce '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2517,7 +2517,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 207 0xcf '' + * 207 0xcf '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2529,7 +2529,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 208 0xd0 '' + * 208 0xd0 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2541,7 +2541,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 209 0xd1 '' + * 209 0xd1 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2553,7 +2553,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 210 0xd2 '' + * 210 0xd2 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2565,7 +2565,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 211 0xd3 '' + * 211 0xd3 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2577,7 +2577,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 212 0xd4 '' + * 212 0xd4 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2589,7 +2589,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 213 0xd5 '' + * 213 0xd5 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2601,7 +2601,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 214 0xd6 '' + * 214 0xd6 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2613,7 +2613,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 215 0xd7 '' + * 215 0xd7 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2625,7 +2625,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 216 0xd8 '' + * 216 0xd8 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2637,7 +2637,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 217 0xd9 '' + * 217 0xd9 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2649,7 +2649,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 218 0xda '' + * 218 0xda '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2661,7 +2661,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 219 0xdb '' + * 219 0xdb '�' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ @@ -2673,7 +2673,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xff, /* 11111111 */ /* - * 220 0xdc '' + * 220 0xdc '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2685,7 +2685,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xff, /* 11111111 */ /* - * 221 0xdd '' + * 221 0xdd '�' */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ @@ -2697,7 +2697,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xf0, /* 11110000 */ /* - * 222 0xde '' + * 222 0xde '�' */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ @@ -2709,7 +2709,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x0f, /* 00001111 */ /* - * 223 0xdf '' + * 223 0xdf '�' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ @@ -2721,7 +2721,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 224 0xe0 '' + * 224 0xe0 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2733,7 +2733,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 225 0xe1 '' + * 225 0xe1 '�' */ 0x78, /* 01111000 */ 0xcc, /* 11001100 */ @@ -2745,7 +2745,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 226 0xe2 '' + * 226 0xe2 '�' */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ @@ -2757,7 +2757,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 227 0xe3 '' + * 227 0xe3 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2769,7 +2769,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 228 0xe4 '' + * 228 0xe4 '�' */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ @@ -2781,7 +2781,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 229 0xe5 '' + * 229 0xe5 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2793,7 +2793,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 230 0xe6 '' + * 230 0xe6 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2805,7 +2805,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc0, /* 11000000 */ /* - * 231 0xe7 '' + * 231 0xe7 '�' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ @@ -2817,7 +2817,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 232 0xe8 '' + * 232 0xe8 '�' */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ @@ -2829,7 +2829,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x7e, /* 01111110 */ /* - * 233 0xe9 '' + * 233 0xe9 '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2841,7 +2841,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 234 0xea '' + * 234 0xea '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2853,7 +2853,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 235 0xeb '' + * 235 0xeb '�' */ 0x0e, /* 00001110 */ 0x18, /* 00011000 */ @@ -2865,7 +2865,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 236 0xec '' + * 236 0xec '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2877,7 +2877,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 237 0xed '' + * 237 0xed '�' */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ @@ -2889,7 +2889,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc0, /* 11000000 */ /* - * 238 0xee '' + * 238 0xee '�' */ 0x1e, /* 00011110 */ 0x30, /* 00110000 */ @@ -2901,7 +2901,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 239 0xef '' + * 239 0xef '�' */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ @@ -2913,7 +2913,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 240 0xf0 '' + * 240 0xf0 '�' */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ @@ -2925,7 +2925,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 241 0xf1 '' + * 241 0xf1 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2937,7 +2937,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 242 0xf2 '' + * 242 0xf2 '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -2949,7 +2949,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 243 0xf3 '' + * 243 0xf3 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -2961,7 +2961,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 244 0xf4 '' + * 244 0xf4 '�' */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ @@ -2973,7 +2973,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 245 0xf5 '' + * 245 0xf5 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2985,7 +2985,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x70, /* 01110000 */ /* - * 246 0xf6 '' + * 246 0xf6 '�' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ @@ -2997,7 +2997,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 247 0xf7 '' + * 247 0xf7 '�' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ @@ -3009,7 +3009,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 248 0xf8 '' + * 248 0xf8 '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -3021,7 +3021,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 249 0xf9 '' + * 249 0xf9 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3033,7 +3033,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 250 0xfa '' + * 250 0xfa '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3045,7 +3045,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 251 0xfb '' + * 251 0xfb '�' */ 0x0f, /* 00001111 */ 0x0c, /* 00001100 */ @@ -3057,7 +3057,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x1c, /* 00011100 */ /* - * 252 0xfc '' + * 252 0xfc '�' */ 0x6c, /* 01101100 */ 0x36, /* 00110110 */ @@ -3069,7 +3069,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 253 0xfd '' + * 253 0xfd '�' */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ @@ -3081,7 +3081,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 254 0xfe '' + * 254 0xfe '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3109,7 +3109,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { /* ---- Character */ -/*! +/* ! \brief Global cache for 8x8 pixel font textures created at runtime. */ static SDL_Texture *SDLTest_CharTextureCache[256]; diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index 8a27fd011..d090c150c 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -173,7 +173,7 @@ SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax) return (Sint32)((number % ((max + 1) - min)) + min); } -/*! +/* ! * Generates a unsigned boundary value between the given boundaries. * Boundary values are inclusive. See the examples below. * If boundary2 < boundary1, the values are swapped. @@ -303,7 +303,7 @@ SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool v validDomain); } -/*! +/* ! * Generates a signed boundary value between the given boundaries. * Boundary values are inclusive. See the examples below. * If boundary2 < boundary1, the values are swapped. diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 291874566..c58eae45a 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -37,7 +37,7 @@ const char *SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d /* Final result message format */ const char *SDLTest_FinalResultFormat = ">>> %s '%s': %s\n"; -/*! \brief Timeout for single test case execution */ +/* ! \brief Timeout for single test case execution */ static Uint32 SDLTest_TestCaseTimeout = 3600; /** diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c index c854c0f7d..caf3ddde4 100644 --- a/src/test/SDL_test_log.c +++ b/src/test/SDL_test_log.c @@ -39,7 +39,7 @@ #include "SDL_test.h" -/*! +/* ! * Converts unix timestamp to its ascii representation in localtime * * Note: Uses a static buffer internally, so the return value diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 81d93f7ab..108f0b394 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -97,23 +97,23 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) /* The Win32 BMP file header (14 bytes) */ char magic[2]; - /*Uint32 bfSize = 0; */ - /*Uint16 bfReserved1 = 0; */ - /*Uint16 bfReserved2 = 0; */ + /* Uint32 bfSize = 0; */ + /* Uint16 bfReserved1 = 0; */ + /* Uint16 bfReserved2 = 0; */ Uint32 bfOffBits = 0; /* The Win32 BITMAPINFOHEADER struct (40 bytes) */ Uint32 biSize = 0; Sint32 biWidth = 0; Sint32 biHeight = 0; - /*Uint16 biPlanes = 0; */ + /* Uint16 biPlanes = 0; */ Uint16 biBitCount = 0; Uint32 biCompression = 0; - /*Uint32 biSizeImage = 0; */ - /*Sint32 biXPelsPerMeter = 0; */ - /*Sint32 biYPelsPerMeter = 0; */ + /* Uint32 biSizeImage = 0; */ + /* Sint32 biXPelsPerMeter = 0; */ + /* Sint32 biYPelsPerMeter = 0; */ Uint32 biClrUsed = 0; - /*Uint32 biClrImportant = 0; */ + /* Uint32 biClrImportant = 0; */ /* Make sure we are passed a valid data source */ surface = NULL; @@ -136,9 +136,9 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) was_error = SDL_TRUE; goto done; } - /*bfSize = */ SDL_ReadLE32(src); - /*bfReserved1 = */ SDL_ReadLE16(src); - /*bfReserved2 = */ SDL_ReadLE16(src); + /* bfSize = */ SDL_ReadLE32(src); + /* bfReserved1 = */ SDL_ReadLE16(src); + /* bfReserved2 = */ SDL_ReadLE16(src); bfOffBits = SDL_ReadLE32(src); /* Read the Win32 BITMAPINFOHEADER */ @@ -146,20 +146,20 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (biSize == 12) { biWidth = (Uint32) SDL_ReadLE16(src); biHeight = (Uint32) SDL_ReadLE16(src); - /*biPlanes = */ SDL_ReadLE16(src); + /* biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = BI_RGB; } else { biWidth = SDL_ReadLE32(src); biHeight = SDL_ReadLE32(src); - /*biPlanes = */ SDL_ReadLE16(src); + /* biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = SDL_ReadLE32(src); - /*biSizeImage = */ SDL_ReadLE32(src); - /*biXPelsPerMeter = */ SDL_ReadLE32(src); - /*biYPelsPerMeter = */ SDL_ReadLE32(src); + /* biSizeImage = */ SDL_ReadLE32(src); + /* biXPelsPerMeter = */ SDL_ReadLE32(src); + /* biYPelsPerMeter = */ SDL_ReadLE32(src); biClrUsed = SDL_ReadLE32(src); - /*biClrImportant = */ SDL_ReadLE32(src); + /* biClrImportant = */ SDL_ReadLE32(src); } if (biHeight < 0) { topDown = SDL_TRUE; diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 6e9b8e796..13236a487 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -119,7 +119,7 @@ SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) SSE_END; } -/*DEFINE_SSE_FILLRECT(1, Uint8) */ +/* DEFINE_SSE_FILLRECT(1, Uint8) */ DEFINE_SSE_FILLRECT(2, Uint16) DEFINE_SSE_FILLRECT(4, Uint32) @@ -212,7 +212,7 @@ SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) MMX_END; } -/*DEFINE_MMX_FILLRECT(1, Uint8) */ +/* DEFINE_MMX_FILLRECT(1, Uint8) */ DEFINE_MMX_FILLRECT(2, Uint16) DEFINE_MMX_FILLRECT(4, Uint32) diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 490714de0..308fefce5 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -33,7 +33,7 @@ SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { SDL_Window *result = NULL; - result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN) */); + result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); if(result != NULL) { result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); if(result->shaper != NULL) { diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index b01d2f35e..3eafc2055 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -38,7 +38,7 @@ (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES /* There's a bug with gcc 4.4.1 and -O2 where srcp doesn't get the correct * value after the first scanline. FIXME? */ -/*#define USE_ASM_STRETCH */ +/* #define USE_ASM_STRETCH */ #endif #ifdef USE_ASM_STRETCH diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 9b144cb96..ee1cf590f 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -963,7 +963,7 @@ SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, surface->h = height; surface->pitch = pitch; /* We don't actually need to set up the clip rect for our purposes */ - /*SDL_SetClipRect(surface, NULL); */ + /* SDL_SetClipRect(surface, NULL); */ /* Allocate an empty mapping */ SDL_zerop(blitmap); diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index d61b5c225..6b6a71e41 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -353,7 +353,7 @@ class SDL_BWin:public BDirectWindow - CTRL+Q to close window (and other shortcuts) - PrintScreen to make screenshot into /boot/home - etc.. */ - /*BDirectWindow::DispatchMessage(msg, target); */ + /* BDirectWindow::DispatchMessage(msg, target); */ break; } @@ -461,7 +461,7 @@ private: msg.AddBool("focusGained", focusGained); _PostWindowEvent(msg); -/*FIXME: Why were these here? +/* FIXME: Why were these here? if false: be_app->SetCursor(B_HAND_CURSOR); if true: SDL_SetCursor(NULL); */ } diff --git a/src/video/bwindow/SDL_bopengl.h b/src/video/bwindow/SDL_bopengl.h index 4e1a5cf7c..9ec972eef 100644 --- a/src/video/bwindow/SDL_bopengl.h +++ b/src/video/bwindow/SDL_bopengl.h @@ -29,13 +29,13 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int BE_GL_LoadLibrary(_THIS, const char *path); /*FIXME */ -extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /*FIXME */ -extern void BE_GL_UnloadLibrary(_THIS); /*TODO */ +extern int BE_GL_LoadLibrary(_THIS, const char *path); /* FIXME */ +extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */ +extern void BE_GL_UnloadLibrary(_THIS); /* TODO */ extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern int BE_GL_SetSwapInterval(_THIS, int interval); /*TODO */ -extern int BE_GL_GetSwapInterval(_THIS); /*TODO */ +extern int BE_GL_SetSwapInterval(_THIS, int interval); /* TODO */ +extern int BE_GL_GetSwapInterval(_THIS); /* TODO */ extern void BE_GL_SwapWindow(_THIS, SDL_Window * window); extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window); extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context); diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index c9f683cce..83912bded 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -131,7 +131,7 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window) SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX)); LoadFont(_this, window); - /*s->SetDrawingFlags(s, DSDRAW_BLEND); */ + /* s->SetDrawingFlags(s, DSDRAW_BLEND); */ s->SetColor(s, COLOR_EXPAND(t->frame_color)); /* top */ for (i = 0; i < t->top_size; i++) @@ -203,7 +203,7 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h) if (!windata->is_managed) windata->theme = theme_none; else if (flags & SDL_WINDOW_BORDERLESS) - /*desc.caps |= DWCAPS_NODECORATION;) */ + /* desc.caps |= DWCAPS_NODECORATION;) */ windata->theme = theme_none; else if (flags & SDL_WINDOW_FULLSCREEN) { windata->theme = theme_none; diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 9c34754fd..cb669bce1 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -132,7 +132,7 @@ MotionAllMice(_THIS, int x, int y) SDL_Mouse *mouse = SDL_GetMouse(index); mouse->x = mouse->last_x = x; mouse->y = mouse->last_y = y; - /*SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0); */ + /* SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0); */ } #endif } @@ -233,7 +233,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) case DWET_KEYDOWN: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym, &unicode); - /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ + /* printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_zero(text); @@ -369,7 +369,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) case DIET_KEYPRESS: kbd_idx = KbdIndex(_this, ievt->device_id); DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym, &unicode); - /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ + /* printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_zero(text); @@ -742,7 +742,7 @@ DirectFB_InitKeyboard(_THIS) void DirectFB_QuitKeyboard(_THIS) { - /*SDL_DFB_DEVICEDATA(_this); */ + /* SDL_DFB_DEVICEDATA(_this); */ SDL_KeyboardQuit(); diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index e40dcbeba..d1cd49dfc 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -326,8 +326,8 @@ DirectFB_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area and update matrices */ - /*SDL_CurrentContext = NULL; */ - /*data->updateSize = SDL_TRUE; */ + /* SDL_CurrentContext = NULL; */ + /* data->updateSize = SDL_TRUE; */ renddata->size_changed = SDL_TRUE; } } @@ -379,7 +379,7 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) /* FIXME: Yet to be tested */ renderer->RenderReadPixels = DirectFB_RenderReadPixels; - /*renderer->RenderWritePixels = DirectFB_RenderWritePixels; */ + /* renderer->RenderWritePixels = DirectFB_RenderWritePixels; */ renderer->DestroyTexture = DirectFB_DestroyTexture; renderer->DestroyRenderer = DirectFB_DestroyRenderer; @@ -450,7 +450,7 @@ DirectFB_ActivateRenderer(SDL_Renderer * renderer) SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); - if (renddata->size_changed /*|| windata->wm_needs_redraw */) { + if (renddata->size_changed /* || windata->wm_needs_redraw */) { renddata->size_changed = SDL_FALSE; } } @@ -701,7 +701,7 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) { switch (texture->blendMode) { case SDL_BLENDMODE_NONE: - /*case SDL_BLENDMODE_MASK: */ + /* case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -717,7 +717,7 @@ DirectFB_SetDrawBlendMode(SDL_Renderer * renderer) { switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - /*case SDL_BLENDMODE_MASK: */ + /* case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -916,7 +916,7 @@ PrepareDraw(SDL_Renderer * renderer) switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - /*case SDL_BLENDMODE_MASK: */ + /* case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: break; case SDL_BLENDMODE_ADD: diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c index 13c3d703e..358078f15 100644 --- a/src/video/directfb/SDL_DirectFB_shape.c +++ b/src/video/directfb/SDL_DirectFB_shape.c @@ -31,7 +31,7 @@ SDL_Window* DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { - return SDL_CreateWindow(title,x,y,w,h,flags /*| SDL_DFB_WINDOW_SHAPED */); + return SDL_CreateWindow(title,x,y,w,h,flags /* | SDL_DFB_WINDOW_SHAPED */); } SDL_WindowShaper* diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index d20b5f122..4e5eae4ed 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -258,7 +258,7 @@ DirectFB_VideoInit(_THIS) &devdata->events)); } else { SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_AXES - /*DICAPS_ALL */ , + /* DICAPS_ALL */ , DFB_TRUE, &devdata->events)); } diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index cdcb4cce6..74c958ab0 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -155,7 +155,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin)); /* remember parent */ - /*windata->sdlwin = window; */ + /* windata->sdlwin = window; */ /* Add to list ... */ diff --git a/src/video/directfb/SDL_DirectFB_window.h b/src/video/directfb/SDL_DirectFB_window.h index a4a1cc840..96afc59ec 100644 --- a/src/video/directfb/SDL_DirectFB_window.h +++ b/src/video/directfb/SDL_DirectFB_window.h @@ -34,7 +34,7 @@ struct _DFB_WindowData IDirectFBSurface *surface; /* client drawing surface */ IDirectFBWindow *dfbwin; IDirectFBEventBuffer *eventbuffer; - /*SDL_Window *sdlwin; */ + /* SDL_Window *sdlwin; */ SDL_Window *next; Uint8 opacity; DFBRectangle client; diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index e2746c628..87bc52995 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -119,7 +119,7 @@ void PSP_PumpEvents(_THIS) sym.scancode = raw; sym.sym = keymap[raw]; /* not tested */ - /*SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ + /* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]); diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index d4ab32bfe..5b6435f56 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -91,7 +91,7 @@ int PSP_GL_GetSwapInterval(_THIS); void PSP_GL_SwapWindow(_THIS, SDL_Window * window); void PSP_GL_DeleteContext(_THIS, SDL_GLContext context); -/*PSP on screen keyboard */ +/* PSP on screen keyboard */ SDL_bool PSP_HasScreenKeyboardSupport(_THIS); void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window); void PSP_HideScreenKeyboard(_THIS, SDL_Window *window); diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 516d4e22d..c33dabfdd 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -36,7 +36,7 @@ /* For GET_X_LPARAM, GET_Y_LPARAM. */ #include -/*#define WMMSG_DEBUG */ +/* #define WMMSG_DEBUG */ #ifdef WMMSG_DEBUG #include #include "wmmsg.h" diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 385039f7e..6919e7742 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -97,7 +97,7 @@ static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) if (a2 != None) atom[count++] = a2; return X11_PickTarget(disp, atom, count); } -/*#define DEBUG_XEVENTS */ +/* #define DEBUG_XEVENTS */ struct KeyRepeatCheckData { @@ -384,7 +384,7 @@ X11_DispatchEvent(_THIS) I think it's better to think the ALT key is held down when it's not, then always lose the ALT modifier on Unity. */ - /*SDL_ResetKeyboard(); */ + /* SDL_ResetKeyboard(); */ } data->pending_focus = PENDING_FOCUS_IN; data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_IN_TIME; diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index be3383227..472416ccd 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -26,7 +26,7 @@ #include "SDL_x11video.h" #include "edid.h" -/*#define X11MODES_DEBUG */ +/* #define X11MODES_DEBUG */ /* I'm becoming more and more convinced that the application should never * use XRandR, and it's the window manager's responsibility to track and @@ -38,7 +38,7 @@ * * However, many people swear by it, so let them swear at it. :) */ -/*#define XRANDR_DISABLED_BY_DEFAULT */ +/* #define XRANDR_DISABLED_BY_DEFAULT */ static int diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 79f61e0fb..1ee982b55 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -176,9 +176,9 @@ SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,KeyCode b,int c),(a,b,c),return) SDL_X11_MODULE(UTF8) SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) SDL_X11_SYM(int,Xutf8LookupString,(XIC a,XKeyPressedEvent* b,char* c,int d,KeySym* e,Status* f),(a,b,c,d,e,f),return) -/*SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ +/* SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ SDL_X11_SYM(void,XDestroyIC,(XIC a),(a),) -/*SDL_X11_SYM(char*,XGetICValues,(XIC, ...),return) !!! ARGH! */ +/* SDL_X11_SYM(char*,XGetICValues,(XIC, ...),return) !!! ARGH! */ SDL_X11_SYM(void,XSetICFocus,(XIC a),(a),) SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),) SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 4b70f6602..a5395ac5f 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -131,7 +131,7 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; Display *display = videodata->display; Atom _NET_WM_STATE = videodata->_NET_WM_STATE; - /*Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; */ + /* Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; */ Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED; Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT; Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ; @@ -213,7 +213,7 @@ X11_GetNetWMState(_THIS, Window xwindow) } /* FIXME, check the size hints for resizable */ - /*flags |= SDL_WINDOW_RESIZABLE; */ + /* flags |= SDL_WINDOW_RESIZABLE; */ return flags; } diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 01b4da34f..6d4b6aaa9 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -95,20 +95,20 @@ X11_InitXinput2(_THIS) return; } - /*Check supported version */ + /* Check supported version */ if(outmajor * 1000 + outminor < major * 1000 + minor) { - /*X server does not support the version we want */ + /* X server does not support the version we want */ return; } xinput2_initialized = 1; #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - /*XInput 2.2 */ + /* XInput 2.2 */ if(outmajor * 1000 + outminor >= major * 1000 + minor) { xinput2_multitouch_supported = 1; } #endif - /*Enable Raw motion events for this display */ + /* Enable Raw motion events for this display */ eventmask.deviceid = XIAllMasterDevices; eventmask.mask_len = sizeof(mask); eventmask.mask = mask; @@ -188,7 +188,7 @@ X11_InitXinput2Multitouch(_THIS) XIAnyClassInfo *class = dev->classes[j]; XITouchClassInfo *t = (XITouchClassInfo*)class; - /*Only touch devices */ + /* Only touch devices */ if (class->type != XITouchClass) continue; diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index ff42f7477..920c17093 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -24,7 +24,7 @@ #define _SDL_x11xinput2_h #ifndef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS -/*Define XGenericEventCookie as forward declaration when +/* Define XGenericEventCookie as forward declaration when *xinput2 is not available in order to compile */ struct XGenericEventCookie; typedef struct XGenericEventCookie XGenericEventCookie; diff --git a/src/video/x11/imKStoUCS.h b/src/video/x11/imKStoUCS.h index 252f9a4bf..cc684c2e3 100644 --- a/src/video/x11/imKStoUCS.h +++ b/src/video/x11/imKStoUCS.h @@ -28,4 +28,4 @@ Project. extern unsigned int X11_KeySymToUcs4(KeySym keysym); -#endif /*_imKStoUCS_h */ +#endif /* _imKStoUCS_h */ diff --git a/test/testautomation_main.c b/test/testautomation_main.c index 481e3daae..ef8f19e9e 100644 --- a/test/testautomation_main.c +++ b/test/testautomation_main.c @@ -1,7 +1,7 @@ /** * Automated SDL subsystems management test. * - * Written by Jrgen Tjern "jorgenpt" + * Written by J�rgen Tjern� "jorgenpt" * * Released under Public Domain. */ @@ -10,7 +10,7 @@ #include "SDL_test.h" -/*! +/* ! * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems * \sa * http://wiki.libsdl.org/moin.cgi/SDL_Init @@ -38,7 +38,7 @@ static int main_testInitQuitJoystickHaptic (void *arg) #endif } -/*! +/* ! * \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem() * \sa * http://wiki.libsdl.org/moin.cgi/SDL_Init diff --git a/test/testautomation_platform.c b/test/testautomation_platform.c index 06699ad96..19896b48d 100644 --- a/test/testautomation_platform.c +++ b/test/testautomation_platform.c @@ -102,7 +102,7 @@ int platform_testEndianessAndSwap(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_GetXYZ() functions * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform @@ -151,7 +151,7 @@ int platform_testGetFunctions (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasXYZ() functions * \sa * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow @@ -200,7 +200,7 @@ int platform_testHasFunctions (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_GetVersion * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion @@ -225,7 +225,7 @@ int platform_testGetVersion(void *arg) } -/*! +/* ! * \brief Tests SDL_VERSION macro */ int platform_testSDLVersion(void *arg) @@ -248,7 +248,7 @@ int platform_testSDLVersion(void *arg) } -/*! +/* ! * \brief Tests default SDL_Init */ int platform_testDefaultInit(void *arg) @@ -270,7 +270,7 @@ int platform_testDefaultInit(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_Get/Set/ClearError * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetError @@ -322,7 +322,7 @@ int platform_testGetSetClearError(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_SetError with empty input * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetError @@ -358,7 +358,7 @@ int platform_testSetErrorEmptyInput(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_SetError with invalid input * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetError @@ -422,7 +422,7 @@ int platform_testSetErrorInvalidInput(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_GetPowerInfo * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo diff --git a/test/testautomation_rect.c b/test/testautomation_rect.c index 7d80f8927..abf19f593 100644 --- a/test/testautomation_rect.c +++ b/test/testautomation_rect.c @@ -12,7 +12,7 @@ /* Helper functions */ -/*! +/* ! * \brief Private helper to check SDL_IntersectRectAndLine results */ void _validateIntersectRectAndLineResults( @@ -39,7 +39,7 @@ void _validateIntersectRectAndLineResults( /* Test case functions */ -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() clipping cases * * \sa @@ -110,7 +110,7 @@ rect_testIntersectRectAndLine (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside * * \sa @@ -177,7 +177,7 @@ rect_testIntersectRectAndLineInside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside * * \sa @@ -232,7 +232,7 @@ rect_testIntersectRectAndLineOutside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() with empty rectangle * * \sa @@ -267,7 +267,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters * * \sa @@ -302,7 +302,7 @@ rect_testIntersectRectAndLineParam (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Private helper to check SDL_HasIntersection results */ void _validateHasIntersectionResults( @@ -325,7 +325,7 @@ void _validateHasIntersectionResults( refRectB->x, refRectB->y, refRectB->w, refRectB->h); } -/*! +/* ! * \brief Private helper to check SDL_IntersectRect results */ void _validateIntersectRectResults( @@ -344,7 +344,7 @@ void _validateIntersectRectResults( } } -/*! +/* ! * \brief Private helper to check SDL_UnionRect results */ void _validateUnionRectResults( @@ -367,7 +367,7 @@ void _validateUnionRectResults( expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); } -/*! +/* ! * \brief Private helper to check SDL_RectEmpty results */ void _validateRectEmptyResults( @@ -385,7 +385,7 @@ void _validateRectEmptyResults( refRect->x, refRect->y, refRect->w, refRect->h); } -/*! +/* ! * \brief Private helper to check SDL_RectEquals results */ void _validateRectEqualsResults( @@ -408,7 +408,7 @@ void _validateRectEqualsResults( refRectB->x, refRectB->y, refRectB->w, refRectB->h); } -/*! +/* ! * \brief Tests SDL_IntersectRect() with B fully inside A * * \sa @@ -436,7 +436,7 @@ int rect_testIntersectRectInside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with B fully outside A * * \sa @@ -464,7 +464,7 @@ int rect_testIntersectRectOutside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with B partially intersecting A * * \sa @@ -553,7 +553,7 @@ int rect_testIntersectRectPartial (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles * * \sa @@ -600,7 +600,7 @@ int rect_testIntersectRectPoint (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with empty rectangles * * \sa @@ -672,7 +672,7 @@ int rect_testIntersectRectEmpty (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_IntersectRect() with invalid parameters * * \sa @@ -702,7 +702,7 @@ int rect_testIntersectRectParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with B fully inside A * * \sa @@ -729,7 +729,7 @@ int rect_testHasIntersectionInside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with B fully outside A * * \sa @@ -756,7 +756,7 @@ int rect_testHasIntersectionOutside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with B partially intersecting A * * \sa @@ -823,7 +823,7 @@ int rect_testHasIntersectionPartial (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles * * \sa @@ -869,7 +869,7 @@ int rect_testHasIntersectionPoint (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with empty rectangles * * \sa @@ -927,7 +927,7 @@ int rect_testHasIntersectionEmpty (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_HasIntersection() with invalid parameters * * \sa @@ -950,7 +950,7 @@ int rect_testHasIntersectionParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Test SDL_EnclosePoints() without clipping * * \sa @@ -1020,7 +1020,7 @@ int rect_testEnclosePoints(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Test SDL_EnclosePoints() with repeated input points * * \sa @@ -1096,7 +1096,7 @@ int rect_testEnclosePointsRepeatedInput(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Test SDL_EnclosePoints() with clipping * * \sa @@ -1195,7 +1195,7 @@ int rect_testEnclosePointsWithClipping(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_EnclosePoints() with invalid parameters * * \sa @@ -1223,7 +1223,7 @@ int rect_testEnclosePointsParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_UnionRect() where rect B is outside rect A * * \sa @@ -1294,7 +1294,7 @@ int rect_testUnionRectOutside(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_UnionRect() where rect A or rect B are empty * * \sa @@ -1359,7 +1359,7 @@ int rect_testUnionRectEmpty(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_UnionRect() where rect B is inside rect A * * \sa @@ -1423,7 +1423,7 @@ int rect_testUnionRectInside(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_UnionRect() with invalid parameters * * \sa @@ -1451,7 +1451,7 @@ int rect_testUnionRectParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_RectEmpty() with various inputs * * \sa @@ -1494,7 +1494,7 @@ int rect_testRectEmpty(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_RectEmpty() with invalid parameters * * \sa @@ -1511,7 +1511,7 @@ int rect_testRectEmptyParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_RectEquals() with various inputs * * \sa @@ -1541,7 +1541,7 @@ int rect_testRectEquals(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_RectEquals() with invalid parameters * * \sa @@ -1674,7 +1674,7 @@ static const SDLTest_TestCaseReference rectTest29 = { (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED }; -/*! +/* ! * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges. * * \sa diff --git a/test/testautomation_rwops.c b/test/testautomation_rwops.c index 7ae19bd7e..c8e1c593b 100644 --- a/test/testautomation_rwops.c +++ b/test/testautomation_rwops.c @@ -165,7 +165,7 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write) i); } -/*! +/* ! * Negative test for SDL_RWFromFile parameters * * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 863a5bd6e..97cc81d84 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -262,7 +262,7 @@ surface_testSaveLoadBitmap(void *arg) return TEST_COMPLETED; } -/*! +/* ! * Tests surface conversion. */ int @@ -307,7 +307,7 @@ surface_testSurfaceConversion(void *arg) } -/*! +/* ! * Tests surface conversion across all pixel formats. */ int diff --git a/test/testgesture.c b/test/testgesture.c index 9c1959b52..016506e11 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -49,7 +49,7 @@ #define BPP 4 #define DEPTH 32 -/*MUST BE A POWER OF 2! */ +/* MUST BE A POWER OF 2! */ #define EVENT_BUF_SIZE 256 @@ -102,9 +102,9 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); SDL_GetRGB(colour,screen->format,&r,&g,&b); - /*r = 0;g = 0; b = 0; */ + /* r = 0;g = 0; b = 0; */ a = (float)((col>>24)&0xFF); - if(a == 0) a = 0xFF; /*Hack, to make things easier. */ + if(a == 0) a = 0xFF; /* Hack, to make things easier. */ a /= 0xFF; r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a)); g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); @@ -127,7 +127,7 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) float xr; for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) { xr = (float)sqrt(r*r - ty*ty); - if(r > 0) { /*r > 0 ==> filled circle */ + if(r > 0) { /* r > 0 ==> filled circle */ for(tx=-xr+.5f;tx<=xr-.5;tx++) { setpix(screen,x+tx,y+ty,c); } @@ -157,7 +157,7 @@ void DrawScreen(SDL_Surface* screen) setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); #endif - /*draw Touch History */ + /* draw Touch History */ for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; @@ -170,7 +170,7 @@ void DrawScreen(SDL_Surface* screen) x = event->tfinger.x; y = event->tfinger.y; - /*draw the touch: */ + /* draw the touch: */ c = colors[event->tfinger.fingerId%7]; col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /*gesture variables */ + /* gesture variables */ knob.r = .1f; knob.ang = 0; @@ -225,7 +225,7 @@ int main(int argc, char* argv[]) while(!quitting) { while(SDL_PollEvent(&event)) { - /*Record _all_ events */ + /* Record _all_ events */ events[eventWrite & (EVENT_BUF_SIZE-1)] = event; eventWrite++; diff --git a/test/testhaptic.c b/test/testhaptic.c index 6f523c565..1e9dd3bdb 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -279,7 +279,7 @@ HapticPrintSupported(SDL_Haptic * haptic) if (supported & SDL_HAPTIC_SINE) SDL_Log(" sine\n"); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*if (supported & SDL_HAPTIC_SQUARE) + /* if (supported & SDL_HAPTIC_SQUARE) SDL_Log(" square\n"); */ if (supported & SDL_HAPTIC_TRIANGLE) SDL_Log(" triangle\n"); diff --git a/test/testoverlay2.c b/test/testoverlay2.c index addbc27b8..4561f9845 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -356,7 +356,7 @@ main(int argc, char **argv) quit(5); } /* Uncomment this to check vertex color with a YUV texture */ - /*SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ + /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ for (i = 0; i < MOOSEFRAMES_COUNT; i++) { Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3]; diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 6c26a7a51..5033c1c5f 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -127,7 +127,7 @@ Draw(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); - /*SDL_Delay(10); */ + /* SDL_Delay(10); */ } int diff --git a/test/testshape.c b/test/testshape.c index 7c987fe49..785ba1acf 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -29,11 +29,11 @@ typedef struct LoadedPicture { void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions) { - /*Clear render-target to blue. */ + /* Clear render-target to blue. */ SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); SDL_RenderClear(renderer); - /*Render the texture. */ + /* Render the texture. */ SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); SDL_RenderPresent(renderer); @@ -188,17 +188,17 @@ int main(int argc,char** argv) next_time += TICK_INTERVAL; } - /*Free the textures. */ + /* Free the textures. */ for(i=0;i Date: Wed, 21 Aug 2013 10:12:16 -0300 Subject: [PATCH 047/258] Fixes for -Wdeclaration-after-statement --- src/render/opengles/SDL_render_gles.c | 11 +++++------ src/timer/unix/SDL_systimer.c | 4 ++-- src/video/SDL_egl.c | 11 ++++++----- src/video/SDL_fillrect.c | 25 +++++++++++++++++-------- src/video/x11/SDL_x11events.c | 7 +++---- src/video/x11/SDL_x11opengl.c | 3 ++- src/video/x11/SDL_x11shape.c | 18 ++++++++++++------ src/video/x11/SDL_x11video.c | 3 ++- src/video/x11/SDL_x11xinput2.c | 11 +++++++---- 9 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 64d3e8cd2..7f7d61ac4 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -864,6 +864,8 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; GLfloat minx, miny, maxx, maxy; GLfloat minu, maxu, minv, maxv; + GLfloat vertices[8]; + GLfloat texCoords[8]; GLES_ActivateRenderer(renderer); @@ -924,9 +926,6 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv *= texturedata->texh; - GLfloat vertices[8]; - GLfloat texCoords[8]; - vertices[0] = minx; vertices[1] = miny; vertices[2] = maxx; @@ -965,6 +964,9 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, GLfloat minx, miny, maxx, maxy; GLfloat minu, maxu, minv, maxv; GLfloat centerx, centery; + GLfloat vertices[8]; + GLfloat texCoords[8]; + GLES_ActivateRenderer(renderer); @@ -1015,9 +1017,6 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv *= texturedata->texh; - GLfloat vertices[8]; - GLfloat texCoords[8]; - vertices[0] = minx; vertices[1] = miny; vertices[2] = maxx; diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 793403297..134c12a91 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -86,11 +86,11 @@ SDL_InitTicks(void) Uint32 SDL_GetTicks(void) { + Uint32 ticks; if (!ticks_started) { SDL_InitTicks(); } - Uint32 ticks; if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME struct timespec now; @@ -115,11 +115,11 @@ SDL_GetTicks(void) Uint64 SDL_GetPerformanceCounter(void) { + Uint64 ticks; if (!ticks_started) { SDL_InitTicks(); } - Uint64 ticks; if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME struct timespec now; diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index da293743b..2fbbc790d 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -305,12 +305,12 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) { + EGLContext egl_context = (EGLContext) context; + if (!_this->egl_data) { return SDL_SetError("OpenGL not initialized"); } - EGLContext egl_context = (EGLContext) context; - /* The android emulator crashes badly if you try to eglMakeCurrent * with a valid context and invalid surface, so we have to check for both here. */ @@ -330,11 +330,12 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) int SDL_EGL_SetSwapInterval(_THIS, int interval) { + EGLBoolean status; + if (_this->egl_data) { return SDL_SetError("OpenGL ES context not active"); } - EGLBoolean status; status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); if (status == EGL_TRUE) { _this->egl_data->egl_swapinterval = interval; @@ -363,13 +364,13 @@ SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface) void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) { + EGLContext egl_context = (EGLContext) context; + /* Clean up GLES and EGL */ if (!_this->egl_data) { return; } - EGLContext egl_context = (EGLContext) context; - if (!egl_context && egl_context != EGL_NO_CONTEXT) { SDL_EGL_MakeCurrent(_this, NULL, NULL); _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 13236a487..630c24802 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -36,12 +36,13 @@ c128.m128_u32[3] = color; #else #define SSE_BEGIN \ + __m128 c128; \ DECLARE_ALIGNED(Uint32, cccc[4], 16); \ cccc[0] = color; \ cccc[1] = color; \ cccc[2] = color; \ cccc[3] = color; \ - __m128 c128 = *(__m128 *)cccc; + c128 = *(__m128 *)cccc; #endif #define SSE_WORK \ @@ -59,11 +60,14 @@ static void \ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ { \ + int i, n; \ + Uint8 *p = NULL; \ + \ SSE_BEGIN; \ \ while (h--) { \ - int i, n = w * bpp; \ - Uint8 *p = pixels; \ + n = w * bpp; \ + p = pixels; \ \ if (n > 63) { \ int adjust = 16 - ((uintptr_t)p & 15); \ @@ -94,11 +98,13 @@ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ static void SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { + int i, n; + Uint8 *p = NULL; + SSE_BEGIN; - while (h--) { - int i, n = w; - Uint8 *p = pixels; + n = w; + p = pixels; if (n > 63) { int adjust = 16 - ((uintptr_t)p & 15); @@ -152,11 +158,14 @@ DEFINE_SSE_FILLRECT(4, Uint32) static void \ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ { \ + int i, n; \ + Uint8 *p = NULL; \ + \ MMX_BEGIN; \ \ while (h--) { \ - int i, n = w * bpp; \ - Uint8 *p = pixels; \ + n = w * bpp; \ + p = pixels; \ \ if (n > 63) { \ int adjust = 8 - ((uintptr_t)p & 7); \ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 6919e7742..0b577ecb4 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -173,11 +173,12 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) */ static char* X11_URIToLocal(char* uri) { char *file = NULL; + SDL_bool local; if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */ - SDL_bool local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' ); + local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' ); /* got a hostname? */ if ( !local && uri[0] == '/' && uri[2] != '/' ) { @@ -267,6 +268,7 @@ X11_DispatchEvent(_THIS) SDL_WindowData *data; XEvent xevent; int i; + XClientMessageEvent m; SDL_zero(xevent); /* valgrind fix. --ryan. */ XNextEvent(display, &xevent); @@ -549,7 +551,6 @@ X11_DispatchEvent(_THIS) else if (xevent.xclient.message_type == videodata->XdndPosition) { /* reply with status */ - XClientMessageEvent m; memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent.xclient.display; @@ -568,7 +569,6 @@ X11_DispatchEvent(_THIS) else if(xevent.xclient.message_type == videodata->XdndDrop) { if (data->xdnd_req == None) { /* say again - not interested! */ - XClientMessageEvent m; memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent.xclient.display; @@ -841,7 +841,6 @@ X11_DispatchEvent(_THIS) XFree(p.data); /* send reply */ - XClientMessageEvent m; SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = display; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 6ddc0de7e..6796b7d30 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -564,6 +564,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) XVisualInfo v, *vinfo; int n; GLXContext context = NULL, share_context; + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = NULL; if (_this->gl_config.share_with_current_context) { share_context = (GLXContext)SDL_GL_GetCurrentContext(); @@ -617,7 +618,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) attribs[iattr++] = 0; /* Get a pointer to the context creation function for GL 3.0 */ - PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = + glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data-> glXGetProcAddress((GLubyte *) "glXCreateContextAttribsARB"); diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index cea280722..d8ab18e92 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -36,6 +36,8 @@ X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) { SDL_WindowShaper* result = NULL; + SDL_ShapeData* data = NULL; + int resized_properly; #if SDL_VIDEO_DRIVER_X11_XSHAPE if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ @@ -44,12 +46,12 @@ X11_CreateShaper(SDL_Window* window) { result->mode.mode = ShapeModeDefault; result->mode.parameters.binarizationCutoff = 1; result->userx = result->usery = 0; - SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData)); + data = SDL_malloc(sizeof(SDL_ShapeData)); result->driverdata = data; data->bitmapsize = 0; data->bitmap = NULL; window->shaper = result; - int resized_properly = X11_ResizeWindowShape(window); + resized_properly = X11_ResizeWindowShape(window); SDL_assert(resized_properly == 0); } #endif @@ -60,9 +62,9 @@ X11_CreateShaper(SDL_Window* window) { int X11_ResizeWindowShape(SDL_Window* window) { SDL_ShapeData* data = window->shaper->driverdata; + unsigned int bitmapsize = window->w / 8; SDL_assert(data != NULL); - unsigned int bitmapsize = window->w / 8; if(window->w % 8 > 0) bitmapsize += 1; bitmapsize *= window->h; @@ -86,6 +88,10 @@ X11_ResizeWindowShape(SDL_Window* window) { int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { + SDL_ShapeData *data = NULL; + SDL_WindowData *windowdata = NULL; + Pixmap shapemask = NULL; + if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) return -1; @@ -94,13 +100,13 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo return -2; if(shape->w != shaper->window->w || shape->h != shaper->window->h) return -3; - SDL_ShapeData *data = shaper->driverdata; + data = shaper->driverdata; /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */ SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8); - SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata); - Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); + windowdata = (SDL_WindowData*)(shaper->window->driverdata); + shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); XSync(windowdata->videodata->display,False); diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 83224bcca..200e57751 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -259,10 +259,11 @@ static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL; static int X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) { + SDL_VideoDevice *device = NULL; /* if we trigger an error in our error handler, don't try again. */ if (!safety_net_triggered) { safety_net_triggered = SDL_TRUE; - SDL_VideoDevice *device = SDL_GetVideoDevice(); + device = SDL_GetVideoDevice(); if (device != NULL) { int i; for (i = 0; i < device->num_displays; i++) { diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 6d4b6aaa9..10b422882 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -206,14 +206,17 @@ void X11_Xinput2SelectTouch(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + SDL_VideoData *data = NULL; + XIEventMask eventmask; + unsigned char mask[3] = { 0,0,0 }; + SDL_WindowData *window_data = NULL; + if (!X11_Xinput2IsMultitouchSupported()) { return; } - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - XIEventMask eventmask; - unsigned char mask[3] = { 0,0,0 }; - SDL_WindowData *window_data = (SDL_WindowData*)window->driverdata; + data = (SDL_VideoData *) _this->driverdata; + window_data = (SDL_WindowData*)window->driverdata; eventmask.deviceid = XIAllMasterDevices; eventmask.mask_len = sizeof(mask); From 91d5b012ad8a88cfc6975a75f7994e7553c1db2d Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 21 Aug 2013 10:13:12 -0300 Subject: [PATCH 048/258] More fixes for -Wdeclaration-after-statement --- src/video/SDL_fillrect.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 630c24802..72e2eefde 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -196,11 +196,14 @@ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ static void SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { + int i, n; + Uint8 *p = NULL; + MMX_BEGIN; while (h--) { - int i, n = w; - Uint8 *p = pixels; + n = w; + p = pixels; if (n > 63) { int adjust = 8 - ((uintptr_t)p & 7); @@ -231,9 +234,12 @@ DEFINE_MMX_FILLRECT(4, Uint32) static void SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { + int n; + Uint8 *p = NULL; + while (h--) { - int n = w; - Uint8 *p = pixels; + n = w; + p = pixels; if (n > 3) { switch ((uintptr_t) p & 3) { @@ -267,9 +273,12 @@ SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) static void SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { + int n; + Uint8 *p = NULL; + while (h--) { - int n = w; - Uint16 *p = (Uint16 *) pixels; + n = w; + p = (Uint16 *) pixels; if (n > 1) { if ((uintptr_t) p & 2) { @@ -291,10 +300,12 @@ SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h) Uint8 r = (Uint8) ((color >> 16) & 0xFF); Uint8 g = (Uint8) ((color >> 8) & 0xFF); Uint8 b = (Uint8) (color & 0xFF); + int n; + Uint8 *p = NULL; while (h--) { - int n = w; - Uint8 *p = pixels; + n = w; + p = pixels; while (n--) { *p++ = r; From 3557ef7451cb1aa9b6543de6212bcf8cb37564db Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 21 Aug 2013 10:27:39 -0300 Subject: [PATCH 049/258] Patched to compile on Darwin --- src/joystick/darwin/SDL_sysjoystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index 2251d0d33..6a75e0819 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -771,7 +771,7 @@ SDL_SYS_JoystickInit(void) ("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching."); } - / */ Now search I/O Registry for matching devices. */ + /* Now search I/O Registry for matching devices. */ result = IOServiceGetMatchingServices(masterPort, hidMatchDictionary, &hidObjectIterator); From 332278ee6f093fe13b7daea375f8d7b484c3c670 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 21 Aug 2013 10:34:32 -0300 Subject: [PATCH 050/258] Fix a couple of warnings --- src/video/SDL_fillrect.c | 2 +- src/video/x11/SDL_x11shape.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 72e2eefde..d891e4e9d 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -274,7 +274,7 @@ static void SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { int n; - Uint8 *p = NULL; + Uint16 *p = NULL; while (h--) { n = w; diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index d8ab18e92..67eeade8a 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -90,7 +90,7 @@ int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { SDL_ShapeData *data = NULL; SDL_WindowData *windowdata = NULL; - Pixmap shapemask = NULL; + Pixmap shapemask; if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) return -1; From 1afef302ac45a73f3ecd9e1c5ca29fa417832343 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 21 Aug 2013 10:07:48 -0700 Subject: [PATCH 051/258] Fixed crash if the IC isn't set up for some reason (bad X11 locale?) --- src/video/x11/SDL_x11window.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index a5395ac5f..6bc2eb950 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -346,6 +346,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *windowdata; Display *display = data->display; int screen = displaydata->screen; Visual *visual; @@ -547,6 +548,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) XDestroyWindow(display, w); return -1; } + windowdata = (SDL_WindowData *) window->driverdata; #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) { @@ -556,9 +558,9 @@ X11_CreateWindow(_THIS, SDL_Window * window) } /* Create the GLES window surface */ - ((SDL_WindowData *) window->driverdata)->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); + windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); - if (((SDL_WindowData *) window->driverdata)->egl_surface == EGL_NO_SURFACE) { + if (windowdata->egl_surface == EGL_NO_SURFACE) { XDestroyWindow(display, w); return SDL_SetError("Could not create GLES window surface"); } @@ -567,9 +569,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) #ifdef X_HAVE_UTF8_STRING - if (SDL_X11_HAVE_UTF8) { - pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, - XNFilterEvents, &fevent, NULL); + if (SDL_X11_HAVE_UTF8 && windowdata->ic) { + pXGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL); } #endif From 8ddc481d359b004e5850d4e5f7c702889bf89e25 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 21 Aug 2013 10:31:44 -0700 Subject: [PATCH 052/258] Fix SDL xinput code to work at all when xinput has devices at high indexes but no device connected at lower index, for instance 0->disconnected, 1->wireles, 2->wired. Previously the SDL code assumed the indexes were always used up in order which is not true at all and lead to a bunch of failure cases where controllers would go unrecognized. This entire function is kind of a mess and more complicated than needed, but I don't want to refactor it too heavily tonight. May look at improving how the indexes are assigned more significanly later. The way it handles not finding a valid "gamepad" type device is also super broken, it leaves in place the xinput bindings but opens the controller with dinput and ends up with completely wrong mappings, not solving that now, but fixing the bug where we'd very frequently not find a controller due to gaps in assigned player numbers should mostly avoid it. --- src/joystick/windows/SDL_dxjoystick.c | 92 +++++++++++++++++---------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 0c915a96d..d85ff18a4 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -1014,40 +1014,66 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) { - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { - const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); - SDL_bool bIsSupported = SDL_FALSE; - /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ - bIsSupported = ( capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD ); + while ( 1 ) + { + result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); + if ( result == ERROR_SUCCESS ) + { + const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); + SDL_bool bIsSupported = SDL_FALSE; + /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ + bIsSupported = ( capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD ); - if ( !bIsSupported ) - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - else - { - /* valid */ - joystick->hwdata->bXInputDevice = SDL_TRUE; - if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { - joystick->hwdata->bXInputHaptic = SDL_TRUE; - } - SDL_memset( joystick->hwdata->XInputState, 0x0, sizeof(joystick->hwdata->XInputState) ); - joystickdevice->XInputUserId = userId; - joystick->hwdata->userid = userId; - joystick->hwdata->currentXInputSlot = 0; - /* The XInput API has a hard coded button/axis mapping, so we just match it */ - joystick->naxes = 6; - joystick->nbuttons = 15; - joystick->nballs = 0; - joystick->nhats = 0; - } - } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - } + if ( !bIsSupported ) + { + joystickdevice->bXInputDevice = SDL_FALSE; + } + else + { + /* valid */ + joystick->hwdata->bXInputDevice = SDL_TRUE; + if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { + joystick->hwdata->bXInputHaptic = SDL_TRUE; + } + SDL_memset( joystick->hwdata->XInputState, 0x0, sizeof(joystick->hwdata->XInputState) ); + joystickdevice->XInputUserId = userId; + joystick->hwdata->userid = userId; + joystick->hwdata->currentXInputSlot = 0; + /* The XInput API has a hard coded button/axis mapping, so we just match it */ + joystick->naxes = 6; + joystick->nbuttons = 15; + joystick->nballs = 0; + joystick->nhats = 0; + } + break; + } + else + { + if ( userId < XUSER_MAX_COUNT && result == ERROR_DEVICE_NOT_CONNECTED ) + { + /* scan the opened joysticks and pick the next free xinput userid for this one */ + ++userId; + + joysticklist = SYS_Joystick; + for( ; joysticklist; joysticklist = joysticklist->pNext) + { + if ( joysticklist->bXInputDevice && joysticklist->XInputUserId == userId ) + userId++; + } + + if ( userId >= XUSER_MAX_COUNT ) + { + joystickdevice->bXInputDevice = SDL_FALSE; + break; + } + } + else + { + joystickdevice->bXInputDevice = SDL_FALSE; + break; + } + } + } } else { From 54d87dfc28b22450ce935bcc67f6702d1d9ac2ef Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 21 Aug 2013 10:32:04 -0700 Subject: [PATCH 053/258] SDL - detect that you tried to open a gamecontroller in xinput mode and failed, then re-get the mapping for the dinput variant you did open (and most likely now just fail the open) CR: SamL --- src/joystick/SDL_gamecontroller.c | 21 +++++++++++++++++++++ src/joystick/SDL_sysjoystick.h | 1 + src/joystick/windows/SDL_dxjoystick.c | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 0a4ad6b0d..05ed473d2 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -851,6 +851,9 @@ SDL_GameControllerOpen(int device_index) SDL_GameController *gamecontroller; SDL_GameController *gamecontrollerlist; ControllerMapping_t *pSupportedController = NULL; +#ifdef SDL_JOYSTICK_DINPUT + SDL_bool bIsXinputDevice; +#endif if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) { SDL_SetError("There are %d joysticks available", SDL_NumJoysticks()); @@ -883,6 +886,11 @@ SDL_GameControllerOpen(int device_index) return NULL; } +#ifdef SDL_JOYSTICK_DINPUT + /* check if we think we should open this device in XInput mode */ + bIsXinputDevice = SDL_SYS_IsXInputDeviceIndex(device_index); +#endif + SDL_memset(gamecontroller, 0, (sizeof *gamecontroller)); gamecontroller->joystick = SDL_JoystickOpen(device_index); if ( !gamecontroller->joystick ) { @@ -890,6 +898,19 @@ SDL_GameControllerOpen(int device_index) return NULL; } +#ifdef SDL_JOYSTICK_DINPUT + if ( !SDL_SYS_IsXInputJoystick( gamecontroller->joystick ) && bIsXinputDevice ) + { + /* we tried to open the controller in XInput mode and failed, so get the mapping again for the direct input variant if possible */ + SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID( device_index ); + pSupportedController = SDL_PrivateGetControllerMappingForGUID(&jGUID); + if ( !pSupportedController ) { + SDL_SetError("Failed to open device in XInput mode (%d)", device_index ); + return (NULL); + } + } +#endif + SDL_PrivateLoadButtonMapping( &gamecontroller->mapping, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping ); /* Add joystick to list */ diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index 4a5019e73..3aeaf0821 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -111,6 +111,7 @@ extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick); #ifdef SDL_JOYSTICK_DINPUT /* Function to get the current instance id of the joystick located at device_index */ extern SDL_bool SDL_SYS_IsXInputDeviceIndex( int device_index ); +extern SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick); #endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index d85ff18a4..eb4ab2a3a 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -1776,6 +1776,12 @@ SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index) return device->bXInputDevice; } +/* return SDL_TRUE if this device was opened with XInput */ +SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick) +{ + return joystick->hwdata->bXInputDevice; +} + #endif /* SDL_JOYSTICK_DINPUT */ /* vi: set ts=4 sw=4 expandtab: */ From 34b9565f87abc7800b489f27070c6daab3def6ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 21 Aug 2013 12:12:04 -0700 Subject: [PATCH 054/258] Fixed compiling on old versions of the DirectX SDK --- src/joystick/windows/SDL_dxjoystick_c.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/joystick/windows/SDL_dxjoystick_c.h b/src/joystick/windows/SDL_dxjoystick_c.h index 01cfca970..1b2717216 100644 --- a/src/joystick/windows/SDL_dxjoystick_c.h +++ b/src/joystick/windows/SDL_dxjoystick_c.h @@ -44,6 +44,17 @@ #include #include +#ifndef XUSER_MAX_COUNT +#define XUSER_MAX_COUNT 4 +#endif +#ifndef XUSER_INDEX_ANY +#define XUSER_INDEX_ANY 0x000000FF +#endif +#ifndef XINPUT_CAPS_FFB_SUPPORTED +#define XINPUT_CAPS_FFB_SUPPORTED 0x0001 +#endif + + /* typedef's for XInput structs we use */ typedef struct { @@ -94,13 +105,8 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ #define XINPUTGETSTATE SDL_XInputGetState #define XINPUTSETSTATE SDL_XInputSetState #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities -#define INVALID_XINPUT_USERID 255 -#define SDL_XINPUT_MAX_DEVICES 4 - -#ifndef XINPUT_CAPS_FFB_SUPPORTED -#define XINPUT_CAPS_FFB_SUPPORTED 0x0001 -#endif - +#define INVALID_XINPUT_USERID XUSER_INDEX_ANY +#define SDL_XINPUT_MAX_DEVICES XUSER_MAX_COUNT #define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ From cd9a7c392cd00c23f90f020f4f3a7014d2514716 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 22 Aug 2013 10:22:22 -0300 Subject: [PATCH 055/258] Fixes #2036 and #2038, bypass camera zoom and shutter keypresses on Android. --- android-project/src/org/libsdl/app/SDLActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index f17365339..52e48e236 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -122,9 +122,13 @@ public class SDLActivity extends Activity { @Override public boolean dispatchKeyEvent(KeyEvent event) { int keyCode = event.getKeyCode(); - // Ignore volume keys so they're handled by Android + // Ignore certain special keys so they're handled by Android if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || - keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + keyCode == KeyEvent.KEYCODE_VOLUME_UP || + keyCode == KeyEvent.KEYCODE_CAMERA || + keyCode == 168 || /* API 11: KeyEvent.KEYCODE_ZOOM_IN */ + keyCode == 169 /* API 11: KeyEvent.KEYCODE_ZOOM_OUT */ + ) { return false; } return super.dispatchKeyEvent(event); From 20512dd292b9983ba26fb6c14af9c0ca3a957a3a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 22 Aug 2013 13:00:05 -0400 Subject: [PATCH 056/258] Added SDL_VIDEO_OPENGL_ES2 to the SDL_config.h templates (Thanks, Kerim!). --- include/SDL_config.h.cmake | 1 + include/SDL_config.h.in | 1 + 2 files changed, 2 insertions(+) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 500e72a2d..f9a9ab9af 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -288,6 +288,7 @@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ #cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@ +#cmakedefine SDL_VIDEO_OPENGL_ES2 @SDL_VIDEO_OPENGL_ES2@ #cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@ #cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@ #cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 7bb12832f..551c8b3e7 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -289,6 +289,7 @@ /* Enable OpenGL support */ #undef SDL_VIDEO_OPENGL #undef SDL_VIDEO_OPENGL_ES +#undef SDL_VIDEO_OPENGL_ES2 #undef SDL_VIDEO_OPENGL_BGL #undef SDL_VIDEO_OPENGL_CGL #undef SDL_VIDEO_OPENGL_EGL From 8f7192143e3ee8f6256a02d5ac6b5ac559a4f221 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 22 Aug 2013 13:32:27 -0400 Subject: [PATCH 057/258] XAudio2/DirectSound: Use the usual Windows string convert (thanks, Norfanin!). --- src/audio/directsound/SDL_directsound.c | 12 ++---------- src/audio/xaudio2/SDL_xaudio2.c | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 23167bf1b..86563a62e 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -91,14 +91,6 @@ DSOUND_Load(void) return loaded; } -static __inline__ char * -utf16_to_utf8(const WCHAR *S) -{ - /* !!! FIXME: this should be UTF-16, not UCS-2! */ - return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), - (SDL_wcslen(S)+1)*sizeof(WCHAR)); -} - static int SetDSerror(const char *function, int code) { @@ -158,7 +150,7 @@ FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data) { SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data; if (guid != NULL) { /* skip default device */ - char *str = utf16_to_utf8(desc); + char *str = WIN_StringToUTF8(desc); if (str != NULL) { addfn(str); SDL_free(str); /* addfn() makes a copy of this string. */ @@ -439,7 +431,7 @@ FindDevGUID(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data) { if (guid != NULL) { /* skip the default device. */ FindDevGUIDData *data = (FindDevGUIDData *) _data; - char *str = utf16_to_utf8(desc); + char *str = WIN_StringToUTF8(desc); const int match = (SDL_strcmp(str, data->devname) == 0); SDL_free(str); if (match) { diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index a2c45ba86..5af4b30e5 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -60,14 +60,6 @@ struct SDL_PrivateAudioData }; -static __inline__ char * -utf16_to_utf8(const WCHAR *S) -{ - /* !!! FIXME: this should be UTF-16, not UCS-2! */ - return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), - (SDL_wcslen(S)+1)*sizeof(WCHAR)); -} - static void XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) { @@ -90,7 +82,7 @@ XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) for (i = 0; i < devcount; i++) { XAUDIO2_DEVICE_DETAILS details; if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) { - char *str = utf16_to_utf8(details.DisplayName); + char *str = WIN_StringToUTF8(details.DisplayName); if (str != NULL) { addfn(str); SDL_free(str); /* addfn() made a copy of the string. */ @@ -265,7 +257,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) for (i = 0; i < devcount; i++) { XAUDIO2_DEVICE_DETAILS details; if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) { - char *str = utf16_to_utf8(details.DisplayName); + char *str = WIN_StringToUTF8(details.DisplayName); if (str != NULL) { const int match = (SDL_strcmp(str, devname) == 0); SDL_free(str); From 65f76b93b9021da3c1c1c4ba0b590941d75f21b3 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 22 Aug 2013 14:56:07 -0300 Subject: [PATCH 058/258] Separate EGL / GL ES detection in CMake --- cmake/sdlchecks.cmake | 34 +++++++++++++++++++--------------- include/SDL_config.h.cmake | 1 + 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 14fb327b1..5666f52fc 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -563,25 +563,29 @@ macro(CheckOpenGLESX11) if(VIDEO_OPENGLES) check_c_source_compiles(" #include - int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES) - if(HAVE_VIDEO_OPENGLES) - check_c_source_compiles(" - #include - #include - int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1) - if(HAVE_VIDEO_OPENGLES_V1) + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL) + if(HAVE_VIDEO_OPENGL_EGL) + set(SDL_VIDEO_OPENGL_EGL 1) + endif(HAVE_VIDEO_OPENGL_EGL) + check_c_source_compiles(" + #include + #include + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1) + if(HAVE_VIDEO_OPENGLES_V1) + set(HAVE_VIDEO_OPENGLES TRUE) set(SDL_VIDEO_OPENGL_ES 1) set(SDL_VIDEO_RENDER_OGL_ES 1) - endif(HAVE_VIDEO_OPENGLES_V1) - check_c_source_compiles(" - #include - #include - int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2) - if(HAVE_VIDEO_OPENGLES_V2) + endif(HAVE_VIDEO_OPENGLES_V1) + check_c_source_compiles(" + #include + #include + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2) + if(HAVE_VIDEO_OPENGLES_V2) + set(HAVE_VIDEO_OPENGLES TRUE) set(SDL_VIDEO_OPENGL_ES2 1) set(SDL_VIDEO_RENDER_OGL_ES2 1) - endif(HAVE_VIDEO_OPENGLES_V2) - endif(HAVE_VIDEO_OPENGLES) + endif(HAVE_VIDEO_OPENGLES_V2) + endif(VIDEO_OPENGLES) endmacro(CheckOpenGLESX11) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index f9a9ab9af..66107e49e 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -293,6 +293,7 @@ #cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@ #cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@ #cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@ +#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@ #cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@ #cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@ From df31e201cb4b672b90c38f9806cc763c153e0865 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 22 Aug 2013 17:26:22 -0300 Subject: [PATCH 059/258] Fix warning in GL ES2 renderer --- src/render/opengles2/SDL_render_gles2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index a0ab94365..83ead0a97 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1174,7 +1174,7 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s { GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - GLES2_ImageSource sourceType; + GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; @@ -1330,7 +1330,7 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect { GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - GLES2_ImageSource sourceType; + GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; From b83dc371b817009d3a6ac20ebbf231470ec79112 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 23 Aug 2013 21:38:54 -0400 Subject: [PATCH 060/258] Add support for some BSDs and Solaris to SDL_GetBasePath(). --HG-- extra : rebase_source : d2c9bc42ea618bcafdf8ec6c24d35d3123741fc6 --- src/filesystem/unix/SDL_sysfilesystem.c | 41 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 09db1e55c..1798f3e04 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -26,9 +26,14 @@ /* System dependent filesystem routines */ #include +#include #include #include +#ifdef __FREEBSD__ +#include +#endif + #include "SDL_error.h" #include "SDL_stdinc.h" #include "SDL_filesystem.h" @@ -73,9 +78,41 @@ SDL_GetBasePath(void) { char *retval = NULL; +#if defined(__FREEBSD__) + char fullpath[PATH_MAX]; + size_t buflen = sizeof (fullpath); + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + if (sysctl(mib, 4, fullpath, &buflen, NULL, 0) != -1) { + retval = SDL_strdup(fullpath); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + } +#elif defined(__SOLARIS__) + const char *path = getexecname(); + if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */ + retval = SDL_strdup(fullpath); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + } +#endif + /* is a Linux-style /proc filesystem available? */ - if (access("/proc", F_OK) == 0) { - retval = readSymLink("/proc/self/exe"); + if (!retval && (access("/proc", F_OK) == 0)) { + #if defined(__FREEBSD__) + retval = readSymLink("/proc/curproc/file"); + #elif defined(__NETBSD__) + retval = readSymLink("/proc/curproc/exe"); + #else + retval = readSymLink("/proc/self/exe"); /* linux. */ + #endif if (retval == NULL) { /* older kernels don't have /proc/self ... try PID version... */ char path[64]; From 327661011ce887dadcf8d80f6a1ee86324cad3be Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 23 Aug 2013 21:48:40 -0400 Subject: [PATCH 061/258] Patched to compile on FreeBSD. --- src/filesystem/unix/SDL_sysfilesystem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 1798f3e04..659d12696 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef __FREEBSD__ #include From e94b620dc671db2edeb78ca8980732c91567482e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 23 Aug 2013 23:34:23 -0400 Subject: [PATCH 062/258] Patched to compile on Solaris. --- src/filesystem/unix/SDL_sysfilesystem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 659d12696..d8eb6e598 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -97,7 +97,7 @@ SDL_GetBasePath(void) #elif defined(__SOLARIS__) const char *path = getexecname(); if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */ - retval = SDL_strdup(fullpath); + retval = SDL_strdup(path); if (!retval) { SDL_OutOfMemory(); return NULL; From 455645d99a36d2d72a25b45c9a30b2c39ae1c282 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Sat, 24 Aug 2013 09:05:18 -0400 Subject: [PATCH 063/258] Fix #2062 Be more diligent about validating trailing "/" existence in HOME and XDG_DATA_HOME env vars --HG-- extra : amend_source : f857f2c2d14cf1fca0d5a5f4ca95c8acef79797e --- src/filesystem/unix/SDL_sysfilesystem.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index d8eb6e598..d3a3a0676 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -173,7 +173,15 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); return NULL; } - append = ".local/share/"; + if (envr[SDL_strlen(envr) - 1] == '/') { + append = ".local/share/"; + } else { + append = "/.local/share/"; + } + } else { + if (envr[SDL_strlen(envr) - 1] == '/') { + append = ""; + } } /* if */ len = SDL_strlen(envr) + SDL_strlen(append) + SDL_strlen(app) + 2; From 2bd35f683de457c0cebc308ae8e870457f92ff15 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Sat, 24 Aug 2013 09:43:14 -0400 Subject: [PATCH 064/258] make the examples in the doc comments match the actual output of the SDL_GetPrefPath function --- include/SDL_filesystem.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/SDL_filesystem.h b/include/SDL_filesystem.h index 71ced94fd..ea8a1b56f 100644 --- a/include/SDL_filesystem.h +++ b/include/SDL_filesystem.h @@ -74,13 +74,13 @@ extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); * path to the directory in UTF-8 encoding. * * On Windows, the string might look like: - * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name" + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" * * On Linux, the string might look like: - * "/home/bob/.local/share/My Program Name" + * "/home/bob/.local/share/My Program Name/" * * On Mac OS X, the string might look like: - * "/Users/bob/Library/Application Support/My Program Name" + * "/Users/bob/Library/Application Support/My Program Name/" * * (etc.) * From 1a56992a7dd3035aabb0cfa5e7adf5b30ed09d54 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 24 Aug 2013 21:15:10 -0400 Subject: [PATCH 065/258] Minor FreeBSD code cleanup. --- src/filesystem/unix/SDL_sysfilesystem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index d3a3a0676..b3e5f5f26 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -82,11 +82,7 @@ SDL_GetBasePath(void) #if defined(__FREEBSD__) char fullpath[PATH_MAX]; size_t buflen = sizeof (fullpath); - int mib[4]; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PATHNAME; - mib[3] = -1; + const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; if (sysctl(mib, 4, fullpath, &buflen, NULL, 0) != -1) { retval = SDL_strdup(fullpath); if (!retval) { From 6dd2b54f3887bc9ad0100e29871b0b2461ea549e Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sun, 25 Aug 2013 11:48:49 -0300 Subject: [PATCH 066/258] Fixes "error: conflicting types for 'GLintptr'" --- src/video/SDL_video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 77abae9f2..b98069cdf 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -39,9 +39,10 @@ #include "SDL_opengles.h" #endif /* SDL_VIDEO_OPENGL_ES */ -#if SDL_VIDEO_OPENGL_ES2 +/* GL and GLES2 headers conflict on Linux 32 bits */ +#if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL #include "SDL_opengles2.h" -#endif /* SDL_VIDEO_OPENGL_ES2 */ +#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */ #include "SDL_syswm.h" From 2770375eb5928fad005ed02eb74c3d29fcbb1fd6 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Sun, 25 Aug 2013 11:20:14 -0400 Subject: [PATCH 067/258] update xcode projects with filesystem API bits. (missing tests and missing from files from some targets) --- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 12 +- .../SDLTest/SDLTest.xcodeproj/project.pbxproj | 206 ++++++++++++++++++ 2 files changed, 214 insertions(+), 4 deletions(-) diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index c190cbf4d..1ec78cae5 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -526,6 +526,10 @@ D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; DB0F489317C400E6008798C5 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB0F489417C400ED008798C5 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB0F490817CA5292008798C5 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; + DB0F490A17CA5293008798C5 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; + DB0F490B17CA57ED008798C5 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB0F490C17CA57ED008798C5 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313F7417554B71006C0E22 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; }; DB313F7517554B71006C0E22 /* SDL_dummyaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD9512E6671700899322 /* SDL_dummyaudio.h */; }; DB313F7617554B71006C0E22 /* SDL_coreaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDA112E6671700899322 /* SDL_coreaudio.h */; }; @@ -1880,6 +1884,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + DB0F490B17CA57ED008798C5 /* SDL_filesystem.h in Headers */, AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */, AA7557FD1595D4D800BBD41B /* close_code.h in Headers */, AA75585F1595D4D800BBD41B /* SDL.h in Headers */, @@ -2018,7 +2023,6 @@ AA628AD4159367F2005138DD /* SDL_x11xinput2.h in Headers */, AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, D55A1B85179F278E00625D7C /* SDL_cocoamousetap.h in Headers */, - 567E2F2217C44C35005F1892 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2026,6 +2030,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + DB0F490C17CA57ED008798C5 /* SDL_filesystem.h in Headers */, DB313FC817554B71006C0E22 /* begin_code.h in Headers */, DB313FC917554B71006C0E22 /* close_code.h in Headers */, DB313FF917554B71006C0E22 /* SDL.h in Headers */, @@ -2164,7 +2169,6 @@ DB313FC717554B71006C0E22 /* SDL_x11xinput2.h in Headers */, DB313FFA17554B71006C0E22 /* SDL_cocoamessagebox.h in Headers */, D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */, - 567E2F2317C44C35005F1892 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2566,7 +2570,7 @@ AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */, AA0F8492178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B84179F263600625D7C /* SDL_cocoamousetap.m in Sources */, - 567E2F1D17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */, + DB0F490817CA5292008798C5 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2684,7 +2688,7 @@ DB31406A17554B71006C0E22 /* SDL_cocoamessagebox.m in Sources */, AA0F8493178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B83179F263500625D7C /* SDL_cocoamousetap.m in Sources */, - 567E2F1E17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */, + DB0F490A17CA5293008798C5 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj index bb4714de2..152c3d23c 100755 --- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj +++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ buildPhases = ( ); dependencies = ( + DB0F490517CA5249008798C5 /* PBXTargetDependency */, + DB0F490717CA5249008798C5 /* PBXTargetDependency */, DB166E9816A1D7CF00A1396C /* PBXTargetDependency */, DB166E9616A1D7CD00A1396C /* PBXTargetDependency */, DB166E6C16A1D72000A1396C /* PBXTargetDependency */, @@ -397,6 +399,28 @@ BEC567930761D90500A33029 /* testtimer.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4880006D86A17F000001 /* testtimer.c */; }; BEC567AD0761D90500A33029 /* testver.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4882006D86A17F000001 /* testver.c */; }; BEC567F00761D90600A33029 /* torturethread.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4887006D86A17F000001 /* torturethread.c */; }; + DB0F48DD17CA51E5008798C5 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; }; + DB0F48DE17CA51E5008798C5 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; }; + DB0F48DF17CA51E5008798C5 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; }; + DB0F48E017CA51E5008798C5 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; }; + DB0F48E117CA51E5008798C5 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; + DB0F48E217CA51E5008798C5 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; }; + DB0F48E317CA51E5008798C5 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; }; + DB0F48E417CA51E5008798C5 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; + DB0F48E517CA51E5008798C5 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; + DB0F48E617CA51E5008798C5 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; }; + DB0F48EE17CA51F8008798C5 /* testdrawchessboard.c in Sources */ = {isa = PBXBuildFile; fileRef = DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */; }; + DB0F48F317CA5212008798C5 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; }; + DB0F48F417CA5212008798C5 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; }; + DB0F48F517CA5212008798C5 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; }; + DB0F48F617CA5212008798C5 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; }; + DB0F48F717CA5212008798C5 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; + DB0F48F817CA5212008798C5 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; }; + DB0F48F917CA5212008798C5 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; }; + DB0F48FA17CA5212008798C5 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; + DB0F48FB17CA5212008798C5 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; + DB0F48FC17CA5212008798C5 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; }; + DB0F490317CA5225008798C5 /* testfilesystem.c in Sources */ = {isa = PBXBuildFile; fileRef = DB0F48D817CA51D2008798C5 /* testfilesystem.c */; }; DB166D7116A1CFB200A1396C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; DB166D7216A1CFB200A1396C /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; DB166D7316A1CFB200A1396C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; @@ -780,6 +804,20 @@ remoteGlobalIDString = BECDF6BE0761BA81005FE872; remoteInfo = "Standard DMG"; }; + DB0F490417CA5249008798C5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DB0F48D917CA51E5008798C5; + remoteInfo = testdrawchessboard; + }; + DB0F490617CA5249008798C5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DB0F48EF17CA5212008798C5; + remoteInfo = testfilesystem; + }; DB166D6D16A1CEAA00A1396C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; @@ -904,6 +942,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB0F48E717CA51E5008798C5 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB0F48FD17CA5212008798C5 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; DB166DDA16A1D40F00A1396C /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1061,6 +1117,10 @@ BEC567980761D90500A33029 /* testtimer */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testtimer; sourceTree = BUILT_PRODUCTS_DIR; }; BEC567B20761D90500A33029 /* testversion */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testversion; sourceTree = BUILT_PRODUCTS_DIR; }; BEC567F50761D90600A33029 /* torturethread */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = torturethread; sourceTree = BUILT_PRODUCTS_DIR; }; + DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testdrawchessboard.c; path = ../../test/testdrawchessboard.c; sourceTree = ""; }; + DB0F48D817CA51D2008798C5 /* testfilesystem.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testfilesystem.c; path = ../../test/testfilesystem.c; sourceTree = ""; }; + DB0F48EC17CA51E5008798C5 /* testdrawchessboard */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testdrawchessboard; sourceTree = BUILT_PRODUCTS_DIR; }; + DB0F490117CA5212008798C5 /* testfilesystem */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testfilesystem; sourceTree = BUILT_PRODUCTS_DIR; }; DB166CBB16A1C74100A1396C /* testgesture.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testgesture.c; path = ../../test/testgesture.c; sourceTree = ""; }; DB166CBC16A1C74100A1396C /* testgles.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testgles.c; path = ../../test/testgles.c; sourceTree = ""; }; DB166CBD16A1C74100A1396C /* testmessage.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testmessage.c; path = ../../test/testmessage.c; sourceTree = ""; }; @@ -1636,6 +1696,40 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB0F48DC17CA51E5008798C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F48DD17CA51E5008798C5 /* Cocoa.framework in Frameworks */, + DB0F48DE17CA51E5008798C5 /* CoreAudio.framework in Frameworks */, + DB0F48DF17CA51E5008798C5 /* ForceFeedback.framework in Frameworks */, + DB0F48E017CA51E5008798C5 /* IOKit.framework in Frameworks */, + DB0F48E117CA51E5008798C5 /* AudioToolbox.framework in Frameworks */, + DB0F48E217CA51E5008798C5 /* CoreFoundation.framework in Frameworks */, + DB0F48E317CA51E5008798C5 /* OpenGL.framework in Frameworks */, + DB0F48E417CA51E5008798C5 /* AudioUnit.framework in Frameworks */, + DB0F48E517CA51E5008798C5 /* Carbon.framework in Frameworks */, + DB0F48E617CA51E5008798C5 /* libSDL2.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB0F48F217CA5212008798C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F48F317CA5212008798C5 /* Cocoa.framework in Frameworks */, + DB0F48F417CA5212008798C5 /* CoreAudio.framework in Frameworks */, + DB0F48F517CA5212008798C5 /* ForceFeedback.framework in Frameworks */, + DB0F48F617CA5212008798C5 /* IOKit.framework in Frameworks */, + DB0F48F717CA5212008798C5 /* AudioToolbox.framework in Frameworks */, + DB0F48F817CA5212008798C5 /* CoreFoundation.framework in Frameworks */, + DB0F48F917CA5212008798C5 /* OpenGL.framework in Frameworks */, + DB0F48FA17CA5212008798C5 /* AudioUnit.framework in Frameworks */, + DB0F48FB17CA5212008798C5 /* Carbon.framework in Frameworks */, + DB0F48FC17CA5212008798C5 /* libSDL2.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DB166D7C16A1D12400A1396C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1883,8 +1977,10 @@ 0017958F1074216E00F5D044 /* testatomic.c */, 001795B01074222D00F5D044 /* testaudioinfo.c */, 001797711074320D00F5D044 /* testdraw2.c */, + DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */, 083E4878006D85357F000001 /* testerror.c */, 002F341709CA1C5B00EBEB88 /* testfile.c */, + DB0F48D817CA51D2008798C5 /* testfilesystem.c */, BBFC088E164C6820003E6A99 /* testgamecontroller.c */, DB166CBB16A1C74100A1396C /* testgesture.c */, 0017972710742FB900F5D044 /* testgl2.c */, @@ -1972,6 +2068,8 @@ DB166E6816A1D6F300A1396C /* testshader */, DB166E7E16A1D78400A1396C /* testspriteminimal */, DB166E9116A1D78C00A1396C /* teststreaming */, + DB0F48EC17CA51E5008798C5 /* testdrawchessboard */, + DB0F490117CA5212008798C5 /* testfilesystem */, ); name = Products; sourceTree = ""; @@ -2512,6 +2610,40 @@ productReference = BEC567F50761D90600A33029 /* torturethread */; productType = "com.apple.product-type.tool"; }; + DB0F48D917CA51E5008798C5 /* testdrawchessboard */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB0F48E917CA51E5008798C5 /* Build configuration list for PBXNativeTarget "testdrawchessboard" */; + buildPhases = ( + DB0F48DA17CA51E5008798C5 /* Sources */, + DB0F48DC17CA51E5008798C5 /* Frameworks */, + DB0F48E717CA51E5008798C5 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testdrawchessboard; + productName = testalpha; + productReference = DB0F48EC17CA51E5008798C5 /* testdrawchessboard */; + productType = "com.apple.product-type.tool"; + }; + DB0F48EF17CA5212008798C5 /* testfilesystem */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB0F48FE17CA5212008798C5 /* Build configuration list for PBXNativeTarget "testfilesystem" */; + buildPhases = ( + DB0F48F017CA5212008798C5 /* Sources */, + DB0F48F217CA5212008798C5 /* Frameworks */, + DB0F48FD17CA5212008798C5 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testfilesystem; + productName = testalpha; + productReference = DB0F490117CA5212008798C5 /* testfilesystem */; + productType = "com.apple.product-type.tool"; + }; DB166D7E16A1D12400A1396C /* SDL_test */ = { isa = PBXNativeTarget; buildConfigurationList = DB166D8016A1D12400A1396C /* Build configuration list for PBXNativeTarget "SDL_test" */; @@ -2730,8 +2862,10 @@ 0017957410741F7900F5D044 /* testatomic */, 00179595107421BF00F5D044 /* testaudioinfo */, 00179756107431B300F5D044 /* testdraw2 */, + DB0F48D917CA51E5008798C5 /* testdrawchessboard */, BEC566FB0761D90300A33029 /* testerror */, 002F340109CA1BFF00EBEB88 /* testfile */, + DB0F48EF17CA5212008798C5 /* testfilesystem */, BBFC08B7164C6862003E6A99 /* testgamecontroller */, DB166DAD16A1D2F600A1396C /* testgesture */, 0017970910742F3200F5D044 /* testgl2 */, @@ -3052,6 +3186,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB0F48DA17CA51E5008798C5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F48EE17CA51F8008798C5 /* testdrawchessboard.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB0F48F017CA5212008798C5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F490317CA5225008798C5 /* testfilesystem.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DB166D7B16A1D12400A1396C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3302,6 +3452,16 @@ target = BEC567EA0761D90600A33029 /* torturethread */; targetProxy = 001799A11074403E00F5D044 /* PBXContainerItemProxy */; }; + DB0F490517CA5249008798C5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DB0F48D917CA51E5008798C5 /* testdrawchessboard */; + targetProxy = DB0F490417CA5249008798C5 /* PBXContainerItemProxy */; + }; + DB0F490717CA5249008798C5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DB0F48EF17CA5212008798C5 /* testfilesystem */; + targetProxy = DB0F490617CA5249008798C5 /* PBXContainerItemProxy */; + }; DB166D6E16A1CEAA00A1396C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = BBFC08B7164C6862003E6A99 /* testgamecontroller */; @@ -3845,6 +4005,34 @@ }; name = Release; }; + DB0F48EA17CA51E5008798C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testdrawchessboard; + }; + name = Debug; + }; + DB0F48EB17CA51E5008798C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testdrawchessboard; + }; + name = Release; + }; + DB0F48FF17CA5212008798C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testfilesystem; + }; + name = Debug; + }; + DB0F490017CA5212008798C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testfilesystem; + }; + name = Release; + }; DB166D8116A1D12400A1396C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4301,6 +4489,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; + DB0F48E917CA51E5008798C5 /* Build configuration list for PBXNativeTarget "testdrawchessboard" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB0F48EA17CA51E5008798C5 /* Debug */, + DB0F48EB17CA51E5008798C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + DB0F48FE17CA5212008798C5 /* Build configuration list for PBXNativeTarget "testfilesystem" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB0F48FF17CA5212008798C5 /* Debug */, + DB0F490017CA5212008798C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; DB166D8016A1D12400A1396C /* Build configuration list for PBXNativeTarget "SDL_test" */ = { isa = XCConfigurationList; buildConfigurations = ( From 7c3d505c9cf76349a667a7a8872ca2f147615ace Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Sun, 25 Aug 2013 11:24:01 -0400 Subject: [PATCH 068/258] reworked GetBasePath on OS X to use Contents/Resource by default if bundled, or exedir if not bundled. - also adds OS X specific magic for bundled apps adding an Info.plist property of name SDL_FILESYSTEM_BASE_DIR_TYPE to the following values will change the bahaviour. * bundle -- use the bundle directory e.g. "/Applications/MyGame/Blah.app/" * parent -- use the bundle parent directory e.g. "/Applications/MyGame/" * resource -- use the bundle resource directory (default) e.g. "/Applications/MyGame/Blah.app/Contents/Resources/" --- src/filesystem/cocoa/SDL_sysfilesystem.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 298c1f75a..c9b0ecceb 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -37,8 +37,21 @@ char * SDL_GetBasePath(void) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - const char *base = [[[NSBundle mainBundle] bundlePath] UTF8String]; + NSBundle *bundle = [NSBundle mainBundle]; + const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; + const char *base = NULL; char *retval = NULL; + if (baseType == NULL) { + baseType = "resource"; + } + if (SDL_strcasecmp(baseType, "bundle")==0) { + base = [[bundle bundlePath] UTF8String]; + } else if (SDL_strcasecmp(baseType, "parent")==0) { + base = [[[bundle bundlePath] stringByDeletingLastPathComponent] UTF8String]; + } else { + /* this returns the exedir for non-bundled and the resourceDir for bundled apps */ + base = [[bundle resourcePath] UTF8String]; + } if (base) { const size_t len = SDL_strlen(base) + 2; retval = (char *) SDL_malloc(len); From b61d361d2dd3fa125132df604a1c3ae50a45b6d8 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 25 Aug 2013 21:28:03 -0400 Subject: [PATCH 069/258] Removed obvious comment to trigger buildbot. --- src/video/bwindow/SDL_bclipboard.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc index 4801483c4..492b2fab3 100644 --- a/src/video/bwindow/SDL_bclipboard.cc +++ b/src/video/bwindow/SDL_bclipboard.cc @@ -89,7 +89,7 @@ SDL_bool BE_HasClipboardText(_THIS) { } #ifdef __cplusplus -} /* Extern C */ +} #endif #endif /* SDL_VIDEO_DRIVER_BWINDOW */ From 4353b43e3fa5eb03a5f60de085a4d86528e0023e Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Mon, 26 Aug 2013 14:23:18 -0300 Subject: [PATCH 070/258] Fixes typo in EGL code (thanks jmcfarlane!) --- src/video/SDL_egl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 2fbbc790d..522516572 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -332,8 +332,8 @@ SDL_EGL_SetSwapInterval(_THIS, int interval) { EGLBoolean status; - if (_this->egl_data) { - return SDL_SetError("OpenGL ES context not active"); + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); } status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); @@ -348,8 +348,8 @@ SDL_EGL_SetSwapInterval(_THIS, int interval) int SDL_EGL_GetSwapInterval(_THIS) { - if (_this->egl_data) { - return SDL_SetError("OpenGL ES context not active"); + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); } return _this->egl_data->egl_swapinterval; From c80fc2858bb9bde137d3eac663a63b02f29da900 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 28 Aug 2013 10:41:25 -0300 Subject: [PATCH 071/258] Fixes test building --- test/configure | 8 ++++---- test/configure.in | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/configure b/test/configure index 319c03298..30b122e4a 100755 --- a/test/configure +++ b/test/configure @@ -3451,7 +3451,7 @@ rm -f core conftest.err conftest.$ac_objext \ rm -f conf.sdltest CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS -lSDL2_test $SDL_LIBS" +LIBS="$LIBS $SDL_LIBS -lSDL2_test" ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3785,16 +3785,16 @@ $as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi if test x$have_x = xyes; then - if test x$ac_x_includes = xno || test x$ac_x_includes = x; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then : else CFLAGS="$CFLAGS -I$ac_x_includes" fi - if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then + if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then : else XPATH="-L$ac_x_libraries" - XLIB="-L$ac_x_libraries -lX11" + XLIB="-lX11" fi fi diff --git a/test/configure.in b/test/configure.in index b74800758..7cca1ea0f 100644 --- a/test/configure.in +++ b/test/configure.in @@ -86,21 +86,21 @@ AM_PATH_SDL2($SDL_VERSION, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) ) CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS -lSDL2_test $SDL_LIBS" +LIBS="$LIBS $SDL_LIBS -lSDL2_test" dnl Check for X11 path, needed for OpenGL on some systems AC_PATH_X if test x$have_x = xyes; then - if test x$ac_x_includes = xno || test x$ac_x_includes = x; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then : else CFLAGS="$CFLAGS -I$ac_x_includes" fi - if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then + if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then : else XPATH="-L$ac_x_libraries" - XLIB="-L$ac_x_libraries -lX11" + XLIB="-lX11" fi fi From 777731aa02ea5c6881788d2726f5029301bcd166 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 28 Aug 2013 12:43:29 -0300 Subject: [PATCH 072/258] [Linux] Test config script: Add the X11 library search path if it is not empty If ac_x_libraries is empty it means that the library's found in the default path, so we skip adding it to the XLIB variable as it screws up the search path. --- test/configure | 6 +++++- test/configure.in | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/configure b/test/configure index 30b122e4a..d69cb4359 100755 --- a/test/configure +++ b/test/configure @@ -3794,7 +3794,11 @@ if test x$have_x = xyes; then : else XPATH="-L$ac_x_libraries" - XLIB="-lX11" + if test "x$ac_x_libraries" = x; then + XLIB="-lX11" + else + XLIB="-L$ac_x_libraries -lX11" + fi fi fi diff --git a/test/configure.in b/test/configure.in index 7cca1ea0f..7fb496ad6 100644 --- a/test/configure.in +++ b/test/configure.in @@ -100,7 +100,11 @@ if test x$have_x = xyes; then : else XPATH="-L$ac_x_libraries" - XLIB="-lX11" + if test "x$ac_x_libraries" = x; then + XLIB="-lX11" + else + XLIB="-L$ac_x_libraries -lX11" + fi fi fi From bbbade42fafa6fb85611f4e35007ada4685a6c05 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 00:07:02 -0400 Subject: [PATCH 073/258] Fixed testgamecontroller output to make sense. --HG-- extra : rebase_source : 88c573edaf1da2153ada5b4f2c6893e91add2310 --- test/testgamecontroller.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index 419593dc4..cbdf8c3b1 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -229,7 +229,7 @@ main(int argc, char *argv[]) /* Print information about the controller */ for (i = 0; i < SDL_NumJoysticks(); ++i) { const char *name; - const char *description = "Joystick (not recognized as game controller)"; + const char *description; SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i), guid, sizeof (guid)); @@ -238,8 +238,10 @@ main(int argc, char *argv[]) { nController++; name = SDL_GameControllerNameForIndex(i); + description = "Controller"; } else { name = SDL_JoystickNameForIndex(i); + description = "Joystick"; } SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid); } From 17c90f11866fd148fb36cd3a5ef452cdc6072868 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 16:35:32 -0400 Subject: [PATCH 074/258] Better XInput detection code for DirectInput device enumeration. This code is way faster than the Wbem code, and less ugly. --HG-- extra : rebase_source : cce46397251068b426e2ec267c15292aa0744386 --- src/joystick/windows/SDL_dxjoystick.c | 202 +++++++------------------- 1 file changed, 50 insertions(+), 152 deletions(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index eb4ab2a3a..53dec5c99 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -46,33 +46,9 @@ #include "../../events/SDL_events_c.h" #endif -/* The latest version of mingw-w64 defines IID_IWbemLocator in wbemcli.h - instead of declaring it like Visual Studio and other mingw32 compilers. - So, we need to take care of this here before we define INITGUID. -*/ -#ifdef __MINGW32__ -#define __IWbemLocator_INTERFACE_DEFINED__ -#endif /* __MINGW32__ */ - #define INITGUID /* Only set here, if set twice will cause mingw32 to break. */ #include "SDL_dxjoystick_c.h" -#ifdef __MINGW32__ -/* And now that we've included wbemcli.h we need to declare these interfaces */ -typedef struct IWbemLocatorVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(IWbemLocator *This,REFIID riid,void **ppvObject); - ULONG (WINAPI *AddRef)(IWbemLocator *This); - ULONG (WINAPI *Release)(IWbemLocator *This); - HRESULT (WINAPI *ConnectServer)(IWbemLocator *This,const BSTR strNetworkResource,const BSTR strUser,const BSTR strPassword,const BSTR strLocale,LONG lSecurityFlags,const BSTR strAuthority,IWbemContext *pCtx,IWbemServices **ppNamespace); - END_INTERFACE -} IWbemLocatorVtbl; -struct IWbemLocator { - CONST_VTBL struct IWbemLocatorVtbl *lpVtbl; -}; -#define IWbemLocator_ConnectServer(This,strNetworkResource,strUser,strPassword,strLocale,lSecurityFlags,strAuthority,pCtx,ppNamespace) (This)->lpVtbl->ConnectServer(This,strNetworkResource,strUser,strPassword,strLocale,lSecurityFlags,strAuthority,pCtx,ppNamespace) -#endif /* __MINGW32__ */ - #ifndef DIDFT_OPTIONAL #define DIDFT_OPTIONAL 0x80000000 #endif @@ -396,156 +372,75 @@ SetDIerror(const char *function, HRESULT code) } \ } -DEFINE_GUID(CLSID_WbemLocator, 0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24); -DEFINE_GUID(IID_IWbemLocator, 0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24); - DEFINE_GUID(IID_ValveStreamingGamepad, MAKELONG( 0x28DE, 0x11FF ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44); +DEFINE_GUID(IID_X360WiredGamepad, MAKELONG( 0x045E, 0x02A1 ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44); +DEFINE_GUID(IID_X360WirelessGamepad, MAKELONG( 0x045E, 0x028E ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44); -/*----------------------------------------------------------------------------- - * - * code from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx - * - * Enum each PNP device using WMI and check each device ID to see if it contains - * "IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device - * Unfortunately this information can not be found by just using DirectInput - *-----------------------------------------------------------------------------*/ -BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) +static PRAWINPUTDEVICELIST SDL_RawDevList = NULL; +static UINT SDL_RawDevListCount = 0; + +static SDL_bool +SDL_IsXInputDevice( const GUID* pGuidProductFromDirectInput ) { static const GUID *s_XInputProductGUID[] = { - &IID_ValveStreamingGamepad + &IID_ValveStreamingGamepad, + &IID_X360WiredGamepad, /* Microsoft's wired X360 controller for Windows. */ + &IID_X360WirelessGamepad /* Microsoft's wireless X360 controller for Windows. */ }; - IWbemLocator* pIWbemLocator = NULL; - IEnumWbemClassObject* pEnumDevices = NULL; - IWbemClassObject* pDevices[20]; - IWbemServices* pIWbemServices = NULL; - DWORD uReturned = 0; - BSTR bstrNamespace = NULL; - BSTR bstrDeviceID = NULL; - BSTR bstrClassName = NULL; - SDL_bool bIsXinputDevice= SDL_FALSE; - UINT iDevice = 0; - VARIANT var; - HRESULT hr; - DWORD bCleanupCOM; - if (!s_bXInputEnabled) - { + size_t iDevice; + SDL_bool retval = SDL_FALSE; + UINT i; + + if (!s_bXInputEnabled) { return SDL_FALSE; } /* Check for well known XInput device GUIDs */ - /* We need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list. */ + /* This lets us skip RAWINPUT for popular devices. Also, we need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list. */ for ( iDevice = 0; iDevice < SDL_arraysize(s_XInputProductGUID); ++iDevice ) { if (SDL_memcmp(pGuidProductFromDirectInput, s_XInputProductGUID[iDevice], sizeof(GUID)) == 0) { return SDL_TRUE; } } - SDL_memset( pDevices, 0x0, sizeof(pDevices) ); + /* Go through RAWINPUT (WinXP and later) to find HID devices. */ + /* Cache this if we end up using it. */ + if (SDL_RawDevList == NULL) { + if ((GetRawInputDeviceList(NULL, &SDL_RawDevListCount, sizeof (RAWINPUTDEVICELIST)) == -1) || (!SDL_RawDevListCount)) { + return SDL_FALSE; /* oh well. */ + } - /* CoInit if needed */ - hr = CoInitialize(NULL); - bCleanupCOM = SUCCEEDED(hr); + SDL_RawDevList = (PRAWINPUTDEVICELIST) SDL_malloc(sizeof (RAWINPUTDEVICELIST) * SDL_RawDevListCount); + if (SDL_RawDevList == NULL) { + SDL_OutOfMemory(); + return SDL_FALSE; + } - /* Create WMI */ - hr = CoCreateInstance( &CLSID_WbemLocator, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IWbemLocator, - (LPVOID*) &pIWbemLocator); - if( FAILED(hr) || pIWbemLocator == NULL ) - goto LCleanup; - - bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup; - bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup; - bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup; - - /* Connect to WMI */ - hr = IWbemLocator_ConnectServer( pIWbemLocator, bstrNamespace, NULL, NULL, 0L, - 0L, NULL, NULL, &pIWbemServices ); - if( FAILED(hr) || pIWbemServices == NULL ) - goto LCleanup; - - /* Switch security level to IMPERSONATE. */ - CoSetProxyBlanket( (IUnknown *)pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, - RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE ); - - hr = IWbemServices_CreateInstanceEnum( pIWbemServices, bstrClassName, 0, NULL, &pEnumDevices ); - if( FAILED(hr) || pEnumDevices == NULL ) - goto LCleanup; - - /* Loop over all devices */ - for( ;; ) - { - /* Get 20 at a time */ - hr = IEnumWbemClassObject_Next( pEnumDevices, 10000, 20, pDevices, &uReturned ); - if( FAILED(hr) ) - goto LCleanup; - if( uReturned == 0 ) - break; - - for( iDevice=0; iDeviceData1 ) - { - bIsXinputDevice = SDL_TRUE; - } - } - if ( pDeviceString ) - SDL_free( pDeviceString ); - - if ( bIsXinputDevice ) - break; - } - SAFE_RELEASE( pDevices[iDevice] ); + if (GetRawInputDeviceList(SDL_RawDevList, &SDL_RawDevListCount, sizeof (RAWINPUTDEVICELIST)) == -1) { + SDL_free(SDL_RawDevList); + SDL_RawDevList = NULL; + return SDL_FALSE; /* oh well. */ } } -LCleanup: + for (i = 0; i < SDL_RawDevListCount; i++) { + RID_DEVICE_INFO rdi; + char devName[128]; + UINT rdiSize = sizeof (rdi); + UINT nameSize = SDL_arraysize(devName); - for( iDevice=0; iDevice<20; iDevice++ ) - SAFE_RELEASE( pDevices[iDevice] ); - SAFE_RELEASE( pEnumDevices ); - SAFE_RELEASE( pIWbemLocator ); - SAFE_RELEASE( pIWbemServices ); + rdi.cbSize = sizeof (rdi); + if ( (SDL_RawDevList[i].dwType == RIM_TYPEHID) && + (GetRawInputDeviceInfoA(SDL_RawDevList[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) && + (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)pGuidProductFromDirectInput->Data1)) && + (GetRawInputDeviceInfoA(SDL_RawDevList[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) && + (SDL_strstr(devName, "IG_") != NULL) ) { + return SDL_TRUE; + } + } - if ( bstrNamespace ) - SysFreeString( bstrNamespace ); - if ( bstrClassName ) - SysFreeString( bstrClassName ); - if ( bstrDeviceID ) - SysFreeString( bstrDeviceID ); - - if( bCleanupCOM ) - CoUninitialize(); - - return bIsXinputDevice; + return SDL_FALSE; } @@ -808,7 +703,7 @@ static BOOL CALLBACK s_bDeviceAdded = SDL_TRUE; - bXInputDevice = IsXInputDevice( &pdidInstance->guidProduct ); + bXInputDevice = SDL_IsXInputDevice( &pdidInstance->guidProduct ); pNewJoystick = (JoyStick_DeviceData *)SDL_malloc( sizeof(JoyStick_DeviceData) ); @@ -872,6 +767,9 @@ void SDL_SYS_JoystickDetect() EnumJoysticksCallback, &pCurList, DIEDFL_ATTACHEDONLY); + SDL_free(SDL_RawDevList); /* in case we used this. */ + SDL_RawDevList = NULL; + SDL_UnlockMutex( s_mutexJoyStickEnum ); } From 6f219909875fb984fb9678feda8455d04ed3102f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 16:43:47 -0400 Subject: [PATCH 075/258] Reworked XInput and DirectInput joystick code. Now multiple XInput controllers map correctly to device indexes instead of grabbing the first available userid, and are completely separated out from DirectInput. Also, the hardcoded limitation on number of DirectInput devices is gone. I don't expect there to really ever be more than eight joysticks plugged into a machine, but it was a leftover limitation for a static array we didn't actually use anymore. Fixes Bugzilla #1984. (etc?) --HG-- extra : rebase_source : 103ce667c1cdd87a3691c9dd9eea2318bad908c8 --- src/joystick/SDL_gamecontroller.c | 21 -- src/joystick/windows/SDL_dxjoystick.c | 323 ++++++++++++-------------- 2 files changed, 151 insertions(+), 193 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 05ed473d2..0a4ad6b0d 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -851,9 +851,6 @@ SDL_GameControllerOpen(int device_index) SDL_GameController *gamecontroller; SDL_GameController *gamecontrollerlist; ControllerMapping_t *pSupportedController = NULL; -#ifdef SDL_JOYSTICK_DINPUT - SDL_bool bIsXinputDevice; -#endif if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) { SDL_SetError("There are %d joysticks available", SDL_NumJoysticks()); @@ -886,11 +883,6 @@ SDL_GameControllerOpen(int device_index) return NULL; } -#ifdef SDL_JOYSTICK_DINPUT - /* check if we think we should open this device in XInput mode */ - bIsXinputDevice = SDL_SYS_IsXInputDeviceIndex(device_index); -#endif - SDL_memset(gamecontroller, 0, (sizeof *gamecontroller)); gamecontroller->joystick = SDL_JoystickOpen(device_index); if ( !gamecontroller->joystick ) { @@ -898,19 +890,6 @@ SDL_GameControllerOpen(int device_index) return NULL; } -#ifdef SDL_JOYSTICK_DINPUT - if ( !SDL_SYS_IsXInputJoystick( gamecontroller->joystick ) && bIsXinputDevice ) - { - /* we tried to open the controller in XInput mode and failed, so get the mapping again for the direct input variant if possible */ - SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID( device_index ); - pSupportedController = SDL_PrivateGetControllerMappingForGUID(&jGUID); - if ( !pSupportedController ) { - SDL_SetError("Failed to open device in XInput mode (%d)", device_index ); - return (NULL); - } - } -#endif - SDL_PrivateLoadButtonMapping( &gamecontroller->mapping, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping ); /* Add joystick to list */ diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 53dec5c99..6d4ed24bd 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -55,7 +55,6 @@ #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ -#define MAX_JOYSTICKS 8 #define AXIS_MIN -32768 /* minimum value for axis coordinate */ #define AXIS_MAX 32767 /* maximum value for axis coordinate */ #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ @@ -70,7 +69,6 @@ static LPDIRECTINPUT8 dinput = NULL; static SDL_bool s_bDeviceAdded = SDL_FALSE; static SDL_bool s_bDeviceRemoved = SDL_FALSE; static SDL_JoystickID s_nInstanceID = -1; -static GUID *s_pKnownJoystickGUIDs = NULL; static SDL_cond *s_condJoystickThread = NULL; static SDL_mutex *s_mutexJoyStickEnum = NULL; static SDL_Thread *s_threadJoystick = NULL; @@ -481,10 +479,10 @@ SDL_JoystickThread(void *_data) HWND messageWindow = 0; HDEVNOTIFY hNotify = 0; DEV_BROADCAST_DEVICEINTERFACE dbh; - SDL_bool bOpenedXInputDevices[4]; + SDL_bool bOpenedXInputDevices[SDL_XINPUT_MAX_DEVICES]; WNDCLASSEX wincl; - SDL_memset( bOpenedXInputDevices, 0x0, sizeof(bOpenedXInputDevices) ); + SDL_zero(bOpenedXInputDevices); WIN_CoInitialize(); @@ -505,7 +503,7 @@ SDL_JoystickThread(void *_data) return SDL_SetError("Failed to create message window for joystick autodetect.", GetLastError()); } - SDL_memset(&dbh, 0x0, sizeof(dbh)); + SDL_zero(dbh); dbh.dbcc_size = sizeof(dbh); dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; @@ -521,9 +519,8 @@ SDL_JoystickThread(void *_data) while ( s_bJoystickThreadQuit == SDL_FALSE ) { MSG messages; - Uint8 userId; - int nCurrentOpenedXInputDevices = 0; - int nNewOpenedXInputDevices = 0; + SDL_bool bXInputChanged = SDL_FALSE; + SDL_CondWaitTimeout( s_condJoystickThread, s_mutexJoyStickEnum, 300 ); while ( s_bJoystickThreadQuit == SDL_FALSE && PeekMessage(&messages, messageWindow, 0, 0, PM_NOREMOVE) ) @@ -534,33 +531,24 @@ SDL_JoystickThread(void *_data) } } - if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) - { + if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) { /* scan for any change in XInput devices */ - for ( userId = 0; userId < 4; userId++ ) - { + Uint8 userId; + for (userId = 0; userId < SDL_XINPUT_MAX_DEVICES; userId++) { XINPUT_CAPABILITIES capabilities; - DWORD result; - - if ( bOpenedXInputDevices[userId] == SDL_TRUE ) - nCurrentOpenedXInputDevices++; - - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { - bOpenedXInputDevices[userId] = SDL_TRUE; - nNewOpenedXInputDevices++; - } - else - { - bOpenedXInputDevices[userId] = SDL_FALSE; + const DWORD result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); + const SDL_bool available = (result == ERROR_SUCCESS); + if (bOpenedXInputDevices[userId] != available) { + bXInputChanged = SDL_TRUE; + bOpenedXInputDevices[userId] = available; } } } - if ( s_pKnownJoystickGUIDs && ( s_bWindowsDeviceChanged || nNewOpenedXInputDevices != nCurrentOpenedXInputDevices ) ) - { + if (s_bWindowsDeviceChanged || bXInputChanged) { + SDL_UnlockMutex( s_mutexJoyStickEnum ); /* let main thread go while we SDL_Delay(). */ SDL_Delay( 300 ); /* wait for direct input to find out about this device */ + SDL_LockMutex( s_mutexJoyStickEnum ); s_bDeviceRemoved = SDL_TRUE; s_bDeviceAdded = SDL_TRUE; @@ -625,15 +613,16 @@ SDL_SYS_JoystickInit(void) return SetDIerror("IDirectInput::Initialize", result); } - s_mutexJoyStickEnum = SDL_CreateMutex(); - s_condJoystickThread = SDL_CreateCond(); - s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */ - SDL_SYS_JoystickDetect(); - if ((s_bXInputEnabled) && (WIN_LoadXInputDLL() == -1)) { s_bXInputEnabled = SDL_FALSE; /* oh well. */ } + s_mutexJoyStickEnum = SDL_CreateMutex(); + s_condJoystickThread = SDL_CreateCond(); + s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */ + + SDL_SYS_JoystickDetect(); + if ( !s_threadJoystick ) { s_bJoystickThreadQuit = SDL_FALSE; @@ -662,15 +651,17 @@ int SDL_SYS_NumJoysticks() return nJoysticks; } -static int s_iNewGUID = 0; - /* helper function for direct input, gets called for each connected joystick */ static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { JoyStick_DeviceData *pNewJoystick; JoyStick_DeviceData *pPrevJoystick = NULL; - SDL_bool bXInputDevice; + + if (SDL_IsXInputDevice( &pdidInstance->guidProduct )) { + return DIENUM_CONTINUE; /* ignore XInput devices here, keep going. */ + } + pNewJoystick = *(JoyStick_DeviceData **)pContext; while ( pNewJoystick ) { @@ -689,58 +680,107 @@ static BOOL CALLBACK pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; - s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; - s_iNewGUID++; - if ( s_iNewGUID < MAX_JOYSTICKS ) - return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ - else - return DIENUM_STOP; + return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ } pPrevJoystick = pNewJoystick; pNewJoystick = pNewJoystick->pNext; } - s_bDeviceAdded = SDL_TRUE; - - bXInputDevice = SDL_IsXInputDevice( &pdidInstance->guidProduct ); - pNewJoystick = (JoyStick_DeviceData *)SDL_malloc( sizeof(JoyStick_DeviceData) ); - - if ( bXInputDevice ) - { - pNewJoystick->bXInputDevice = SDL_TRUE; - pNewJoystick->XInputUserId = INVALID_XINPUT_USERID; + if (!pNewJoystick) { + return DIENUM_CONTINUE; /* better luck next time? */ } - else - { - pNewJoystick->bXInputDevice = SDL_FALSE; + + SDL_zerop(pNewJoystick); + pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName); + if (!pNewJoystick->joystickname) { + SDL_free(pNewJoystick); + return DIENUM_CONTINUE; /* better luck next time? */ } SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance, sizeof(DIDEVICEINSTANCE)); - pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName); + pNewJoystick->XInputUserId = INVALID_XINPUT_USERID; pNewJoystick->send_add_event = 1; pNewJoystick->nInstanceID = ++s_nInstanceID; SDL_memcpy( &pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid) ); - pNewJoystick->pNext = NULL; - - if ( SYS_Joystick ) - { - pNewJoystick->pNext = SYS_Joystick; - } + pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; - s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; - s_iNewGUID++; + s_bDeviceAdded = SDL_TRUE; - if ( s_iNewGUID < MAX_JOYSTICKS ) - return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ - else - return DIENUM_STOP; + return DIENUM_CONTINUE; /* get next device, please */ } +static void +AddXInputDevice(const Uint8 userid, JoyStick_DeviceData **pContext) +{ + char name[32]; + JoyStick_DeviceData *pPrevJoystick = NULL; + JoyStick_DeviceData *pNewJoystick = *pContext; + + while (pNewJoystick) { + if ((pNewJoystick->bXInputDevice) && (pNewJoystick->XInputUserId == userid)) { + /* if we are replacing the front of the list then update it */ + if (pNewJoystick == *pContext) { + *pContext = pNewJoystick->pNext; + } else if (pPrevJoystick) { + pPrevJoystick->pNext = pNewJoystick->pNext; + } + + pNewJoystick->pNext = SYS_Joystick; + SYS_Joystick = pNewJoystick; + } + + pPrevJoystick = pNewJoystick; + pNewJoystick = pNewJoystick->pNext; + return; /* already in the list. */ + } + + pNewJoystick = (JoyStick_DeviceData *) SDL_malloc(sizeof (JoyStick_DeviceData)); + if (!pNewJoystick) { + return; /* better luck next time? */ + } + SDL_zerop(pNewJoystick); + + SDL_snprintf(name, sizeof (name), "XInput Controller #%d", (int) userid); + pNewJoystick->joystickname = SDL_strdup(name); + if (!pNewJoystick->joystickname) { + SDL_free(pNewJoystick); + return; /* better luck next time? */ + } + + pNewJoystick->bXInputDevice = SDL_TRUE; + pNewJoystick->XInputUserId = userid; + pNewJoystick->send_add_event = 1; + pNewJoystick->nInstanceID = ++s_nInstanceID; + pNewJoystick->pNext = SYS_Joystick; + SYS_Joystick = pNewJoystick; + + s_bDeviceAdded = SDL_TRUE; +} + +static void +EnumXInputDevices(JoyStick_DeviceData **pContext) +{ + if (s_bXInputEnabled) { + Uint8 userid; + for (userid = 0; userid < SDL_XINPUT_MAX_DEVICES; userid++) { + XINPUT_CAPABILITIES capabilities; + if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) { + /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ + /* !!! FIXME: we might want to support steering wheels or guitars or whatever laster. */ + if (capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD) { + AddXInputDevice(userid, pContext); + } + } + } + } +} + + /* detect any new joysticks being inserted into the system */ void SDL_SYS_JoystickDetect() { @@ -748,27 +788,26 @@ void SDL_SYS_JoystickDetect() /* only enum the devices if the joystick thread told us something changed */ if ( s_bDeviceAdded || s_bDeviceRemoved ) { + SDL_LockMutex( s_mutexJoyStickEnum ); + s_bDeviceAdded = SDL_FALSE; s_bDeviceRemoved = SDL_FALSE; pCurList = SYS_Joystick; SYS_Joystick = NULL; - s_iNewGUID = 0; - SDL_LockMutex( s_mutexJoyStickEnum ); - if ( !s_pKnownJoystickGUIDs ) - s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS ); + /* Look for XInput devices... */ + EnumXInputDevices(&pCurList); - SDL_memset( s_pKnownJoystickGUIDs, 0x0, sizeof(GUID)*MAX_JOYSTICKS ); - - /* Look for joysticks, wheels, head trackers, gamepads, etc.. */ + /* Look for DirectInput joysticks, wheels, head trackers, gamepads, etc.. */ IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, &pCurList, DIEDFL_ATTACHEDONLY); - SDL_free(SDL_RawDevList); /* in case we used this. */ + SDL_free(SDL_RawDevList); /* in case we used this in DirectInput enumerator. */ SDL_RawDevList = NULL; + SDL_RawDevListCount = 0; SDL_UnlockMutex( s_mutexJoyStickEnum ); } @@ -872,17 +911,11 @@ int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) { HRESULT result; - LPDIRECTINPUTDEVICE8 device; - DIPROPDWORD dipdw; JoyStick_DeviceData *joystickdevice = SYS_Joystick; for (; device_index > 0; device_index--) joystickdevice = joystickdevice->pNext; - SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD)); - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - /* allocate memory for system specific hardware data */ joystick->instance_id = joystickdevice->nInstanceID; joystick->closed = 0; @@ -891,97 +924,50 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) if (joystick->hwdata == NULL) { return SDL_OutOfMemory(); } - SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata)); - joystick->hwdata->buffered = 1; - joystick->hwdata->removed = 0; - joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); - joystick->hwdata->guid = joystickdevice->guid; + SDL_zerop(joystick->hwdata); - if ( joystickdevice->bXInputDevice ) - { + if (joystickdevice->bXInputDevice) { + const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); + const Uint8 userId = joystickdevice->XInputUserId; XINPUT_CAPABILITIES capabilities; - Uint8 userId = 0; - DWORD result; - JoyStick_DeviceData *joysticklist = SYS_Joystick; - /* scan the opened joysticks and pick the next free xinput userid for this one */ - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->XInputUserId == userId ) - userId++; - } - if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) - { - while ( 1 ) - { - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { - const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); - SDL_bool bIsSupported = SDL_FALSE; - /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ - bIsSupported = ( capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD ); + SDL_assert(s_bXInputEnabled); + SDL_assert(XINPUTGETCAPABILITIES); + SDL_assert(userId >= 0); + SDL_assert(userId < SDL_XINPUT_MAX_DEVICES); - if ( !bIsSupported ) - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - else - { - /* valid */ - joystick->hwdata->bXInputDevice = SDL_TRUE; - if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { - joystick->hwdata->bXInputHaptic = SDL_TRUE; - } - SDL_memset( joystick->hwdata->XInputState, 0x0, sizeof(joystick->hwdata->XInputState) ); - joystickdevice->XInputUserId = userId; - joystick->hwdata->userid = userId; - joystick->hwdata->currentXInputSlot = 0; - /* The XInput API has a hard coded button/axis mapping, so we just match it */ - joystick->naxes = 6; - joystick->nbuttons = 15; - joystick->nballs = 0; - joystick->nhats = 0; - } - break; - } - else - { - if ( userId < XUSER_MAX_COUNT && result == ERROR_DEVICE_NOT_CONNECTED ) - { - /* scan the opened joysticks and pick the next free xinput userid for this one */ - ++userId; + joystick->hwdata->bXInputDevice = SDL_TRUE; - joysticklist = SYS_Joystick; - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->XInputUserId == userId ) - userId++; - } + if (XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities) != ERROR_SUCCESS) { + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; + return SDL_SetError("Failed to obtain XInput device capabilities. Device disconnected?"); + } else { + /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ + SDL_assert(capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD); + if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { + joystick->hwdata->bXInputHaptic = SDL_TRUE; + } + joystick->hwdata->userid = userId; - if ( userId >= XUSER_MAX_COUNT ) - { - joystickdevice->bXInputDevice = SDL_FALSE; - break; - } - } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - break; - } - } - } - } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - } + /* The XInput API has a hard coded button/axis mapping, so we just match it */ + joystick->naxes = 6; + joystick->nbuttons = 15; + joystick->nballs = 0; + joystick->nhats = 0; + } + } else { /* use DirectInput, not XInput. */ + LPDIRECTINPUTDEVICE8 device; + DIPROPDWORD dipdw; - if ( joystickdevice->bXInputDevice == SDL_FALSE ) - { - joystick->hwdata->bXInputDevice = SDL_FALSE; + joystick->hwdata->buffered = 1; + joystick->hwdata->removed = 0; + joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); + joystick->hwdata->guid = joystickdevice->guid; + + SDL_zero(dipdw); + dipdw.diph.dwSize = sizeof(DIPROPDWORD); + dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); result = IDirectInput8_CreateDevice(dinput, @@ -1633,18 +1619,11 @@ SDL_SYS_JoystickQuit(void) coinitialized = SDL_FALSE; } - if ( s_pKnownJoystickGUIDs ) - { - SDL_free( s_pKnownJoystickGUIDs ); - s_pKnownJoystickGUIDs = NULL; - } - if (s_bXInputEnabled) { WIN_UnloadXInputDLL(); } } - /* return the stable device guid for this device index */ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { From cd94a10070031c470550e923b9534067c24587ae Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 17:12:07 -0400 Subject: [PATCH 076/258] Fixed comment typo. --- src/haptic/darwin/SDL_syshaptic.c | 2 +- src/haptic/linux/SDL_syshaptic.c | 2 +- src/haptic/windows/SDL_syshaptic.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 124cc41af..8d9f17b55 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -506,7 +506,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* - * Checks to see if the haptic device and joystick and in reality the same. + * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 401249196..e209d0500 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -368,7 +368,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* - * Checks to see if the haptic device and joystick and in reality the same. + * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 9ba020a88..5a393b3a9 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -631,7 +631,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* - * Checks to see if the haptic device and joystick and in reality the same. + * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) From 526597ad953fac6b7f5e9f9c1760d6faba7919f6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 17:17:21 -0400 Subject: [PATCH 077/258] Make XInput joystick names match the numbers on the device. (And how the Haptic code already names them.) --- src/joystick/windows/SDL_dxjoystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 6d4ed24bd..9399ee67a 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -745,7 +745,7 @@ AddXInputDevice(const Uint8 userid, JoyStick_DeviceData **pContext) } SDL_zerop(pNewJoystick); - SDL_snprintf(name, sizeof (name), "XInput Controller #%d", (int) userid); + SDL_snprintf(name, sizeof (name), "XInput Controller #%u", ((unsigned int) userid) + 1); pNewJoystick->joystickname = SDL_strdup(name); if (!pNewJoystick->joystickname) { SDL_free(pNewJoystick); From a2cce5ee08ecc88effdd16719b9eb4c4eb9aa430 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 22:05:16 -0400 Subject: [PATCH 078/258] Fix endlines for logging via OutputDebugString(). --- src/SDL_log.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SDL_log.c b/src/SDL_log.c index 2245946c6..e47249021 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -332,16 +332,16 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, if (!attachResult) { attachError = GetLastError(); if (attachError == ERROR_INVALID_HANDLE) { - OutputDebugString(TEXT("Parent process has no console")); + OutputDebugString(TEXT("Parent process has no console\r\n")); consoleAttached = -1; } else if (attachError == ERROR_GEN_FAILURE) { - OutputDebugString(TEXT("Could not attach to console of parent process")); + OutputDebugString(TEXT("Could not attach to console of parent process\r\n")); consoleAttached = -1; } else if (attachError == ERROR_ACCESS_DENIED) { /* Already attached */ consoleAttached = 1; } else { - OutputDebugString(TEXT("Error attaching console")); + OutputDebugString(TEXT("Error attaching console\r\n")); consoleAttached = -1; } } else { @@ -354,9 +354,9 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, } } - length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1; + length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1; output = SDL_stack_alloc(char, length); - SDL_snprintf(output, length, "%s: %s\n", SDL_priority_prefixes[priority], message); + SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message); tstr = WIN_UTF8ToString(output); /* Output to debugger */ @@ -365,10 +365,10 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, /* Screen output to stderr, if console was attached. */ if (consoleAttached == 1) { if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) { - OutputDebugString(TEXT("Error calling WriteConsole")); + OutputDebugString(TEXT("Error calling WriteConsole\r\n")); } if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) { - OutputDebugString(TEXT("Insufficient heap memory to write message")); + OutputDebugString(TEXT("Insufficient heap memory to write message\r\n")); } } From e670fc63f18218705fb8b4513bcdcd19a6b45b9d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 22:07:54 -0400 Subject: [PATCH 079/258] Don't corrupt XInput device state during SDL_SYS_JoystickClose(). --- src/joystick/windows/SDL_dxjoystick.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 9399ee67a..2648ef3ad 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -1552,21 +1552,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - if ( joystick->hwdata->bXInputDevice ) - { - JoyStick_DeviceData *joysticklist = SYS_Joystick; - /* scan the opened joysticks and clear the userid for this instance */ - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->nInstanceID == joystick->instance_id ) - { - joysticklist->XInputUserId = INVALID_XINPUT_USERID; - } - } - - } - else - { + if (!joystick->hwdata->bXInputDevice) { IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); IDirectInputDevice8_Release(joystick->hwdata->InputDevice); } From 44918e378d9e759558ad424dac8dd4fbb17d0b56 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Aug 2013 22:09:17 -0400 Subject: [PATCH 080/258] Change order we enumerate Windows joysticks. Make it so XInput devices are listed before DirectInput devices, and that the XInput devices are sorted by userid in ascending numeric order (so device 0 comes first). --- src/joystick/windows/SDL_dxjoystick.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 2648ef3ad..4165c7011 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -766,8 +766,10 @@ static void EnumXInputDevices(JoyStick_DeviceData **pContext) { if (s_bXInputEnabled) { - Uint8 userid; - for (userid = 0; userid < SDL_XINPUT_MAX_DEVICES; userid++) { + int iuserid; + /* iterate in reverse, so these are in the final list in ascending numeric order. */ + for (iuserid = SDL_XINPUT_MAX_DEVICES-1; iuserid >= 0; iuserid--) { + const Uint8 userid = (Uint8) iuserid; XINPUT_CAPABILITIES capabilities; if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) { /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ @@ -796,9 +798,6 @@ void SDL_SYS_JoystickDetect() pCurList = SYS_Joystick; SYS_Joystick = NULL; - /* Look for XInput devices... */ - EnumXInputDevices(&pCurList); - /* Look for DirectInput joysticks, wheels, head trackers, gamepads, etc.. */ IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, @@ -809,6 +808,9 @@ void SDL_SYS_JoystickDetect() SDL_RawDevList = NULL; SDL_RawDevListCount = 0; + /* Look for XInput devices. Do this last, so they're first in the final list. */ + EnumXInputDevices(&pCurList); + SDL_UnlockMutex( s_mutexJoyStickEnum ); } From 18517df9b2072bca53403d66a82566109eabf664 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:24:43 -0700 Subject: [PATCH 081/258] Christoph Mallon: Simplify avoidance of duplicate / in SDL_GetPrefPath() --- src/filesystem/unix/SDL_sysfilesystem.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index b3e5f5f26..557b3f77f 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -156,7 +156,7 @@ SDL_GetPrefPath(const char *org, const char *app) * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */ const char *envr = SDL_getenv("XDG_DATA_HOME"); - const char *append = "/"; + const char *append; char *retval = NULL; char *ptr = NULL; size_t len = 0; @@ -169,18 +169,16 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); return NULL; } - if (envr[SDL_strlen(envr) - 1] == '/') { - append = ".local/share/"; - } else { - append = "/.local/share/"; - } + append = "/.local/share/"; } else { - if (envr[SDL_strlen(envr) - 1] == '/') { - append = ""; - } + append = "/"; } /* if */ - len = SDL_strlen(envr) + SDL_strlen(append) + SDL_strlen(app) + 2; + len = SDL_strlen(envr); + if (envr[len - 1] == '/') + append += 1; + + len += SDL_strlen(append) + SDL_strlen(app) + 2; retval = (char *) SDL_malloc(len); if (!retval) { SDL_OutOfMemory(); From 911e984c3624af56e9de62c445cf77b98b3df1fd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:25:24 -0700 Subject: [PATCH 082/258] Christoph Mallon: Remove lone /* if */ comment. --- src/filesystem/unix/SDL_sysfilesystem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 557b3f77f..3be5eb762 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -172,7 +172,7 @@ SDL_GetPrefPath(const char *org, const char *app) append = "/.local/share/"; } else { append = "/"; - } /* if */ + } len = SDL_strlen(envr); if (envr[len - 1] == '/') From aca1b3acc75d3ef05ac6abfd08739b64f99e0bd6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:25:54 -0700 Subject: [PATCH 083/258] Christoph Mallon: Report an error, if creating the directories in SDL_GetPrefPath() failed. --- src/filesystem/unix/SDL_sysfilesystem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 3be5eb762..f5517b8fb 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -25,6 +25,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ +#include +#include #include #include #include @@ -190,11 +192,17 @@ SDL_GetPrefPath(const char *org, const char *app) for (ptr = retval+1; *ptr; ptr++) { if (*ptr == '/') { *ptr = '\0'; - mkdir(retval, 0700); + if (mkdir(retval, 0700) != 0 && errno != EEXIST) + goto error; *ptr = '/'; } } - mkdir(retval, 0700); + if (mkdir(retval, 0700) != 0 && errno != EEXIST) { +error: + SDL_SetError("Couldn't create directory '%s': ", retval, strerror(errno)); + SDL_free(retval); + return NULL; + } return retval; } From 8c2129f4b1fabc08cf6f9d30c4a8c20dbf7a727c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:26:24 -0700 Subject: [PATCH 084/258] Christoph Mallon: Simplify assignment. --- src/SDL_hints.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/SDL_hints.c b/src/SDL_hints.c index b00e961cc..63be87a11 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -75,11 +75,7 @@ SDL_SetHintWithPriority(const char *name, const char *value, if (hint->value) { SDL_free(hint->value); } - if (value) { - hint->value = SDL_strdup(value); - } else { - hint->value = NULL; - } + hint->value = value ? SDL_strdup(value) : NULL; } hint->priority = priority; return SDL_TRUE; From 79dab267964532c995d0837cee639f22bb7aa69d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:26:55 -0700 Subject: [PATCH 085/258] Christoph Mallon: Use SDL_arraysize() --- src/filesystem/unix/SDL_sysfilesystem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index f5517b8fb..c871b1aab 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -84,8 +84,8 @@ SDL_GetBasePath(void) #if defined(__FREEBSD__) char fullpath[PATH_MAX]; size_t buflen = sizeof (fullpath); - const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; - if (sysctl(mib, 4, fullpath, &buflen, NULL, 0) != -1) { + const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) { retval = SDL_strdup(fullpath); if (!retval) { SDL_OutOfMemory(); From edc88be724869bcd3bfa476774790ab0b2e6d85a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:27:25 -0700 Subject: [PATCH 086/258] Christoph Mallon: Correct indendation. --- src/filesystem/unix/SDL_sysfilesystem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index c871b1aab..acd363278 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -105,13 +105,13 @@ SDL_GetBasePath(void) /* is a Linux-style /proc filesystem available? */ if (!retval && (access("/proc", F_OK) == 0)) { - #if defined(__FREEBSD__) +#if defined(__FREEBSD__) retval = readSymLink("/proc/curproc/file"); - #elif defined(__NETBSD__) +#elif defined(__NETBSD__) retval = readSymLink("/proc/curproc/exe"); - #else +#else retval = readSymLink("/proc/self/exe"); /* linux. */ - #endif +#endif if (retval == NULL) { /* older kernels don't have /proc/self ... try PID version... */ char path[64]; From 08dfaaa2e60aea603be78ad111a5f8f34d88a3d3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:29:21 -0700 Subject: [PATCH 087/258] Christoph Mallon: Remove pointless if (x) before SDL_free(x) --- src/SDL_hints.c | 8 +--- src/audio/SDL_audio.c | 12 ++---- src/audio/SDL_wave.c | 20 +++------ src/audio/alsa/SDL_alsa_audio.c | 6 +-- src/audio/arts/SDL_artsaudio.c | 6 +-- src/audio/bsd/SDL_bsdaudio.c | 6 +-- src/audio/disk/SDL_diskaudio.c | 6 +-- src/audio/dsp/SDL_dspaudio.c | 6 +-- src/audio/esd/SDL_esdaudio.c | 6 +-- src/audio/fusionsound/SDL_fsaudio.c | 6 +-- src/audio/nas/SDL_nasaudio.c | 6 +-- src/audio/paudio/SDL_paudio.c | 6 +-- src/audio/pulseaudio/SDL_pulseaudio.c | 6 +-- src/audio/qsa/SDL_qsa_audio.c | 6 +-- src/audio/sndio/SDL_sndioaudio.c | 6 +-- src/audio/sun/SDL_sunaudio.c | 12 ++---- src/audio/winmm/SDL_winmm.c | 8 ++-- src/audio/xaudio2/SDL_xaudio2.c | 4 +- src/events/SDL_events.c | 6 +-- src/events/SDL_touch.c | 6 +-- src/file/SDL_rwops.c | 6 +-- src/filesystem/unix/SDL_sysfilesystem.c | 4 +- src/haptic/SDL_haptic.c | 6 +-- src/haptic/darwin/SDL_syshaptic.c | 24 ++++------- src/haptic/windows/SDL_syshaptic.c | 30 +++++-------- src/joystick/SDL_joystick.c | 19 +++------ src/joystick/beos/SDL_bejoystick.cc | 8 +--- src/joystick/bsd/SDL_sysjoystick.c | 10 ++--- src/joystick/windows/SDL_dxjoystick.c | 8 ++-- src/joystick/windows/SDL_mmjoystick.c | 14 +++--- src/render/SDL_render.c | 4 +- src/render/SDL_yuv_sw.c | 12 ++---- src/render/direct3d/SDL_render_d3d.c | 4 +- src/render/opengl/SDL_render_gl.c | 4 +- src/render/opengles/SDL_render_gles.c | 8 +--- src/render/opengles2/SDL_render_gles2.c | 8 +--- src/render/psp/SDL_render_psp.c | 5 +-- src/render/software/SDL_render_sw.c | 4 +- src/stdlib/SDL_iconv.c | 2 +- src/test/SDL_test_common.c | 4 +- src/video/SDL_RLEaccel.c | 6 +-- src/video/SDL_clipboard.c | 4 +- src/video/SDL_pixels.c | 10 ++--- src/video/SDL_surface.c | 2 +- src/video/SDL_video.c | 52 +++++++---------------- src/video/cocoa/SDL_cocoamodes.m | 4 +- src/video/cocoa/SDL_cocoavideo.m | 4 +- src/video/directfb/SDL_DirectFB_render.c | 4 +- src/video/directfb/SDL_DirectFB_video.h | 2 +- src/video/dummy/SDL_nullvideo.c | 4 +- src/video/uikit/SDL_uikitvideo.m | 4 +- src/video/windows/SDL_windowsmessagebox.c | 4 +- src/video/windows/SDL_windowsvideo.c | 4 +- src/video/windows/SDL_windowswindow.c | 4 +- src/video/x11/SDL_x11opengl.c | 6 +-- src/video/x11/SDL_x11video.c | 4 +- test/testautomation.c | 8 +--- test/testautomation_audio.c | 4 +- test/testautomation_clipboard.c | 12 +++--- test/testautomation_render.c | 4 +- test/testautomation_video.c | 8 ++-- test/testiconv.c | 8 +--- test/testsprite2.c | 12 ++---- 63 files changed, 157 insertions(+), 349 deletions(-) diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 63be87a11..a1eae9ffd 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -72,9 +72,7 @@ SDL_SetHintWithPriority(const char *name, const char *value, entry->callback(entry->userdata, name, hint->value, value); entry = next; } - if (hint->value) { - SDL_free(hint->value); - } + SDL_free(hint->value); hint->value = value ? SDL_strdup(value) : NULL; } hint->priority = priority; @@ -206,9 +204,7 @@ void SDL_ClearHints(void) SDL_hints = hint->next; SDL_free(hint->name); - if (hint->value) { - SDL_free(hint->value); - } + SDL_free(hint->value); for (entry = hint->callbacks; entry; ) { SDL_HintWatch *freeable = entry; entry = entry->next; diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 69e6bf138..5631bb2fd 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -300,9 +300,7 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) static void SDL_StreamDeinit(SDL_AudioStreamer * stream) { - if (stream->buffer != NULL) { - SDL_free(stream->buffer); - } + SDL_free(stream->buffer); } #if defined(ANDROID) @@ -632,9 +630,7 @@ free_device_list(char ***devices, int *devCount) } } - if (*devices != NULL) { - SDL_free(*devices); - } + SDL_free(*devices); *devices = NULL; *devCount = 0; @@ -761,9 +757,7 @@ close_audio_device(SDL_AudioDevice * device) if (device->mixer_lock != NULL) { SDL_DestroyMutex(device->mixer_lock); } - if (device->fake_stream != NULL) { - SDL_FreeAudioMem(device->fake_stream); - } + SDL_FreeAudioMem(device->fake_stream); if (device->convert.needed) { SDL_FreeAudioMem(device->convert.buf); } diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index d9ff16536..fac24cb3b 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -449,10 +449,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, /* Read the audio data format chunk */ chunk.data = NULL; do { - if (chunk.data != NULL) { - SDL_free(chunk.data); - chunk.data = NULL; - } + SDL_free(chunk.data); + chunk.data = NULL; lenread = ReadChunk(src, &chunk); if (lenread < 0) { was_error = 1; @@ -549,10 +547,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, /* Read the audio data chunk */ *audio_buf = NULL; do { - if (*audio_buf != NULL) { - SDL_free(*audio_buf); - *audio_buf = NULL; - } + SDL_free(*audio_buf); + *audio_buf = NULL; lenread = ReadChunk(src, &chunk); if (lenread < 0) { was_error = 1; @@ -583,9 +579,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, *audio_len &= ~(samplesize - 1); done: - if (format != NULL) { - SDL_free(format); - } + SDL_free(format); if (src) { if (freesrc) { SDL_RWclose(src); @@ -606,9 +600,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, void SDL_FreeWAV(Uint8 * audio_buf) { - if (audio_buf != NULL) { - SDL_free(audio_buf); - } + SDL_free(audio_buf); } static int diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 7c5792416..73bdcf284 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -340,10 +340,8 @@ static void ALSA_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->pcm_handle) { ALSA_snd_pcm_drain(this->hidden->pcm_handle); ALSA_snd_pcm_close(this->hidden->pcm_handle); diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index ac0bb9d5d..bd8064326 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -204,10 +204,8 @@ static void ARTS_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->stream) { SDL_NAME(arts_close_stream) (this->hidden->stream); this->hidden->stream = 0; diff --git a/src/audio/bsd/SDL_bsdaudio.c b/src/audio/bsd/SDL_bsdaudio.c index b63c838ad..ad51dc387 100644 --- a/src/audio/bsd/SDL_bsdaudio.c +++ b/src/audio/bsd/SDL_bsdaudio.c @@ -214,10 +214,8 @@ static void BSDAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index 2286ba095..0dc650e12 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -88,10 +88,8 @@ static void DISKAUD_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->output != NULL) { SDL_RWclose(this->hidden->output); this->hidden->output = NULL; diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index c62a22f8a..e3190170d 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -61,10 +61,8 @@ static void DSP_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index 92716f39b..c63056562 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -176,10 +176,8 @@ static void ESD_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { SDL_NAME(esd_close) (this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index 2e468d5c6..49ad2c163 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -169,10 +169,8 @@ static void SDL_FS_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->stream) { this->hidden->stream->Release(this->hidden->stream); this->hidden->stream = NULL; diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index 4e3dc0a13..c2bf67745 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -191,10 +191,8 @@ static void NAS_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->aud) { NAS_AuCloseServer(this->hidden->aud); this->hidden->aud = 0; diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 5a18b45e5..6584ddd86 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -231,10 +231,8 @@ static void PAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 46269d177..7bf4accac 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -300,10 +300,8 @@ static void PULSEAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->stream) { PULSEAUDIO_pa_stream_disconnect(this->hidden->stream); PULSEAUDIO_pa_stream_unref(this->hidden->stream); diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index e3877b463..a5286d8cb 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c @@ -328,10 +328,8 @@ QSA_CloseDevice(_THIS) this->hidden->audio_handle = NULL; } - if (this->hidden->pcm_buf != NULL) { - SDL_FreeAudioMem(this->hidden->pcm_buf); - this->hidden->pcm_buf = NULL; - } + SDL_FreeAudioMem(this->hidden->pcm_buf); + this->hidden->pcm_buf = NULL; SDL_free(this->hidden); this->hidden = NULL; diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index 16d0ec356..309472da0 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -181,10 +181,8 @@ static void SNDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if ( this->hidden->dev != NULL ) { SNDIO_sio_close(this->hidden->dev); this->hidden->dev = NULL; diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 950ba444c..98acf4446 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -184,14 +184,10 @@ static void SUNAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } - if (this->hidden->ulaw_buf != NULL) { - SDL_free(this->hidden->ulaw_buf); - this->hidden->ulaw_buf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; + SDL_free(this->hidden->ulaw_buf); + this->hidden->ulaw_buf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index 9c8da7ae2..4220afd41 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -176,11 +176,9 @@ WINMM_CloseDevice(_THIS) } } - if (this->hidden->mixbuf != NULL) { - /* Free raw mixing buffer */ - SDL_free(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + /* Free raw mixing buffer */ + SDL_free(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->hin) { waveInClose(this->hidden->hin); diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index 5af4b30e5..4f378ea3d 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -205,9 +205,7 @@ XAUDIO2_CloseDevice(_THIS) if (ixa2 != NULL) { IXAudio2_Release(ixa2); } - if (this->hidden->mixbuf != NULL) { - SDL_free(this->hidden->mixbuf); - } + SDL_free(this->hidden->mixbuf); if (this->hidden->semaphore != NULL) { CloseHandle(this->hidden->semaphore); } diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 06cb0f2e7..9213dae57 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -141,10 +141,8 @@ SDL_StopEventLoop(void) /* Clear disabled event state */ for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) { - if (SDL_disabled_events[i]) { - SDL_free(SDL_disabled_events[i]); - SDL_disabled_events[i] = NULL; - } + SDL_free(SDL_disabled_events[i]); + SDL_disabled_events[i] = NULL; } while (SDL_event_watchers) { diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 3429b57d7..1874ba7f5 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -355,10 +355,8 @@ SDL_TouchQuit(void) } SDL_assert(SDL_num_touch == 0); - if (SDL_touchDevices) { - SDL_free(SDL_touchDevices); - SDL_touchDevices = NULL; - } + SDL_free(SDL_touchDevices); + SDL_touchDevices = NULL; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index afbc39aa0..dc89e22fb 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -275,10 +275,8 @@ windows_file_close(SDL_RWops * context) CloseHandle(context->hidden.windowsio.h); context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ } - if (context->hidden.windowsio.buffer.data) { - SDL_free(context->hidden.windowsio.buffer.data); - context->hidden.windowsio.buffer.data = NULL; - } + SDL_free(context->hidden.windowsio.buffer.data); + context->hidden.windowsio.buffer.data = NULL; SDL_FreeRW(context); } return (0); diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index acd363278..e1d06c449 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -69,9 +69,7 @@ readSymLink(const char *path) len *= 2; /* grow buffer, try again. */ } - if (retval != NULL) { - SDL_free(retval); - } + SDL_free(retval); return NULL; } diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index d7e1c5062..33dd4277c 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -379,10 +379,8 @@ void SDL_HapticQuit(void) { SDL_SYS_HapticQuit(); - if (SDL_haptics != NULL) { - SDL_free(SDL_haptics); - SDL_haptics = NULL; - } + SDL_free(SDL_haptics); + SDL_haptics = NULL; SDL_numhaptics = 0; } diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 8d9f17b55..c999a77d3 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -943,14 +943,10 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) { FFCUSTOMFORCE *custom; - if (effect->lpEnvelope != NULL) { - SDL_free(effect->lpEnvelope); - effect->lpEnvelope = NULL; - } - if (effect->rgdwAxes != NULL) { - SDL_free(effect->rgdwAxes); - effect->rgdwAxes = NULL; - } + SDL_free(effect->lpEnvelope); + effect->lpEnvelope = NULL; + SDL_free(effect->rgdwAxes); + effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (FFCUSTOMFORCE *) effect->lpvTypeSpecificParams; @@ -960,10 +956,8 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) SDL_free(effect->lpvTypeSpecificParams); effect->lpvTypeSpecificParams = NULL; } - if (effect->rglDirection != NULL) { - SDL_free(effect->rglDirection); - effect->rglDirection = NULL; - } + SDL_free(effect->rglDirection); + effect->rglDirection = NULL; } @@ -1061,10 +1055,8 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, err_effectdone: SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type); err_hweffect: - if (effect->hweffect != NULL) { - SDL_free(effect->hweffect); - effect->hweffect = NULL; - } + SDL_free(effect->hweffect); + effect->hweffect = NULL; return -1; } diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 5a393b3a9..f8b909627 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -751,10 +751,8 @@ SDL_SYS_HapticQuit(void) } for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) { - if (SDL_hapticlist[i].name) { - SDL_free(SDL_hapticlist[i].name); - SDL_hapticlist[i].name = NULL; - } + SDL_free(SDL_hapticlist[i].name); + SDL_hapticlist[i].name = NULL; } if (dinput != NULL) { @@ -1127,14 +1125,10 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) { DICUSTOMFORCE *custom; - if (effect->lpEnvelope != NULL) { - SDL_free(effect->lpEnvelope); - effect->lpEnvelope = NULL; - } - if (effect->rgdwAxes != NULL) { - SDL_free(effect->rgdwAxes); - effect->rgdwAxes = NULL; - } + SDL_free(effect->lpEnvelope); + effect->lpEnvelope = NULL; + SDL_free(effect->rgdwAxes); + effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams; @@ -1144,10 +1138,8 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) SDL_free(effect->lpvTypeSpecificParams); effect->lpvTypeSpecificParams = NULL; } - if (effect->rglDirection != NULL) { - SDL_free(effect->rglDirection); - effect->rglDirection = NULL; - } + SDL_free(effect->rglDirection); + effect->rglDirection = NULL; } @@ -1250,10 +1242,8 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, err_effectdone: SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type); err_hweffect: - if (effect->hweffect != NULL) { - SDL_free(effect->hweffect); - effect->hweffect = NULL; - } + SDL_free(effect->hweffect); + effect->hweffect = NULL; return -1; } diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 4e086248d..730939502 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -437,22 +437,13 @@ SDL_JoystickClose(SDL_Joystick * joystick) joysticklist = joysticklist->next; } - if (joystick->name) - SDL_free(joystick->name); + SDL_free(joystick->name); /* Free the data associated with this joystick */ - if (joystick->axes) { - SDL_free(joystick->axes); - } - if (joystick->hats) { - SDL_free(joystick->hats); - } - if (joystick->balls) { - SDL_free(joystick->balls); - } - if (joystick->buttons) { - SDL_free(joystick->buttons); - } + SDL_free(joystick->axes); + SDL_free(joystick->hats); + SDL_free(joystick->balls); + SDL_free(joystick->buttons); SDL_free(joystick); } diff --git a/src/joystick/beos/SDL_bejoystick.cc b/src/joystick/beos/SDL_bejoystick.cc index 4e342ed41..c32458134 100644 --- a/src/joystick/beos/SDL_bejoystick.cc +++ b/src/joystick/beos/SDL_bejoystick.cc @@ -231,12 +231,8 @@ extern "C" if (joystick->hwdata) { joystick->hwdata->stick->Close(); delete joystick->hwdata->stick; - if (joystick->hwdata->new_hats) { - SDL_free(joystick->hwdata->new_hats); - } - if (joystick->hwdata->new_axes) { - SDL_free(joystick->hwdata->new_axes); - } + SDL_free(joystick->hwdata->new_hats); + SDL_free(joystick->hwdata->new_axes); SDL_free(joystick->hwdata); joystick->hwdata = NULL; } diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index 6d35d91b5..c5816b6b7 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -577,10 +577,8 @@ SDL_SYS_JoystickQuit(void) int i; for (i = 0; i < MAX_JOYS; i++) { - if (joynames[i] != NULL) - SDL_free(joynames[i]); - if (joydevnames[i] != NULL) - SDL_free(joydevnames[i]); + SDL_free(joynames[i]); + SDL_free(joydevnames[i]); } return; @@ -657,9 +655,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind) static void report_free(struct report *r) { - if (r->buf != NULL) { - SDL_free(r->buf); - } + SDL_free(r->buf); r->status = SREPORT_UNINIT; } diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 4165c7011..54d54d26d 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -834,7 +834,7 @@ void SDL_SYS_JoystickDetect() pListNext = pCurList->pNext; SDL_free(pCurList->joystickname); - SDL_free( pCurList ); + SDL_free(pCurList); pCurList = pListNext; } @@ -1559,10 +1559,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick) IDirectInputDevice8_Release(joystick->hwdata->InputDevice); } - if (joystick->hwdata != NULL) { - /* free system specific hardware data */ - SDL_free(joystick->hwdata); - } + /* free system specific hardware data */ + SDL_free(joystick->hwdata); joystick->closed = 1; } diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c index 413053f14..f236dff96 100644 --- a/src/joystick/windows/SDL_mmjoystick.c +++ b/src/joystick/windows/SDL_mmjoystick.c @@ -384,11 +384,9 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - if (joystick->hwdata != NULL) { - /* free system specific hardware data */ - SDL_free(joystick->hwdata); - joystick->hwdata = NULL; - } + /* free system specific hardware data */ + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; } /* Function to perform any system-specific joystick related cleanup */ @@ -397,10 +395,8 @@ SDL_SYS_JoystickQuit(void) { int i; for (i = 0; i < MAX_JOYSTICKS; i++) { - if (SYS_JoystickName[i] != NULL) { - SDL_free(SYS_JoystickName[i]); - SYS_JoystickName[i] = NULL; - } + SDL_free(SYS_JoystickName[i]); + SYS_JoystickName[i] = NULL; } } diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 5dfc38dcb..1e7f01f62 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1712,9 +1712,7 @@ SDL_DestroyTexture(SDL_Texture * texture) if (texture->yuv) { SDL_SW_DestroyYUVTexture(texture->yuv); } - if (texture->pixels) { - SDL_free(texture->pixels); - } + SDL_free(texture->pixels); renderer->DestroyTexture(renderer, texture); SDL_free(texture); diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 46b680cd8..96047833d 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1335,15 +1335,9 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) { if (swdata) { - if (swdata->pixels) { - SDL_free(swdata->pixels); - } - if (swdata->colortab) { - SDL_free(swdata->colortab); - } - if (swdata->rgb_2_pix) { - SDL_free(swdata->rgb_2_pix); - } + SDL_free(swdata->pixels); + SDL_free(swdata->colortab); + SDL_free(swdata->rgb_2_pix); if (swdata->stretch) { SDL_FreeSurface(swdata->stretch); } diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 6e72b30d3..2ce22626b 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1813,9 +1813,7 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (data->vtexture) { IDirect3DTexture9_Release(data->vtexture); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; } diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index b1473b07b..043e5017a 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1318,9 +1318,7 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) renderdata->glDeleteTextures(1, &data->utexture); renderdata->glDeleteTextures(1, &data->vtexture); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; } diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 7f7d61ac4..1b3ea0f79 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -573,9 +573,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, data->format, data->formattype, src); - if (blob) { - SDL_free(blob); - } + SDL_free(blob); if (renderdata->glGetError() != GL_NO_ERROR) { @@ -1116,9 +1114,7 @@ GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (data->texture) { renderdata->glDeleteTextures(1, &data->texture); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 83ead0a97..db030c6c0 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -336,9 +336,7 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) } SDL_GL_DeleteContext(rdata->context); } - if (rdata->shader_formats) { - SDL_free(rdata->shader_formats); - } + SDL_free(rdata->shader_formats); SDL_free(rdata); } SDL_free(renderer); @@ -541,9 +539,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect tdata->pixel_format, tdata->pixel_type, src); - if (blob) { - SDL_free(blob); - } + SDL_free(blob); if (rdata->glGetError() != GL_NO_ERROR) { return SDL_SetError("Failed to update texture"); diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 5b104373c..b8cd265de 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -988,10 +988,7 @@ PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if(psp_texture == 0) return; - if(psp_texture->data != 0) - { - SDL_free(psp_texture->data); - } + SDL_free(psp_texture->data); SDL_free(psp_texture); texture->driverdata = NULL; } diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 78f6ca1e9..348dd98c2 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -718,9 +718,7 @@ SW_DestroyRenderer(SDL_Renderer * renderer) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - if (data) { - SDL_free(data); - } + SDL_free(data); SDL_free(renderer); } diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index 109e03ed6..4de2ebe3f 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -843,7 +843,7 @@ SDL_iconv(SDL_iconv_t cd, int SDL_iconv_close(SDL_iconv_t cd) { - if (cd && cd != (SDL_iconv_t) - 1) { + if (cd != (SDL_iconv_t)-1) { SDL_free(cd); } return 0; diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 14add55b2..3b2028ab0 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1388,9 +1388,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state) { int i; - if (state->windows) { - SDL_free(state->windows); - } + SDL_free(state->windows); if (state->renderers) { for (i = 0; i < state->num_windows; ++i) { if (state->renderers[i]) { diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 25ecd4556..6db43b092 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1558,10 +1558,8 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode) surface->map->info.flags &= ~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY); - if (surface->map->data) { - SDL_free(surface->map->data); - surface->map->data = NULL; - } + SDL_free(surface->map->data); + surface->map->data = NULL; } } diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index 83c2e346e..cd1d341fc 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -35,9 +35,7 @@ SDL_SetClipboardText(const char *text) if (_this->SetClipboardText) { return _this->SetClipboardText(_this, text); } else { - if (_this->clipboard_text) { - SDL_free(_this->clipboard_text); - } + SDL_free(_this->clipboard_text); _this->clipboard_text = SDL_strdup(text); return 0; } diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index c472c38b5..0300155fc 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -707,9 +707,7 @@ SDL_FreePalette(SDL_Palette * palette) if (--palette->refcount > 0) { return; } - if (palette->colors) { - SDL_free(palette->colors); - } + SDL_free(palette->colors); SDL_free(palette); } @@ -985,10 +983,8 @@ SDL_InvalidateMap(SDL_BlitMap * map) map->dst = NULL; map->src_palette_version = 0; map->dst_palette_version = 0; - if (map->info.table) { - SDL_free(map->info.table); - map->info.table = NULL; - } + SDL_free(map->info.table); + map->info.table = NULL; } int diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index ee1cf590f..84d3a4dc6 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -1076,7 +1076,7 @@ SDL_FreeSurface(SDL_Surface * surface) SDL_FreeBlitMap(surface->map); surface->map = NULL; } - if (surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC)) { + if (!(surface->flags & SDL_PREALLOC)) { SDL_free(surface->pixels); } SDL_free(surface); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b98069cdf..dcf049468 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -263,10 +263,8 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix SDL_DestroyTexture(data->texture); data->texture = NULL; } - if (data->pixels) { - SDL_free(data->pixels); - data->pixels = NULL; - } + SDL_free(data->pixels); + data->pixels = NULL; if (SDL_GetRendererInfo(data->renderer, &info) < 0) { return -1; @@ -351,9 +349,7 @@ SDL_DestroyWindowTexture(_THIS, SDL_Window * window) if (data->renderer) { SDL_DestroyRenderer(data->renderer); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); } @@ -1407,9 +1403,7 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title) if (title == window->title) { return; } - if (window->title) { - SDL_free(window->title); - } + SDL_free(window->title); if (title && *title) { window->title = SDL_strdup(title); } else { @@ -2188,15 +2182,11 @@ SDL_DestroyWindow(SDL_Window * window) window->magic = NULL; /* Free memory associated with the window */ - if (window->title) { - SDL_free(window->title); - } + SDL_free(window->title); if (window->icon) { SDL_FreeSurface(window->icon); } - if (window->gamma) { - SDL_free(window->gamma); - } + SDL_free(window->gamma); while (window->data) { SDL_WindowUserData *data = window->data; @@ -2283,23 +2273,15 @@ SDL_VideoQuit(void) for (i = 0; i < _this->num_displays; ++i) { SDL_VideoDisplay *display = &_this->displays[i]; for (j = display->num_display_modes; j--;) { - if (display->display_modes[j].driverdata) { - SDL_free(display->display_modes[j].driverdata); - display->display_modes[j].driverdata = NULL; - } - } - if (display->display_modes) { - SDL_free(display->display_modes); - display->display_modes = NULL; - } - if (display->desktop_mode.driverdata) { - SDL_free(display->desktop_mode.driverdata); - display->desktop_mode.driverdata = NULL; - } - if (display->driverdata) { - SDL_free(display->driverdata); - display->driverdata = NULL; + SDL_free(display->display_modes[j].driverdata); + display->display_modes[j].driverdata = NULL; } + SDL_free(display->display_modes); + display->display_modes = NULL; + SDL_free(display->desktop_mode.driverdata); + display->desktop_mode.driverdata = NULL; + SDL_free(display->driverdata); + display->driverdata = NULL; } if (_this->displays) { for (i = 0; i < _this->num_displays; ++i) { @@ -2309,10 +2291,8 @@ SDL_VideoQuit(void) _this->displays = NULL; _this->num_displays = 0; } - if (_this->clipboard_text) { - SDL_free(_this->clipboard_text); - _this->clipboard_text = NULL; - } + SDL_free(_this->clipboard_text); + _this->clipboard_text = NULL; _this->free(_this); _this = NULL; } diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index f10e7ee20..d71cb1767 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -281,7 +281,7 @@ Cocoa_InitModes(_THIS) display.name = (char *)Cocoa_GetDisplayName(displays[i]); if (!GetDisplayMode (_this, moderef, &mode)) { Cocoa_ReleaseDisplayMode(_this, moderef); - if (display.name) SDL_free(display.name); + SDL_free(display.name); SDL_free(displaydata); continue; } @@ -290,7 +290,7 @@ Cocoa_InitModes(_THIS) display.current_mode = mode; display.driverdata = displaydata; SDL_AddVideoDisplay(&display); - if (display.name) SDL_free(display.name); + SDL_free(display.name); } } SDL_stack_free(displays); diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 849915247..da71df03f 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -71,9 +71,7 @@ Cocoa_CreateDevice(int devindex) } if (!data) { SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } + SDL_free(device); return NULL; } device->driverdata = data; diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index d1cd49dfc..dc886469e 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -1226,9 +1226,7 @@ DirectFB_DestroyRenderer(SDL_Renderer * renderer) } #endif - if (data) { - SDL_free(data); - } + SDL_free(data); SDL_free(renderer); } diff --git a/src/video/directfb/SDL_DirectFB_video.h b/src/video/directfb/SDL_DirectFB_video.h index 53fcdcfb9..c3630fd8f 100644 --- a/src/video/directfb/SDL_DirectFB_video.h +++ b/src/video/directfb/SDL_DirectFB_video.h @@ -76,7 +76,7 @@ #define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */ #define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(x->Release(x)); x = NULL; } } while (0) -#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0) +#define SDL_DFB_FREE(x) do { SDL_free((x)); (x) = NULL; } while (0) #define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0) #define SDL_DFB_CONTEXT "SDL_DirectFB" diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 21f1124b6..9d6ea6785 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -82,9 +82,7 @@ DUMMY_CreateDevice(int devindex) device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } + SDL_free(device); return (0); } diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 662b10906..74b24b8da 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -63,9 +63,7 @@ UIKit_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { - if (device) { - SDL_free(device); - } + SDL_free(device); SDL_OutOfMemory(); return (0); } diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index bbe79237f..f54425902 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -233,9 +233,7 @@ static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int static void FreeDialogData(WIN_DialogData *dialog) { - if (dialog->data) { - SDL_free(dialog->data); - } + SDL_free(dialog->data); SDL_free(dialog); } diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 883cafae4..77b63a21a 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -75,9 +75,7 @@ WIN_CreateDevice(int devindex) data = NULL; } if (!data) { - if (device) { - SDL_free(device); - } + SDL_free(device); SDL_OutOfMemory(); return NULL; } diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 94f555baf..c28da5204 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -319,9 +319,7 @@ WIN_SetWindowTitle(_THIS, SDL_Window * window) title = NULL; } SetWindowText(hwnd, title ? title : TEXT("")); - if (title) { - SDL_free(title); - } + SDL_free(title); } void diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 6796b7d30..6f1cc8b6b 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -267,10 +267,8 @@ X11_GL_UnloadLibrary(_THIS) #endif /* Free OpenGL memory */ - if (_this->gl_data) { - SDL_free(_this->gl_data); - _this->gl_data = NULL; - } + SDL_free(_this->gl_data); + _this->gl_data = NULL; } static SDL_bool diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 200e57751..5ed47d5e8 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -565,9 +565,7 @@ X11_VideoQuit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - if (data->classname) { - SDL_free(data->classname); - } + SDL_free(data->classname); #ifdef X_HAVE_UTF8_STRING if (data->im) { XCloseIM(data->im); diff --git a/test/testautomation.c b/test/testautomation.c index 6610d8a4f..0a181bd9b 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -113,12 +113,8 @@ main(int argc, char *argv[]) } /* Clean up */ - if (userRunSeed != NULL) { - SDL_free(userRunSeed); - } - if (filter != NULL) { - SDL_free(filter); - } + SDL_free(userRunSeed); + SDL_free(filter); /* Shutdown everything */ quit(result); diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index 50c16144b..780c9e976 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -747,11 +747,9 @@ int audio_convertAudio() SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio); /* Free converted buffer */ - if (cvt.buf != NULL) { SDL_free(cvt.buf); cvt.buf = NULL; - } - } + } } } } diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c index 92aec7d03..1c438eea6 100644 --- a/test/testautomation_clipboard.c +++ b/test/testautomation_clipboard.c @@ -41,7 +41,7 @@ clipboard_testGetClipboardText(void *arg) charResult = SDL_GetClipboardText(); SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - if (charResult) SDL_free(charResult); + SDL_free(charResult); return TEST_COMPLETED; } @@ -69,8 +69,8 @@ clipboard_testSetClipboardText(void *arg) textRef, text); /* Cleanup */ - if (textRef) SDL_free(textRef); - if (text) SDL_free(text); + SDL_free(textRef); + SDL_free(text); return TEST_COMPLETED; } @@ -145,9 +145,9 @@ clipboard_testClipboardTextFunctions(void *arg) textRef, charResult); /* Cleanup */ - if (textRef) SDL_free(textRef); - if (text) SDL_free(text); - if (charResult) SDL_free(charResult); + SDL_free(textRef); + SDL_free(text); + SDL_free(charResult); return TEST_COMPLETED; } diff --git a/test/testautomation_render.c b/test/testautomation_render.c index d582cb07c..858679d82 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -995,9 +995,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error) SDLTest_AssertCheck(result == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", result); /* Clean up. */ - if (pixels != NULL) { - SDL_free(pixels); - } + SDL_free(pixels); if (testSurface != NULL) { SDL_FreeSurface(testSurface); } diff --git a/test/testautomation_video.c b/test/testautomation_video.c index 350f0d0d3..3a7bfca05 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -1714,10 +1714,10 @@ video_getSetWindowData(void *arg) _destroyVideoSuiteTestWindow(window); cleanup: - if (referenceUserdata != NULL) SDL_free(referenceUserdata); - if (referenceUserdata2 != NULL) SDL_free(referenceUserdata2); - if (userdata != NULL) SDL_free(userdata); - if (userdata2 != NULL) SDL_free(userdata2); + SDL_free(referenceUserdata); + SDL_free(referenceUserdata2); + SDL_free(userdata); + SDL_free(userdata2); return returnValue; } diff --git a/test/testiconv.c b/test/testiconv.c index 435e2392f..3165b3426 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -75,12 +75,8 @@ main(int argc, char *argv[]) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]); ++errors; } - if (test[0]) { - SDL_free(test[0]); - } - if (test[1]) { - SDL_free(test[1]); - } + SDL_free(test[0]); + SDL_free(test[1]); } test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len); SDL_free(ucs4); diff --git a/test/testsprite2.c b/test/testsprite2.c index 26cc29f66..b40efd3f8 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -42,15 +42,9 @@ static int iterations = -1; static void quit(int rc) { - if (sprites) { - SDL_free(sprites); - } - if (positions) { - SDL_free(positions); - } - if (velocities) { - SDL_free(velocities); - } + SDL_free(sprites); + SDL_free(positions); + SDL_free(velocities); SDLTest_CommonQuit(state); exit(rc); } From 62d7359fd5c6488a065595907c42c73708e95bd7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:29:51 -0700 Subject: [PATCH 088/258] Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x) --- src/events/SDL_mouse.c | 4 +- src/render/SDL_yuv_sw.c | 14 ++--- src/video/SDL_bmp.c | 4 +- src/video/SDL_video.c | 8 +-- src/video/directfb/SDL_DirectFB_window.c | 3 +- src/video/dummy/SDL_nullframebuffer.c | 8 +-- test/testautomation_render.c | 64 ++++++++--------------- test/testautomation_surface.c | 66 +++++++----------------- test/testshape.c | 3 +- 9 files changed, 51 insertions(+), 123 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index dd6049af0..e322437b8 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -571,9 +571,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) mouse->cursors = cursor; } - if (temp) { - SDL_FreeSurface(temp); - } + SDL_FreeSurface(temp); return cursor; } diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 96047833d..2c7e72449 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1012,10 +1012,8 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) break; } - if (swdata->display) { - SDL_FreeSurface(swdata->display); - swdata->display = NULL; - } + SDL_FreeSurface(swdata->display); + swdata->display = NULL; return 0; } @@ -1338,12 +1336,8 @@ SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) SDL_free(swdata->pixels); SDL_free(swdata->colortab); SDL_free(swdata->rgb_2_pix); - if (swdata->stretch) { - SDL_FreeSurface(swdata->stretch); - } - if (swdata->display) { - SDL_FreeSurface(swdata->display); - } + SDL_FreeSurface(swdata->stretch); + SDL_FreeSurface(swdata->display); SDL_free(swdata); } } diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 108f0b394..9244b28db 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -398,9 +398,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (src) { SDL_RWseek(src, fp_offset, RW_SEEK_SET); } - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); surface = NULL; } if (freesrc && src) { diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index dcf049468..53de05710 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1432,9 +1432,7 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) return; } - if (window->icon) { - SDL_FreeSurface(window->icon); - } + SDL_FreeSurface(window->icon); /* Convert the icon into ARGB8888 */ window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0); @@ -2183,9 +2181,7 @@ SDL_DestroyWindow(SDL_Window * window) /* Free memory associated with the window */ SDL_free(window->title); - if (window->icon) { - SDL_FreeSurface(window->icon); - } + SDL_FreeSurface(window->icon); SDL_free(window->gamma); while (window->data) { SDL_WindowUserData *data = window->data; diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index 74c958ab0..e373d4beb 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -237,8 +237,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) } return; error: - if (surface) - SDL_FreeSurface(surface); + SDL_FreeSurface(surface); SDL_DFB_RELEASE(windata->icon); return; } diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index f3904918a..f18ceea26 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -38,9 +38,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma /* Free the old framebuffer surface */ surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE); - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); /* Create a new one */ SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); @@ -83,9 +81,7 @@ void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window) SDL_Surface *surface; surface = (SDL_Surface *) SDL_SetWindowData(window, DUMMY_SURFACE, NULL); - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); } #endif /* SDL_VIDEO_DRIVER_DUMMY */ diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 858679d82..e380181f7 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -190,10 +190,8 @@ int render_testPrimitives (void *arg) _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); /* Clean up. */ - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -333,10 +331,8 @@ int render_testPrimitivesBlend (void *arg) _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); /* Clean up. */ - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -400,10 +396,8 @@ render_testBlit(void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -470,10 +464,8 @@ render_testBlitColor (void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -543,10 +535,8 @@ render_testBlitAlpha (void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -655,37 +645,29 @@ render_testBlitBlend (void *arg) _testBlitBlendMode( tface, SDL_BLENDMODE_NONE ); referenceSurface = SDLTest_ImageBlitBlendNone(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Test Blend. */ _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ); referenceSurface = SDLTest_ImageBlitBlend(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Test Add. */ _testBlitBlendMode( tface, SDL_BLENDMODE_ADD ); referenceSurface = SDLTest_ImageBlitBlendAdd(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Test Mod. */ _testBlitBlendMode( tface, SDL_BLENDMODE_MOD); referenceSurface = SDLTest_ImageBlitBlendMod(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Clear surface. */ _clearScreen(); @@ -733,10 +715,8 @@ render_testBlitBlend (void *arg) /* Check to see if final image matches. */ referenceSurface = SDLTest_ImageBlitBlendAll(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -996,9 +976,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error) /* Clean up. */ SDL_free(pixels); - if (testSurface != NULL) { - SDL_FreeSurface(testSurface); - } + SDL_FreeSurface(testSurface); } /** diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 97cc81d84..d81491837 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -63,14 +63,10 @@ _surfaceSetUp(void *arg) void _surfaceTearDown(void *arg) { - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } - if (testSurface != NULL) { - SDL_FreeSurface(testSurface); - testSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; + SDL_FreeSurface(testSurface); + testSurface = NULL; } /** @@ -193,10 +189,8 @@ void _testBlitBlendMode(int mode) SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4); /* Clean up */ - if (face != NULL) { - SDL_FreeSurface(face); - face = NULL; - } + SDL_FreeSurface(face); + face = NULL; } /* Helper to check that a file exists */ @@ -250,14 +244,10 @@ surface_testSaveLoadBitmap(void *arg) unlink(sampleFilename); /* Clean up */ - if (face != NULL) { SDL_FreeSurface(face); face = NULL; - } - if (rface != NULL) { SDL_FreeSurface(rface); rface = NULL; - } return TEST_COMPLETED; } @@ -294,14 +284,10 @@ surface_testSurfaceConversion(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (face != NULL) { - SDL_FreeSurface( face ); - face = NULL; - } - if (rface != NULL) { - SDL_FreeSurface( rface ); - rface = NULL; - } + SDL_FreeSurface(face); + face = NULL; + SDL_FreeSurface(rface); + rface = NULL; return TEST_COMPLETED; } @@ -427,9 +413,7 @@ surface_testBlit(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -452,9 +436,7 @@ surface_testBlitColorMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -477,9 +459,7 @@ surface_testBlitAlphaMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -503,9 +483,7 @@ surface_testBlitBlendNone(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -528,9 +506,7 @@ surface_testBlitBlendBlend(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -553,9 +529,7 @@ surface_testBlitBlendAdd(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -578,9 +552,7 @@ surface_testBlitBlendMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -603,9 +575,7 @@ surface_testBlitBlendLoop(void *arg) { SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface(compareSurface); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; diff --git a/test/testshape.c b/test/testshape.c index 785ba1acf..c202d8ec6 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -90,8 +90,7 @@ int main(int argc,char** argv) if(pictures[i].surface == NULL) { j = 0; for(j=0;j Date: Thu, 29 Aug 2013 08:30:21 -0700 Subject: [PATCH 089/258] Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)). --- src/test/SDL_test_harness.c | 12 ++++----- src/video/SDL_clipboard.c | 2 +- src/video/SDL_video.c | 4 +-- src/video/bwindow/SDL_bclipboard.cc | 2 +- src/video/cocoa/SDL_cocoaclipboard.m | 2 +- src/video/windows/SDL_windowsclipboard.c | 2 +- src/video/x11/SDL_x11clipboard.c | 2 +- test/testautomation_audio.c | 14 +++++------ test/testautomation_clipboard.c | 2 +- test/testautomation_pixels.c | 10 ++++---- test/testautomation_sdltest.c | 32 ++++++++++++------------ test/testime.c | 2 +- 12 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index c58eae45a..1bfe9c281 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -109,17 +109,17 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter Uint32 entireStringLength; char *buffer; - if (runSeed == NULL || SDL_strlen(runSeed)==0) { + if (runSeed == NULL || runSeed[0] == '\0') { SDLTest_LogError("Invalid runSeed string."); return -1; } - if (suiteName == NULL || SDL_strlen(suiteName)==0) { + if (suiteName == NULL || suiteName[0] == '\0') { SDLTest_LogError("Invalid suiteName string."); return -1; } - if (testName == NULL || SDL_strlen(testName)==0) { + if (testName == NULL || testName[0] == '\0') { SDLTest_LogError("Invalid testName string."); return -1; } @@ -399,7 +399,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user } /* Generate run see if we don't have one already */ - if (userRunSeed == NULL || SDL_strlen(userRunSeed) == 0) { + if (userRunSeed == NULL || userRunSeed[0] == '\0') { runSeed = SDLTest_GenerateRunSeed(16); if (runSeed == NULL) { SDLTest_LogError("Generating a random seed failed"); @@ -422,7 +422,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed); /* Initialize filtering */ - if (filter != NULL && SDL_strlen(filter) > 0) { + if (filter != NULL && filter[0] != '\0') { /* Loop over all suites to check if we have a filter match */ suiteCounter = 0; while (testSuites[suiteCounter] && suiteFilter == 0) { @@ -521,7 +521,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user suiteCounter, testCounter, currentTestName); - if (testCase->description != NULL && SDL_strlen(testCase->description)>0) { + if (testCase->description != NULL && testCase->description[0] != '\0') { SDLTest_Log("Test Description: '%s'", (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat); } diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index cd1d341fc..8c0626ef2 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -65,7 +65,7 @@ SDL_HasClipboardText(void) if (_this->HasClipboardText) { return _this->HasClipboardText(_this); } else { - if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) { + if (_this->clipboard_text && _this->clipboard_text[0] != '\0') { return SDL_TRUE; } else { return SDL_FALSE; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 53de05710..53e6e0208 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1453,7 +1453,7 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) CHECK_WINDOW_MAGIC(window, NULL); /* Input validation */ - if (name == NULL || SDL_strlen(name) == 0) { + if (name == NULL || name[0] == '\0') { SDL_InvalidParamError("name"); return NULL; } @@ -1500,7 +1500,7 @@ SDL_GetWindowData(SDL_Window * window, const char *name) CHECK_WINDOW_MAGIC(window, NULL); /* Input validation */ - if (name == NULL || SDL_strlen(name) == 0) { + if (name == NULL || name[0] == '\0') { SDL_InvalidParamError("name"); return NULL; } diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc index 492b2fab3..2ec80c6ba 100644 --- a/src/video/bwindow/SDL_bclipboard.cc +++ b/src/video/bwindow/SDL_bclipboard.cc @@ -82,7 +82,7 @@ SDL_bool BE_HasClipboardText(_THIS) { SDL_bool result = SDL_FALSE; char *text = BE_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index ab31031b4..62c34b53f 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -95,7 +95,7 @@ Cocoa_HasClipboardText(_THIS) SDL_bool result = SDL_FALSE; char *text = Cocoa_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 3d1db4a41..15eea1aa8 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -137,7 +137,7 @@ WIN_HasClipboardText(_THIS) SDL_bool result = SDL_FALSE; char *text = WIN_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 54b5eb602..970aeaf15 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -165,7 +165,7 @@ X11_HasClipboardText(_THIS) SDL_bool result = SDL_FALSE; char *text = X11_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index 780c9e976..c5c3f047d 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -77,7 +77,7 @@ int audio_initQuitAudio() audioDriver = SDL_GetAudioDriver(i); SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* Call Init */ result = SDL_AudioInit(audioDriver); @@ -134,7 +134,7 @@ int audio_initOpenCloseQuitAudio() audioDriver = SDL_GetAudioDriver(i); SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* Change specs */ for (j = 0; j < 2; j++) { @@ -226,14 +226,14 @@ int audio_enumerateAndNameAudioDevices() SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t); if (name != NULL) { - SDLTest_AssertCheck(SDL_strlen(name)>0, "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name); + SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name); if (t==1) { /* Also try non-zero type */ tt = t + SDLTest_RandomIntegerInRange(1,10); nameAgain = SDL_GetAudioDeviceName(i, tt); SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt); if (nameAgain != NULL) { - SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); + SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", i, t, i, tt); @@ -318,7 +318,7 @@ int audio_printAudioDrivers() SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i); SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); if (name != NULL) { - SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name); + SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); } } } @@ -339,7 +339,7 @@ int audio_printCurrentAudioDriver() SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()"); SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); if (name != NULL) { - SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name); + SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); } return TEST_COMPLETED; @@ -509,7 +509,7 @@ int audio_buildAudioCVTNegative() SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && SDL_strlen(error)>0, "Validate that error message was not NULL or empty"); + SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty"); } SDL_ClearError(); diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c index 1c438eea6..9ce4f5149 100644 --- a/test/testautomation_clipboard.c +++ b/test/testautomation_clipboard.c @@ -118,7 +118,7 @@ clipboard_testClipboardTextFunctions(void *arg) charResult != NULL, "Verify SDL_GetClipboardText did not return NULL"); SDLTest_AssertCheck( - SDL_strlen(charResult) == 0, + charResult[0] == '\0', "Verify SDL_GetClipboardText returned string with length 0, got length %i", SDL_strlen(charResult)); intResult = SDL_SetClipboardText((const char *)text); diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c index 3c0f63b57..5112333cd 100644 --- a/test/testautomation_pixels.c +++ b/test/testautomation_pixels.c @@ -242,7 +242,7 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, "Verify result text; expected: %s, got %s", unknownFormat, result); } @@ -257,7 +257,7 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); } @@ -273,7 +273,7 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); } @@ -290,14 +290,14 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty; got: %s", result); SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); } error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && SDL_strlen(error) == 0, "Validate that error message is empty"); + SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message is empty"); } return TEST_COMPLETED; diff --git a/test/testautomation_sdltest.c b/test/testautomation_sdltest.c index e0d921b49..d9ce7d281 100644 --- a/test/testautomation_sdltest.c +++ b/test/testautomation_sdltest.c @@ -192,7 +192,7 @@ sdltest_randomBoundaryNumberUint8(void *arg) "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE); @@ -202,7 +202,7 @@ sdltest_randomBoundaryNumberUint8(void *arg) "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE); @@ -302,7 +302,7 @@ sdltest_randomBoundaryNumberUint16(void *arg) "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE); @@ -312,7 +312,7 @@ sdltest_randomBoundaryNumberUint16(void *arg) "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE); @@ -412,7 +412,7 @@ sdltest_randomBoundaryNumberUint32(void *arg) "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE); @@ -422,7 +422,7 @@ sdltest_randomBoundaryNumberUint32(void *arg) "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE); @@ -522,7 +522,7 @@ sdltest_randomBoundaryNumberUint64(void *arg) "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE); @@ -532,7 +532,7 @@ sdltest_randomBoundaryNumberUint64(void *arg) "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %lld", uresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE); @@ -632,7 +632,7 @@ sdltest_randomBoundaryNumberSint8(void *arg) "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE); @@ -642,7 +642,7 @@ sdltest_randomBoundaryNumberSint8(void *arg) "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SCHAR_MAX, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE); @@ -742,7 +742,7 @@ sdltest_randomBoundaryNumberSint16(void *arg) "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE); @@ -752,7 +752,7 @@ sdltest_randomBoundaryNumberSint16(void *arg) "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SHRT_MAX, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE); @@ -859,7 +859,7 @@ sdltest_randomBoundaryNumberSint32(void *arg) "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE); @@ -869,7 +869,7 @@ sdltest_randomBoundaryNumberSint32(void *arg) "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", long_max, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE); @@ -969,7 +969,7 @@ sdltest_randomBoundaryNumberSint64(void *arg) "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE); @@ -979,7 +979,7 @@ sdltest_randomBoundaryNumberSint64(void *arg) "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %lld, got: %lld", LLONG_MAX, sresult); lastError = (char *)SDL_GetError(); SDLTest_AssertPass("SDL_GetError()"); - SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set"); + SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set"); /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE); diff --git a/test/testime.c b/test/testime.c index 0baf43733..93b33e0c6 100644 --- a/test/testime.c +++ b/test/testime.c @@ -331,7 +331,7 @@ int main(int argc, char *argv[]) { break; case SDL_TEXTINPUT: - if (SDL_strlen(event.text.text) == 0 || event.text.text[0] == '\n' || + if (event.text.text[0] == '\0' || event.text.text[0] == '\n' || markedRect.w < 0) break; From f8c07dc1bd4cbb22a4c69140e187440af483adde Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 29 Aug 2013 14:03:44 -0300 Subject: [PATCH 090/258] Fixes bug #2074 - Thanks Sylvain! SDL_syssem.c:159 comparison of unsigned expression >= 0 is always true Solved by comparing unsigneds directly SDL_systimer.c:164: warning: control may reach end of Compile Solved by returning the default value if all else fails. SDL_androidgl.c:41:1: warning: type specifier missing, defaults to 'int' SDL_androidgl.c:47:1: warning: control reaches end of non-void function Solved by adding void return type to the function implementation --- src/thread/pthread/SDL_syssem.c | 2 +- src/timer/unix/SDL_systimer.c | 6 +++--- src/video/android/SDL_androidgl.c | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 4acd6bfb5..91932f64c 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -156,7 +156,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) #else end = SDL_GetTicks() + timeout; while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) { - if ((SDL_GetTicks() - end) >= 0) { + if (SDL_GetTicks() >= end) { break; } SDL_Delay(0); diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 134c12a91..88a40ba51 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -158,9 +158,9 @@ SDL_GetPerformanceFrequency(void) freq /= mach_base_info.numer; return freq; #endif - } else { - return 1000000; - } + } + + return 1000000; } void diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index 1a3eb4c5f..691fbf7fb 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -38,6 +38,7 @@ SDL_EGL_CreateContext_impl(Android) SDL_EGL_MakeCurrent_impl(Android) +void Android_GLES_SwapWindow(_THIS, SDL_Window * window) { /* FIXME: These two functions were in the Java code, do we really need them? */ From efb1f10b7ccee9a3c15c194a77c347e75d5917ad Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 29 Aug 2013 15:02:32 -0300 Subject: [PATCH 091/258] Fixes bug #2040, prepare SDL_GL_CONTEXT_EGL for deprecation on v2.1 SDL_GL_CONTEXT_EGL = 1 is now internally treated as profile_mask = SDL_GL_CONTEXT_PROFILE_ES --- src/render/opengles/SDL_render_gles.c | 2 +- src/render/opengles2/SDL_render_gles2.c | 2 +- src/video/SDL_video.c | 28 ++++++++------ src/video/x11/SDL_x11opengl.c | 51 +++++++++++-------------- src/video/x11/SDL_x11opengles.c | 4 +- src/video/x11/SDL_x11window.c | 10 +++-- 6 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 1b3ea0f79..b3ce79096 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -280,7 +280,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) GLint value; Uint32 windowFlags; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index db030c6c0..484186e33 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1628,7 +1628,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) Uint32 windowFlags; GLint window_framebuffer; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 53e6e0208..72bd07470 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -477,26 +477,21 @@ SDL_VideoInit(const char *driver_name) _this->gl_config.multisamplesamples = 0; _this->gl_config.retained_backing = 1; _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ + _this->gl_config.profile_mask = 0; #if SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; _this->gl_config.minor_version = 1; - _this->gl_config.use_egl = 0; #elif SDL_VIDEO_OPENGL_ES _this->gl_config.major_version = 1; _this->gl_config.minor_version = 1; -#if SDL_VIDEO_OPENGL_EGL - _this->gl_config.use_egl = 1; -#endif + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; #elif SDL_VIDEO_OPENGL_ES2 _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; -#if SDL_VIDEO_OPENGL_EGL - _this->gl_config.use_egl = 1; -#endif - + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; #endif _this->gl_config.flags = 0; - _this->gl_config.profile_mask = 0; + _this->gl_config.share_with_current_context = 0; _this->current_glwin_tls = SDL_TLSCreate(); @@ -2516,7 +2511,12 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) _this->gl_config.minor_version = value; break; case SDL_GL_CONTEXT_EGL: - _this->gl_config.use_egl = value; + /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */ + if (value != 0) { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + } else { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); + }; break; case SDL_GL_CONTEXT_FLAGS: if( value & ~(SDL_GL_CONTEXT_DEBUG_FLAG | @@ -2686,8 +2686,14 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return 0; } case SDL_GL_CONTEXT_EGL: + /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */ { - *value = _this->gl_config.use_egl; + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { + *value = 1; + } + else { + *value = 0; + } return 0; } case SDL_GL_CONTEXT_FLAGS: diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 6f1cc8b6b..67a4b06cc 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -210,36 +210,31 @@ X11_GL_LoadLibrary(_THIS, const char *path) /* Initialize extensions */ X11_GL_InitExtensions(_this); - /* If SDL_GL_CONTEXT_EGL has been changed to 1, and there's - * no GLX_EXT_create_context_es2_profile extension switch over to X11_GLES functions */ - if (_this->gl_config.use_egl == 1) { - if (_this->gl_data->HAS_GLX_EXT_create_context_es2_profile) { - /* We cheat a little bit here by using GLX instead of EGL - * to improve our chances of getting hardware acceleration */ - _this->gl_config.use_egl = 0; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; - } else { + /* If we need a GL ES context and there's no + * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions + */ + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && + ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) { #if SDL_VIDEO_OPENGL_EGL - X11_GL_UnloadLibrary(_this); - /* Better avoid conflicts! */ - if (_this->gl_config.dll_handle != NULL ) { - GL_UnloadObject(_this->gl_config.dll_handle); - _this->gl_config.dll_handle = NULL; - } - _this->GL_LoadLibrary = X11_GLES_LoadLibrary; - _this->GL_GetProcAddress = X11_GLES_GetProcAddress; - _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; - _this->GL_CreateContext = X11_GLES_CreateContext; - _this->GL_MakeCurrent = X11_GLES_MakeCurrent; - _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; - _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; - _this->GL_SwapWindow = X11_GLES_SwapWindow; - _this->GL_DeleteContext = X11_GLES_DeleteContext; - return X11_GLES_LoadLibrary(_this, NULL); -#else - return SDL_SetError("SDL not configured with EGL support"); -#endif + X11_GL_UnloadLibrary(_this); + /* Better avoid conflicts! */ + if (_this->gl_config.dll_handle != NULL ) { + GL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; } + _this->GL_LoadLibrary = X11_GLES_LoadLibrary; + _this->GL_GetProcAddress = X11_GLES_GetProcAddress; + _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; + _this->GL_CreateContext = X11_GLES_CreateContext; + _this->GL_MakeCurrent = X11_GLES_MakeCurrent; + _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; + _this->GL_SwapWindow = X11_GLES_SwapWindow; + _this->GL_DeleteContext = X11_GLES_DeleteContext; + return X11_GLES_LoadLibrary(_this, NULL); +#else + return SDL_SetError("SDL not configured with EGL support"); +#endif } return 0; diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 2d2054ae3..98183258f 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -33,8 +33,8 @@ X11_GLES_LoadLibrary(_THIS, const char *path) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - /* If SDL_GL_CONTEXT_EGL has been changed to 0, switch over to X11_GL functions */ - if (_this->gl_config.use_egl == 0) { + /* If the profile requested is not GL ES, switch over to X11_GL functions */ + if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { #if SDL_VIDEO_OPENGL_GLX _this->GL_LoadLibrary = X11_GL_LoadLibrary; _this->GL_GetProcAddress = X11_GL_GetProcAddress; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 6bc2eb950..a8915289e 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -366,10 +366,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { - XVisualInfo *vinfo; + XVisualInfo *vinfo = NULL; #if SDL_VIDEO_OPENGL_EGL - if (_this->gl_config.use_egl == 1) { + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && + ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile )) { vinfo = X11_GLES_GetVisual(_this, display, screen); } else #endif @@ -378,6 +379,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) vinfo = X11_GL_GetVisual(_this, display, screen); #endif } + if (!vinfo) { return -1; } @@ -551,7 +553,9 @@ X11_CreateWindow(_THIS, SDL_Window * window) windowdata = (SDL_WindowData *) window->driverdata; #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) { + if ((window->flags & SDL_WINDOW_OPENGL) && + _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && + (!_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile) ) { if (!_this->egl_data) { XDestroyWindow(display, w); return -1; From c4aae28ea4bbe54daa37faf8aa8fbc3b22671449 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 31 Aug 2013 01:36:38 -0400 Subject: [PATCH 092/258] Enabled thread naming on Windows. This is now done without compiler or C runtime support for __try/__except. (Granted, it uses Visual Studio-style inline asm, but still...) --- src/thread/windows/SDL_systhread.c | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 6cf826ec7..7117ba394 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -146,6 +146,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) } #ifdef _MSC_VER +#pragma warning(disable : 4733) #pragma pack(push,8) typedef struct tagTHREADNAME_INFO { @@ -155,31 +156,46 @@ typedef struct tagTHREADNAME_INFO DWORD dwFlags; /* reserved for future use, must be zero */ } THREADNAME_INFO; #pragma pack(pop) + +static EXCEPTION_DISPOSITION +ignore_exception(void *a, void *b, void *c, void *d) +{ + return ExceptionContinueExecution; +} #endif void SDL_SYS_SetupThread(const char *name) { if (name != NULL) { - #if 0 /* !!! FIXME: __except needs C runtime, which we don't link against. */ - #ifdef _MSC_VER /* !!! FIXME: can we do SEH on other compilers yet? */ - /* This magic tells the debugger to name a thread if it's listening. */ + #ifdef _MSC_VER + /* This magic tells the debugger to name a thread if it's listening. + The inline asm sets up SEH (__try/__except) without C runtime + support. See Microsoft Systems Journal, January 1997: + http://www.microsoft.com/msj/0197/exception/exception.aspx */ + INT_PTR handler = (INT_PTR) ignore_exception; THREADNAME_INFO inf; + inf.dwType = 0x1000; inf.szName = name; inf.dwThreadID = (DWORD) -1; inf.dwFlags = 0; - __try - { - RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf); + __asm { /* set up SEH */ + push handler + push fs:[0] + mov fs:[0],esp } - __except(EXCEPTION_CONTINUE_EXECUTION) - { - /* The program itself should ignore this bogus exception. */ + + /* The program itself should ignore this bogus exception. */ + RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf); + + __asm { /* tear down SEH. */ + mov eax,[esp] + mov fs:[0], eax + add esp, 8 } #endif - #endif } } From d7839b78272e109ffbdf98a05bc281a459fee835 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 4 Sep 2013 23:40:11 -0400 Subject: [PATCH 093/258] The SDL_PixelFormat* passed to SDL_ConvertSurface() should be const. --- include/SDL_surface.h | 2 +- src/video/SDL_surface.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_surface.h b/include/SDL_surface.h index 4062012df..e18153a69 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -357,7 +357,7 @@ extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, * surface. */ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface - (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags); + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 84d3a4dc6..1c4631c40 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -801,7 +801,7 @@ SDL_UnlockSurface(SDL_Surface * surface) * Convert a surface into the specified pixel format. */ SDL_Surface * -SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format, +SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format, Uint32 flags) { SDL_Surface *convert; From 961b96e84222d2c0421c6073b9806c8b78e112fc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 5 Sep 2013 06:43:34 -0700 Subject: [PATCH 094/258] Fixed bug 2084 - SDL_log xxx on Android outputs to Logcat with incorrect priority. Pallav Nawani This effects all SDL_Logxxx functions. On android, the debug output has a priority that is 1 higher than intended, ie, if you try SDL_LogInfo, the log has the priority of Warn instead. --- src/SDL_log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SDL_log.c b/src/SDL_log.c index e47249021..802a6f25c 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -84,6 +84,7 @@ static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = { }; static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { + ANDROID_LOG_UNKNOWN, ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, From e74da385291d7d5bb43bb8476a5399329ed0956b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 5 Sep 2013 06:59:34 -0700 Subject: [PATCH 095/258] Fixed bug 2082 - SDL stdlib implementation does not force upper case for %X format specifier norfanin When SDL_vsnprintf handles the %x format specifier, a boolean is set to signal forced lower case. It also should be able to signal forced upper case for the %X specifier. A boolean is not sufficient anymore. The attached patch adds an enum for the three cases: lower, upper and no change. --- src/stdlib/SDL_string.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 89f5f358e..980f025ae 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -1293,13 +1293,20 @@ int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) } #else /* FIXME: implement more of the format specifiers */ +typedef enum +{ + SDL_CASE_NOCHANGE, + SDL_CASE_LOWER, + SDL_CASE_UPPER +} SDL_letter_case; + typedef struct { SDL_bool left_justify; SDL_bool force_sign; SDL_bool force_type; SDL_bool pad_zeroes; - SDL_bool do_lowercase; + SDL_letter_case force_case; int width; int radix; int precision; @@ -1322,8 +1329,12 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str length += SDL_strlcpy(text, string, maxlen); - if (info && info->do_lowercase) { - SDL_strlwr(text); + if (info) { + if (info->force_case == SDL_CASE_LOWER) { + SDL_strlwr(text); + } else if (info->force_case == SDL_CASE_UPPER) { + SDL_strupr(text); + } } return length; } @@ -1573,9 +1584,12 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) break; case 'p': case 'x': - info.do_lowercase = SDL_TRUE; + info.force_case = SDL_CASE_LOWER; /* Fall through to 'X' handling */ case 'X': + if (info.force_case == SDL_CASE_NOCHANGE) { + info.force_case = SDL_CASE_UPPER; + } if (info.radix == 10) { info.radix = 16; } From 494f3f253ecdd93126007f2f2d14f5bd3f2dbdd3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 5 Sep 2013 07:02:27 -0700 Subject: [PATCH 096/258] Fixed bug 2081 - Add name to SDL_Point structure Dmitry Marakasov Unlike SDL_Rect (typedef struct SDL_Rect {} SDL_Rect), SDL_Point (typedef struct {} SDL_Point) structure is unnamed. This feels inconsistent and makes it impossible to use forward declaration for SDL_Point, having to include whole SDL_rect.h instead. --- include/SDL_rect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_rect.h b/include/SDL_rect.h index c8af7c197..7132e1b44 100644 --- a/include/SDL_rect.h +++ b/include/SDL_rect.h @@ -44,7 +44,7 @@ extern "C" { * * \sa SDL_EnclosePoints */ -typedef struct +typedef struct SDL_Point { int x; int y; From 1fbbf57ee3748f583821b56b1e90784b2c6f3f6f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 5 Sep 2013 07:15:26 -0700 Subject: [PATCH 097/258] Fixed bug 2076 - OpenGL doesn't work with --disable-threads stepik-777 Thread local storage is used to store current window and current opengl context. OpenGL worked before this changeset: 7596 (45e5c263c096) --- src/thread/SDL_systhread.h | 1 + src/thread/SDL_thread.c | 4 ++++ src/thread/SDL_thread_c.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index 738ea27b0..36898f389 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -26,6 +26,7 @@ #define _SDL_systhread_h #include "SDL_thread.h" +#include "SDL_thread_c.h" /* This function creates a thread, passing args to SDL_RunThread(), saves a system-dependent thread id in thread->id, and returns 0 diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 5eaed0c0c..4b070dadc 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -125,6 +125,7 @@ SDL_Generic_GetTLSData() SDL_TLSEntry *entry; SDL_TLSData *storage = NULL; +#if !SDL_THREADS_DISABLED if (!SDL_generic_TLS_mutex) { static SDL_SpinLock tls_lock; SDL_AtomicLock(&tls_lock); @@ -139,6 +140,7 @@ SDL_Generic_GetTLSData() } SDL_AtomicUnlock(&tls_lock); } +#endif /* SDL_THREADS_DISABLED */ SDL_MemoryBarrierAcquire(); SDL_LockMutex(SDL_generic_TLS_mutex); @@ -148,7 +150,9 @@ SDL_Generic_GetTLSData() break; } } +#if !SDL_THREADS_DISABLED SDL_UnlockMutex(SDL_generic_TLS_mutex); +#endif return storage; } diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 1971ded24..c7b063e07 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -23,6 +23,8 @@ #ifndef _SDL_thread_c_h #define _SDL_thread_c_h +#include "SDL_thread.h" + /* Need the definitions of SYS_ThreadHandle */ #if SDL_THREADS_DISABLED #include "generic/SDL_systhread_c.h" From 70519db23994bda618d7cebd496cafa316dafc54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Thu, 5 Sep 2013 15:49:57 -0700 Subject: [PATCH 098/258] Fix to buffer overrun in SDL_JoystickGetGUIDString(). --- src/joystick/SDL_joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 730939502..805eb5e2f 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -776,7 +776,7 @@ void SDL_JoystickGetGUIDString( SDL_JoystickGUID guid, char *pszGUID, int cbGUID return; } - for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1); i++ ) + for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1)/2; i++ ) { /* each input byte writes 2 ascii chars, and might write a null byte. */ /* If we don't have room for next input byte, stop */ From 651f894b694802dacb57ff3fdf3a73f92a81341f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 6 Sep 2013 20:45:08 -0700 Subject: [PATCH 099/258] Fixed time comparison and explicitly delay 1 ms instead of an arbitrary scheduled time. --- src/thread/pthread/SDL_syssem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 91932f64c..b10f9b0df 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -156,10 +156,10 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) #else end = SDL_GetTicks() + timeout; while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) { - if (SDL_GetTicks() >= end) { + if ((Sint32)(SDL_GetTicks() - end) >= 0) { break; } - SDL_Delay(0); + SDL_Delay(1); } #endif /* HAVE_SEM_TIMEDWAIT */ From 8d1d55e8fc0950fdb25d43e1986d4cb6f4bd950a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 6 Sep 2013 20:54:14 -0700 Subject: [PATCH 100/258] Fixed bug 2090 - Some joystick inputs are delayed on FreeBSD kikuchan Some joysticks with high sampling rate need to be read() more fast, otherwise it delay user inputs due to internal queue. Especially, an app that issues SDL_PollEvent() not so frequent --- src/joystick/bsd/SDL_sysjoystick.c | 164 ++++++++++++++--------------- 1 file changed, 80 insertions(+), 84 deletions(-) diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index c5816b6b7..41a8693d6 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -446,48 +446,47 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy) static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; if (joy->hwdata->type == BSDJOY_JOY) { - if (read(joy->hwdata->fd, &gameport, sizeof gameport) != - sizeof gameport) - return; - if (abs(x - gameport.x) > 8) { - x = gameport.x; - if (x < xmin) { - xmin = x; + while (read(joy->hwdata->fd, &gameport, sizeof gameport) == sizeof gameport) { + if (abs(x - gameport.x) > 8) { + x = gameport.x; + if (x < xmin) { + xmin = x; + } + if (x > xmax) { + xmax = x; + } + if (xmin == xmax) { + xmin--; + xmax++; + } + v = (Sint32) x; + v -= (xmax + xmin + 1) / 2; + v *= 32768 / ((xmax - xmin + 1) / 2); + SDL_PrivateJoystickAxis(joy, 0, v); } - if (x > xmax) { - xmax = x; + if (abs(y - gameport.y) > 8) { + y = gameport.y; + if (y < ymin) { + ymin = y; + } + if (y > ymax) { + ymax = y; + } + if (ymin == ymax) { + ymin--; + ymax++; + } + v = (Sint32) y; + v -= (ymax + ymin + 1) / 2; + v *= 32768 / ((ymax - ymin + 1) / 2); + SDL_PrivateJoystickAxis(joy, 1, v); } - if (xmin == xmax) { - xmin--; - xmax++; + if (gameport.b1 != joy->buttons[0]) { + SDL_PrivateJoystickButton(joy, 0, gameport.b1); } - v = (Sint32) x; - v -= (xmax + xmin + 1) / 2; - v *= 32768 / ((xmax - xmin + 1) / 2); - SDL_PrivateJoystickAxis(joy, 0, v); - } - if (abs(y - gameport.y) > 8) { - y = gameport.y; - if (y < ymin) { - ymin = y; + if (gameport.b2 != joy->buttons[1]) { + SDL_PrivateJoystickButton(joy, 1, gameport.b2); } - if (y > ymax) { - ymax = y; - } - if (ymin == ymax) { - ymin--; - ymax++; - } - v = (Sint32) y; - v -= (ymax + ymin + 1) / 2; - v *= 32768 / ((ymax - ymin + 1) / 2); - SDL_PrivateJoystickAxis(joy, 1, v); - } - if (gameport.b1 != joy->buttons[0]) { - SDL_PrivateJoystickButton(joy, 0, gameport.b1); - } - if (gameport.b2 != joy->buttons[1]) { - SDL_PrivateJoystickButton(joy, 1, gameport.b2); } return; } @@ -495,65 +494,62 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy) rep = &joy->hwdata->inreport; - if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { - return; - } + while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) { #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) - hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); + hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); #else - hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); + hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { - fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path); - return; - } + if (hdata == NULL) { + /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ + continue; + } - for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) { - switch (hitem.kind) { - case hid_input: - switch (HID_PAGE(hitem.usage)) { - case HUP_GENERIC_DESKTOP: - { - unsigned usage = HID_USAGE(hitem.usage); - int joyaxe = usage_to_joyaxe(usage); - if (joyaxe >= 0) { - naxe = joy->hwdata->axis_map[joyaxe]; - /* scaleaxe */ - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - v -= (hitem.logical_maximum + - hitem.logical_minimum + 1) / 2; - v *= 32768 / - ((hitem.logical_maximum - - hitem.logical_minimum + 1) / 2); - if (v != joy->axes[naxe]) { - SDL_PrivateJoystickAxis(joy, naxe, v); + for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) { + switch (hitem.kind) { + case hid_input: + switch (HID_PAGE(hitem.usage)) { + case HUP_GENERIC_DESKTOP: + { + unsigned usage = HID_USAGE(hitem.usage); + int joyaxe = usage_to_joyaxe(usage); + if (joyaxe >= 0) { + naxe = joy->hwdata->axis_map[joyaxe]; + /* scaleaxe */ + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + v -= (hitem.logical_maximum + + hitem.logical_minimum + 1) / 2; + v *= 32768 / + ((hitem.logical_maximum - + hitem.logical_minimum + 1) / 2); + if (v != joy->axes[naxe]) { + SDL_PrivateJoystickAxis(joy, naxe, v); + } + } else if (usage == HUG_HAT_SWITCH) { + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, + hatval_to_sdl(v) - + hitem.logical_minimum); } - } else if (usage == HUG_HAT_SWITCH) { - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, - hatval_to_sdl(v) - - hitem.logical_minimum); + break; } + case HUP_BUTTON: + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + if (joy->buttons[nbutton] != v) { + SDL_PrivateJoystickButton(joy, nbutton, v); + } + nbutton++; break; + default: + continue; } - case HUP_BUTTON: - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - if (joy->buttons[nbutton] != v) { - SDL_PrivateJoystickButton(joy, nbutton, v); - } - nbutton++; break; default: - continue; + break; } - break; - default: - break; } + hid_end_parse(hdata); } - hid_end_parse(hdata); - - return; } /* Function to close a joystick after use */ From f48477bea06095ebe95143bdb1d4b6ddd34d8534 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 7 Sep 2013 13:47:14 -0400 Subject: [PATCH 101/258] Disable thread naming on Win64 for now. We can't use _try/_except without the C runtime, and we can't use inline asm with the Win64 compiler. We'll need to move this to an .asm file or something later. --HG-- extra : rebase_source : 2f1b255b44b4a5d9b88d9257eb3e064e485dd760 --- src/thread/windows/SDL_systhread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 7117ba394..8efcd5089 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -168,7 +168,7 @@ void SDL_SYS_SetupThread(const char *name) { if (name != NULL) { - #ifdef _MSC_VER + #if (defined(_MSC_VER) && defined(_M_IX86)) /* This magic tells the debugger to name a thread if it's listening. The inline asm sets up SEH (__try/__except) without C runtime support. See Microsoft Systems Journal, January 1997: From f049ab5e9fe3b1248882956051909f15c300eafc Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 7 Sep 2013 13:57:20 -0400 Subject: [PATCH 102/258] Workaround for compiling with /W4 warnings on Visual C++. --- include/SDL_assert.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/SDL_assert.h b/include/SDL_assert.h index 53ee9ba74..432943406 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -86,8 +86,14 @@ This also solves the problem of... disable assertions. */ +#ifdef _MSC_VER /* stupid /W4 warnings. */ +#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + #define SDL_disabled_assert(condition) \ - do { (void) sizeof ((condition)); } while (0) + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) typedef enum { @@ -140,7 +146,7 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, } \ break; /* not retrying. */ \ } \ - } while (0) + } while (SDL_NULL_WHILE_LOOP_CONDITION) #endif /* enabled assertions support code */ From 905b5aa01a42feff7f7abf54049885110bb6c220 Mon Sep 17 00:00:00 2001 From: "pgriffais@spaceport" Date: Tue, 10 Sep 2013 18:25:13 -0700 Subject: [PATCH 103/258] [SDL] X11+GL: Allow Visual override for GL windows. SDL provides an SDL_VIDEO_X11_VISUALID environment variable that lets you override window visuals, but it wasn't being checked for OpenGL windows. CR: Sam. --- src/video/x11/SDL_x11window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index a8915289e..2dde727d5 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -365,7 +365,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) Uint32 fevent = 0; #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL - if (window->flags & SDL_WINDOW_OPENGL) { + if ((window->flags & SDL_WINDOW_OPENGL) && + !SDL_getenv("SDL_VIDEO_X11_VISUALID")) { XVisualInfo *vinfo = NULL; #if SDL_VIDEO_OPENGL_EGL From 4e681a4151684af89cbb9a0d3488656731d66ebb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 13 Sep 2013 17:40:41 -0700 Subject: [PATCH 104/258] Mac: Fix cast warning. --- src/video/cocoa/SDL_cocoaopengl.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 0d49ba0cc..33d539378 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -344,7 +344,7 @@ Cocoa_GL_SwapWindow(_THIS, SDL_Window * window) pool = [[NSAutoreleasePool alloc] init]; - SDLOpenGLContext* nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext(); + SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext(); [nscontext flushBuffer]; [nscontext updateIfNeeded]; From 23c6df8eae89afd27b1c2f5287b43cba345425b0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 13 Sep 2013 17:41:17 -0700 Subject: [PATCH 105/258] Mac: Turn off momentum-based scrolling. --- src/video/cocoa/SDL_cocoaevents.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index f0a65e322..6a673c3d3 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -231,6 +231,9 @@ Cocoa_RegisterApp(void) CreateApplicationMenus(); } [NSApp finishLaunching]; + NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"AppleMomentumScrollSupported"]; + [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; + } if (NSApp && ![NSApp delegate]) { [NSApp setDelegate:[[SDLAppDelegate alloc] init]]; From c3ffb3ce884383ad8ed067baa458407c557c0356 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 13 Sep 2013 17:42:31 -0700 Subject: [PATCH 106/258] Mac: Translate Ctrl-Left click to right click. --- src/video/cocoa/SDL_cocoawindow.h | 1 + src/video/cocoa/SDL_cocoawindow.m | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 022694f52..c08c55c11 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -30,6 +30,7 @@ typedef struct SDL_WindowData SDL_WindowData; @interface Cocoa_WindowListener : NSResponder { SDL_WindowData *_data; BOOL observingVisible; + BOOL wasCtrlLeft; BOOL wasVisible; } diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index cd4771d44..ecfab8204 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -62,6 +62,7 @@ static void ScheduleContextUpdates(SDL_WindowData *data) _data = data; observingVisible = YES; + wasCtrlLeft = NO; wasVisible = [window isVisible]; center = [NSNotificationCenter defaultCenter]; @@ -333,7 +334,13 @@ static void ScheduleContextUpdates(SDL_WindowData *data) switch ([theEvent buttonNumber]) { case 0: - button = SDL_BUTTON_LEFT; + if ([theEvent modifierFlags] & NSControlKeyMask) { + wasCtrlLeft = YES; + button = SDL_BUTTON_RIGHT; + } else { + wasCtrlLeft = NO; + button = SDL_BUTTON_LEFT; + } break; case 1: button = SDL_BUTTON_RIGHT; @@ -364,7 +371,12 @@ static void ScheduleContextUpdates(SDL_WindowData *data) switch ([theEvent buttonNumber]) { case 0: - button = SDL_BUTTON_LEFT; + if (wasCtrlLeft) { + button = SDL_BUTTON_RIGHT; + wasCtrlLeft = NO; + } else { + button = SDL_BUTTON_LEFT; + } break; case 1: button = SDL_BUTTON_RIGHT; From 8f58be5fbe4b8b13f6ba42b14f42774c2c2e92b2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 13 Sep 2013 17:42:38 -0700 Subject: [PATCH 107/258] Fix X11_RestoreWindow() and X11_RaiseWindow() to properly do window activation. X11_RestoreWindow() had a call ordering problem that prevented activation, and X11_RaiseWindow() wasn't attempting activation. Windows and OS X both activate in these cases. CR: saml --- src/video/x11/SDL_x11window.c | 59 ++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 2dde727d5..0a8e3dfd5 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -935,6 +935,34 @@ X11_HideWindow(_THIS, SDL_Window * window) } } +static void +SetWindowActive(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_DisplayData *displaydata = + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + Display *display = data->videodata->display; + Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_ACTIVE_WINDOW; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = 1; /* source indication. 1 = application */ + e.xclient.data.l[1] = CurrentTime; + e.xclient.data.l[2] = 0; + + XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + + XFlush(display); + } +} + void X11_RaiseWindow(_THIS, SDL_Window * window) { @@ -942,6 +970,7 @@ X11_RaiseWindow(_THIS, SDL_Window * window) Display *display = data->videodata->display; XRaiseWindow(display, data->xwindow); + SetWindowActive(_this, window); XFlush(display); } @@ -1002,40 +1031,12 @@ X11_MinimizeWindow(_THIS, SDL_Window * window) XFlush(display); } -static void -SetWindowActive(_THIS, SDL_Window * window) -{ - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - Display *display = data->videodata->display; - Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; - - if (X11_IsWindowMapped(_this, window)) { - XEvent e; - - SDL_zero(e); - e.xany.type = ClientMessage; - e.xclient.message_type = _NET_ACTIVE_WINDOW; - e.xclient.format = 32; - e.xclient.window = data->xwindow; - e.xclient.data.l[0] = 1; /* source indication. 1 = application */ - e.xclient.data.l[1] = CurrentTime; - e.xclient.data.l[2] = 0; - - XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); - - XFlush(display); - } -} - void X11_RestoreWindow(_THIS, SDL_Window * window) { SetWindowMaximized(_this, window, SDL_FALSE); - SetWindowActive(_this, window); X11_ShowWindow(_this, window); + SetWindowActive(_this, window); } /* This asks the Window Manager to handle fullscreen for us. Most don't do it right, though. */ From 0d7001777d55945b176045b9c2afd9afaba45c3d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 13 Sep 2013 17:42:46 -0700 Subject: [PATCH 108/258] Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now. CR: Sam --- include/SDL_system.h | 14 ++++- src/render/direct3d/SDL_render_d3d.c | 91 ++++++++++++++++++++++------ src/video/SDL_sysvideo.h | 1 + src/video/SDL_video.c | 8 +++ 4 files changed, 96 insertions(+), 18 deletions(-) diff --git a/include/SDL_system.h b/include/SDL_system.h index 26e9eaa0a..68ff8990a 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -41,6 +41,19 @@ extern "C" { #endif + +/* Platform specific functions for Windows */ +#ifdef __WIN32__ + +/* Returns the D3D9 adapter index that matches the specified display index. + This adapter index can be passed to IDirect3D9::CreateDevice and controls + on which monitor a full screen application will appear. +*/ +extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); + +#endif /* __WIN32__ */ + + /* Platform specific functions for iOS */ #if defined(__IPHONEOS__) && __IPHONEOS__ @@ -93,7 +106,6 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); #endif /* __ANDROID__ */ - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 2ce22626b..d99057e3c 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -29,6 +29,8 @@ #include "SDL_loadso.h" #include "SDL_syswm.h" #include "../SDL_sysrender.h" +#include "../../video/SDL_sysvideo.h" +#include "../../video/windows/SDL_windowsmodes.h" #include #if SDL_VIDEO_RENDER_D3D @@ -531,6 +533,72 @@ D3D_ActivateRenderer(SDL_Renderer * renderer) return 0; } +SDL_bool +D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) +{ + *pD3DDLL = SDL_LoadObject("D3D9.DLL"); + if (*pD3DDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); + + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, + "Direct3DCreate9"); + if (D3DCreate) { + *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); + } + if (!*pDirect3D9Interface) { + SDL_UnloadObject(*pD3DDLL); + *pD3DDLL = NULL; + return SDL_FALSE; + } + + return SDL_TRUE; + } else { + *pDirect3D9Interface = NULL; + return SDL_FALSE; + } +} + + +int +SDL_Direct3D9GetAdapterIndex( int displayIndex ) +{ + void *pD3DDLL; + IDirect3D9 *pD3D; + if (!D3D_LoadDLL( &pD3DDLL, &pD3D)) { + SDL_SetError("Unable to create Direct3D interface"); + return D3DADAPTER_DEFAULT; + } else { + SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData( displayIndex ); + int adapterIndex = D3DADAPTER_DEFAULT; + + if (!pData) { + SDL_SetError( "Invalid display index" ); + } else { + char *displayName = WIN_StringToUTF8( pData->DeviceName ); + unsigned int count = IDirect3D9_GetAdapterCount( pD3D ); + unsigned int i; + for (i=0; id3dDLL = SDL_LoadObject("D3D9.DLL"); - if (data->d3dDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL, - "Direct3DCreate9"); - if (D3DCreate) { - data->d3d = D3DCreate(D3D_SDK_VERSION); - } - if (!data->d3d) { - SDL_UnloadObject(data->d3dDLL); - data->d3dDLL = NULL; - } - + if( D3D_LoadDLL( &data->d3dDLL, &data->d3d ) ) { for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) { LPTSTR dllName; SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion); @@ -667,8 +722,10 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } - /* FIXME: Which adapter? */ - data->adapter = D3DADAPTER_DEFAULT; + /* Get the adapter for the display that the window is on */ + displayIndex = SDL_GetWindowDisplayIndex( window ); + data->adapter = SDL_Direct3D9GetAdapterIndex( displayIndex ); + IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); result = IDirect3D9_CreateDevice(data->d3d, data->adapter, diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 084742fd8..2d36c9d7a 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -371,6 +371,7 @@ extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display); extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window); +extern void *SDL_GetDisplayDriverData( int displayIndex ); extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 72bd07470..8622d731f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -615,6 +615,14 @@ SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) return 0; } +void * +SDL_GetDisplayDriverData( int displayIndex ) +{ + CHECK_DISPLAY_INDEX( displayIndex, NULL ); + + return _this->displays[displayIndex].driverdata; +} + const char * SDL_GetDisplayName(int displayIndex) { From 9e17cee1114956b2dd0e70f82a3cfdae7c4595ff Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 14 Sep 2013 01:30:57 -0400 Subject: [PATCH 109/258] Don't incorrectly report success for negative swap intervals on Mac OS X. --- src/video/cocoa/SDL_cocoaopengl.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 33d539378..93d0b2ad2 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -302,6 +302,10 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval) GLint value; int status; + if (interval < 0) { /* no extension for this on Mac OS X at the moment. */ + return SDL_SetError("Late swap tearing currently unsupported"); + } + pool = [[NSAutoreleasePool alloc] init]; nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext(); From 1af00322ef44ddea189a5cc1fac58cbca44b88cb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 14 Sep 2013 11:25:52 -0700 Subject: [PATCH 110/258] Fixed syntax error in C style block comment. --- src/video/directfb/SDL_DirectFB_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index dc886469e..1a63f5ab1 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -266,7 +266,7 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, case SDL_BLENDMODE_ADD: data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; - /* FIXME: SRCALPHA kills performance on radeon ... */ + /* FIXME: SRCALPHA kills performance on radeon ... * It will be cheaper to copy the surface to a temporary surface and premultiply */ if (source && TextureHasAlpha(source)) From a449178caafdf3f3b10d4e29b7566dad126dff0e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Sep 2013 22:09:51 -0700 Subject: [PATCH 111/258] Default to OpenGL ES 2.0 instead of 1.0 when it's available. --- src/video/SDL_video.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8622d731f..88296928f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -481,14 +481,14 @@ SDL_VideoInit(const char *driver_name) #if SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; _this->gl_config.minor_version = 1; -#elif SDL_VIDEO_OPENGL_ES - _this->gl_config.major_version = 1; - _this->gl_config.minor_version = 1; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; #elif SDL_VIDEO_OPENGL_ES2 _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#elif SDL_VIDEO_OPENGL_ES + _this->gl_config.major_version = 1; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; #endif _this->gl_config.flags = 0; From 3a11d954440bce2db8501d07dda52ac53d10b409 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Fri, 20 Sep 2013 13:43:00 -0400 Subject: [PATCH 112/258] add in High DPI support (aka Retina) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - based on Jørgen's patch with a few bug fixes --- include/SDL_hints.h | 5 +++++ include/SDL_video.h | 29 +++++++++++++++++++++----- src/render/SDL_render.c | 11 +++++++--- src/render/opengl/SDL_render_gl.c | 10 +++++++++ src/test/SDL_test_common.c | 6 +++++- src/video/SDL_sysvideo.h | 1 + src/video/SDL_video.c | 23 +++++++++++++++++++++ src/video/cocoa/SDL_cocoaopengl.h | 2 ++ src/video/cocoa/SDL_cocoaopengl.m | 34 +++++++++++++++++++++++++++++++ src/video/cocoa/SDL_cocoavideo.m | 1 + src/video/cocoa/SDL_cocoawindow.m | 14 +++++++++++++ test/testgl2.c | 9 ++++++-- 12 files changed, 134 insertions(+), 11 deletions(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index 74b63ee09..e90ba2e9d 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -257,6 +257,11 @@ extern "C" { #define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" +/** + * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac) + */ +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_HIGHDPI_DISABLED" + /** * \brief An enumeration of hint priorities diff --git a/include/SDL_video.h b/include/SDL_video.h index d4133b026..6822173a5 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -107,7 +107,8 @@ typedef enum SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), - SDL_WINDOW_FOREIGN = 0x00000800 /**< window not created by SDL */ + SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported */ } SDL_WindowFlags; /** @@ -393,10 +394,11 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); * \param w The width of the window. * \param h The height of the window. * \param flags The flags for the window, a mask of any of the following: - * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, - * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, - * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, - * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED. + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_ALLOW_HIGHDPI. * * \return The id of the window created, or zero if window creation failed. * @@ -899,6 +901,23 @@ extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); */ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); +/** + * \brief Get the size of a window's underlying drawable (for use with glViewport). + * + * \param w Pointer to variable for storing the width, may be NULL + * \param h Pointer to variable for storing the height, may be NULL + * + * This may differ from SDL_GetWindowSize if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, + int *h); + /** * \brief Set the swap interval for the current OpenGL context. * diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 1e7f01f62..ef690cf79 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -117,7 +117,12 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) /* Window was resized, reset viewport */ int w, h; - SDL_GetWindowSize(window, &w, &h); + if (renderer->GetOutputSize) { + renderer->GetOutputSize(renderer, &w, &h); + } else { + SDL_GetWindowSize(renderer->window, &w, &h); + } + if (renderer->target) { renderer->viewport_backup.x = 0; renderer->viewport_backup.y = 0; @@ -335,11 +340,11 @@ SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h) if (renderer->target) { return SDL_QueryTexture(renderer->target, NULL, NULL, w, h); + } else if (renderer->GetOutputSize) { + return renderer->GetOutputSize(renderer, w, h); } else if (renderer->window) { SDL_GetWindowSize(renderer->window, w, h); return 0; - } else if (renderer->GetOutputSize) { - return renderer->GetOutputSize(renderer, w, h); } else { /* This should never happen */ SDL_SetError("Renderer doesn't support querying output size"); diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 043e5017a..cd0a7085d 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -47,6 +47,7 @@ static const float inv255f = 1.0f / 255.0f; static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags); static void GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event); +static int GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, @@ -399,6 +400,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) } renderer->WindowEvent = GL_WindowEvent; + renderer->GetOutputSize = GL_GetOutputSize; renderer->CreateTexture = GL_CreateTexture; renderer->UpdateTexture = GL_UpdateTexture; renderer->LockTexture = GL_LockTexture; @@ -539,6 +541,14 @@ GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } +static int +GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + + return 0; +} + SDL_FORCE_INLINE int power_of_2(int input) { diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 3b2028ab0..e0ff37607 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -27,7 +27,7 @@ #include #define VIDEO_USAGE \ -"[--video driver] [--renderer driver] [--gldebug] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --fullscreen-desktop | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--min-geometry WxH] [--max-geometry WxH] [--logical WxH] [--scale N] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]" +"[--video driver] [--renderer driver] [--gldebug] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --fullscreen-desktop | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--min-geometry WxH] [--max-geometry WxH] [--logical WxH] [--scale N] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--allow-hidpi]" #define AUDIO_USAGE \ "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]" @@ -194,6 +194,10 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) state->num_windows = 1; return 1; } + if (SDL_strcasecmp(argv[index], "--allow-highdpi") == 0) { + state->window_flags |= SDL_WINDOW_ALLOW_HIGHDPI; + return 1; + } if (SDL_strcasecmp(argv[index], "--windows") == 0) { ++index; if (!argv[index] || !SDL_isdigit(*argv[index])) { diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 2d36c9d7a..32966997d 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -224,6 +224,7 @@ struct SDL_VideoDevice void (*GL_UnloadLibrary) (_THIS); SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window); int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context); + void (*GL_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h); int (*GL_SetSwapInterval) (_THIS, int interval); int (*GL_GetSwapInterval) (_THIS); void (*GL_SwapWindow) (_THIS, SDL_Window * window); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 88296928f..b5c31324d 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1187,6 +1187,7 @@ SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { SDL_Window *window; + const char *hint; if (!_this) { /* Initialize the video system if needed */ @@ -1245,6 +1246,17 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); window->brightness = 1.0f; window->next = _this->windows; + + /* Unless the user has specified the high-DPI disabling hint, respect the + * SDL_WINDOW_ALLOW_HIGHDPI flag. + */ + hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED); + if (!hint || *hint != '1') { + if ((flags & SDL_WINDOW_ALLOW_HIGHDPI)) { + window->flags |= SDL_WINDOW_ALLOW_HIGHDPI; + } + } + if (_this->windows) { _this->windows->prev = window; } @@ -2813,6 +2825,17 @@ SDL_GL_GetCurrentContext(void) return (SDL_GLContext)SDL_TLSGet(_this->current_glctx_tls); } +void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) +{ + CHECK_WINDOW_MAGIC(window, ); + + if (_this->GL_GetDrawableSize) { + _this->GL_GetDrawableSize(_this, window, w, h); + } else { + SDL_GetWindowSize(window, w, h); + } +} + int SDL_GL_SetSwapInterval(int interval) { diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index 2d06700b6..e7ef1f66c 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -54,6 +54,8 @@ extern void Cocoa_GL_UnloadLibrary(_THIS); extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window); extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern void Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, + int * w, int * h); extern int Cocoa_GL_SetSwapInterval(_THIS, int interval); extern int Cocoa_GL_GetSwapInterval(_THIS); extern void Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 93d0b2ad2..13c7777b1 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -35,6 +35,18 @@ #define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +/* New methods for converting to and from backing store pixels, taken from + * AppKite/NSView.h in 10.8 SDK. */ +@interface NSView (Backing) +- (NSPoint)convertPointToBacking:(NSPoint)aPoint; +- (NSPoint)convertPointFromBacking:(NSPoint)aPoint; +- (NSSize)convertSizeToBacking:(NSSize)aSize; +- (NSSize)convertSizeFromBacking:(NSSize)aSize; +- (NSRect)convertRectToBacking:(NSRect)aRect; +- (NSRect)convertRectFromBacking:(NSRect)aRect; +@end +#endif #ifndef kCGLPFAOpenGLProfile #define kCGLPFAOpenGLProfile 99 @@ -294,6 +306,28 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; } +void +Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) +{ + SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; + NSView *contentView = [windata->nswindow contentView]; + NSRect viewport = [contentView bounds]; + + /* This gives us the correct viewport for a Retina-enabled view, only + * supported on 10.7+. */ + if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) { + viewport = [contentView convertRectToBacking:viewport]; + } + + if (w) { + *w = viewport.size.width; + } + + if (h) { + *h = viewport.size.height; + } +} + int Cocoa_GL_SetSwapInterval(_THIS, int interval) { diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index da71df03f..d1b958768 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -119,6 +119,7 @@ Cocoa_CreateDevice(int devindex) device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; device->GL_CreateContext = Cocoa_GL_CreateContext; device->GL_MakeCurrent = Cocoa_GL_MakeCurrent; + device->GL_GetDrawableSize = Cocoa_GL_GetDrawableSize; device->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; device->GL_SwapWindow = Cocoa_GL_SwapWindow; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index ecfab8204..581590b67 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -34,6 +34,13 @@ #include "SDL_cocoamouse.h" #include "SDL_cocoaopengl.h" +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +/* Taken from AppKit/NSOpenGLView.h in 10.8 SDK. */ +@interface NSView (NSOpenGLSurfaceResolution) +- (BOOL)wantsBestResolutionOpenGLSurface; +- (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; +@end +#endif static Uint32 s_moveHack; @@ -739,6 +746,13 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) /* Create a default view for this window */ rect = [nswindow contentRectForFrameRect:[nswindow frame]]; NSView *contentView = [[SDLView alloc] initWithFrame:rect]; + + if ((window->flags & SDL_WINDOW_ALLOW_HIGHDPI) > 0) { + if ([contentView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { + [contentView setWantsBestResolutionOpenGLSurface:YES]; + } + } + [nswindow setContentView: contentView]; [contentView release]; diff --git a/test/testgl2.c b/test/testgl2.c index 571a69d9a..642fe47c6 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -180,6 +180,7 @@ main(int argc, char *argv[]) SDL_Event event; Uint32 then, now, frames; int status; + int dw, dh; /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); @@ -254,6 +255,10 @@ main(int argc, char *argv[]) SDL_GetCurrentDisplayMode(0, &mode); SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format)); SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); + SDL_GetWindowSize(state->windows[0], &dw, &dh); + SDL_Log("Window Size : %d,%d\n", dw, dh); + SDL_GL_GetDrawableSize(state->windows[0], &dw, &dh); + SDL_Log("Draw Size : %d,%d\n", dw, dh); SDL_Log("\n"); SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); @@ -322,7 +327,7 @@ main(int argc, char *argv[]) glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); - + /* Main render loop */ frames = 0; then = SDL_GetTicks(); @@ -336,7 +341,7 @@ main(int argc, char *argv[]) for (i = 0; i < state->num_windows; ++i) { int w, h; SDL_GL_MakeCurrent(state->windows[i], context); - SDL_GetWindowSize(state->windows[i], &w, &h); + SDL_GL_GetDrawableSize(state->windows[i], &w, &h); glViewport(0, 0, w, h); Render(); SDL_GL_SwapWindow(state->windows[i]); From 1a91f805867d397ffe18c23f0f6dfdd7e5df070c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Sep 2013 23:19:22 -0700 Subject: [PATCH 113/258] Fixed the name of the environment variable to match the name of the hint. --- include/SDL_hints.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index e90ba2e9d..9dc9cfe76 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -260,7 +260,7 @@ extern "C" { /** * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac) */ -#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_HIGHDPI_DISABLED" +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" /** From 64ba536a10e27656026f8b723788aa327d67377c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Sep 2013 23:29:05 -0700 Subject: [PATCH 114/258] Fixed bug 2100 - directfb fails to build --- src/video/directfb/SDL_DirectFB_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 1a63f5ab1..4e6645eb8 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -674,7 +674,7 @@ DirectFB_GetTexturePalette(SDL_Renderer * renderer, colors[i].r = entries[i].r; colors[i].g = entries[i].g; colors[i].b = entries[i].b; - colors[i].unused = SDL_ALPHA_OPAQUE; + colors[i].a = SDL_ALPHA_OPAQUE; } return 0; } else { From 75265a79a9219abb658499c6de436ad136abdb10 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Sep 2013 23:35:17 -0700 Subject: [PATCH 115/258] # User Darren Salt # Date 1379621782 -3600 # Thu Sep 19 21:16:22 2013 +0100 Work around a false-positive in the X11 mouse wheel code This false positive occurs when one particular button on my mouse is pressed. The kernel which I'm using is patched to cause a release event to be synthesised immediately when the mouse says that this button is pressed because the mouse doesn't signal release until the button is next pressed. (Also documents a false negative, observed with the horizontal scroll wheel on the same mouse.) --- src/video/x11/SDL_x11events.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 0b577ecb4..c260019c6 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -135,7 +135,9 @@ static Bool X11_IsWheelCheckIfEvent(Display *display, XEvent *chkev, XPointer arg) { XEvent *event = (XEvent *) arg; + /* we only handle buttons 4 and 5 - false positive avoidance */ if (chkev->type == ButtonRelease && + (event->xbutton.button == Button4 || event->xbutton.button == Button5) && chkev->xbutton.button == event->xbutton.button && chkev->xbutton.time == event->xbutton.time) return True; @@ -150,7 +152,12 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) however, mouse wheel events trigger a button press and a button release immediately. thus, checking if the same button was released at the same time as it was pressed, should be an adequate hack to derive a mouse - wheel event. */ + wheel event. + However, there is broken and unusual hardware out there... + - False positive: a button for which a release event is + generated (or synthesised) immediately. + - False negative: a wheel which, when rolled, doesn't have + a release event generated immediately. */ if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, (XPointer) event)) { From 55fe573688b647a8345c11f049a996c32c55afbc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Sep 2013 23:47:57 -0700 Subject: [PATCH 116/258] Fixed bug 2101 - CWBackPixel causes weird window flickering on window resize aBothe I tried to experiment a bit with SDL2 and OpenGL today and noticed that something caused some weird flickering when resizing my nicely drawn SDL2/OpenGL window: Just after resizing, the background went black and I had to let my OpenGL code redraw the contents.. However, after some hours spent with googling I found out that in OpenGL examples where this CWBackPixel flag was not used when creating X windows, there was no flickering while resizing the window. See http://www.sbin.org/doc/Xlib/chapt_04.html @ "The Window Background" for more info. --- src/video/x11/SDL_x11window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 0a8e3dfd5..07e863bc8 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -395,7 +395,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } xattr.override_redirect = False; - xattr.background_pixel = 0; + xattr.background_pixmap = None; xattr.border_pixel = 0; if (visual->class == DirectColor) { @@ -480,7 +480,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) w = XCreateWindow(display, RootWindow(display, screen), window->x, window->y, window->w, window->h, 0, depth, InputOutput, visual, - (CWOverrideRedirect | CWBackPixel | CWBorderPixel | + (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | CWColormap), &xattr); if (!w) { return SDL_SetError("Couldn't create window"); From 95e08da47b26d27efdf8c6e3d26170890405756a Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sat, 28 Sep 2013 12:48:26 +0200 Subject: [PATCH 117/258] Corrected name of SDL_Color field from unused to a. --- src/video/directfb/SDL_DirectFB_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 4e6645eb8..3e8ba4759 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -308,7 +308,7 @@ DisplayPaletteChanged(void *userdata, SDL_Palette * palette) entries[i].r = palette->colors[i].r; entries[i].g = palette->colors[i].g; entries[i].b = palette->colors[i].b; - entries[i].a = palette->colors[i].unused; + entries[i].a = palette->colors[i].a; } SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0)); return 0; From e0b5831e142a075e6c49a9fc8c4f25412cab3297 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sat, 28 Sep 2013 12:55:32 +0200 Subject: [PATCH 118/258] Fixed doxygen warning. --- include/SDL_video.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/SDL_video.h b/include/SDL_video.h index 6822173a5..3b02cce2f 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -904,6 +904,7 @@ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); /** * \brief Get the size of a window's underlying drawable (for use with glViewport). * + * \param window Window from which the drawable size should be queried * \param w Pointer to variable for storing the width, may be NULL * \param h Pointer to variable for storing the height, may be NULL * From c7f38347b753870eafdfc10dfeaad504ea5f96bd Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sat, 28 Sep 2013 13:28:19 -0300 Subject: [PATCH 119/258] Raspberry Pi support (also unified UDEV and EVDEV support) --- README-raspberrypi.txt | 48 ++ build-scripts/config.guess | 8 +- configure | 23 + configure.in | 23 + include/SDL_config.h.in | 1 + src/core/linux/SDL_udev.c | 404 ++++++++++++++++ src/core/linux/SDL_udev.h | 114 +++++ src/events/SDL_mouse.c | 2 - src/input/evdev/SDL_evdev.c | 646 ++++++++++++++++++++++++++ src/input/evdev/SDL_evdev.h | 65 +++ src/video/SDL_egl.c | 92 ++-- src/video/SDL_sysvideo.h | 3 + src/video/SDL_video.c | 3 + src/video/raspberry/SDL_rpievents.c | 45 ++ src/video/raspberry/SDL_rpievents_c.h | 31 ++ src/video/raspberry/SDL_rpimouse.c | 277 +++++++++++ src/video/raspberry/SDL_rpimouse.h | 43 ++ src/video/raspberry/SDL_rpiopengles.c | 42 ++ src/video/raspberry/SDL_rpiopengles.h | 48 ++ src/video/raspberry/SDL_rpivideo.c | 361 ++++++++++++++ src/video/raspberry/SDL_rpivideo.h | 98 ++++ 21 files changed, 2331 insertions(+), 46 deletions(-) create mode 100644 README-raspberrypi.txt create mode 100644 src/core/linux/SDL_udev.c create mode 100644 src/core/linux/SDL_udev.h create mode 100644 src/input/evdev/SDL_evdev.c create mode 100644 src/input/evdev/SDL_evdev.h create mode 100644 src/video/raspberry/SDL_rpievents.c create mode 100644 src/video/raspberry/SDL_rpievents_c.h create mode 100644 src/video/raspberry/SDL_rpimouse.c create mode 100644 src/video/raspberry/SDL_rpimouse.h create mode 100644 src/video/raspberry/SDL_rpiopengles.c create mode 100644 src/video/raspberry/SDL_rpiopengles.h create mode 100644 src/video/raspberry/SDL_rpivideo.c create mode 100644 src/video/raspberry/SDL_rpivideo.h diff --git a/README-raspberrypi.txt b/README-raspberrypi.txt new file mode 100644 index 000000000..a95932dae --- /dev/null +++ b/README-raspberrypi.txt @@ -0,0 +1,48 @@ +================================================================================ +SDL2 for Raspberry Pi +================================================================================ + +Requirements: + +Raspbian (other Linux distros may work as well). + +================================================================================ + Features +================================================================================ + +* Works without X11 +* Hardware accelerated OpenGL ES 2.x +* Sound via ALSA +* Input (mouse/keyboard/joystick) via EVDEV +* Hotplugging of input devices via UDEV + +================================================================================ + Raspbian Build Dependencies +================================================================================ + +sudo apt-get install libudev-dev libasound2-dev + +You also need the VideoCore binary stuff that ships in /opt/vc for EGL and +OpenGL ES 2.x, it usually comes pre installed, but in any case: + +sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev + +================================================================================ + No HDMI Audio +================================================================================ + +If you notice that ALSA works but there's no audio over HDMI, try adding: + + hdmi_drive=2 + +to your config.txt file and reboot. + +Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062 + +================================================================================ + Notes +================================================================================ + +* Building has only been tested natively (i.e. not cross compiled). Cross + compilation might work though, feedback is welcome! +* No Text Input yet. \ No newline at end of file diff --git a/build-scripts/config.guess b/build-scripts/config.guess index 137bedf2e..ddb36220a 100644 --- a/build-scripts/config.guess +++ b/build-scripts/config.guess @@ -896,12 +896,16 @@ EOF then echo ${UNAME_MACHINE}-unknown-linux-gnu else + case `sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + BCM2708) MANUFACTURER=raspberry;; + *) MANUFACTURER=unknown;; + esac if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabi else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabihf fi fi exit ;; diff --git a/configure b/configure index dffecba4e..c38982cc7 100755 --- a/configure +++ b/configure @@ -22028,6 +22028,21 @@ fi case "$host" in *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*) case "$host" in + *-raspberry-linux*) + # Raspberry Pi + ARCH=linux + RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux" + RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host" + CFLAGS="$CFLAGS $RPI_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS" + SDL_LIBS="$SDL_LIBS $RPI_LDFLAGS" + + if test x$enable_video = xyes; then + SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c" + $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h + fi + ;; *-*-linux*) ARCH=linux ;; *-*-uclinux*) ARCH=linux ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; @@ -22151,6 +22166,14 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes fi + # Set up files for udev hotplugging support + if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then + SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c" + fi + # Set up files for evdev input + if test x$use_input_events = xyes; then + SOURCES="$SOURCES $srcdir/src/input/evdev/*.c" + fi ;; *-*-cygwin* | *-*-mingw32*) ARCH=win32 diff --git a/configure.in b/configure.in index a1fc311fd..f1d64497b 100644 --- a/configure.in +++ b/configure.in @@ -2343,6 +2343,21 @@ dnl Set up the configuration based on the host platform! case "$host" in *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*) case "$host" in + *-raspberry-linux*) + # Raspberry Pi + ARCH=linux + RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux" + RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host" + CFLAGS="$CFLAGS $RPI_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS" + SDL_LIBS="$SDL_LIBS $RPI_LDFLAGS" + + if test x$enable_video = xyes; then + SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c" + $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h + fi + ;; *-*-linux*) ARCH=linux ;; *-*-uclinux*) ARCH=linux ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; @@ -2450,6 +2465,14 @@ case "$host" in SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes fi + # Set up files for udev hotplugging support + if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then + SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c" + fi + # Set up files for evdev input + if test x$use_input_events = xyes; then + SOURCES="$SOURCES $srcdir/src/input/evdev/*.c" + fi ;; *-*-cygwin* | *-*-mingw32*) ARCH=win32 diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 551c8b3e7..08299411b 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -259,6 +259,7 @@ #undef SDL_VIDEO_DRIVER_DUMMY #undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_X11 +#undef SDL_VIDEO_DRIVER_RPI #undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c new file mode 100644 index 000000000..82f3e6636 --- /dev/null +++ b/src/core/linux/SDL_udev.c @@ -0,0 +1,404 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * To list the properties of a device, try something like: + * udevadm info -a -n snd/hwC0D0 (for a sound card) + * udevadm info --query=all -n input/event3 (for a keyboard, mouse, etc) + * udevadm info --query=property -n input/event2 + */ + +#include "SDL_udev.h" + +#ifdef SDL_USE_LIBUDEV + +static char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" }; + +#define _THIS SDL_UDEV_PrivateData *_this +static _THIS = NULL; + +#include "SDL.h" + +static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr); +static int SDL_UDEV_load_syms(void); +static SDL_bool SDL_UDEV_hotplug_update_available(void); +static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); + +static SDL_bool +SDL_UDEV_load_sym(const char *fn, void **addr) +{ + *addr = SDL_LoadFunction(_this->udev_handle, fn); + if (*addr == NULL) { + /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + return SDL_FALSE; + } + + return SDL_TRUE; +} + +static int +SDL_UDEV_load_syms(void) +{ + /* cast funcs to char* first, to please GCC's strict aliasing rules. */ + #define SDL_UDEV_SYM(x) \ + if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->x)) return -1 + + SDL_UDEV_SYM(udev_device_get_action); + SDL_UDEV_SYM(udev_device_get_devnode); + SDL_UDEV_SYM(udev_device_get_subsystem); + SDL_UDEV_SYM(udev_device_get_property_value); + SDL_UDEV_SYM(udev_device_new_from_syspath); + SDL_UDEV_SYM(udev_device_unref); + SDL_UDEV_SYM(udev_enumerate_add_match_property); + SDL_UDEV_SYM(udev_enumerate_add_match_subsystem); + SDL_UDEV_SYM(udev_enumerate_get_list_entry); + SDL_UDEV_SYM(udev_enumerate_new); + SDL_UDEV_SYM(udev_enumerate_scan_devices); + SDL_UDEV_SYM(udev_enumerate_unref); + SDL_UDEV_SYM(udev_list_entry_get_name); + SDL_UDEV_SYM(udev_list_entry_get_next); + SDL_UDEV_SYM(udev_monitor_enable_receiving); + SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype); + SDL_UDEV_SYM(udev_monitor_get_fd); + SDL_UDEV_SYM(udev_monitor_new_from_netlink); + SDL_UDEV_SYM(udev_monitor_receive_device); + SDL_UDEV_SYM(udev_monitor_unref); + SDL_UDEV_SYM(udev_new); + SDL_UDEV_SYM(udev_unref); + SDL_UDEV_SYM(udev_device_new_from_devnum); + SDL_UDEV_SYM(udev_device_get_devnum); + #undef SDL_UDEV_SYM + + return 0; +} + +static SDL_bool +SDL_UDEV_hotplug_update_available(void) +{ + if (_this->udev_mon != NULL) { + const int fd = _this->udev_monitor_get_fd(_this->udev_mon); + fd_set fds; + struct timeval tv; + + FD_ZERO(&fds); + FD_SET(fd, &fds); + tv.tv_sec = 0; + tv.tv_usec = 0; + if ((select(fd+1, &fds, NULL, NULL, &tv) > 0) && (FD_ISSET(fd, &fds))) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + + +int +SDL_UDEV_Init(void) +{ + int retval = 0; + + if (_this == NULL) { + _this = (SDL_UDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); + if(_this == NULL) { + return SDL_OutOfMemory(); + } + + retval = SDL_UDEV_LoadLibrary(); + if (retval < 0) { + SDL_UDEV_Quit(); + return retval; + } + + /* Set up udev monitoring + * Listen for input devices (mouse, keyboard, joystick, etc) and sound devices + */ + + _this->udev = _this->udev_new(); + if (_this->udev == NULL) { + SDL_UDEV_Quit(); + return SDL_SetError("udev_new() failed"); + } + + _this->udev_mon = _this->udev_monitor_new_from_netlink(_this->udev, "udev"); + if (_this->udev_mon == NULL) { + SDL_UDEV_Quit(); + return SDL_SetError("udev_monitor_new_from_netlink() failed"); + } + + _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL); + _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL); + _this->udev_monitor_enable_receiving(_this->udev_mon); + + /* Do an initial scan of existing devices */ + SDL_UDEV_Scan(); + + } + + _this->ref_count += 1; + + return retval; +} + +void +SDL_UDEV_Quit(void) +{ + SDL_UDEV_CallbackList *item; + + if (_this == NULL) { + return; + } + + _this->ref_count -= 1; + + if (_this->ref_count < 1) { + + if (_this->udev_mon != NULL) { + _this->udev_monitor_unref(_this->udev_mon); + _this->udev_mon = NULL; + } + if (_this->udev != NULL) { + _this->udev_unref(_this->udev); + _this->udev = NULL; + } + + /* Remove existing devices */ + while (_this->first != NULL) { + item = _this->first; + _this->first = _this->first->next; + SDL_free(item); + } + + SDL_UDEV_UnloadLibrary(); + SDL_free(_this); + _this = NULL; + } +} + +void +SDL_UDEV_Scan(void) +{ + struct udev_enumerate *enumerate = NULL; + struct udev_list_entry *devs = NULL; + struct udev_list_entry *item = NULL; + + if (_this == NULL) { + return; + } + + enumerate = _this->udev_enumerate_new(_this->udev); + if (enumerate == NULL) { + SDL_UDEV_Quit(); + SDL_SetError("udev_monitor_new_from_netlink() failed"); + return; + } + + _this->udev_enumerate_add_match_subsystem(enumerate, "input"); + _this->udev_enumerate_add_match_subsystem(enumerate, "sound"); + + _this->udev_enumerate_scan_devices(enumerate); + devs = _this->udev_enumerate_get_list_entry(enumerate); + for (item = devs; item; item = _this->udev_list_entry_get_next(item)) { + const char *path = _this->udev_list_entry_get_name(item); + struct udev_device *dev = _this->udev_device_new_from_syspath(_this->udev, path); + if (dev != NULL) { + device_event(SDL_UDEV_DEVICEADDED, dev); + _this->udev_device_unref(dev); + } + } + + _this->udev_enumerate_unref(enumerate); +} + + +void +SDL_UDEV_UnloadLibrary(void) +{ + if (_this == NULL) { + return; + } + + if (_this->udev_handle != NULL) { + SDL_UnloadObject(_this->udev_handle); + _this->udev_handle = NULL; + } +} + +int +SDL_UDEV_LoadLibrary(void) +{ + int retval = 0, i; + + if (_this == NULL) { + return SDL_SetError("UDEV not initialized"); + } + + + if (_this->udev_handle == NULL) { + for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { + _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); + if (_this->udev_handle != NULL) { + retval = SDL_UDEV_load_syms(); + if (retval < 0) { + SDL_UDEV_UnloadLibrary(); + } + else { + break; + } + } + } + + if (_this->udev_handle == NULL) { + retval = -1; + /* Don't call SDL_SetError(): SDL_LoadObject already did. */ + } + } + + return retval; +} + +static void +device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) +{ + const char *subsystem; + const char *val = NULL; + SDL_UDEV_deviceclass devclass = 0; + const char *path; + SDL_UDEV_CallbackList *item; + + path = _this->udev_device_get_devnode(dev); + if (path == NULL) { + return; + } + + subsystem = _this->udev_device_get_subsystem(dev); + if (SDL_strcmp(subsystem, "sound") == 0) { + devclass = SDL_UDEV_DEVICE_SOUND; + } + else if (SDL_strcmp(subsystem, "input") == 0) { + val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass = SDL_UDEV_DEVICE_JOYSTICK; + } + + if (devclass == 0) { + val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass = SDL_UDEV_DEVICE_MOUSE; + } + } + + if (devclass == 0) { + val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass = SDL_UDEV_DEVICE_KEYBOARD; + } + } + + if (devclass == 0) { + return; + } + } + else { + return; + } + + /* Process callbacks */ + for (item = _this->first; item != NULL; item = item->next) { + item->callback(type, devclass, path); + } +} + +void +SDL_UDEV_Poll(void) +{ + struct udev_device *dev = NULL; + const char *action = NULL; + + if (_this == NULL) { + return; + } + + while (SDL_UDEV_hotplug_update_available()) { + dev = _this->udev_monitor_receive_device(_this->udev_mon); + if (dev == NULL) { + break; + } + action = _this->udev_device_get_action(dev); + + if (SDL_strcmp(action, "add") == 0) { + device_event(SDL_UDEV_DEVICEADDED, dev); + } else if (SDL_strcmp(action, "remove") == 0) { + device_event(SDL_UDEV_DEVICEREMOVED, dev); + } + + _this->udev_device_unref(dev); + } +} + +int +SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) +{ + SDL_UDEV_CallbackList *item; + item = (SDL_UDEV_CallbackList *) SDL_calloc(1, sizeof (SDL_UDEV_CallbackList)); + if (item == NULL) { + return SDL_OutOfMemory(); + } + + item->callback = cb; + + if (_this->last == NULL) { + _this->first = _this->last = item; + } else { + _this->last->next = item; + _this->last = item; + } + + return 1; +} + +void +SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) +{ + SDL_UDEV_CallbackList *item; + SDL_UDEV_CallbackList *prev = NULL; + + for (item = _this->first; item != NULL; item = item->next) { + /* found it, remove it. */ + if (item->callback == cb) { + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(_this->first == item); + _this->first = item->next; + } + if (item == _this->last) { + _this->last = prev; + } + SDL_free(item); + return; + } + prev = item; + } + +} + + +#endif /* SDL_USE_LIBUDEV */ \ No newline at end of file diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h new file mode 100644 index 000000000..0ec86db1c --- /dev/null +++ b/src/core/linux/SDL_udev.h @@ -0,0 +1,114 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#ifndef _SDL_udev_h +#define _SDL_udev_h + +#if HAVE_LIBUDEV_H + +#ifndef SDL_USE_LIBUDEV +#define SDL_USE_LIBUDEV 1 +#endif + +#include "SDL_loadso.h" +#include "SDL_events.h" +#include +#include +#include + +/** + * \brief Device type + */ + +typedef enum +{ + SDL_UDEV_DEVICEADDED = 0x0001, + SDL_UDEV_DEVICEREMOVED +} SDL_UDEV_deviceevent; + +typedef enum +{ + SDL_UDEV_DEVICE_MOUSE = 0x0001, + SDL_UDEV_DEVICE_KEYBOARD, + SDL_UDEV_DEVICE_JOYSTICK, + SDL_UDEV_DEVICE_SOUND +} SDL_UDEV_deviceclass; + +typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); + +typedef struct SDL_UDEV_CallbackList { + SDL_UDEV_Callback callback; + struct SDL_UDEV_CallbackList *next; +} SDL_UDEV_CallbackList; + +typedef struct SDL_UDEV_PrivateData +{ + const char *udev_library; + void *udev_handle; + struct udev *udev; + struct udev_monitor *udev_mon; + int ref_count; + SDL_UDEV_CallbackList *first, *last; + + /* Function pointers */ + const char *(*udev_device_get_action)(struct udev_device *); + const char *(*udev_device_get_devnode)(struct udev_device *); + const char *(*udev_device_get_subsystem)(struct udev_device *); + const char *(*udev_device_get_property_value)(struct udev_device *, const char *); + struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *); + void (*udev_device_unref)(struct udev_device *); + int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *); + int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *); + struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *); + struct udev_enumerate *(*udev_enumerate_new)(struct udev *); + int (*udev_enumerate_scan_devices)(struct udev_enumerate *); + void (*udev_enumerate_unref)(struct udev_enumerate *); + const char *(*udev_list_entry_get_name)(struct udev_list_entry *); + struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *); + int (*udev_monitor_enable_receiving)(struct udev_monitor *); + int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *); + int (*udev_monitor_get_fd)(struct udev_monitor *); + struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *); + struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *); + void (*udev_monitor_unref)(struct udev_monitor *); + struct udev *(*udev_new)(void); + void (*udev_unref)(struct udev *); + struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum); + dev_t (*udev_device_get_devnum) (struct udev_device *udev_device); +} SDL_UDEV_PrivateData; + +extern int SDL_UDEV_Init(void); +extern void SDL_UDEV_Quit(void); +extern void SDL_UDEV_UnloadLibrary(void); +extern int SDL_UDEV_LoadLibrary(void); +extern void SDL_UDEV_Poll(void); +extern void SDL_UDEV_Scan(void); +extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb); +extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); + + + + +#endif /* HAVE_LIBUDEV_H */ + +#endif /* _SDL_udev_h */ \ No newline at end of file diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index e322437b8..0886f54fa 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -246,13 +246,11 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ mouse->xdelta += xrel; mouse->ydelta += yrel; -#if 0 /* FIXME */ /* Move the mouse cursor, if needed */ if (mouse->cursor_shown && !mouse->relative_mode && mouse->MoveCursor && mouse->cur_cursor) { mouse->MoveCursor(mouse->cur_cursor); } -#endif /* Post the event, if desired */ posted = 0; diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c new file mode 100644 index 000000000..ea911d68c --- /dev/null +++ b/src/input/evdev/SDL_evdev.c @@ -0,0 +1,646 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_INPUT_LINUXEV + +/* This is based on the linux joystick driver */ +/* References: https://www.kernel.org/doc/Documentation/input/input.txt + * https://www.kernel.org/doc/Documentation/input/event-codes.txt + * /usr/include/linux/input.h + * The evtest application is also useful to debug the protocol + */ + + +#include "SDL_evdev.h" +#define _THIS SDL_EVDEV_PrivateData *_this +static _THIS = NULL; + +#include +#include +#include +#include +#include /* For the definition of PATH_MAX */ + + +#include "SDL.h" +#include "SDL_assert.h" +#include "SDL_endian.h" +#include "../../core/linux/SDL_udev.h" +#include "SDL_scancode.h" +#include "../../events/SDL_events_c.h" + +/* This isn't defined in older Linux kernel headers */ +#ifndef SYN_DROPPED +#define SYN_DROPPED 3 +#endif + + +static int SDL_EVDEV_device_removed(const char *devpath); +static int SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath); +static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode); +static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); +void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); + +static SDL_Scancode EVDEV_Keycodes[] = { + SDL_SCANCODE_UNKNOWN, /* KEY_RESERVED 0 */ + SDL_SCANCODE_ESCAPE, /* KEY_ESC 1 */ + SDL_SCANCODE_1, /* KEY_1 2 */ + SDL_SCANCODE_2, /* KEY_2 3 */ + SDL_SCANCODE_3, /* KEY_3 4 */ + SDL_SCANCODE_4, /* KEY_4 5 */ + SDL_SCANCODE_5, /* KEY_5 6 */ + SDL_SCANCODE_6, /* KEY_6 7 */ + SDL_SCANCODE_7, /* KEY_7 8 */ + SDL_SCANCODE_8, /* KEY_8 9 */ + SDL_SCANCODE_9, /* KEY_9 10 */ + SDL_SCANCODE_0, /* KEY_0 11 */ + SDL_SCANCODE_MINUS, /* KEY_MINUS 12 */ + SDL_SCANCODE_EQUALS, /* KEY_EQUAL 13 */ + SDL_SCANCODE_BACKSPACE, /* KEY_BACKSPACE 14 */ + SDL_SCANCODE_TAB, /* KEY_TAB 15 */ + SDL_SCANCODE_Q, /* KEY_Q 16 */ + SDL_SCANCODE_W, /* KEY_W 17 */ + SDL_SCANCODE_E, /* KEY_E 18 */ + SDL_SCANCODE_R, /* KEY_R 19 */ + SDL_SCANCODE_T, /* KEY_T 20 */ + SDL_SCANCODE_Y, /* KEY_Y 21 */ + SDL_SCANCODE_U, /* KEY_U 22 */ + SDL_SCANCODE_I, /* KEY_I 23 */ + SDL_SCANCODE_O, /* KEY_O 24 */ + SDL_SCANCODE_P, /* KEY_P 25 */ + SDL_SCANCODE_LEFTBRACKET, /* KEY_LEFTBRACE 26 */ + SDL_SCANCODE_RIGHTBRACKET, /* KEY_RIGHTBRACE 27 */ + SDL_SCANCODE_RETURN, /* KEY_ENTER 28 */ + SDL_SCANCODE_LCTRL, /* KEY_LEFTCTRL 29 */ + SDL_SCANCODE_A, /* KEY_A 30 */ + SDL_SCANCODE_S, /* KEY_S 31 */ + SDL_SCANCODE_D, /* KEY_D 32 */ + SDL_SCANCODE_F, /* KEY_F 33 */ + SDL_SCANCODE_G, /* KEY_G 34 */ + SDL_SCANCODE_H, /* KEY_H 35 */ + SDL_SCANCODE_J, /* KEY_J 36 */ + SDL_SCANCODE_K, /* KEY_K 37 */ + SDL_SCANCODE_L, /* KEY_L 38 */ + SDL_SCANCODE_SEMICOLON, /* KEY_SEMICOLON 39 */ + SDL_SCANCODE_APOSTROPHE, /* KEY_APOSTROPHE 40 */ + SDL_SCANCODE_GRAVE, /* KEY_GRAVE 41 */ + SDL_SCANCODE_LSHIFT, /* KEY_LEFTSHIFT 42 */ + SDL_SCANCODE_BACKSLASH, /* KEY_BACKSLASH 43 */ + SDL_SCANCODE_Z, /* KEY_Z 44 */ + SDL_SCANCODE_X, /* KEY_X 45 */ + SDL_SCANCODE_C, /* KEY_C 46 */ + SDL_SCANCODE_V, /* KEY_V 47 */ + SDL_SCANCODE_B, /* KEY_B 48 */ + SDL_SCANCODE_N, /* KEY_N 49 */ + SDL_SCANCODE_M, /* KEY_M 50 */ + SDL_SCANCODE_COMMA, /* KEY_COMMA 51 */ + SDL_SCANCODE_PERIOD, /* KEY_DOT 52 */ + SDL_SCANCODE_SLASH, /* KEY_SLASH 53 */ + SDL_SCANCODE_RSHIFT, /* KEY_RIGHTSHIFT 54 */ + SDL_SCANCODE_KP_MULTIPLY, /* KEY_KPASTERISK 55 */ + SDL_SCANCODE_LALT, /* KEY_LEFTALT 56 */ + SDL_SCANCODE_SPACE, /* KEY_SPACE 57 */ + SDL_SCANCODE_CAPSLOCK, /* KEY_CAPSLOCK 58 */ + SDL_SCANCODE_F1, /* KEY_F1 59 */ + SDL_SCANCODE_F2, /* KEY_F2 60 */ + SDL_SCANCODE_F3, /* KEY_F3 61 */ + SDL_SCANCODE_F4, /* KEY_F4 62 */ + SDL_SCANCODE_F5, /* KEY_F5 63 */ + SDL_SCANCODE_F6, /* KEY_F6 64 */ + SDL_SCANCODE_F7, /* KEY_F7 65 */ + SDL_SCANCODE_F8, /* KEY_F8 66 */ + SDL_SCANCODE_F9, /* KEY_F9 67 */ + SDL_SCANCODE_F10, /* KEY_F10 68 */ + SDL_SCANCODE_NUMLOCKCLEAR, /* KEY_NUMLOCK 69 */ + SDL_SCANCODE_SCROLLLOCK, /* KEY_SCROLLLOCK 70 */ + SDL_SCANCODE_KP_7, /* KEY_KP7 71 */ + SDL_SCANCODE_KP_8, /* KEY_KP8 72 */ + SDL_SCANCODE_KP_9, /* KEY_KP9 73 */ + SDL_SCANCODE_KP_MINUS, /* KEY_KPMINUS 74 */ + SDL_SCANCODE_KP_4, /* KEY_KP4 75 */ + SDL_SCANCODE_KP_5, /* KEY_KP5 76 */ + SDL_SCANCODE_KP_6, /* KEY_KP6 77 */ + SDL_SCANCODE_KP_PLUS, /* KEY_KPPLUS 78 */ + SDL_SCANCODE_KP_1, /* KEY_KP1 79 */ + SDL_SCANCODE_KP_2, /* KEY_KP2 80 */ + SDL_SCANCODE_KP_3, /* KEY_KP3 81 */ + SDL_SCANCODE_KP_0, /* KEY_KP0 82 */ + SDL_SCANCODE_KP_PERIOD, /* KEY_KPDOT 83 */ + SDL_SCANCODE_UNKNOWN, /* 84 */ + SDL_SCANCODE_LANG5, /* KEY_ZENKAKUHANKAKU 85 */ + SDL_SCANCODE_UNKNOWN, /* KEY_102ND 86 */ + SDL_SCANCODE_F11, /* KEY_F11 87 */ + SDL_SCANCODE_F12, /* KEY_F12 88 */ + SDL_SCANCODE_UNKNOWN, /* KEY_RO 89 */ + SDL_SCANCODE_LANG3, /* KEY_KATAKANA 90 */ + SDL_SCANCODE_LANG4, /* KEY_HIRAGANA 91 */ + SDL_SCANCODE_UNKNOWN, /* KEY_HENKAN 92 */ + SDL_SCANCODE_LANG3, /* KEY_KATAKANAHIRAGANA 93 */ + SDL_SCANCODE_UNKNOWN, /* KEY_MUHENKAN 94 */ + SDL_SCANCODE_KP_COMMA, /* KEY_KPJPCOMMA 95 */ + SDL_SCANCODE_KP_ENTER, /* KEY_KPENTER 96 */ + SDL_SCANCODE_RCTRL, /* KEY_RIGHTCTRL 97 */ + SDL_SCANCODE_KP_DIVIDE, /* KEY_KPSLASH 98 */ + SDL_SCANCODE_SYSREQ, /* KEY_SYSRQ 99 */ + SDL_SCANCODE_RALT, /* KEY_RIGHTALT 100 */ + SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED 101 */ + SDL_SCANCODE_HOME, /* KEY_HOME 102 */ + SDL_SCANCODE_UP, /* KEY_UP 103 */ + SDL_SCANCODE_PAGEUP, /* KEY_PAGEUP 104 */ + SDL_SCANCODE_LEFT, /* KEY_LEFT 105 */ + SDL_SCANCODE_RIGHT, /* KEY_RIGHT 106 */ + SDL_SCANCODE_END, /* KEY_END 107 */ + SDL_SCANCODE_DOWN, /* KEY_DOWN 108 */ + SDL_SCANCODE_PAGEDOWN, /* KEY_PAGEDOWN 109 */ + SDL_SCANCODE_INSERT, /* KEY_INSERT 110 */ + SDL_SCANCODE_DELETE, /* KEY_DELETE 111 */ + SDL_SCANCODE_UNKNOWN, /* KEY_MACRO 112 */ + SDL_SCANCODE_MUTE, /* KEY_MUTE 113 */ + SDL_SCANCODE_VOLUMEDOWN, /* KEY_VOLUMEDOWN 114 */ + SDL_SCANCODE_VOLUMEUP, /* KEY_VOLUMEUP 115 */ + SDL_SCANCODE_POWER, /* KEY_POWER 116 SC System Power Down */ + SDL_SCANCODE_KP_EQUALS, /* KEY_KPEQUAL 117 */ + SDL_SCANCODE_KP_MINUS, /* KEY_KPPLUSMINUS 118 */ + SDL_SCANCODE_PAUSE, /* KEY_PAUSE 119 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SCALE 120 AL Compiz Scale (Expose) */ + SDL_SCANCODE_KP_COMMA, /* KEY_KPCOMMA 121 */ + SDL_SCANCODE_LANG1, /* KEY_HANGEUL,KEY_HANGUEL 122 */ + SDL_SCANCODE_LANG2, /* KEY_HANJA 123 */ + SDL_SCANCODE_INTERNATIONAL3,/* KEY_YEN 124 */ + SDL_SCANCODE_LGUI, /* KEY_LEFTMETA 125 */ + SDL_SCANCODE_RGUI, /* KEY_RIGHTMETA 126 */ + SDL_SCANCODE_APPLICATION, /* KEY_COMPOSE 127 */ + SDL_SCANCODE_STOP, /* KEY_STOP 128 AC Stop */ + SDL_SCANCODE_AGAIN, /* KEY_AGAIN 129 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PROPS 130 AC Properties */ + SDL_SCANCODE_UNDO, /* KEY_UNDO 131 AC Undo */ + SDL_SCANCODE_UNKNOWN, /* KEY_FRONT 132 */ + SDL_SCANCODE_COPY, /* KEY_COPY 133 AC Copy */ + SDL_SCANCODE_UNKNOWN, /* KEY_OPEN 134 AC Open */ + SDL_SCANCODE_PASTE, /* KEY_PASTE 135 AC Paste */ + SDL_SCANCODE_FIND, /* KEY_FIND 136 AC Search */ + SDL_SCANCODE_CUT, /* KEY_CUT 137 AC Cut */ + SDL_SCANCODE_HELP, /* KEY_HELP 138 AL Integrated Help Center */ + SDL_SCANCODE_MENU, /* KEY_MENU 139 Menu (show menu) */ + SDL_SCANCODE_CALCULATOR, /* KEY_CALC 140 AL Calculator */ + SDL_SCANCODE_UNKNOWN, /* KEY_SETUP 141 */ + SDL_SCANCODE_SLEEP, /* KEY_SLEEP 142 SC System Sleep */ + SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP 143 System Wake Up */ + SDL_SCANCODE_UNKNOWN, /* KEY_FILE 144 AL Local Machine Browser */ + SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE 145 */ + SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE 146 */ + SDL_SCANCODE_UNKNOWN, /* KEY_XFER 147 */ + SDL_SCANCODE_APP1, /* KEY_PROG1 148 */ + SDL_SCANCODE_APP1, /* KEY_PROG2 149 */ + SDL_SCANCODE_WWW, /* KEY_WWW 150 AL Internet Browser */ + SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS 151 */ + SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE,KEY_SCREENLOCK 152 AL Terminal Lock/Screensaver */ + SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTION 153 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS 154 */ + SDL_SCANCODE_MAIL, /* KEY_MAIL 155 */ + SDL_SCANCODE_AC_BOOKMARKS, /* KEY_BOOKMARKS 156 AC Bookmarks */ + SDL_SCANCODE_COMPUTER, /* KEY_COMPUTER 157 */ + SDL_SCANCODE_AC_BACK, /* KEY_BACK 158 AC Back */ + SDL_SCANCODE_AC_FORWARD, /* KEY_FORWARD 159 AC Forward */ + SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD 160 */ + SDL_SCANCODE_EJECT, /* KEY_EJECTCD 161 */ + SDL_SCANCODE_UNKNOWN, /* KEY_EJECTCLOSECD 162 */ + SDL_SCANCODE_AUDIONEXT, /* KEY_NEXTSONG 163 */ + SDL_SCANCODE_AUDIOPLAY, /* KEY_PLAYPAUSE 164 */ + SDL_SCANCODE_AUDIOPREV, /* KEY_PREVIOUSSONG 165 */ + SDL_SCANCODE_AUDIOSTOP, /* KEY_STOPCD 166 */ + SDL_SCANCODE_UNKNOWN, /* KEY_RECORD 167 */ + SDL_SCANCODE_UNKNOWN, /* KEY_REWIND 168 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PHONE 169 Media Select Telephone */ + SDL_SCANCODE_UNKNOWN, /* KEY_ISO 170 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG 171 AL Consumer Control Configuration */ + SDL_SCANCODE_AC_HOME, /* KEY_HOMEPAGE 172 AC Home */ + SDL_SCANCODE_AC_REFRESH, /* KEY_REFRESH 173 AC Refresh */ + SDL_SCANCODE_UNKNOWN, /* KEY_EXIT 174 AC Exit */ + SDL_SCANCODE_UNKNOWN, /* KEY_MOVE 175 */ + SDL_SCANCODE_UNKNOWN, /* KEY_EDIT 176 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP 177 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN 178 */ + SDL_SCANCODE_KP_LEFTPAREN, /* KEY_KPLEFTPAREN 179 */ + SDL_SCANCODE_KP_RIGHTPAREN, /* KEY_KPRIGHTPAREN 180 */ + SDL_SCANCODE_UNKNOWN, /* KEY_NEW 181 AC New */ + SDL_SCANCODE_AGAIN, /* KEY_REDO 182 AC Redo/Repeat */ + SDL_SCANCODE_F13, /* KEY_F13 183 */ + SDL_SCANCODE_F14, /* KEY_F14 184 */ + SDL_SCANCODE_F15, /* KEY_F15 185 */ + SDL_SCANCODE_F16, /* KEY_F16 186 */ + SDL_SCANCODE_F17, /* KEY_F17 187 */ + SDL_SCANCODE_F18, /* KEY_F18 188 */ + SDL_SCANCODE_F19, /* KEY_F19 189 */ + SDL_SCANCODE_F20, /* KEY_F20 190 */ + SDL_SCANCODE_F21, /* KEY_F21 191 */ + SDL_SCANCODE_F22, /* KEY_F22 192 */ + SDL_SCANCODE_F23, /* KEY_F23 193 */ + SDL_SCANCODE_F24, /* KEY_F24 194 */ + SDL_SCANCODE_UNKNOWN, /* 195 */ + SDL_SCANCODE_UNKNOWN, /* 196 */ + SDL_SCANCODE_UNKNOWN, /* 197 */ + SDL_SCANCODE_UNKNOWN, /* 198 */ + SDL_SCANCODE_UNKNOWN, /* 199 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PLAYCD 200 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PAUSECD 201 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 202 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 203 */ + SDL_SCANCODE_UNKNOWN, /* KEY_DASHBOARD 204 AL Dashboard */ + SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND 205 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CLOSE 206 AC Close */ + SDL_SCANCODE_UNKNOWN, /* KEY_PLAY 207 */ + SDL_SCANCODE_UNKNOWN, /* KEY_FASTFORWARD 208 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST 209 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PRINT 210 AC Print */ + SDL_SCANCODE_UNKNOWN, /* KEY_HP 211 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA 212 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SOUND 213 */ + SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION 214 */ + SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL 215 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CHAT 216 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SEARCH 217 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT 218 */ + SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE 219 AL Checkbook/Finance */ + SDL_SCANCODE_UNKNOWN, /* KEY_SPORT 220 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SHOP 221 */ + SDL_SCANCODE_UNKNOWN, /* KEY_ALTERASE 222 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CANCEL 223 AC Cancel */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESSDOWN 224 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESSUP 225 */ + SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA 226 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SWITCHVIDEOMODE 227 Cycle between available video outputs (Monitor/LCD/TV-out/etc) */ + SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMTOGGLE 228 */ + SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMDOWN 229 */ + SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMUP 230 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SEND 231 AC Send */ + SDL_SCANCODE_UNKNOWN, /* KEY_REPLY 232 AC Reply */ + SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL 233 AC Forward Msg */ + SDL_SCANCODE_UNKNOWN, /* KEY_SAVE 234 AC Save */ + SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS 235 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY 236 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BLUETOOTH 237 */ + SDL_SCANCODE_UNKNOWN, /* KEY_WLAN 238 */ + SDL_SCANCODE_UNKNOWN, /* KEY_UWB 239 */ + SDL_SCANCODE_UNKNOWN, /* KEY_UNKNOWN 240 */ + SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO_NEXT 241 drive next video source */ + SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO_PREV 242 drive previous video source */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_CYCLE 243 brightness up, after max is min */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_ZERO 244 brightness off, use ambient */ + SDL_SCANCODE_UNKNOWN, /* KEY_DISPLAY_OFF 245 display device to off state */ + SDL_SCANCODE_UNKNOWN, /* KEY_WIMAX 246 */ + SDL_SCANCODE_UNKNOWN, /* KEY_RFKILL 247 Key that controls all radios */ + SDL_SCANCODE_UNKNOWN, /* KEY_MICMUTE 248 Mute / unmute the microphone */ +}; + +static Uint8 EVDEV_MouseButtons[] = { + SDL_BUTTON_LEFT, /* BTN_LEFT 0x110 */ + SDL_BUTTON_RIGHT, /* BTN_RIGHT 0x111 */ + SDL_BUTTON_MIDDLE, /* BTN_MIDDLE 0x112 */ + SDL_BUTTON_X1, /* BTN_SIDE 0x113 */ + SDL_BUTTON_X2, /* BTN_EXTRA 0x114 */ + SDL_BUTTON_X2 + 1, /* BTN_FORWARD 0x115 */ + SDL_BUTTON_X2 + 2, /* BTN_BACK 0x116 */ + SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */ +}; + +int +SDL_EVDEV_Init(void) +{ + int retval = 0; + + if (_this == NULL) { + _this = (SDL_EVDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); + if(_this == NULL) { + return SDL_OutOfMemory(); + } + +#if SDL_USE_LIBUDEV + if (SDL_UDEV_Init() < 0) { + SDL_free(_this); + _this = NULL; + return -1; + } + + /* Set up the udev callback */ + if ( SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) { + SDL_EVDEV_Quit(); + return -1; + } + + /* Force a scan to build the initial device list */ + SDL_UDEV_Scan(); +#else + /* TODO: Scan the devices manually, like a caveman */ +#endif /* SDL_USE_LIBUDEV */ + + } + + _this->ref_count += 1; + + return retval; +} + +void +SDL_EVDEV_Quit(void) +{ + if (_this == NULL) { + return; + } + + _this->ref_count -= 1; + + if (_this->ref_count < 1) { + +#if SDL_USE_LIBUDEV + SDL_UDEV_DelCallback(SDL_EVDEV_udev_callback); + SDL_UDEV_Quit(); +#endif /* SDL_USE_LIBUDEV */ + + /* Remove existing devices */ + while(_this->first != NULL) { + SDL_EVDEV_device_removed(_this->first->path); + } + + SDL_assert(_this->first == NULL); + SDL_assert(_this->last == NULL); + SDL_assert(_this->numdevices == 0); + + SDL_free(_this); + _this = NULL; + } +} + +void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath) +{ + SDL_EVDEV_deviceclass devclass; + + if (devpath == NULL) { + return; + } + + switch( udev_class ) + { + case SDL_UDEV_DEVICE_MOUSE: + devclass = SDL_EVDEV_DEVICE_MOUSE; + break; + + case SDL_UDEV_DEVICE_KEYBOARD: + devclass = SDL_EVDEV_DEVICE_KEYBOARD; + break; + + default: + return; + } + + switch( udev_type ) + { + case SDL_UDEV_DEVICEADDED: + SDL_EVDEV_device_added(devclass, devpath); + break; + + case SDL_UDEV_DEVICEREMOVED: + SDL_EVDEV_device_removed(devpath); + break; + + default: + break; + + } + +} + +void +SDL_EVDEV_Poll(void) +{ + struct input_event events[32]; + int i, len; + SDL_evdevlist_item *item; + SDL_Scancode scan_code; + int mouse_button; + SDL_Mouse *mouse; + +#if SDL_USE_LIBUDEV + SDL_UDEV_Poll(); +#endif + + for (item = _this->first; item != NULL; item = item->next) { + while ((len = read(item->fd, events, (sizeof events))) > 0) { + len /= sizeof(events[0]); + for (i = 0; i < len; ++i) { + switch(item->devclass) { + case SDL_EVDEV_DEVICE_KEYBOARD: + switch (events[i].type) { + case EV_KEY: + scan_code = SDL_EVDEV_translate_keycode(events[i].code); + if (scan_code != SDL_SCANCODE_UNKNOWN) { + if (events[i].value == 0) { + SDL_SendKeyboardKey(SDL_RELEASED, scan_code); + } + else if (events[i].value == 1) { + SDL_SendKeyboardKey(SDL_PRESSED, scan_code); + } + else if (events[i].value == 2) { + /* Key repeated */ + SDL_SendKeyboardKey(SDL_PRESSED, scan_code); + } + } + break; + + default: + break; + } + break; /* SDL_EVDEV_DEVICE_KEYBOARD */ + + case SDL_EVDEV_DEVICE_MOUSE: + mouse = SDL_GetMouse(); + switch (events[i].type) { + case EV_KEY: + mouse_button = events[i].code - BTN_MOUSE; + if (mouse_button >= 0 && mouse_button < SDL_arraysize(EVDEV_MouseButtons)) { + if (events[i].value == 0) { + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, EVDEV_MouseButtons[mouse_button]); + } + else if (events[i].value == 1) { + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, EVDEV_MouseButtons[mouse_button]); + } + } + break; + case EV_ABS: + switch(events[i].code) { + case ABS_X: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, events[i].value, mouse->y); + break; + case ABS_Y: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, mouse->x, events[i].value); + break; + default: + break; + } + break; + case EV_REL: + switch(events[i].code) { + case REL_X: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, events[i].value, 0); + break; + case REL_Y: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value); + break; + case REL_WHEEL: + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value); + break; + case REL_HWHEEL: + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0); + break; + default: + break; + } + break; + default: + break; + } + break; /* SDL_EVDEV_DEVICE_MOUSE */ + + default: + break; + } + + + /* Handle events not specific to any type of device */ + switch (events[i].type) { + case EV_SYN: + switch (events[i].code) { + case SYN_DROPPED : + SDL_EVDEV_sync_device(item); + break; + default: + break; + } + } + + } + } + } +} + +static SDL_Scancode +SDL_EVDEV_translate_keycode(int keycode) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (keycode < SDL_arraysize(EVDEV_Keycodes)) { + scancode = EVDEV_Keycodes[keycode]; + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list EVDEV KeyCode %d \n", keycode); + } + return scancode; +} + +static void +SDL_EVDEV_sync_device(SDL_evdevlist_item *item) +{ + /* TODO: get full state of device and report whatever is required */ +} + +static int +SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath) +{ + SDL_evdevlist_item *item; + + /* Check to make sure it's not already in list. */ + for (item = _this->first; item != NULL; item = item->next) { + if (strcmp(devpath, item->path) == 0) { + return -1; /* already have this one */ + } + } + + item = (SDL_evdevlist_item *) SDL_calloc(1, sizeof (SDL_evdevlist_item)); + if (item == NULL) { + return SDL_OutOfMemory(); + } + + item->devclass = devclass; + + + item->fd = open(devpath, O_RDONLY, 0); + if (item->fd < 0) { + SDL_free(item); + return SDL_SetError("Unable to open %s", devpath); + } + + item->path = SDL_strdup(devpath); + if (item->path == NULL) { + close(item->fd); + SDL_free(item); + return SDL_OutOfMemory(); + } + + /* Non blocking read mode */ + fcntl(item->fd, F_SETFL, O_NONBLOCK); + + if (_this->last == NULL) { + _this->first = _this->last = item; + } else { + _this->last->next = item; + _this->last = item; + } + + SDL_EVDEV_sync_device(item); + + return _this->numdevices++; +} + + +static int +SDL_EVDEV_device_removed(const char *devpath) +{ + SDL_evdevlist_item *item; + SDL_evdevlist_item *prev = NULL; + + for (item = _this->first; item != NULL; item = item->next) { + /* found it, remove it. */ + if ( strcmp(devpath, item->path) ==0 ) { + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(_this->first == item); + _this->first = item->next; + } + if (item == _this->last) { + _this->last = prev; + } + close(item->fd); + SDL_free(item->path); + SDL_free(item); + _this->numdevices--; + return 0; + } + prev = item; + } + + return -1; +} + +#endif /* SDL_INPUT_LINUXEV */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/input/evdev/SDL_evdev.h b/src/input/evdev/SDL_evdev.h new file mode 100644 index 000000000..5a6038f61 --- /dev/null +++ b/src/input/evdev/SDL_evdev.h @@ -0,0 +1,65 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include + +#include "SDL_config.h" + +#ifndef _SDL_evdev_h +#define _SDL_evdev_h + +#ifdef SDL_INPUT_LINUXEV + +#include "SDL_events.h" +#include + +typedef enum +{ + SDL_EVDEV_DEVICE_MOUSE = 0x0001, + SDL_EVDEV_DEVICE_KEYBOARD +} SDL_EVDEV_deviceclass; + +typedef struct SDL_evdevlist_item +{ + char *path; + int fd; + SDL_EVDEV_deviceclass devclass; + struct SDL_evdevlist_item *next; +} SDL_evdevlist_item; + +typedef struct SDL_EVDEV_PrivateData +{ + SDL_evdevlist_item *first; + SDL_evdevlist_item *last; + int numdevices; + int ref_count; +} SDL_EVDEV_PrivateData; + +extern int SDL_EVDEV_Init(void); +extern void SDL_EVDEV_Quit(void); +extern void SDL_EVDEV_Poll(void); + + +#endif /* SDL_INPUT_LINUXEV */ + +#endif /* _SDL_evdev_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 522516572..1501a748a 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -25,13 +25,20 @@ #include "SDL_sysvideo.h" #include "SDL_egl.h" -#define DEFAULT_EGL "libEGL.so" -#define DEFAULT_OGL_ES2 "libGLESv2.so" -#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" -#define DEFAULT_OGL_ES "libGLESv1_CM.so" +#if SDL_VIDEO_DRIVER_RPI +#define DEFAULT_EGL "/opt/vc/lib/libEGL.so" +#define DEFAULT_OGL_ES2 "/opt/vc/lib/libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so" +#define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so" +#else +#define DEFAULT_EGL "libEGL.so.1" +#define DEFAULT_OGL_ES2 "libGLESv2.so.2" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1" +#define DEFAULT_OGL_ES "libGLESv1_CM.so.1" +#endif /* SDL_VIDEO_DRIVER_RPI */ #define LOAD_FUNC(NAME) \ -*((void**)&_this->egl_data->NAME) = dlsym(handle, #NAME); \ +*((void**)&_this->egl_data->NAME) = dlsym(dll_handle, #NAME); \ if (!_this->egl_data->NAME) \ { \ return SDL_SetError("Could not retrieve EGL function " #NAME); \ @@ -88,9 +95,10 @@ SDL_EGL_UnloadLibrary(_THIS) } int -SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display) +SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display) { - void *handle; + void *dll_handle, *egl_dll_handle; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */ + char *path; int dlopen_flags; if (_this->egl_data) { @@ -105,22 +113,44 @@ SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display) #else dlopen_flags = RTLD_LAZY; #endif - handle = dlopen(path, dlopen_flags); + + /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ + path = getenv("SDL_VIDEO_GL_DRIVER"); + egl_dll_handle = dlopen(path, dlopen_flags); + if ((path == NULL) | (egl_dll_handle == NULL)) { + if (_this->gl_config.major_version > 1) { + path = DEFAULT_OGL_ES2; + egl_dll_handle = dlopen(path, dlopen_flags); + } else { + path = DEFAULT_OGL_ES; + egl_dll_handle = dlopen(path, dlopen_flags); + if (egl_dll_handle == NULL) { + path = DEFAULT_OGL_ES_PVR; + egl_dll_handle = dlopen(path, dlopen_flags); + } + } + } + + if (egl_dll_handle == NULL) { + return SDL_SetError("Could not initialize OpenGL ES library: %s", dlerror()); + } + + /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ + dll_handle = dlopen(egl_path, dlopen_flags); /* Catch the case where the application isn't linked with EGL */ - if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) { - - dlclose(handle); + if ((dlsym(dll_handle, "eglChooseConfig") == NULL) && (egl_path == NULL)) { + dlclose(dll_handle); path = getenv("SDL_VIDEO_EGL_DRIVER"); if (path == NULL) { path = DEFAULT_EGL; } - handle = dlopen(path, dlopen_flags); - } - - if (handle == NULL) { - return SDL_SetError("Could not load OpenGL ES/EGL library"); + dll_handle = dlopen(path, dlopen_flags); } + if (dll_handle == NULL) { + return SDL_SetError("Could not load EGL library: %s", dlerror()); + } + _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData)); if (!_this->egl_data) { return SDL_OutOfMemory(); @@ -153,36 +183,14 @@ SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display) return SDL_SetError("Could not initialize EGL"); } - _this->egl_data->egl_dll_handle = handle; - - path = getenv("SDL_VIDEO_GL_DRIVER"); - handle = dlopen(path, dlopen_flags); - if ((path == NULL) | (handle == NULL)) { - if (_this->gl_config.major_version > 1) { - path = DEFAULT_OGL_ES2; - handle = dlopen(path, dlopen_flags); - } else { - path = DEFAULT_OGL_ES; - handle = dlopen(path, dlopen_flags); - if (handle == NULL) { - path = DEFAULT_OGL_ES_PVR; - handle = dlopen(path, dlopen_flags); - } - } - } - - if (handle == NULL) { - return SDL_SetError("Could not initialize OpenGL ES library"); - } - - _this->gl_config.dll_handle = handle; + _this->gl_config.dll_handle = dll_handle; + _this->egl_data->egl_dll_handle = egl_dll_handle; _this->gl_config.driver_loaded = 1; if (path) { - strncpy(_this->gl_config.driver_path, path, - sizeof(_this->gl_config.driver_path) - 1); + strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1); } else { - strcpy(_this->gl_config.driver_path, ""); + strcpy(_this->gl_config.driver_path, ""); } /* We need to select a config here to satisfy some video backends such as X11 */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 32966997d..bdb2a3130 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -363,6 +363,9 @@ extern VideoBootStrap Android_bootstrap; #if SDL_VIDEO_DRIVER_PSP extern VideoBootStrap PSP_bootstrap; #endif +#if SDL_VIDEO_DRIVER_RPI +extern VideoBootStrap RPI_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b5c31324d..cd40aeb48 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -80,6 +80,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_PSP &PSP_bootstrap, #endif +#if SDL_VIDEO_DRIVER_RPI + &RPI_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif diff --git a/src/video/raspberry/SDL_rpievents.c b/src/video/raspberry/SDL_rpievents.c new file mode 100644 index 000000000..8c420fe71 --- /dev/null +++ b/src/video/raspberry/SDL_rpievents.c @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI + +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "SDL_rpivideo.h" +#include "SDL_rpievents_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../input/evdev/SDL_evdev.h" +#endif + +void RPI_PumpEvents(_THIS) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#endif + +} + +#endif /* SDL_VIDEO_DRIVER_RPI */ + diff --git a/src/video/raspberry/SDL_rpievents_c.h b/src/video/raspberry/SDL_rpievents_c.h new file mode 100644 index 000000000..54d3119d1 --- /dev/null +++ b/src/video/raspberry/SDL_rpievents_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_rpievents_c_h +#define _SDL_rpievents_c_h + +#include "SDL_rpivideo.h" + +void RPI_PumpEvents(_THIS); +void RPI_EventInit(_THIS); +void RPI_EventQuit(_THIS); + +#endif /* _SDL_rpievents_c_h */ diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c new file mode 100644 index 000000000..429214b91 --- /dev/null +++ b/src/video/raspberry/SDL_rpimouse.c @@ -0,0 +1,277 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI + +#include "SDL_assert.h" +#include "SDL_surface.h" + +#include "SDL_rpivideo.h" +#include "SDL_rpimouse.h" + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/default_cursor.h" + +/* Copied from vc_vchi_dispmanx.h which is bugged and tries to include a non existing file */ +/* Attributes changes flag mask */ +#define ELEMENT_CHANGE_LAYER (1<<0) +#define ELEMENT_CHANGE_OPACITY (1<<1) +#define ELEMENT_CHANGE_DEST_RECT (1<<2) +#define ELEMENT_CHANGE_SRC_RECT (1<<3) +#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) +#define ELEMENT_CHANGE_TRANSFORM (1<<5) +/* End copied from vc_vchi_dispmanx.h */ + +static SDL_Cursor *RPI_CreateDefaultCursor(void); +static SDL_Cursor *RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); +static int RPI_ShowCursor(SDL_Cursor * cursor); +static void RPI_MoveCursor(SDL_Cursor * cursor); +static void RPI_FreeCursor(SDL_Cursor * cursor); +static void RPI_WarpMouse(SDL_Window * window, int x, int y); + +static SDL_Cursor * +RPI_CreateDefaultCursor(void) +{ + return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); +} + +/* Create a cursor from a surface */ +static SDL_Cursor * +RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + RPI_CursorData *curdata; + SDL_Cursor *cursor; + int ret; + VC_RECT_T dst_rect; + Uint32 dummy; + + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + + cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + curdata = (RPI_CursorData *) SDL_calloc(1, sizeof(*curdata)); + + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + + /* This usage is inspired by Wayland/Weston RPI code, how they figured this out is anyone's guess */ + curdata->resource = vc_dispmanx_resource_create( VC_IMAGE_ARGB8888, surface->w | (surface->pitch << 16), surface->h | (surface->h << 16), &dummy ); + SDL_assert(curdata->resource); + vc_dispmanx_rect_set( &dst_rect, 0, 0, curdata->w, curdata->h); + /* A note from Weston: + * vc_dispmanx_resource_write_data() ignores ifmt, + * rect.x, rect.width, and uses stride only for computing + * the size of the transfer as rect.height * stride. + * Therefore we can only write rows starting at x=0. + */ + ret = vc_dispmanx_resource_write_data( curdata->resource, VC_IMAGE_ARGB8888, surface->pitch, surface->pixels, &dst_rect ); + SDL_assert ( ret == DISPMANX_SUCCESS ); + + cursor->driverdata = curdata; + + return cursor; + +} + +/* Show the specified cursor, or hide if cursor is NULL */ +static int +RPI_ShowCursor(SDL_Cursor * cursor) +{ + int ret; + DISPMANX_UPDATE_HANDLE_T update; + RPI_CursorData *curdata; + VC_RECT_T src_rect, dst_rect; + SDL_Mouse *mouse; + SDL_VideoDisplay *display; + SDL_DisplayData *data; + VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */ , 255 /*opacity 0->255*/, 0 /* mask */ }; + + mouse = SDL_GetMouse(); + if (mouse == NULL) { + return -1; + } + + if (cursor == NULL) { + /* FIXME: We hide the current mouse's cursor, what we actually need is *_HideCursor */ + + if ( mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { + curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; + if (curdata->element > DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + ret = vc_dispmanx_element_remove( update, curdata->element ); + SDL_assert( ret == DISPMANX_SUCCESS ); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + curdata->element = DISPMANX_NO_HANDLE; + } + } + return 0; + } + + curdata = (RPI_CursorData *) cursor->driverdata; + if (curdata == NULL) { + return -1; + } + + if (mouse->focus == NULL) { + return -1; + } + + display = SDL_GetDisplayForWindow(mouse->focus); + if (display == NULL) { + return -1; + } + + data = (SDL_DisplayData*) display->driverdata; + if (data == NULL) { + return -1; + } + + if (curdata->element == DISPMANX_NO_HANDLE) { + vc_dispmanx_rect_set( &src_rect, 0, 0, curdata->w << 16, curdata->h << 16 ); + vc_dispmanx_rect_set( &dst_rect, 0, 0, curdata->w, curdata->h); + + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + + curdata->element = vc_dispmanx_element_add( update, + data->dispman_display, + SDL_RPI_MOUSELAYER, // layer + &dst_rect, + curdata->resource, + &src_rect, + DISPMANX_PROTECTION_NONE, + &alpha, + DISPMANX_NO_HANDLE, // clamp + VC_IMAGE_ROT0 ); + SDL_assert( curdata->element > DISPMANX_NO_HANDLE); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + + return 0; +} + +/* Free a window manager cursor */ +static void +RPI_FreeCursor(SDL_Cursor * cursor) +{ + int ret; + DISPMANX_UPDATE_HANDLE_T update; + RPI_CursorData *curdata; + + if (cursor != NULL) { + curdata = (RPI_CursorData *) cursor->driverdata; + + if (curdata != NULL) { + if (curdata->element != DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + ret = vc_dispmanx_element_remove( update, curdata->element ); + SDL_assert( ret == DISPMANX_SUCCESS ); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + + if (curdata->resource != DISPMANX_NO_HANDLE) { + ret = vc_dispmanx_resource_delete( curdata->resource ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + + SDL_free(cursor->driverdata); + } + SDL_free(cursor); + } +} + +/* Warp the mouse to (x,y) */ +static void +RPI_WarpMouse(SDL_Window * window, int x, int y) +{ + RPI_CursorData *curdata; + DISPMANX_UPDATE_HANDLE_T update; + int ret; + VC_RECT_T dst_rect; + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { + curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; + if (curdata->element != DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + vc_dispmanx_rect_set( &dst_rect, x, y, curdata->w, curdata->h); + ret = vc_dispmanx_element_change_attributes( + update, + curdata->element, + ELEMENT_CHANGE_DEST_RECT, + 0, + 0, + &dst_rect, + NULL, + DISPMANX_NO_HANDLE, + DISPMANX_NO_ROTATE); + SDL_assert( ret == DISPMANX_SUCCESS ); + /* Submit asynchronously, otherwise the peformance suffers a lot */ + ret = vc_dispmanx_update_submit( update, 0, NULL ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + } +} + +void +RPI_InitMouse(_THIS) +{ + /* FIXME: Using UDEV it should be possible to scan all mice + * but there's no point in doing so as there's no multimice support...yet! + */ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = RPI_CreateCursor; + mouse->ShowCursor = RPI_ShowCursor; + mouse->MoveCursor = RPI_MoveCursor; + mouse->FreeCursor = RPI_FreeCursor; + mouse->WarpMouse = RPI_WarpMouse; + + SDL_SetDefaultCursor(RPI_CreateDefaultCursor()); +} + +void +RPI_QuitMouse(_THIS) +{ + +} + +/* This is called when a mouse motion event occurs */ +static void +RPI_MoveCursor(SDL_Cursor * cursor) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + RPI_WarpMouse(mouse->focus, mouse->x, mouse->y); +} + +#endif /* SDL_VIDEO_DRIVER_RPI */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpimouse.h b/src/video/raspberry/SDL_rpimouse.h new file mode 100644 index 000000000..aa8eec9ba --- /dev/null +++ b/src/video/raspberry/SDL_rpimouse.h @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_RPI_mouse_h +#define _SDL_RPI_mouse_h + +#include "../SDL_sysvideo.h" + +typedef struct _RPI_CursorData RPI_CursorData; +struct _RPI_CursorData +{ + DISPMANX_RESOURCE_HANDLE_T resource; + DISPMANX_ELEMENT_HANDLE_T element; + int hot_x, hot_y; + int w, h; +}; + +#define SDL_RPI_CURSORDATA(curs) RPI_CursorData *curdata = (RPI_CursorData *) ((curs) ? (curs)->driverdata : NULL) + +extern void RPI_InitMouse(_THIS); +extern void RPI_QuitMouse(_THIS); + +#endif /* _SDL_RPI_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpiopengles.c b/src/video/raspberry/SDL_rpiopengles.c new file mode 100644 index 000000000..23c89fe0d --- /dev/null +++ b/src/video/raspberry/SDL_rpiopengles.c @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL + +#include "SDL_rpivideo.h" +#include "SDL_rpiopengles.h" + +/* EGL implementation of SDL OpenGL support */ + +int +RPI_GLES_LoadLibrary(_THIS, const char *path) { + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); +} + +SDL_EGL_CreateContext_impl(RPI) +SDL_EGL_SwapWindow_impl(RPI) +SDL_EGL_MakeCurrent_impl(RPI) + +#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/video/raspberry/SDL_rpiopengles.h b/src/video/raspberry/SDL_rpiopengles.h new file mode 100644 index 000000000..deb4b2f36 --- /dev/null +++ b/src/video/raspberry/SDL_rpiopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_rpiopengles_h +#define _SDL_rpiopengles_h + +#if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl.h" + +/* OpenGLES functions */ +#define RPI_GLES_GetAttribute SDL_EGL_GetAttribute +#define RPI_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define RPI_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define RPI_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define RPI_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define RPI_GLES_DeleteContext SDL_EGL_DeleteContext + +extern int RPI_GLES_LoadLibrary(_THIS, const char *path); +extern SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window); +extern void RPI_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); + +#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_rpiopengles_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c new file mode 100644 index 000000000..ae9dc7dc4 --- /dev/null +++ b/src/video/raspberry/SDL_rpivideo.c @@ -0,0 +1,361 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI + +/* References + * http://elinux.org/RPi_VideoCore_APIs + * https://github.com/raspberrypi/firmware/blob/master/opt/vc/src/hello_pi/hello_triangle/triangle.c + * http://cgit.freedesktop.org/wayland/weston/tree/src/rpi-renderer.c + * http://cgit.freedesktop.org/wayland/weston/tree/src/compositor-rpi.c + */ + +/* SDL internals */ +#include "../SDL_sysvideo.h" +#include "SDL_version.h" +#include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_events.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../input/evdev/SDL_evdev.h" +#endif + +/* RPI declarations */ +#include "SDL_rpivideo.h" +#include "SDL_rpievents_c.h" +#include "SDL_rpiopengles.h" +#include "SDL_rpimouse.h" + +static int +RPI_Available(void) +{ + return 1; +} + +static void +RPI_Destroy(SDL_VideoDevice * device) +{ + /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ + + if (device->driverdata != NULL) { + device->driverdata = NULL; + } +} + +static SDL_VideoDevice * +RPI_Create() +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; + + /* Initialize SDL_VideoDevice structure */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + /* Initialize internal data */ + phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + if (phdata == NULL) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + + device->driverdata = phdata; + + /* Setup amount of available displays and current display */ + device->num_displays = 0; + + /* Set device free function */ + device->free = RPI_Destroy; + + /* Setup all functions which we can handle */ + device->VideoInit = RPI_VideoInit; + device->VideoQuit = RPI_VideoQuit; + device->GetDisplayModes = RPI_GetDisplayModes; + device->SetDisplayMode = RPI_SetDisplayMode; + device->CreateWindow = RPI_CreateWindow; + device->CreateWindowFrom = RPI_CreateWindowFrom; + device->SetWindowTitle = RPI_SetWindowTitle; + device->SetWindowIcon = RPI_SetWindowIcon; + device->SetWindowPosition = RPI_SetWindowPosition; + device->SetWindowSize = RPI_SetWindowSize; + device->ShowWindow = RPI_ShowWindow; + device->HideWindow = RPI_HideWindow; + device->RaiseWindow = RPI_RaiseWindow; + device->MaximizeWindow = RPI_MaximizeWindow; + device->MinimizeWindow = RPI_MinimizeWindow; + device->RestoreWindow = RPI_RestoreWindow; + device->SetWindowGrab = RPI_SetWindowGrab; + device->DestroyWindow = RPI_DestroyWindow; + device->GetWindowWMInfo = RPI_GetWindowWMInfo; + device->GL_LoadLibrary = RPI_GLES_LoadLibrary; + device->GL_GetProcAddress = RPI_GLES_GetProcAddress; + device->GL_UnloadLibrary = RPI_GLES_UnloadLibrary; + device->GL_CreateContext = RPI_GLES_CreateContext; + device->GL_MakeCurrent = RPI_GLES_MakeCurrent; + device->GL_SetSwapInterval = RPI_GLES_SetSwapInterval; + device->GL_GetSwapInterval = RPI_GLES_GetSwapInterval; + device->GL_SwapWindow = RPI_GLES_SwapWindow; + device->GL_DeleteContext = RPI_GLES_DeleteContext; + + device->PumpEvents = RPI_PumpEvents; + + return device; +} + +VideoBootStrap RPI_bootstrap = { + "RPI", + "RPI Video Driver", + RPI_Available, + RPI_Create +}; + +/*****************************************************************************/ +/* SDL Video and Display initialization/handling functions */ +/*****************************************************************************/ +int +RPI_VideoInit(_THIS) +{ + SDL_VideoDisplay display; + SDL_DisplayMode current_mode; + uint32_t w,h; + + /* Initialize BCM Host */ + bcm_host_init(); + + SDL_zero(current_mode); + + if (graphics_get_display_size( 0, &w, &h) < 0) { + return -1; + } + + current_mode.w = w; + current_mode.h = h; + /* FIXME: Is there a way to tell the actual refresh rate? */ + current_mode.refresh_rate = 60; + /* 32 bpp for default */ + current_mode.format = SDL_PIXELFORMAT_ABGR8888; + + current_mode.driverdata = NULL; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + + SDL_DisplayData *data; + + /* Allocate display internal data */ + data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + if (data == NULL) { + return SDL_OutOfMemory(); + } + + data->dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + + display.driverdata = data; + + SDL_AddVideoDisplay(&display); + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Init(); +#endif + + RPI_InitMouse(_this); + + return 1; +} + +void +RPI_VideoQuit(_THIS) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif +} + +void +RPI_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + /* Only one display mode available, the current one */ + SDL_AddDisplayMode(display, &display->current_mode); +} + +int +RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + return 0; +} + +int +RPI_CreateWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *wdata; + SDL_VideoDisplay *display; + SDL_DisplayData *displaydata; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + VC_DISPMANX_ALPHA_T dispman_alpha; + DISPMANX_UPDATE_HANDLE_T dispman_update; + + /* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */ + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0; + + /* Allocate window internal data */ + wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + if (wdata == NULL) { + return SDL_OutOfMemory(); + } + display = SDL_GetDisplayForWindow(window); + displaydata = (SDL_DisplayData *) display->driverdata; + + /* Windows have one size for now */ + window->w = display->desktop_mode.w; + window->h = display->desktop_mode.h; + + /* OpenGL ES is the law here, buddy */ + window->flags |= SDL_WINDOW_OPENGL; + + /* Create a dispman element and associate a window to it */ + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = window->w; + dst_rect.height = window->h; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = window->w << 16; + src_rect.height = window->h << 16; + + dispman_update = vc_dispmanx_update_start( 0 ); + wdata->dispman_window.element = vc_dispmanx_element_add ( dispman_update, displaydata->dispman_display, SDL_RPI_VIDEOLAYER /* layer */, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /*alpha*/, 0/*clamp*/, 0/*transform*/); + wdata->dispman_window.width = window->w; + wdata->dispman_window.height = window->h; + vc_dispmanx_update_submit_sync( dispman_update ); + + if (!_this->egl_data) { + if (SDL_GL_LoadLibrary(NULL) < 0) { + return -1; + } + } + wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) &wdata->dispman_window); + + if (wdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + /* Setup driver data for this window */ + window->driverdata = wdata; + + /* One window, it always has focus */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + /* Window has been successfully created */ + return 0; +} + +int +RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +{ + return -1; +} + +void +RPI_SetWindowTitle(_THIS, SDL_Window * window) +{ +} +void +RPI_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +{ +} +void +RPI_SetWindowPosition(_THIS, SDL_Window * window) +{ +} +void +RPI_SetWindowSize(_THIS, SDL_Window * window) +{ +} +void +RPI_ShowWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_HideWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_RaiseWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_MaximizeWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_MinimizeWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_RestoreWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + +} +void +RPI_DestroyWindow(_THIS, SDL_Window * window) +{ +} + +/*****************************************************************************/ +/* SDL Window Manager function */ +/*****************************************************************************/ +SDL_bool +RPI_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +{ + if (info->version.major <= SDL_MAJOR_VERSION) { + return SDL_TRUE; + } else { + SDL_SetError("application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } + + /* Failed to get window manager information */ + return SDL_FALSE; +} + +#endif /* SDL_VIDEO_DRIVER_RPI */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpivideo.h b/src/video/raspberry/SDL_rpivideo.h new file mode 100644 index 000000000..6359badc9 --- /dev/null +++ b/src/video/raspberry/SDL_rpivideo.h @@ -0,0 +1,98 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __SDL_RPIVIDEO_H__ +#define __SDL_RPIVIDEO_H__ + +#include "SDL_config.h" +#include "../SDL_sysvideo.h" + +#include "bcm_host.h" +#include "GLES/gl.h" +#include "EGL/egl.h" +#include "EGL/eglext.h" + +typedef struct SDL_VideoData +{ + uint32_t egl_refcount; /* OpenGL ES reference count */ +} SDL_VideoData; + + +typedef struct SDL_DisplayData +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display; +} SDL_DisplayData; + + +typedef struct SDL_WindowData +{ + EGL_DISPMANX_WINDOW_T dispman_window; +#if SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif +} SDL_WindowData; + +#define SDL_RPI_VIDEOLAYER 10000 /* High enough so to occlude everything */ +#define SDL_RPI_MOUSELAYER SDL_RPI_VIDEOLAYER + 1 + + +/****************************************************************************/ +/* SDL_VideoDevice functions declaration */ +/****************************************************************************/ + +/* Display and window functions */ +int RPI_VideoInit(_THIS); +void RPI_VideoQuit(_THIS); +void RPI_GetDisplayModes(_THIS, SDL_VideoDisplay * display); +int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +int RPI_CreateWindow(_THIS, SDL_Window * window); +int RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +void RPI_SetWindowTitle(_THIS, SDL_Window * window); +void RPI_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); +void RPI_SetWindowPosition(_THIS, SDL_Window * window); +void RPI_SetWindowSize(_THIS, SDL_Window * window); +void RPI_ShowWindow(_THIS, SDL_Window * window); +void RPI_HideWindow(_THIS, SDL_Window * window); +void RPI_RaiseWindow(_THIS, SDL_Window * window); +void RPI_MaximizeWindow(_THIS, SDL_Window * window); +void RPI_MinimizeWindow(_THIS, SDL_Window * window); +void RPI_RestoreWindow(_THIS, SDL_Window * window); +void RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +void RPI_DestroyWindow(_THIS, SDL_Window * window); + +/* Window manager function */ +SDL_bool RPI_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info); + +/* OpenGL/OpenGL ES functions */ +int RPI_GLES_LoadLibrary(_THIS, const char *path); +void *RPI_GLES_GetProcAddress(_THIS, const char *proc); +void RPI_GLES_UnloadLibrary(_THIS); +SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window); +int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +int RPI_GLES_SetSwapInterval(_THIS, int interval); +int RPI_GLES_GetSwapInterval(_THIS); +void RPI_GLES_SwapWindow(_THIS, SDL_Window * window); +void RPI_GLES_DeleteContext(_THIS, SDL_GLContext context); + +#endif /* __SDL_RPIVIDEO_H__ */ + +/* vi: set ts=4 sw=4 expandtab: */ From edf503e8701dd9a768043053a8767b6e792c52ee Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 10:30:51 -0700 Subject: [PATCH 120/258] Fixed bug 1820 - building SDL as a static library with static runtime doesn't compile/link with visual studio norfanin Adds a condition so only the MSVC 2012 compiler defines the macros for the functions of its version. Attaching a patch that adds a condition so that the HAVE_X supported by MSVC 2012 only get defined with that compiler. MSVC 2008 and 2010 will then build without any modification to the SDL source code. Also moved HAVE_M_PI to a separate check. The Microsoft headers require _USE_MATH_DEFINES to be defined before they define the constants. --HG-- extra : rebase_source : 5a348adc971f36b3e524a3f30759c6b4c04c400d --- include/SDL_config_windows.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 9f3448ec3..7307763f2 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -105,12 +105,10 @@ typedef unsigned int uintptr_t; #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 -#define HAVE_ITOA 1 #define HAVE__LTOA 1 #define HAVE__ULTOA 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 @@ -118,22 +116,28 @@ typedef unsigned int uintptr_t; #define HAVE_STRNCMP 1 #define HAVE__STRICMP 1 #define HAVE__STRNICMP 1 -#define HAVE_SSCANF 1 -#define HAVE_M_PI 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 #define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 #define HAVE_COS 1 #define HAVE_COSF 1 #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 +#if _MSC_VER >= 1700 +#define HAVE_ITOA 1 +#define HAVE_STRTOLL 1 +#define HAVE_SSCANF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_SCALBN 1 +#endif +#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) +#define HAVE_M_PI 1 +#endif #else #define HAVE_STDARG_H 1 #define HAVE_STDDEF_H 1 From a7429dfa2222cce680acb3f461396062172c55b8 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sat, 28 Sep 2013 15:48:32 -0300 Subject: [PATCH 121/258] Do not use UDEV references in EVDEV if UDEV has not been detected --- src/input/evdev/SDL_evdev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c index ea911d68c..99b994976 100644 --- a/src/input/evdev/SDL_evdev.c +++ b/src/input/evdev/SDL_evdev.c @@ -53,12 +53,14 @@ static _THIS = NULL; #define SYN_DROPPED 3 #endif - -static int SDL_EVDEV_device_removed(const char *devpath); -static int SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath); static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode); static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); + +#if SDL_USE_LIBUDEV +static int SDL_EVDEV_device_removed(const char *devpath); +static int SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath); void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); +#endif /* SDL_USE_LIBUDEV */ static SDL_Scancode EVDEV_Keycodes[] = { SDL_SCANCODE_UNKNOWN, /* KEY_RESERVED 0 */ @@ -390,6 +392,7 @@ SDL_EVDEV_Quit(void) } } +#if SDL_USE_LIBUDEV void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath) { SDL_EVDEV_deviceclass devclass; @@ -429,6 +432,8 @@ void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclas } +#endif /* SDL_USE_LIBUDEV */ + void SDL_EVDEV_Poll(void) { @@ -562,6 +567,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) /* TODO: get full state of device and report whatever is required */ } +#if SDL_USE_LIBUDEV static int SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath) { @@ -640,6 +646,7 @@ SDL_EVDEV_device_removed(const char *devpath) return -1; } +#endif /* SDL_USE_LIBUDEV */ #endif /* SDL_INPUT_LINUXEV */ From a759ac24a1a3e76cb1fd1d7631fee7b99d5e06d9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:20 -0700 Subject: [PATCH 122/258] Moved D3D_LoadDLL and SDL_Direct3D9GetAdapterIndex to SDL_windowswindow.c at Jorgen's insistence. That file is wrapped in a more appropriate define check so it will work if somebody builds a binary without D3D support. Added a reference to SDL_Direct3D9GetAdapterIndex to SDL_test_common.c so SDL will fail to compile if the new symbol isn't included properly. CR: Jorgen --- src/render/direct3d/SDL_render_d3d.c | 72 ++----------------------- src/test/SDL_test_common.c | 10 +++- src/video/windows/SDL_windowswindow.c | 76 +++++++++++++++++++++++++++ src/video/windows/SDL_windowswindow.h | 3 ++ 4 files changed, 92 insertions(+), 69 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index d99057e3c..0248b21a0 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -28,11 +28,13 @@ #include "SDL_hints.h" #include "SDL_loadso.h" #include "SDL_syswm.h" +#include "SDL_system.h" #include "../SDL_sysrender.h" -#include "../../video/SDL_sysvideo.h" -#include "../../video/windows/SDL_windowsmodes.h" #include +#include "../../video/SDL_sysvideo.h" +#include "../../video/windows/SDL_windowswindow.h" + #if SDL_VIDEO_RENDER_D3D #define D3D_DEBUG_INFO #include @@ -533,72 +535,6 @@ D3D_ActivateRenderer(SDL_Renderer * renderer) return 0; } -SDL_bool -D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) -{ - *pD3DDLL = SDL_LoadObject("D3D9.DLL"); - if (*pD3DDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, - "Direct3DCreate9"); - if (D3DCreate) { - *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); - } - if (!*pDirect3D9Interface) { - SDL_UnloadObject(*pD3DDLL); - *pD3DDLL = NULL; - return SDL_FALSE; - } - - return SDL_TRUE; - } else { - *pDirect3D9Interface = NULL; - return SDL_FALSE; - } -} - - -int -SDL_Direct3D9GetAdapterIndex( int displayIndex ) -{ - void *pD3DDLL; - IDirect3D9 *pD3D; - if (!D3D_LoadDLL( &pD3DDLL, &pD3D)) { - SDL_SetError("Unable to create Direct3D interface"); - return D3DADAPTER_DEFAULT; - } else { - SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData( displayIndex ); - int adapterIndex = D3DADAPTER_DEFAULT; - - if (!pData) { - SDL_SetError( "Invalid display index" ); - } else { - char *displayName = WIN_StringToUTF8( pData->DeviceName ); - unsigned int count = IDirect3D9_GetAdapterCount( pD3D ); - unsigned int i; - for (i=0; i + /* Windows CE compatibility */ #ifndef SWP_NOCOPYBITS #define SWP_NOCOPYBITS 0 @@ -683,6 +691,74 @@ void WIN_OnWindowEnter(_THIS, SDL_Window * window) #endif /* WM_MOUSELEAVE */ } +SDL_bool +D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) +{ + *pD3DDLL = SDL_LoadObject("D3D9.DLL"); + if (*pD3DDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); + + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, + "Direct3DCreate9"); + if (D3DCreate) { + *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); + } + if (!*pDirect3D9Interface) { + SDL_UnloadObject(*pD3DDLL); + *pD3DDLL = NULL; + return SDL_FALSE; + } + + return SDL_TRUE; + } else { + *pDirect3D9Interface = NULL; + return SDL_FALSE; + } +} + + +int +SDL_Direct3D9GetAdapterIndex( int displayIndex ) +{ + void *pD3DDLL; + IDirect3D9 *pD3D; + if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { + SDL_SetError("Unable to create Direct3D interface"); + return D3DADAPTER_DEFAULT; + } else { + SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); + int adapterIndex = D3DADAPTER_DEFAULT; + + if (!pData) { + SDL_SetError("Invalid display index"); + adapterIndex = -1; /* make sure we return something invalid */ + } else { + char *displayName = WIN_StringToUTF8(pData->DeviceName); + unsigned int count = IDirect3D9_GetAdapterCount(pD3D); + unsigned int i; + for (i=0; i Date: Sat, 28 Sep 2013 14:06:31 -0700 Subject: [PATCH 123/258] SDL_LoadObject on Windows now calls LoadLibrary a second time in its EX form whenever the first load fails. This second call uses the "altered" search path for DLL dependencies, which includes searching the directory that the DLL itself lives in. --- src/loadso/windows/SDL_sysloadso.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index 21e7a6c54..ebad03453 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -34,6 +34,19 @@ SDL_LoadObject(const char *sofile) { LPTSTR tstr = WIN_UTF8ToString(sofile); void *handle = (void *) LoadLibrary(tstr); + + /* By default LoadLibrary uses the current working directory + * as the first item on the search path for implicit dependencies + * of whatever it's loading. That is somewhat inconsistent with + * what dlopen does on other platforms, so we will try again + * with LoadLibraryEx and a slightly different search path. This + * causes Windows to search for dependencies in the directory + * that the module itself lives in. */ + if(handle == NULL) + { + handle = (void *) LoadLibraryEx(tstr, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + } + SDL_free(tstr); /* Generate an error message if all loads failed */ From 45bd5e2b835b5f7764eee5f8a356b6f5fc612f2e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:39 -0700 Subject: [PATCH 124/258] Rolled back my LoadLibrary change. The first failed call causes a dialog to pop up in Windows apps (but not console apps) and that's really bad. I'll have to deal with this in my app. --- src/loadso/windows/SDL_sysloadso.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index ebad03453..21e7a6c54 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -34,19 +34,6 @@ SDL_LoadObject(const char *sofile) { LPTSTR tstr = WIN_UTF8ToString(sofile); void *handle = (void *) LoadLibrary(tstr); - - /* By default LoadLibrary uses the current working directory - * as the first item on the search path for implicit dependencies - * of whatever it's loading. That is somewhat inconsistent with - * what dlopen does on other platforms, so we will try again - * with LoadLibraryEx and a slightly different search path. This - * causes Windows to search for dependencies in the directory - * that the module itself lives in. */ - if(handle == NULL) - { - handle = (void *) LoadLibraryEx(tstr, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - } - SDL_free(tstr); /* Generate an error message if all loads failed */ From 43cc5c1cbb5022d8aa84ef69afb857d084e63dae Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:47 -0700 Subject: [PATCH 125/258] Added optimized YUV texture upload path with SDL_UpdateYUVTexture() --- include/SDL_render.h | 25 ++++++++ src/render/SDL_render.c | 100 ++++++++++++++++++++++++++++++ src/render/SDL_sysrender.h | 5 ++ src/render/SDL_yuv_sw.c | 54 ++++++++++++++++ src/render/SDL_yuv_sw_c.h | 4 ++ src/render/opengl/SDL_render_gl.c | 41 ++++++++++++ 6 files changed, 229 insertions(+) diff --git a/include/SDL_render.h b/include/SDL_render.h index 1e24619f0..a765dc79f 100644 --- a/include/SDL_render.h +++ b/include/SDL_render.h @@ -381,6 +381,31 @@ extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +/** + * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane The raw pixel data for the Y plane. + * \param Ypitch The number of bytes between rows of pixel data for the Y plane. + * \param Uplane The raw pixel data for the U plane. + * \param Upitch The number of bytes between rows of pixel data for the U plane. + * \param Vplane The raw pixel data for the V plane. + * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note You can use SDL_UpdateTexture() as long as your pixel data is + * a contiguous block of Y and U/V planes in the proper order, but + * this function is available if your pixel data is not contiguous. + */ +extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + /** * \brief Lock a portion of the texture for write-only pixel access. * diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index ef690cf79..680b32421 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -804,6 +804,106 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, } } +static int +SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + SDL_Texture *native = texture->native; + SDL_Rect full_rect; + + if (SDL_SW_UpdateYUVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch) < 0) { + return -1; + } + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels; + int native_pitch; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + void *temp_pixels; + int temp_pitch; + + temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + return 0; +} + +int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (!Yplane) { + return SDL_InvalidParamError("Yplane"); + } + if (!Ypitch) { + return SDL_InvalidParamError("Ypitch"); + } + if (!Uplane) { + return SDL_InvalidParamError("Uplane"); + } + if (!Upitch) { + return SDL_InvalidParamError("Upitch"); + } + if (!Vplane) { + return SDL_InvalidParamError("Vplane"); + } + if (!Vpitch) { + return SDL_InvalidParamError("Vpitch"); + } + + if (texture->format != SDL_PIXELFORMAT_YV12 && + texture->format != SDL_PIXELFORMAT_IYUV) { + return SDL_SetError("Texture format must by YV12 or IYUV"); + } + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if (texture->yuv) { + return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + SDL_assert(!texture->native); + renderer = texture->renderer; + SDL_assert(renderer->UpdateTextureYUV); + return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } +} + static int SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index f06ee1d80..b3d68688b 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -89,6 +89,11 @@ struct SDL_Renderer int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); + int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 2c7e72449..a978d4b36 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1184,6 +1184,60 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, return 0; } +int +SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + Uint8 *src, *dst; + int row; + size_t length; + + /* Copy the Y plane */ + src = Yplane; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += Ypitch; + dst += swdata->w; + } + + /* Copy the U plane */ + src = Uplane; + if (swdata->format == SDL_PIXELFORMAT_IYUV) { + dst = swdata->pixels + swdata->h * swdata->w; + } else { + dst = swdata->pixels + swdata->h * swdata->w + + (swdata->h * swdata->w) / 4; + } + dst += rect->y/2 * swdata->w/2 + rect->x/2; + length = rect->w / 2; + for (row = 0; row < rect->h/2; ++row) { + SDL_memcpy(dst, src, length); + src += Upitch; + dst += swdata->w/2; + } + + /* Copy the V plane */ + src = Vplane; + if (swdata->format == SDL_PIXELFORMAT_YV12) { + dst = swdata->pixels + swdata->h * swdata->w; + } else { + dst = swdata->pixels + swdata->h * swdata->w + + (swdata->h * swdata->w) / 4; + } + dst += rect->y/2 * swdata->w/2 + rect->x/2; + length = rect->w / 2; + for (row = 0; row < rect->h/2; ++row) { + SDL_memcpy(dst, src, length); + src += Vpitch; + dst += swdata->w/2; + } + return 0; +} + int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, void **pixels, int *pitch) diff --git a/src/render/SDL_yuv_sw_c.h b/src/render/SDL_yuv_sw_c.h index 9debacbcf..f1280417f 100644 --- a/src/render/SDL_yuv_sw_c.h +++ b/src/render/SDL_yuv_sw_c.h @@ -57,6 +57,10 @@ int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, int *pitch); int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, const void *pixels, int pitch); +int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, void **pixels, int *pitch); void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata); diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index cd0a7085d..824ae8cce 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -52,6 +52,11 @@ static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +static int GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -403,6 +408,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->GetOutputSize = GL_GetOutputSize; renderer->CreateTexture = GL_CreateTexture; renderer->UpdateTexture = GL_UpdateTexture; + renderer->UpdateTextureYUV = GL_UpdateTextureYUV; renderer->LockTexture = GL_LockTexture; renderer->UnlockTexture = GL_UnlockTexture; renderer->SetRenderTarget = GL_SetRenderTarget; @@ -801,6 +807,41 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return GL_CheckError("glTexSubImage2D()", renderer); } +static int +GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + GL_ActivateRenderer(renderer); + + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Ypitch); + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + Yplane); + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Upitch); + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + data->format, data->formattype, Uplane); + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Vpitch); + renderdata->glBindTexture(data->type, data->vtexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + data->format, data->formattype, Vplane); + renderdata->glDisable(data->type); + return GL_CheckError("glTexSubImage2D()", renderer); +} + static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) From b03fdbe67f992c6b9a3fc29554c39fd1ce665fce Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:51 -0700 Subject: [PATCH 126/258] Added missing SDL_assert.h --- src/render/SDL_render.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 680b32421..1b9bfd6e8 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -22,6 +22,7 @@ /* The SDL 2D rendering system */ +#include "SDL_assert.h" #include "SDL_hints.h" #include "SDL_log.h" #include "SDL_render.h" From 018c78cd9fca8a38429e473bd10ce207f379efca Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:55 -0700 Subject: [PATCH 127/258] Implemented SDL_UpdateYUVTexture() for Direct3D --- src/render/SDL_render.c | 8 +++++-- src/render/direct3d/SDL_render_d3d.c | 36 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 1b9bfd6e8..8420d2f74 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -901,8 +901,12 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, SDL_assert(!texture->native); renderer = texture->renderer; SDL_assert(renderer->UpdateTextureYUV); - return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); - } + if (renderer->UpdateTextureYUV) { + return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + return SDL_Unsupported(); + } + } } static int diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 0248b21a0..865ac21c0 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -211,6 +211,11 @@ static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +static int D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -599,6 +604,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->WindowEvent = D3D_WindowEvent; renderer->CreateTexture = D3D_CreateTexture; renderer->UpdateTexture = D3D_UpdateTexture; + renderer->UpdateTextureYUV = D3D_UpdateTextureYUV; renderer->LockTexture = D3D_LockTexture; renderer->UnlockTexture = D3D_UnlockTexture; renderer->SetRenderTarget = D3D_SetRenderTarget; @@ -1016,6 +1022,36 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } +static int +D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + SDL_bool full_texture = SDL_FALSE; + +#ifdef USE_DYNAMIC_TEXTURE + if (texture->access == SDL_TEXTUREACCESS_STREAMING && + rect->x == 0 && rect->y == 0 && + rect->w == texture->w && rect->h == texture->h) { + full_texture = SDL_TRUE; + } +#endif + + if (D3D_UpdateTextureInternal(data->texture, texture->format, full_texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + if (D3D_UpdateTextureInternal(data->utexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) { + return -1; + } + if (D3D_UpdateTextureInternal(data->vtexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) { + return -1; + } + return 0; +} + static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) From 585fd26052748d0599fd04250fc3e015b2f32e80 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:59 -0700 Subject: [PATCH 128/258] Moved SDL_Direct3D9GetAdapterIndex() to SDL_windowsvideo.c since it doesn't belong in the window code. --- src/render/direct3d/SDL_render_d3d.c | 5 +- src/video/windows/SDL_windowsvideo.c | 71 +++++++++++++++++++++++++ src/video/windows/SDL_windowsvideo.h | 4 ++ src/video/windows/SDL_windowswindow.c | 76 --------------------------- src/video/windows/SDL_windowswindow.h | 3 -- 5 files changed, 76 insertions(+), 83 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 865ac21c0..73a2c82ce 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -30,10 +30,7 @@ #include "SDL_syswm.h" #include "SDL_system.h" #include "../SDL_sysrender.h" -#include - -#include "../../video/SDL_sysvideo.h" -#include "../../video/windows/SDL_windowswindow.h" +#include "../../video/windows/SDL_windowsvideo.h" #if SDL_VIDEO_RENDER_D3D #define D3D_DEBUG_INFO diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 77b63a21a..8f708cf0d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -25,6 +25,7 @@ #include "SDL_main.h" #include "SDL_video.h" #include "SDL_mouse.h" +#include "SDL_system.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" @@ -174,6 +175,76 @@ WIN_VideoQuit(_THIS) WIN_QuitMouse(_this); } + +#define D3D_DEBUG_INFO +#include + +SDL_bool +D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) +{ + *pD3DDLL = SDL_LoadObject("D3D9.DLL"); + if (*pD3DDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); + + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, + "Direct3DCreate9"); + if (D3DCreate) { + *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); + } + if (!*pDirect3D9Interface) { + SDL_UnloadObject(*pD3DDLL); + *pD3DDLL = NULL; + return SDL_FALSE; + } + + return SDL_TRUE; + } else { + *pDirect3D9Interface = NULL; + return SDL_FALSE; + } +} + + +int +SDL_Direct3D9GetAdapterIndex( int displayIndex ) +{ + void *pD3DDLL; + IDirect3D9 *pD3D; + if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { + SDL_SetError("Unable to create Direct3D interface"); + return D3DADAPTER_DEFAULT; + } else { + SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); + int adapterIndex = D3DADAPTER_DEFAULT; + + if (!pData) { + SDL_SetError("Invalid display index"); + adapterIndex = -1; /* make sure we return something invalid */ + } else { + char *displayName = WIN_StringToUTF8(pData->DeviceName); + unsigned int count = IDirect3D9_GetAdapterCount(pD3D); + unsigned int i; + for (i=0; i - /* Windows CE compatibility */ #ifndef SWP_NOCOPYBITS #define SWP_NOCOPYBITS 0 @@ -691,74 +683,6 @@ void WIN_OnWindowEnter(_THIS, SDL_Window * window) #endif /* WM_MOUSELEAVE */ } -SDL_bool -D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) -{ - *pD3DDLL = SDL_LoadObject("D3D9.DLL"); - if (*pD3DDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, - "Direct3DCreate9"); - if (D3DCreate) { - *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); - } - if (!*pDirect3D9Interface) { - SDL_UnloadObject(*pD3DDLL); - *pD3DDLL = NULL; - return SDL_FALSE; - } - - return SDL_TRUE; - } else { - *pDirect3D9Interface = NULL; - return SDL_FALSE; - } -} - - -int -SDL_Direct3D9GetAdapterIndex( int displayIndex ) -{ - void *pD3DDLL; - IDirect3D9 *pD3D; - if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { - SDL_SetError("Unable to create Direct3D interface"); - return D3DADAPTER_DEFAULT; - } else { - SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); - int adapterIndex = D3DADAPTER_DEFAULT; - - if (!pData) { - SDL_SetError("Invalid display index"); - adapterIndex = -1; /* make sure we return something invalid */ - } else { - char *displayName = WIN_StringToUTF8(pData->DeviceName); - unsigned int count = IDirect3D9_GetAdapterCount(pD3D); - unsigned int i; - for (i=0; i Date: Sat, 28 Sep 2013 14:07:05 -0700 Subject: [PATCH 129/258] Added platform specific call: SDL_RenderGetD3DDevice() --- include/SDL_system.h | 10 ++++++---- src/render/direct3d/SDL_render_d3d.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/SDL_system.h b/include/SDL_system.h index 68ff8990a..5c3193739 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -29,11 +29,9 @@ #define _SDL_system_h #include "SDL_stdinc.h" - -#if defined(__IPHONEOS__) && __IPHONEOS__ -#include "SDL_video.h" #include "SDL_keyboard.h" -#endif +#include "SDL_render.h" +#include "SDL_video.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -51,6 +49,10 @@ extern "C" { */ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); +/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. */ +typedef struct IDirect3DDevice9 IDirect3DDevice9; +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3DDevice(SDL_Renderer * renderer); + #endif /* __WIN32__ */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 73a2c82ce..2ac597493 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1875,6 +1875,19 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } +IDirect3DDevice9 * +SDL_RenderGetD3DDevice(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + + // Make sure that this is a D3D renderer + if (renderer->DestroyRenderer != D3D_DestroyRenderer) { + SDL_SetError("Renderer is not a D3D renderer"); + return NULL; + } + return data->device; +} + #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ From f86e83feba595ddbf0f6ca13e084a14b73584e52 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:07:08 -0700 Subject: [PATCH 130/258] Added a hint to create the D3D device in thread-safe mode: SDL_HINT_RENDER_DIRECT3D_THREADSAFE --- include/SDL_hints.h | 11 +++++++++++ src/render/direct3d/SDL_render_d3d.c | 22 +++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index 9dc9cfe76..dac928e07 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -94,6 +94,17 @@ extern "C" { */ #define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" +/** + * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. + * + * This variable can be set to the following values: + * "0" - Thread-safety is not enabled (faster) + * "1" - Thread-safety is enabled + * + * By default the Direct3D device is created with thread-safety disabled. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + /** * \brief A variable controlling the scaling quality * diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 2ac597493..fdaf796b6 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -544,9 +544,11 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) D3D_RenderData *data; SDL_SysWMinfo windowinfo; HRESULT result; + const char *hint; D3DPRESENT_PARAMETERS pparams; IDirect3DSwapChain9 *chain; D3DCAPS9 caps; + DWORD device_flags; Uint32 window_flags; int w, h; SDL_DisplayMode fullscreen_mode; @@ -589,8 +591,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) } } - - if (!data->d3d || !data->matrixStack) { SDL_free(renderer); SDL_free(data); @@ -667,14 +667,22 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); + device_flags = D3DCREATE_FPU_PRESERVE; + if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { + device_flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; + } else { + device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; + } + + hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE); + if (hint && SDL_atoi(hint)) { + device_flags |= D3DCREATE_MULTITHREADED; + } + result = IDirect3D9_CreateDevice(data->d3d, data->adapter, D3DDEVTYPE_HAL, pparams.hDeviceWindow, - D3DCREATE_FPU_PRESERVE | ((caps. - DevCaps & - D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? - D3DCREATE_HARDWARE_VERTEXPROCESSING : - D3DCREATE_SOFTWARE_VERTEXPROCESSING), + device_flags, &pparams, &data->device); if (FAILED(result)) { D3D_DestroyRenderer(renderer); From 2ef24caf1d30d477d1e20b2e5b1e7aa9177d1ef7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:07:14 -0700 Subject: [PATCH 131/258] Make it clear we're just returning a D3D9 device, allowing for new functions to get other D3D versions --- include/SDL_system.h | 2 +- src/render/direct3d/SDL_render_d3d.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_system.h b/include/SDL_system.h index 5c3193739..1ca607fbf 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -51,7 +51,7 @@ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); /* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. */ typedef struct IDirect3DDevice9 IDirect3DDevice9; -extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3DDevice(SDL_Renderer * renderer); +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); #endif /* __WIN32__ */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index fdaf796b6..36205eb87 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1884,7 +1884,7 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) } IDirect3DDevice9 * -SDL_RenderGetD3DDevice(SDL_Renderer * renderer) +SDL_RenderGetD3D9Device(SDL_Renderer * renderer) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; From 06caf6a344eb58151b532e9a8007ab3084f8ba7b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:07:17 -0700 Subject: [PATCH 132/258] Call AddRef() on the device so it doesn't accidentally get released from underneath the caller. --- include/SDL_system.h | 4 +++- src/render/direct3d/SDL_render_d3d.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/SDL_system.h b/include/SDL_system.h index 1ca607fbf..9af2a4c2c 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -49,7 +49,9 @@ extern "C" { */ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); -/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. */ +/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. + Once you are done using the device, you should release it to avoid a resource leak. + */ typedef struct IDirect3DDevice9 IDirect3DDevice9; extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 36205eb87..33665e370 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1887,13 +1887,19 @@ IDirect3DDevice9 * SDL_RenderGetD3D9Device(SDL_Renderer * renderer) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + IDirect3DDevice9 *device; // Make sure that this is a D3D renderer if (renderer->DestroyRenderer != D3D_DestroyRenderer) { SDL_SetError("Renderer is not a D3D renderer"); return NULL; } - return data->device; + + device = data->device; + if (device) { + IDirect3DDevice9_AddRef( device ); + } + return device; } #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ From b832dd0230bc10be42ca4ef05ad038a384234e21 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sat, 28 Sep 2013 19:17:27 -0300 Subject: [PATCH 133/258] Fix: SDL_EVDEV_device_removed does not need UDEV --- src/input/evdev/SDL_evdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c index 99b994976..4581ac0ce 100644 --- a/src/input/evdev/SDL_evdev.c +++ b/src/input/evdev/SDL_evdev.c @@ -55,9 +55,9 @@ static _THIS = NULL; static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode); static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); +static int SDL_EVDEV_device_removed(const char *devpath); #if SDL_USE_LIBUDEV -static int SDL_EVDEV_device_removed(const char *devpath); static int SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath); void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); #endif /* SDL_USE_LIBUDEV */ @@ -615,7 +615,7 @@ SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath) return _this->numdevices++; } - +#endif /* SDL_USE_LIBUDEV */ static int SDL_EVDEV_device_removed(const char *devpath) @@ -646,7 +646,7 @@ SDL_EVDEV_device_removed(const char *devpath) return -1; } -#endif /* SDL_USE_LIBUDEV */ + #endif /* SDL_INPUT_LINUXEV */ From 774637beab414fa4328a79fc9f38cb97ecf08b74 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sat, 28 Sep 2013 19:23:59 -0300 Subject: [PATCH 134/258] Removes unused property use_egl from internal structure gl_config --- src/video/SDL_sysvideo.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index bdb2a3130..beedc7474 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -292,7 +292,6 @@ struct SDL_VideoDevice int minor_version; int flags; int profile_mask; - int use_egl; int share_with_current_context; int retained_backing; int driver_loaded; From 0a805ff1374b8a6aa7d66f024ca2a1e68c606d06 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 30 Sep 2013 21:57:03 -0700 Subject: [PATCH 135/258] Fixed bug 2119 - compiler warnings (-pedantic) SDL_video.h:111:42 --- include/SDL_video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_video.h b/include/SDL_video.h index 3b02cce2f..aa2dc692d 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -108,7 +108,7 @@ typedef enum SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ - SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /**< window should be created in high-DPI mode if supported */ } SDL_WindowFlags; /** From 76f3df86db91cae11a8e1fe4ccc5dbcaea133b96 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 30 Sep 2013 22:16:14 -0700 Subject: [PATCH 136/258] Fixed bug 2122 - SDL_CreateTexture allows illegal texture sizes Lloyd Bryant SDL_CreateTexture() is succeeding (i.e. returning a valid pointer) when the requested horizontal or vertical size of the texture exceeds the maximum allowed by the render. This results in hard-to-understand errors showing up when later attempting to use that texture (such as with SDL_SetRenderTarget()). --- src/render/SDL_render.c | 5 +++++ src/render/opengles2/SDL_render_gles2.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 8420d2f74..5546d4a61 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -410,6 +410,11 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int SDL_SetError("Texture dimensions can't be 0"); return NULL; } + if ((renderer->info.max_texture_width && w > renderer->info.max_texture_width) || + (renderer->info.max_texture_height && h > renderer->info.max_texture_height)) { + SDL_SetError("Texture dimensions are limited to %dx%d", renderer->info.max_texture_width, renderer->info.max_texture_height); + return NULL; + } texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); if (!texture) { SDL_OutOfMemory(); diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 484186e33..10cb42d8f 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1627,6 +1627,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) #endif Uint32 windowFlags; GLint window_framebuffer; + GLint value; SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); @@ -1685,6 +1686,13 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } + value = 0; + rdata->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + value = 0; + rdata->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + /* Determine supported shader formats */ /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ rdata->glGetError(); From 414ff3106c2fee138aeaf314ef877f124e8d471d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 30 Sep 2013 22:35:32 -0700 Subject: [PATCH 137/258] Fixed bug 2121 - GCC throws error on SDL_FORCE_INLINE when compiling with -ansi --- include/begin_code.h | 17 +++++++++-------- src/filesystem/cocoa/SDL_sysfilesystem.m | 4 ++-- src/video/cocoa/SDL_cocoamodes.m | 10 ++++++---- src/video/cocoa/SDL_cocoashape.m | 4 ++-- src/video/cocoa/SDL_cocoawindow.m | 7 ++++--- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/include/begin_code.h b/include/begin_code.h index 902aeb114..5261d26c1 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -99,11 +99,9 @@ #endif #endif /* Compiler needs structure packing set */ +#ifndef __inline__ /* Set up compiler-specific options for inlining functions */ #ifndef SDL_INLINE_OKAY -#ifdef __GNUC__ -#define SDL_INLINE_OKAY -#else /* Add any special compiler-specific cases here */ #if defined(_MSC_VER) || defined(__BORLANDC__) || \ defined(__DMC__) || defined(__SC__) || \ @@ -112,31 +110,34 @@ #ifndef __inline__ #define __inline__ __inline #endif -#define SDL_INLINE_OKAY +#define SDL_INLINE_OKAY 1 #else #if !defined(__MRC__) && !defined(_SGI_SOURCE) #ifndef __inline__ #define __inline__ inline #endif -#define SDL_INLINE_OKAY +#define SDL_INLINE_OKAY 1 #endif /* Not a funky compiler */ #endif /* Visual C++ */ -#endif /* GNU C */ #endif /* SDL_INLINE_OKAY */ /* If inlining isn't supported, remove "__inline__", turning static inlined functions into static functions (resulting in code bloat in all files which include the offending header files) */ -#ifndef SDL_INLINE_OKAY +#if !SDL_INLINE_OKAY || __STRICT_ANSI__ +#ifdef __inline__ +#undef __inline__ +#endif #define __inline__ #endif +#endif /* __inline__ not defined */ #ifndef SDL_FORCE_INLINE #if defined(_MSC_VER) #define SDL_FORCE_INLINE __forceinline #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) -#define SDL_FORCE_INLINE __attribute__((always_inline)) static inline +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ #else #define SDL_FORCE_INLINE static __inline__ #endif diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index c9b0ecceb..43e024c2b 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -73,9 +73,9 @@ SDL_GetPrefPath(const char *org, const char *app) NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); char *retval = NULL; - (void) org; // unused on Mac OS X and iOS. + (void) org; /* unused on Mac OS X and iOS. */ - if ([array count] > 0) { // we only want the first item in the list. + if ([array count] > 0) { /* we only want the first item in the list. */ NSString *str = [array objectAtIndex:0]; const char *base = [str UTF8String]; if (base) { diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index d71cb1767..501684fc9 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -33,7 +33,9 @@ /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ #include -static inline void Cocoa_ToggleMenuBar(const BOOL show) + +static void +Cocoa_ToggleMenuBar(const BOOL show) { /* !!! FIXME: keep an eye on this. * ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries. @@ -57,7 +59,7 @@ static inline void Cocoa_ToggleMenuBar(const BOOL show) #define MAC_OS_X_VERSION_MIN_REQUIRED 1050 #endif -static inline BOOL +static BOOL IS_SNOW_LEOPARD_OR_LATER(_THIS) { #if FORCE_OLD_API @@ -179,7 +181,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode) return SDL_TRUE; } -static inline void +static void Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) { if (IS_SNOW_LEOPARD_OR_LATER(_this)) { @@ -187,7 +189,7 @@ Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) } } -static inline void +static void Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist) { if (IS_SNOW_LEOPARD_OR_LATER(_this)) { diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index 71085261a..ae8df8d19 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -82,8 +82,8 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape data->saved = SDL_FALSE; } - //[data->context saveGraphicsState]; - //data->saved = SDL_TRUE; + /*[data->context saveGraphicsState];*/ + /*data->saved = SDL_TRUE;*/ [NSGraphicsContext setCurrentContext:data->context]; [[NSColor clearColor] set]; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 581590b67..923cd51c5 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -44,7 +44,7 @@ static Uint32 s_moveHack; -static __inline__ void ConvertNSRect(NSRect *r) +static void ConvertNSRect(NSRect *r) { r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; } @@ -920,8 +920,9 @@ Cocoa_RaiseWindow(_THIS, SDL_Window * window) SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata); NSWindow *nswindow = windowData->nswindow; - // makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing - // a minimized or hidden window, so check for that before showing it. + /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing + a minimized or hidden window, so check for that before showing it. + */ [windowData->listener pauseVisibleObservation]; if (![nswindow isMiniaturized] && [nswindow isVisible]) { [nswindow makeKeyAndOrderFront:nil]; From f82f0ebb6f66acd895320f9b1f5bc71973676434 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Tue, 1 Oct 2013 08:47:06 -0300 Subject: [PATCH 138/258] Uses SDL_UDEV for Linux joystick hotplugging --- src/joystick/linux/SDL_sysjoystick.c | 325 +++++++-------------------- 1 file changed, 81 insertions(+), 244 deletions(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 8582838a7..686731397 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -52,124 +52,13 @@ #define SYN_DROPPED 3 #endif -/* - * !!! FIXME: move all the udev stuff to src/core/linux, so I can reuse it - * !!! FIXME: for audio hardware disconnects. - */ -#ifdef HAVE_LIBUDEV_H -#define SDL_USE_LIBUDEV 1 -#include "SDL_loadso.h" -#include -#include -#include +#include "../../core/linux/SDL_udev.h" -/* we never link directly to libudev. */ -/* !!! FIXME: can we generalize this? ALSA, etc, do the same things. */ -static const char *udev_library = "libudev.so.0"; -static void *udev_handle = NULL; - -/* !!! FIXME: this is kinda ugly. */ -static SDL_bool -load_udev_sym(const char *fn, void **addr) -{ - *addr = SDL_LoadFunction(udev_handle, fn); - if (*addr == NULL) { - /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ - return SDL_FALSE; - } - - return SDL_TRUE; -} - -/* libudev entry points... */ -static const char *(*UDEV_udev_device_get_action)(struct udev_device *) = NULL; -static const char *(*UDEV_udev_device_get_devnode)(struct udev_device *) = NULL; -static const char *(*UDEV_udev_device_get_property_value)(struct udev_device *, const char *) = NULL; -static struct udev_device *(*UDEV_udev_device_new_from_syspath)(struct udev *, const char *) = NULL; -static void (*UDEV_udev_device_unref)(struct udev_device *) = NULL; -static int (*UDEV_udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *) = NULL; -static int (*UDEV_udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *) = NULL; -static struct udev_list_entry *(*UDEV_udev_enumerate_get_list_entry)(struct udev_enumerate *) = NULL; -static struct udev_enumerate *(*UDEV_udev_enumerate_new)(struct udev *) = NULL; -static int (*UDEV_udev_enumerate_scan_devices)(struct udev_enumerate *) = NULL; -static void (*UDEV_udev_enumerate_unref)(struct udev_enumerate *) = NULL; -static const char *(*UDEV_udev_list_entry_get_name)(struct udev_list_entry *) = NULL; -static struct udev_list_entry *(*UDEV_udev_list_entry_get_next)(struct udev_list_entry *) = NULL; -static int (*UDEV_udev_monitor_enable_receiving)(struct udev_monitor *) = NULL; -static int (*UDEV_udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *) = NULL; -static int (*UDEV_udev_monitor_get_fd)(struct udev_monitor *) = NULL; -static struct udev_monitor *(*UDEV_udev_monitor_new_from_netlink)(struct udev *, const char *) = NULL; -static struct udev_device *(*UDEV_udev_monitor_receive_device)(struct udev_monitor *) = NULL; -static void (*UDEV_udev_monitor_unref)(struct udev_monitor *) = NULL; -static struct udev *(*UDEV_udev_new)(void) = NULL; -static void (*UDEV_udev_unref)(struct udev *) = NULL; - -static int -load_udev_syms(void) -{ - /* cast funcs to char* first, to please GCC's strict aliasing rules. */ - #define SDL_UDEV_SYM(x) \ - if (!load_udev_sym(#x, (void **) (char *) &UDEV_##x)) return -1 - - SDL_UDEV_SYM(udev_device_get_action); - SDL_UDEV_SYM(udev_device_get_devnode); - SDL_UDEV_SYM(udev_device_get_property_value); - SDL_UDEV_SYM(udev_device_new_from_syspath); - SDL_UDEV_SYM(udev_device_unref); - SDL_UDEV_SYM(udev_enumerate_add_match_property); - SDL_UDEV_SYM(udev_enumerate_add_match_subsystem); - SDL_UDEV_SYM(udev_enumerate_get_list_entry); - SDL_UDEV_SYM(udev_enumerate_new); - SDL_UDEV_SYM(udev_enumerate_scan_devices); - SDL_UDEV_SYM(udev_enumerate_unref); - SDL_UDEV_SYM(udev_list_entry_get_name); - SDL_UDEV_SYM(udev_list_entry_get_next); - SDL_UDEV_SYM(udev_monitor_enable_receiving); - SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype); - SDL_UDEV_SYM(udev_monitor_get_fd); - SDL_UDEV_SYM(udev_monitor_new_from_netlink); - SDL_UDEV_SYM(udev_monitor_receive_device); - SDL_UDEV_SYM(udev_monitor_unref); - SDL_UDEV_SYM(udev_new); - SDL_UDEV_SYM(udev_unref); - - #undef SDL_UDEV_SYM - - return 0; -} - -static void -UnloadUDEVLibrary(void) -{ - if (udev_handle != NULL) { - SDL_UnloadObject(udev_handle); - udev_handle = NULL; - } -} - -static int -LoadUDEVLibrary(void) -{ - int retval = 0; - if (udev_handle == NULL) { - udev_handle = SDL_LoadObject(udev_library); - if (udev_handle == NULL) { - retval = -1; - /* Don't call SDL_SetError(): SDL_LoadObject already did. */ - } else { - retval = load_udev_syms(); - if (retval < 0) { - UnloadUDEVLibrary(); - } - } - } - - return retval; -} - -static struct udev *udev = NULL; -static struct udev_monitor *udev_mon = NULL; -#endif +static int MaybeAddDevice(const char *path); +#if SDL_USE_LIBUDEV +static int MaybeRemoveDevice(const char *path); +void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); +#endif /* SDL_USE_LIBUDEV */ /* A linked list of available joysticks */ @@ -246,6 +135,62 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui return 1; } +#if SDL_USE_LIBUDEV +void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath) +{ + int instance; + + if (devpath == NULL || udev_class != SDL_UDEV_DEVICE_JOYSTICK) { + return; + } + + switch( udev_type ) + { + case SDL_UDEV_DEVICEADDED: + instance = MaybeAddDevice(devpath); + if (instance != -1) { + /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceAdded() function? */ + #if !SDL_EVENTS_DISABLED + SDL_Event event; + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = instance; + if ( (SDL_EventOK == NULL) || + (*SDL_EventOK) (SDL_EventOKParam, &event) ) { + SDL_PushEvent(&event); + } + } + #endif /* !SDL_EVENTS_DISABLED */ + } + break; + + case SDL_UDEV_DEVICEREMOVED: + instance = MaybeRemoveDevice(devpath); + if (instance != -1) { + /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceRemoved() function? */ + #if !SDL_EVENTS_DISABLED + SDL_Event event; + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = instance; + if ( (SDL_EventOK == NULL) || + (*SDL_EventOK) (SDL_EventOKParam, &event) ) { + SDL_PushEvent(&event); + } + } + #endif /* !SDL_EVENTS_DISABLED */ + } + break; + + default: + break; + } + +} +#endif /* SDL_USE_LIBUDEV */ + /* !!! FIXME: I would love to dump this code and use libudev instead. */ static int @@ -380,40 +325,19 @@ JoystickInitWithoutUdev(void) static int JoystickInitWithUdev(void) { - struct udev_enumerate *enumerate = NULL; - struct udev_list_entry *devs = NULL; - struct udev_list_entry *item = NULL; - SDL_assert(udev == NULL); - udev = UDEV_udev_new(); - if (udev == NULL) { - return SDL_SetError("udev_new() failed"); + if (SDL_UDEV_Init() < 0) { + return SDL_SetError("Could not initialize UDEV"); } - udev_mon = UDEV_udev_monitor_new_from_netlink(udev, "udev"); - if (udev_mon != NULL) { /* okay if it's NULL, we just lose hotplugging. */ - UDEV_udev_monitor_filter_add_match_subsystem_devtype(udev_mon, - "input", NULL); - UDEV_udev_monitor_enable_receiving(udev_mon); + /* Set up the udev callback */ + if ( SDL_UDEV_AddCallback(joystick_udev_callback) < 0) { + SDL_UDEV_Quit(); + return SDL_SetError("Could not set up joystick <-> udev callback"); } - - enumerate = UDEV_udev_enumerate_new(udev); - if (enumerate == NULL) { - return SDL_SetError("udev_enumerate_new() failed"); - } - - UDEV_udev_enumerate_add_match_subsystem(enumerate, "input"); - UDEV_udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1"); - UDEV_udev_enumerate_scan_devices(enumerate); - devs = UDEV_udev_enumerate_get_list_entry(enumerate); - for (item = devs; item; item = UDEV_udev_list_entry_get_next(item)) { - const char *path = UDEV_udev_list_entry_get_name(item); - struct udev_device *dev = UDEV_udev_device_new_from_syspath(udev, path); - MaybeAddDevice(UDEV_udev_device_get_devnode(dev)); - UDEV_udev_device_unref(dev); - } - - UDEV_udev_enumerate_unref(enumerate); + + /* Force a scan to build the initial device list */ + SDL_UDEV_Scan(); return numjoysticks; } @@ -439,9 +363,7 @@ SDL_SYS_JoystickInit(void) } #if SDL_USE_LIBUDEV - if (LoadUDEVLibrary() == 0) { /* okay if this fails, FOR NOW. */ - return JoystickInitWithUdev(); - } + return JoystickInitWithUdev(); #endif return JoystickInitWithoutUdev(); @@ -452,99 +374,21 @@ int SDL_SYS_NumJoysticks() return numjoysticks; } -static SDL_bool -HotplugUpdateAvailable(void) -{ -#if SDL_USE_LIBUDEV - if (udev_mon != NULL) { - const int fd = UDEV_udev_monitor_get_fd(udev_mon); - fd_set fds; - struct timeval tv; - - FD_ZERO(&fds); - FD_SET(fd, &fds); - tv.tv_sec = 0; - tv.tv_usec = 0; - if ((select(fd+1, &fds, NULL, NULL, &tv) > 0) && (FD_ISSET(fd, &fds))) { - return SDL_TRUE; - } - } -#endif - - return SDL_FALSE; -} - void SDL_SYS_JoystickDetect() { #if SDL_USE_LIBUDEV - struct udev_device *dev = NULL; - const char *devnode = NULL; - const char *action = NULL; - const char *val = NULL; - - while (HotplugUpdateAvailable()) { - dev = UDEV_udev_monitor_receive_device(udev_mon); - if (dev == NULL) { - break; - } - val = UDEV_udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); - if ((!val) || (SDL_strcmp(val, "1") != 0)) { - continue; - } - - action = UDEV_udev_device_get_action(dev); - devnode = UDEV_udev_device_get_devnode(dev); - - if (SDL_strcmp(action, "add") == 0) { - const int device_index = MaybeAddDevice(devnode); - if (device_index != -1) { - /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceAdded() function? */ - #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEADDED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = device_index; - if ( (SDL_EventOK == NULL) || - (*SDL_EventOK) (SDL_EventOKParam, &event) ) { - SDL_PushEvent(&event); - } - } - #endif /* !SDL_EVENTS_DISABLED */ - } - } else if (SDL_strcmp(action, "remove") == 0) { - const int inst = MaybeRemoveDevice(devnode); - if (inst != -1) { - /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceRemoved() function? */ - #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = inst; - if ( (SDL_EventOK == NULL) || - (*SDL_EventOK) (SDL_EventOKParam, &event) ) { - SDL_PushEvent(&event); - } - } - #endif /* !SDL_EVENTS_DISABLED */ - } - } - UDEV_udev_device_unref(dev); - } + SDL_UDEV_Poll(); #endif + } SDL_bool SDL_SYS_JoystickNeedsPolling() { - /* - * This results in a select() call, so technically we're polling to - * decide if we should poll, but I think this function is here because - * Windows has to do an enormous amount of work to detect new sticks, - * whereas libudev just needs to see if there's more data available on - * a socket...so this should be acceptable, I hope. - */ - return HotplugUpdateAvailable(); +#if SDL_USE_LIBUDEV + return SDL_TRUE; +#endif + + return SDL_FALSE; } static SDL_joylist_item * @@ -1011,15 +855,8 @@ SDL_SYS_JoystickQuit(void) instance_counter = 0; #if SDL_USE_LIBUDEV - if (udev_mon != NULL) { - UDEV_udev_monitor_unref(udev_mon); - udev_mon = NULL; - } - if (udev != NULL) { - UDEV_udev_unref(udev); - udev = NULL; - } - UnloadUDEVLibrary(); + SDL_UDEV_DelCallback(joystick_udev_callback); + SDL_UDEV_Quit(); #endif } From 715ccd02a5b6d5ce10e4f69767ac34edc49d42ed Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 2 Oct 2013 22:16:11 -0400 Subject: [PATCH 139/258] Get rid of glGetError() calls in GLES2 renderer. It's not usually useful, and it causes pipeline stalls. --HG-- extra : rebase_source : fb1b9b3ffdee2a41fdaee5d30e7f218eacb2eaaa --- src/render/opengles2/SDL_render_gles2.c | 59 +------------------------ 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 10cb42d8f..1a1320eff 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -414,12 +414,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } /* Allocate the texture */ - rdata->glGetError(); rdata->glGenTextures(1, &tdata->texture); - if (rdata->glGetError() != GL_NO_ERROR) { - SDL_free(tdata); - return SDL_SetError("Texture creation failed in glGenTextures()"); - } rdata->glActiveTexture(GL_TEXTURE0); rdata->glBindTexture(tdata->texture_type, tdata->texture); rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); @@ -427,11 +422,6 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); - if (rdata->glGetError() != GL_NO_ERROR) { - rdata->glDeleteTextures(1, &tdata->texture); - SDL_free(tdata); - return SDL_SetError("Texture creation failed"); - } texture->driverdata = tdata; if (texture->access == SDL_TEXTUREACCESS_TARGET) { @@ -526,7 +516,6 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect } /* Create a texture subimage with the supplied data */ - rdata->glGetError(); rdata->glActiveTexture(GL_TEXTURE0); rdata->glBindTexture(tdata->texture_type, tdata->texture); rdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -541,9 +530,6 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect src); SDL_free(blob); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to update texture"); - } return 0; } @@ -629,7 +615,6 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, entry->blend_mode = blendMode; /* Create the program and link it */ - rdata->glGetError(); entry->id = rdata->glCreateProgram(); rdata->glAttachShader(entry->id, vertex->id); rdata->glAttachShader(entry->id, fragment->id); @@ -639,7 +624,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center"); rdata->glLinkProgram(entry->id); rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); - if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful) + if (!linkSuccessful) { rdata->glDeleteProgram(entry->id); SDL_free(entry); @@ -754,7 +739,6 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b entry->instance = instance; /* Compile or load the selected shader instance */ - rdata->glGetError(); entry->id = rdata->glCreateShader(instance->type); if (instance->format == (GLenum)-1) { @@ -767,7 +751,7 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b rdata->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); compileSuccessful = GL_TRUE; } - if (rdata->glGetError() != GL_NO_ERROR || !compileSuccessful) + if (!compileSuccessful) { char *info = NULL; int length = 0; @@ -872,13 +856,7 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM goto fault; /* Select that program in OpenGL */ - rdata->glGetError(); rdata->glUseProgram(program->id); - if (rdata->glGetError() != GL_NO_ERROR) - { - SDL_SetError("Failed to select program"); - goto fault; - } /* Set the current program */ rdata->current_program = program; @@ -937,11 +915,7 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer) /* Set the projection matrix */ locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; - rdata->glGetError(); rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to set orthographic projection"); - } return 0; } @@ -1028,8 +1002,6 @@ GLES2_SetDrawingState(SDL_Renderer * renderer) int blendMode = renderer->blendMode; GLuint locColor; - rdata->glGetError(); - GLES2_ActivateRenderer(renderer); GLES2_SetBlendMode(rdata, blendMode); @@ -1080,13 +1052,9 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } - rdata->glGetError(); rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); rdata->glDrawArrays(GL_POINTS, 0, count); SDL_stack_free(vertices); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render points"); - } return 0; } @@ -1110,7 +1078,6 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } - rdata->glGetError(); rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); rdata->glDrawArrays(GL_LINE_STRIP, 0, count); @@ -1120,9 +1087,6 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun rdata->glDrawArrays(GL_POINTS, count-1, 1); } SDL_stack_free(vertices); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render lines"); - } return 0; } @@ -1138,7 +1102,6 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) } /* Emit a line loop for each rectangle */ - rdata->glGetError(); for (idx = 0; idx < count; ++idx) { const SDL_FRect *rect = &rects[idx]; @@ -1158,9 +1121,6 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render filled rects"); - } return 0; } @@ -1266,7 +1226,6 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s /* Select the target texture */ locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - rdata->glGetError(); rdata->glActiveTexture(GL_TEXTURE0); rdata->glBindTexture(tdata->texture_type, tdata->texture); rdata->glUniform1i(locTexture, 0); @@ -1314,9 +1273,6 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render texture"); - } return 0; } @@ -1432,7 +1388,6 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect /* Select the target texture */ locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - rdata->glGetError(); rdata->glActiveTexture(GL_TEXTURE0); rdata->glBindTexture(tdata->texture_type, tdata->texture); rdata->glUniform1i(locTexture, 0); @@ -1496,9 +1451,6 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render texture"); - } return 0; } @@ -1695,7 +1647,6 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) /* Determine supported shader formats */ /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ - rdata->glGetError(); #ifdef ZUNE_HD nFormats = 1; #else /* !ZUNE_HD */ @@ -1716,12 +1667,6 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; #else /* !ZUNE_HD */ rdata->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats); - if (rdata->glGetError() != GL_NO_ERROR) - { - GLES2_DestroyRenderer(renderer); - SDL_SetError("Failed to query supported shader formats"); - return NULL; - } if (hasCompiler) rdata->shader_formats[nFormats - 1] = (GLenum)-1; #endif /* ZUNE_HD */ From 1e8c10c155f2b8acaf12df601da724ce2f257bb3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 2 Oct 2013 22:18:04 -0400 Subject: [PATCH 140/258] SDLK_DELETE should probably be SDLK_BACKSPACE on iOS. The key on the software keyboard works like backspace, at least. Not sure what happens with a bluetooth keyboard here. --HG-- extra : rebase_source : 9db0fb0ccf78490db0443e975a55344a39416954 --- src/video/uikit/SDL_uikitview.m | 4 ++-- src/video/uikit/keyinfotable.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index e808962ef..66129be23 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -246,8 +246,8 @@ { if ([string length] == 0) { /* it wants to replace text with nothing, ie a delete */ - SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); - SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE); } else { /* go through all the characters in the string we've been sent diff --git a/src/video/uikit/keyinfotable.h b/src/video/uikit/keyinfotable.h index d12674b9a..d588f915e 100644 --- a/src/video/uikit/keyinfotable.h +++ b/src/video/uikit/keyinfotable.h @@ -166,7 +166,7 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 124 */{ SDL_SCANCODE_BACKSLASH, KMOD_SHIFT }, /* plus shift modifier '|' */ /* 125 */{ SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT }, /* plus shift modifier '}' */ /* 126 */{ SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* plus shift modifier '~' */ -/* 127 */{ SDL_SCANCODE_DELETE, KMOD_SHIFT } +/* 127 */{ SDL_SCANCODE_BACKSPACE, KMOD_SHIFT } }; #endif /* UIKitKeyInfo */ From 72d208407735c38ee0e73721a6cd0742149477f6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 3 Oct 2013 00:54:58 -0700 Subject: [PATCH 141/258] Fixed bug 2130 - Two members of Windows WindowData not initialized norfanin SetupWindowData in SDL_windowswindow.c doesn't initialize two members of SDL_WindowData with NULL. This is an issue because other parts of the SDL code seem to make the assumption that this is the case. WIN_DestroyWindowFramebuffer for example uses data->mdc and data->hbm if they're not NULL. --- src/video/windows/SDL_windowswindow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index c28da5204..07b873f7f 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -113,7 +113,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) SDL_WindowData *data; /* Allocate the window data */ - data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); + data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); if (!data) { return SDL_OutOfMemory(); } From 7501cc4354bb029ddc7b24f4ad18ca86c0a27e6f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 14 Jul 2013 11:28:44 -0700 Subject: [PATCH 142/258] Added the platform specific messagebox function to the video function list --- src/video/cocoa/SDL_cocoavideo.m | 3 +++ src/video/uikit/SDL_uikitvideo.m | 4 ++++ src/video/windows/SDL_windowsvideo.c | 3 +++ src/video/x11/SDL_x11video.c | 3 +++ 4 files changed, 13 insertions(+) diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index d1b958768..e6de2ff56 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -33,6 +33,7 @@ #include "SDL_endian.h" #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" +#include "SDL_cocoamessagebox.h" #include "SDL_assert.h" /* Initialization/Query functions */ @@ -134,6 +135,8 @@ Cocoa_CreateDevice(int devindex) device->GetClipboardText = Cocoa_GetClipboardText; device->HasClipboardText = Cocoa_HasClipboardText; + device->ShowMessageBox = Cocoa_ShowMessageBox; + device->free = Cocoa_DeleteDevice; return device; diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 74b24b8da..e90172806 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -35,6 +35,7 @@ #include "SDL_uikitmodes.h" #include "SDL_uikitwindow.h" #include "SDL_uikitopengles.h" +#include "SDL_uikitmessagebox.h" #define UIKITVID_DRIVER_NAME "uikit" @@ -98,6 +99,9 @@ UIKit_CreateDevice(int devindex) device->GL_DeleteContext = UIKit_GL_DeleteContext; device->GL_GetProcAddress = UIKit_GL_GetProcAddress; device->GL_LoadLibrary = UIKit_GL_LoadLibrary; + + device->ShowMessageBox = UIKit_ShowMessageBox; + device->free = UIKit_DeleteDevice; device->gl_config.accelerated = 1; diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 8f708cf0d..1a0ad55c2 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -32,6 +32,7 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsframebuffer.h" #include "SDL_windowsshape.h" +#include "SDL_windowsmessagebox.h" /* Initialization/Query functions */ static int WIN_VideoInit(_THIS); @@ -145,6 +146,8 @@ WIN_CreateDevice(int devindex) device->GetClipboardText = WIN_GetClipboardText; device->HasClipboardText = WIN_HasClipboardText; + device->ShowMessageBox = WIN_ShowMessageBox; + device->free = WIN_DeleteDevice; return device; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 5ed47d5e8..020bba019 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -34,6 +34,7 @@ #include "SDL_x11shape.h" #include "SDL_x11touch.h" #include "SDL_x11xinput2.h" +#include "SDL_x11messagebox.h" #if SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" @@ -411,6 +412,8 @@ X11_CreateDevice(int devindex) device->GetClipboardText = X11_GetClipboardText; device->HasClipboardText = X11_HasClipboardText; + device->ShowMessageBox = X11_ShowMessageBox; + device->free = X11_DeleteDevice; return device; From 201fa56aaa2cc1a19bc16177f7dca4ef92b887c1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 3 Oct 2013 03:31:05 -0700 Subject: [PATCH 143/258] Fixed const/non-const warning --- src/render/SDL_yuv_sw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index a978d4b36..14b825d9c 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1190,7 +1190,8 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch) { - Uint8 *src, *dst; + const Uint8 *src; + Uint8 *dst; int row; size_t length; From 7b5e9e302bac00abe29ae15fe3e19df29c62817b Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 3 Oct 2013 10:28:10 -0300 Subject: [PATCH 144/258] SDL_TEXTINPUT support for EVDEV --- README-raspberrypi.txt | 43 +++++++++++- configure | 40 +++++++++++ configure.in | 23 +++++++ include/SDL_config.h.in | 1 + src/events/SDL_keyboard.c | 2 +- src/events/SDL_keyboard_c.h | 3 + src/input/evdev/SDL_evdev.c | 129 +++++++++++++++++++++++++++++++----- src/input/evdev/SDL_evdev.h | 5 +- 8 files changed, 224 insertions(+), 22 deletions(-) diff --git a/README-raspberrypi.txt b/README-raspberrypi.txt index a95932dae..b0f0b25b2 100644 --- a/README-raspberrypi.txt +++ b/README-raspberrypi.txt @@ -20,13 +20,21 @@ Raspbian (other Linux distros may work as well). Raspbian Build Dependencies ================================================================================ -sudo apt-get install libudev-dev libasound2-dev +sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev You also need the VideoCore binary stuff that ships in /opt/vc for EGL and OpenGL ES 2.x, it usually comes pre installed, but in any case: sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev +================================================================================ + No input +================================================================================ + +Make sure you belong to the "input" group. + + sudo usermod -aG input `whoami` + ================================================================================ No HDMI Audio ================================================================================ @@ -39,10 +47,41 @@ to your config.txt file and reboot. Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062 +================================================================================ + Text Input API support +================================================================================ + +The Text Input API is supported, with translation of scan codes done via the +kernel symbol tables. For this to work, SDL needs access to a valid console. +If you notice there's no SDL_TEXTINPUT message being emmited, double check that +your app has read access to one of the following: + +* /proc/self/fd/0 +* /dev/tty +* /dev/tty[0...6] +* /dev/vc/0 +* /dev/console + +This is usually not a problem if you run from the physical terminal (as opposed +to running from a pseudo terminal, such as via SSH). If running from a PTS, a +quick workaround is to run your app as root or add yourself to the tty group, +then re login to the system. + + sudo usermod -aG tty `whoami` + +The keyboard layout used by SDL is the same as the one the kernel uses. +To configure the layout on Raspbian: + + sudo dpkg-reconfigure keyboard-configuration + +To configure the locale, which controls which keys are interpreted as letters, +this determining the CAPS LOCK behavior: + + sudo dpkg-reconfigure locales + ================================================================================ Notes ================================================================================ * Building has only been tested natively (i.e. not cross compiled). Cross compilation might work though, feedback is welcome! -* No Text Input yet. \ No newline at end of file diff --git a/configure b/configure index c38982cc7..68b62c537 100755 --- a/configure +++ b/configure @@ -20754,6 +20754,45 @@ $as_echo "#define SDL_INPUT_LINUXEV 1" >>confdefs.h fi } +CheckInputKD() +{ + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux kd.h" >&5 +$as_echo_n "checking for Linux kd.h... " >&6; } + use_input_kd=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + struct kbentry kbe; + kbe.kb_table = KG_CTRL; + ioctl(0, KDGKBENT, &kbe); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + use_input_kd=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_kd" >&5 +$as_echo "$use_input_kd" >&6; } + if test x$use_input_kd = xyes; then + +$as_echo "#define SDL_INPUT_LINUXKD 1" >>confdefs.h + + fi +} + CheckLibUDev() { # Check whether --enable-libudev was given. @@ -22080,6 +22119,7 @@ case "$host" in CheckLibUDev CheckDBus CheckInputEvents + CheckInputKD CheckTslib CheckUSBHID CheckPTHREAD diff --git a/configure.in b/configure.in index f1d64497b..f6810cbba 100644 --- a/configure.in +++ b/configure.in @@ -1791,6 +1791,28 @@ CheckInputEvents() fi } +dnl See if we can use the kernel kd.h header +CheckInputKD() +{ + + AC_MSG_CHECKING(for Linux kd.h) + use_input_kd=no + AC_TRY_COMPILE([ + #include + #include + ],[ + struct kbentry kbe; + kbe.kb_table = KG_CTRL; + ioctl(0, KDGKBENT, &kbe); + ],[ + use_input_kd=yes + ]) + AC_MSG_RESULT($use_input_kd) + if test x$use_input_kd = xyes; then + AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ]) + fi +} + dnl See if the platform offers libudev for device enumeration and hotplugging. CheckLibUDev() { @@ -2395,6 +2417,7 @@ case "$host" in CheckLibUDev CheckDBus CheckInputEvents + CheckInputKD CheckTslib CheckUSBHID CheckPTHREAD diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 08299411b..b2daf6fa3 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -217,6 +217,7 @@ /* Enable various input drivers */ #undef SDL_INPUT_LINUXEV +#undef SDL_INPUT_LINUXKD #undef SDL_INPUT_TSLIB #undef SDL_JOYSTICK_BEOS #undef SDL_JOYSTICK_DINPUT diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 607046e0e..34d94d0ef 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -507,7 +507,7 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = { }; /* Taken from SDL_iconv() */ -static char * +char * SDL_UCS4ToUTF8(Uint32 ch, char *dst) { Uint8 *p = (Uint8 *) dst; diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index 17203998b..cd9f1bb6b 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -59,6 +59,9 @@ extern int SDL_SendEditingText(const char *text, int start, int end); /* Shutdown the keyboard subsystem */ extern void SDL_KeyboardQuit(void); +/* Convert to UTF-8 */ +extern char *SDL_UCS4ToUTF8(Uint32 ch, char *dst); + #endif /* _SDL_keyboard_c_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c index 4581ac0ce..b9b647306 100644 --- a/src/input/evdev/SDL_evdev.c +++ b/src/input/evdev/SDL_evdev.c @@ -39,7 +39,11 @@ static _THIS = NULL; #include #include #include /* For the definition of PATH_MAX */ - +#include +#ifdef SDL_INPUT_LINUXKD +#include +#include +#endif #include "SDL.h" #include "SDL_assert.h" @@ -325,12 +329,54 @@ static Uint8 EVDEV_MouseButtons[] = { SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */ }; +static char* EVDEV_consoles[] = { + "/proc/self/fd/0", + "/dev/tty", + "/dev/tty0", + "/dev/tty1", + "/dev/tty2", + "/dev/tty3", + "/dev/tty4", + "/dev/tty5", + "/dev/tty6", + "/dev/vc/0", + "/dev/console" +}; + +#define IS_CONSOLE(fd) isatty (fd) && ioctl(fd, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84)) + +static int SDL_EVDEV_get_console_fd(void) +{ + int fd, i; + char arg = 0; + + /* Try a few consoles to see which one we have read access to */ + + for( i = 0; i < SDL_arraysize(EVDEV_consoles); i++) { + fd = open(EVDEV_consoles[i], O_RDONLY); + if (fd >= 0) { + if (IS_CONSOLE(fd)) return fd; + close(fd); + } + } + + /* Try stdin, stdout, stderr */ + + for( fd = 0; fd < 3; fd++) { + if (IS_CONSOLE(fd)) return fd; + } + + /* We won't be able to send SDL_TEXTINPUT events */ + return -1; +} + int SDL_EVDEV_Init(void) { int retval = 0; if (_this == NULL) { + _this = (SDL_EVDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); if(_this == NULL) { return SDL_OutOfMemory(); @@ -354,6 +400,9 @@ SDL_EVDEV_Init(void) #else /* TODO: Scan the devices manually, like a caveman */ #endif /* SDL_USE_LIBUDEV */ + + /* We need a physical terminal (not PTS) to be able to translate key code to symbols via the kernel tables */ + _this->console_fd = SDL_EVDEV_get_console_fd(); } @@ -378,6 +427,9 @@ SDL_EVDEV_Quit(void) SDL_UDEV_Quit(); #endif /* SDL_USE_LIBUDEV */ + if (_this->console_fd >= 0) { + close(_this->console_fd); + } /* Remove existing devices */ while(_this->first != NULL) { SDL_EVDEV_device_removed(_this->first->path); @@ -443,11 +495,18 @@ SDL_EVDEV_Poll(void) SDL_Scancode scan_code; int mouse_button; SDL_Mouse *mouse; - +#ifdef SDL_INPUT_LINUXKD + Uint16 modstate; + struct kbentry kbe; + static char keysym[8]; + char *end; + Uint32 kval; +#endif + #if SDL_USE_LIBUDEV SDL_UDEV_Poll(); #endif - + for (item = _this->first; item != NULL; item = item->next) { while ((len = read(item->fd, events, (sizeof events))) > 0) { len /= sizeof(events[0]); @@ -455,20 +514,57 @@ SDL_EVDEV_Poll(void) switch(item->devclass) { case SDL_EVDEV_DEVICE_KEYBOARD: switch (events[i].type) { - case EV_KEY: - scan_code = SDL_EVDEV_translate_keycode(events[i].code); - if (scan_code != SDL_SCANCODE_UNKNOWN) { - if (events[i].value == 0) { - SDL_SendKeyboardKey(SDL_RELEASED, scan_code); - } - else if (events[i].value == 1) { - SDL_SendKeyboardKey(SDL_PRESSED, scan_code); - } - else if (events[i].value == 2) { - /* Key repeated */ - SDL_SendKeyboardKey(SDL_PRESSED, scan_code); - } + case EV_KEY: + scan_code = SDL_EVDEV_translate_keycode(events[i].code); + if (scan_code != SDL_SCANCODE_UNKNOWN) { + if (events[i].value == 0) { + SDL_SendKeyboardKey(SDL_RELEASED, scan_code); } + else if (events[i].value == 1 || events[i].value == 2 /* Key repeated */ ) { + SDL_SendKeyboardKey(SDL_PRESSED, scan_code); +#ifdef SDL_INPUT_LINUXKD + if (_this->console_fd >= 0) { + kbe.kb_index = events[i].code; + /* Convert the key to an UTF-8 char */ + /* Ref: http://www.linuxjournal.com/article/2783 */ + modstate = SDL_GetModState(); + kbe.kb_table = 0; + + /* Ref: http://graphics.stanford.edu/~seander/bithacks.html#ConditionalSetOrClearBitsWithoutBranching */ + kbe.kb_table |= -( (modstate & KMOD_LCTRL) != 0) & (1 << KG_CTRLL | 1 << KG_CTRL); + kbe.kb_table |= -( (modstate & KMOD_RCTRL) != 0) & (1 << KG_CTRLR | 1 << KG_CTRL); + kbe.kb_table |= -( (modstate & KMOD_LSHIFT) != 0) & (1 << KG_SHIFTL | 1 << KG_SHIFT); + kbe.kb_table |= -( (modstate & KMOD_RSHIFT) != 0) & (1 << KG_SHIFTR | 1 << KG_SHIFT); + kbe.kb_table |= -( (modstate & KMOD_LALT) != 0) & (1 << KG_ALT); + kbe.kb_table |= -( (modstate & KMOD_RALT) != 0) & (1 << KG_ALTGR); + + if(ioctl(_this->console_fd, KDGKBENT, (unsigned long)&kbe) == 0 && + ( (KTYP(kbe.kb_value) == KT_LATIN) || (KTYP(kbe.kb_value) == KT_ASCII) || (KTYP(kbe.kb_value) == KT_LETTER) )) + { + kval = KVAL(kbe.kb_value); + + /* While there's a KG_CAPSSHIFT symbol, it's not useful to build the table index with it + * because 1 << KG_CAPSSHIFT overflows the 8 bits of kb_table + * So, we do the CAPS LOCK logic here. Note that isalpha depends on the locale! + */ + if ( modstate & KMOD_CAPS && isalpha(kval) ) { + if ( isupper(kval) ) { + kval = tolower(kval); + } + else { + kval = toupper(kval); + } + } + + /* Convert to UTF-8 and send */ + end = SDL_UCS4ToUTF8( kval, keysym); + *end = '\0'; + SDL_SendKeyboardText(keysym); + } + } +#endif + } + } break; default: @@ -651,3 +747,4 @@ SDL_EVDEV_device_removed(const char *devpath) #endif /* SDL_INPUT_LINUXEV */ /* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/input/evdev/SDL_evdev.h b/src/input/evdev/SDL_evdev.h index 5a6038f61..d63b87f7a 100644 --- a/src/input/evdev/SDL_evdev.h +++ b/src/input/evdev/SDL_evdev.h @@ -19,8 +19,6 @@ 3. This notice may not be removed or altered from any source distribution. */ -#include - #include "SDL_config.h" #ifndef _SDL_evdev_h @@ -42,7 +40,7 @@ typedef struct SDL_evdevlist_item char *path; int fd; SDL_EVDEV_deviceclass devclass; - struct SDL_evdevlist_item *next; + struct SDL_evdevlist_item *next; } SDL_evdevlist_item; typedef struct SDL_EVDEV_PrivateData @@ -51,6 +49,7 @@ typedef struct SDL_EVDEV_PrivateData SDL_evdevlist_item *last; int numdevices; int ref_count; + int console_fd; } SDL_EVDEV_PrivateData; extern int SDL_EVDEV_Init(void); From d564d4ea29690fb8c8750a5f194371cce2249da3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 3 Oct 2013 20:42:43 -0700 Subject: [PATCH 145/258] Fixed a potential double-free bug if glGenTextures() failed. --- src/render/opengl/SDL_render_gl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 824ae8cce..8a61f788f 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -639,8 +639,6 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } - texture->driverdata = data; - if (texture->access == SDL_TEXTUREACCESS_TARGET) { data->fbo = GL_GetFBO(renderdata, texture->w, texture->h); } else { @@ -653,6 +651,8 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) SDL_free(data); return -1; } + texture->driverdata = data; + if ((renderdata->GL_ARB_texture_rectangle_supported) /* && texture->access != SDL_TEXTUREACCESS_TARGET */){ data->type = GL_TEXTURE_RECTANGLE_ARB; @@ -804,6 +804,7 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, data->format, data->formattype, pixels); } renderdata->glDisable(data->type); + return GL_CheckError("glTexSubImage2D()", renderer); } @@ -839,6 +840,7 @@ GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, rect->w/2, rect->h/2, data->format, data->formattype, Vplane); renderdata->glDisable(data->type); + return GL_CheckError("glTexSubImage2D()", renderer); } @@ -1318,7 +1320,9 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, format, type, temp_pixels); - GL_CheckError("", renderer); + if (GL_CheckError("glReadPixels()", renderer) < 0) { + return -1; + } /* Flip the rows to be top-down */ length = rect->w * SDL_BYTESPERPIXEL(temp_format); From 325d333774c0064a9e936fade7f1fcb2e65e35fc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 3 Oct 2013 20:48:52 -0700 Subject: [PATCH 146/258] Added optional error checking for OpenGL ES 2.0 in the same style as the OpenGL renderer. You can enable it like this: SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); --- src/render/opengles2/SDL_render_gles2.c | 685 ++++++++++++++---------- 1 file changed, 391 insertions(+), 294 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 1a1320eff..4b7e645b1 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -138,6 +138,9 @@ typedef enum typedef struct GLES2_DriverContext { SDL_GLContext *context; + + SDL_bool debug_enabled; + struct { int blendMode; SDL_bool tex_coords; @@ -158,6 +161,72 @@ typedef struct GLES2_DriverContext #define GLES2_MAX_CACHED_PROGRAMS 8 + +SDL_FORCE_INLINE const char* +GL_TranslateError (GLenum error) +{ +#define GL_ERROR_TRANSLATE(e) case e: return #e; + switch (error) { + GL_ERROR_TRANSLATE(GL_INVALID_ENUM) + GL_ERROR_TRANSLATE(GL_INVALID_VALUE) + GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) + GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) + GL_ERROR_TRANSLATE(GL_NO_ERROR) + default: + return "UNKNOWN"; +} +#undef GL_ERROR_TRANSLATE +} + +SDL_FORCE_INLINE void +GL_ClearErrors(SDL_Renderer *renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + + if (!data->debug_enabled) + { + return; + } + while (data->glGetError() != GL_NO_ERROR) { + continue; + } +} + +SDL_FORCE_INLINE int +GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + int ret = 0; + + if (!data->debug_enabled) + { + return 0; + } + /* check gl errors (can return multiple errors) */ + for (;;) { + GLenum error = data->glGetError(); + if (error != GL_NO_ERROR) { + if (prefix == NULL || prefix[0] == '\0') { + prefix = "generic"; + } + SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); + ret = -1; + } else { + break; + } + } + return ret; +} + +#if 0 +#define GL_CheckError(prefix, renderer) +#elif defined(_MSC_VER) +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, __FILE__, __LINE__, __FUNCTION__) +#else +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#endif + + /************************************************************************************************* * Renderer state APIs * *************************************************************************************************/ @@ -222,26 +291,29 @@ GLES2_GetFBO(GLES2_DriverContext *data, Uint32 w, Uint32 h) static int GLES2_ActivateRenderer(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - if (SDL_CurrentContext != rdata->context) { + if (SDL_CurrentContext != data->context) { /* Null out the current program to ensure we set it again */ - rdata->current_program = NULL; + data->current_program = NULL; - if (SDL_GL_MakeCurrent(renderer->window, rdata->context) < 0) { + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { return -1; } - SDL_CurrentContext = rdata->context; + SDL_CurrentContext = data->context; GLES2_UpdateViewport(renderer); } + + GL_ClearErrors(renderer); + return 0; } static void GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || event->event == SDL_WINDOWEVENT_SHOWN || @@ -252,45 +324,45 @@ GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) if (event->event == SDL_WINDOWEVENT_MINIMIZED) { /* According to Apple documentation, we need to finish drawing NOW! */ - rdata->glFinish(); + data->glFinish(); } } static int GLES2_UpdateViewport(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - if (SDL_CurrentContext != rdata->context) { + if (SDL_CurrentContext != data->context) { /* We'll update the viewport after we rebind the context */ return 0; } - rdata->glViewport(renderer->viewport.x, renderer->viewport.y, + data->glViewport(renderer->viewport.x, renderer->viewport.y, renderer->viewport.w, renderer->viewport.h); - if (rdata->current_program) { + if (data->current_program) { GLES2_SetOrthographicProjection(renderer); } - return 0; + return GL_CheckError("", renderer); } static int GLES2_UpdateClipRect(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; const SDL_Rect *rect = &renderer->clip_rect; - if (SDL_CurrentContext != rdata->context) { + if (SDL_CurrentContext != data->context) { /* We'll update the clip rect after we rebind the context */ return 0; } if (!SDL_RectEmpty(rect)) { - rdata->glEnable(GL_SCISSOR_TEST); - rdata->glScissor(rect->x, renderer->viewport.h - rect->y - rect->h, rect->w, rect->h); + data->glEnable(GL_SCISSOR_TEST); + data->glScissor(rect->x, renderer->viewport.h - rect->y - rect->h, rect->w, rect->h); } else { - rdata->glDisable(GL_SCISSOR_TEST); + data->glDisable(GL_SCISSOR_TEST); } return 0; } @@ -298,19 +370,19 @@ GLES2_UpdateClipRect(SDL_Renderer * renderer) static void GLES2_DestroyRenderer(SDL_Renderer *renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; /* Deallocate everything */ - if (rdata) { + if (data) { GLES2_ActivateRenderer(renderer); { GLES2_ShaderCacheEntry *entry; GLES2_ShaderCacheEntry *next; - entry = rdata->shader_cache.head; + entry = data->shader_cache.head; while (entry) { - rdata->glDeleteShader(entry->id); + data->glDeleteShader(entry->id); next = entry->next; SDL_free(entry); entry = next; @@ -319,25 +391,26 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) { GLES2_ProgramCacheEntry *entry; GLES2_ProgramCacheEntry *next; - entry = rdata->program_cache.head; + entry = data->program_cache.head; while (entry) { - rdata->glDeleteProgram(entry->id); + data->glDeleteProgram(entry->id); next = entry->next; SDL_free(entry); entry = next; } } - if (rdata->context) { - while (rdata->framebuffers) { - GLES2_FBOList *nextnode = rdata->framebuffers->next; - rdata->glDeleteFramebuffers(1, &rdata->framebuffers->FBO); - SDL_free(rdata->framebuffers); - rdata->framebuffers = nextnode; + if (data->context) { + while (data->framebuffers) { + GLES2_FBOList *nextnode = data->framebuffers->next; + data->glDeleteFramebuffers(1, &data->framebuffers->FBO); + GL_CheckError("", renderer); + SDL_free(data->framebuffers); + data->framebuffers = nextnode; } - SDL_GL_DeleteContext(rdata->context); + SDL_GL_DeleteContext(data->context); } - SDL_free(rdata->shader_formats); - SDL_free(rdata); + SDL_free(data->shader_formats); + SDL_free(data); } SDL_free(renderer); } @@ -347,13 +420,13 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) *************************************************************************************************/ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch); static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch); static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, - const void *pixels, int pitch); static int GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); static GLenum GetScaleQuality(void) @@ -370,8 +443,8 @@ GetScaleQuality(void) static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - GLES2_TextureData *tdata; + GLES2_DriverContext *renderdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *data; GLenum format; GLenum type; GLenum scaleMode; @@ -393,62 +466,105 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } /* Allocate a texture struct */ - tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); - if (!tdata) { + data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); + if (!data) { return SDL_OutOfMemory(); } - tdata->texture = 0; - tdata->texture_type = GL_TEXTURE_2D; - tdata->pixel_format = format; - tdata->pixel_type = type; + data->texture = 0; + data->texture_type = GL_TEXTURE_2D; + data->pixel_format = format; + data->pixel_type = type; scaleMode = GetScaleQuality(); - /* Allocate a blob for image data */ + /* Allocate a blob for image renderdata */ if (texture->access == SDL_TEXTUREACCESS_STREAMING) { - tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); - tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h); - if (!tdata->pixel_data) { - SDL_free(tdata); + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + data->pixel_data = SDL_calloc(1, data->pitch * texture->h); + if (!data->pixel_data) { + SDL_free(data); return SDL_OutOfMemory(); } } /* Allocate the texture */ - rdata->glGenTextures(1, &tdata->texture); - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); - texture->driverdata = tdata; + GL_CheckError("", renderer); + renderdata->glGenTextures(1, &data->texture); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; + } + texture->driverdata = data; - if (texture->access == SDL_TEXTUREACCESS_TARGET) { - tdata->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); - } else { - tdata->fbo = NULL; + renderdata->glActiveTexture(GL_TEXTURE0); + renderdata->glBindTexture(data->texture_type, data->texture); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; } - return 0; + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); + } else { + data->fbo = NULL; + } + + return GL_CheckError("", renderer); } -static void -GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static int +GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + Uint8 *blob = NULL; + Uint8 *src; + int srcPitch; + int y; GLES2_ActivateRenderer(renderer); - /* Destroy the texture */ - if (tdata) - { - rdata->glDeleteTextures(1, &tdata->texture); - SDL_free(tdata->pixel_data); - SDL_free(tdata); - texture->driverdata = NULL; + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) + return 0; + + /* Reformat the texture data into a tightly packed array */ + srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + src = (Uint8 *)pixels; + if (pitch != srcPitch) { + blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); + if (!blob) { + return SDL_OutOfMemory(); + } + src = blob; + for (y = 0; y < rect->h; ++y) + { + SDL_memcpy(src, pixels, srcPitch); + src += srcPitch; + pixels = (Uint8 *)pixels + pitch; + } + src = blob; } + + /* Create a texture subimage with the supplied data */ + data->glActiveTexture(GL_TEXTURE0); + data->glBindTexture(tdata->texture_type, tdata->texture); + data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + data->glTexSubImage2D(tdata->texture_type, + 0, + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + src); + SDL_free(blob); + + return GL_CheckError("glTexSubImage2D()", renderer); } static int @@ -480,59 +596,6 @@ GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch); } -static int -GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, - const void *pixels, int pitch) -{ - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - Uint8 *blob = NULL; - Uint8 *src; - int srcPitch; - int y; - - GLES2_ActivateRenderer(renderer); - - /* Bail out if we're supposed to update an empty rectangle */ - if (rect->w <= 0 || rect->h <= 0) - return 0; - - /* Reformat the texture data into a tightly packed array */ - srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); - src = (Uint8 *)pixels; - if (pitch != srcPitch) { - blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); - if (!blob) { - return SDL_OutOfMemory(); - } - src = blob; - for (y = 0; y < rect->h; ++y) - { - SDL_memcpy(src, pixels, srcPitch); - src += srcPitch; - pixels = (Uint8 *)pixels + pitch; - } - src = blob; - } - - /* Create a texture subimage with the supplied data */ - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - rdata->glTexSubImage2D(tdata->texture_type, - 0, - rect->x, - rect->y, - rect->w, - rect->h, - tdata->pixel_format, - tdata->pixel_type, - src); - SDL_free(blob); - - return 0; -} - static int GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) { @@ -556,6 +619,24 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } +static void +GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Destroy the texture */ + if (tdata) + { + data->glDeleteTextures(1, &tdata->texture); + SDL_free(tdata->pixel_data); + SDL_free(tdata); + texture->driverdata = NULL; + } +} + /************************************************************************************************* * Shader management functions * *************************************************************************************************/ @@ -574,13 +655,13 @@ static GLES2_ProgramCacheEntry * GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, GLES2_ShaderCacheEntry *fragment, SDL_BlendMode blendMode) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ProgramCacheEntry *entry; GLES2_ShaderCacheEntry *shaderEntry; GLint linkSuccessful; /* Check if we've already cached this program */ - entry = rdata->program_cache.head; + entry = data->program_cache.head; while (entry) { if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) @@ -589,16 +670,16 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, } if (entry) { - if (rdata->program_cache.head != entry) + if (data->program_cache.head != entry) { if (entry->next) entry->next->prev = entry->prev; if (entry->prev) entry->prev->next = entry->next; entry->prev = NULL; - entry->next = rdata->program_cache.head; - rdata->program_cache.head->prev = entry; - rdata->program_cache.head = entry; + entry->next = data->program_cache.head; + data->program_cache.head->prev = entry; + data->program_cache.head = entry; } return entry; } @@ -615,18 +696,18 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, entry->blend_mode = blendMode; /* Create the program and link it */ - entry->id = rdata->glCreateProgram(); - rdata->glAttachShader(entry->id, vertex->id); - rdata->glAttachShader(entry->id, fragment->id); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle"); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center"); - rdata->glLinkProgram(entry->id); - rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); + entry->id = data->glCreateProgram(); + data->glAttachShader(entry->id, vertex->id); + data->glAttachShader(entry->id, fragment->id); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center"); + data->glLinkProgram(entry->id); + data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); if (!linkSuccessful) { - rdata->glDeleteProgram(entry->id); + data->glDeleteProgram(entry->id); SDL_free(entry); SDL_SetError("Failed to link shader program"); return NULL; @@ -634,47 +715,47 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, /* Predetermine locations of uniform variables */ entry->uniform_locations[GLES2_UNIFORM_PROJECTION] = - rdata->glGetUniformLocation(entry->id, "u_projection"); + data->glGetUniformLocation(entry->id, "u_projection"); entry->uniform_locations[GLES2_UNIFORM_TEXTURE] = - rdata->glGetUniformLocation(entry->id, "u_texture"); + data->glGetUniformLocation(entry->id, "u_texture"); entry->uniform_locations[GLES2_UNIFORM_MODULATION] = - rdata->glGetUniformLocation(entry->id, "u_modulation"); + data->glGetUniformLocation(entry->id, "u_modulation"); entry->uniform_locations[GLES2_UNIFORM_COLOR] = - rdata->glGetUniformLocation(entry->id, "u_color"); + data->glGetUniformLocation(entry->id, "u_color"); entry->uniform_locations[GLES2_UNIFORM_COLORTABLE] = - rdata->glGetUniformLocation(entry->id, "u_colorTable"); + data->glGetUniformLocation(entry->id, "u_colorTable"); /* Cache the linked program */ - if (rdata->program_cache.head) + if (data->program_cache.head) { - entry->next = rdata->program_cache.head; - rdata->program_cache.head->prev = entry; + entry->next = data->program_cache.head; + data->program_cache.head->prev = entry; } else { - rdata->program_cache.tail = entry; + data->program_cache.tail = entry; } - rdata->program_cache.head = entry; - ++rdata->program_cache.count; + data->program_cache.head = entry; + ++data->program_cache.count; /* Increment the refcount of the shaders we're using */ ++vertex->references; ++fragment->references; /* Evict the last entry from the cache if we exceed the limit */ - if (rdata->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) + if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { - shaderEntry = rdata->program_cache.tail->vertex_shader; + shaderEntry = data->program_cache.tail->vertex_shader; if (--shaderEntry->references <= 0) GLES2_EvictShader(renderer, shaderEntry); - shaderEntry = rdata->program_cache.tail->fragment_shader; + shaderEntry = data->program_cache.tail->fragment_shader; if (--shaderEntry->references <= 0) GLES2_EvictShader(renderer, shaderEntry); - rdata->glDeleteProgram(rdata->program_cache.tail->id); - rdata->program_cache.tail = rdata->program_cache.tail->prev; - SDL_free(rdata->program_cache.tail->next); - rdata->program_cache.tail->next = NULL; - --rdata->program_cache.count; + data->glDeleteProgram(data->program_cache.tail->id); + data->program_cache.tail = data->program_cache.tail->prev; + SDL_free(data->program_cache.tail->next); + data->program_cache.tail->next = NULL; + --data->program_cache.count; } return entry; } @@ -682,7 +763,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, static GLES2_ShaderCacheEntry * GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode blendMode) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; const GLES2_Shader *shader; const GLES2_ShaderInstance *instance = NULL; GLES2_ShaderCacheEntry *entry = NULL; @@ -700,13 +781,13 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b /* Find a matching shader instance that's supported on this hardware */ for (i = 0; i < shader->instance_count && !instance; ++i) { - for (j = 0; j < rdata->shader_format_count && !instance; ++j) + for (j = 0; j < data->shader_format_count && !instance; ++j) { if (!shader->instances) continue; if (!shader->instances[i]) continue; - if (shader->instances[i]->format != rdata->shader_formats[j]) + if (shader->instances[i]->format != data->shader_formats[j]) continue; instance = shader->instances[i]; } @@ -718,7 +799,7 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b } /* Check if we've already cached this shader */ - entry = rdata->shader_cache.head; + entry = data->shader_cache.head; while (entry) { if (entry->instance == instance) @@ -739,16 +820,16 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b entry->instance = instance; /* Compile or load the selected shader instance */ - entry->id = rdata->glCreateShader(instance->type); + entry->id = data->glCreateShader(instance->type); if (instance->format == (GLenum)-1) { - rdata->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL); - rdata->glCompileShader(entry->id); - rdata->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); + data->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL); + data->glCompileShader(entry->id); + data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); } else { - rdata->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); + data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); compileSuccessful = GL_TRUE; } if (!compileSuccessful) @@ -756,11 +837,11 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b char *info = NULL; int length = 0; - rdata->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); + data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); if (length > 0) { info = SDL_stack_alloc(char, length); if (info) { - rdata->glGetShaderInfoLog(entry->id, length, &length, info); + data->glGetShaderInfoLog(entry->id, length, &length, info); } } if (info) { @@ -769,45 +850,45 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b } else { SDL_SetError("Failed to load the shader"); } - rdata->glDeleteShader(entry->id); + data->glDeleteShader(entry->id); SDL_free(entry); return NULL; } /* Link the shader entry in at the front of the cache */ - if (rdata->shader_cache.head) + if (data->shader_cache.head) { - entry->next = rdata->shader_cache.head; - rdata->shader_cache.head->prev = entry; + entry->next = data->shader_cache.head; + data->shader_cache.head->prev = entry; } - rdata->shader_cache.head = entry; - ++rdata->shader_cache.count; + data->shader_cache.head = entry; + ++data->shader_cache.count; return entry; } static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; /* Unlink the shader from the cache */ if (entry->next) entry->next->prev = entry->prev; if (entry->prev) entry->prev->next = entry->next; - if (rdata->shader_cache.head == entry) - rdata->shader_cache.head = entry->next; - --rdata->shader_cache.count; + if (data->shader_cache.head == entry) + data->shader_cache.head = entry->next; + --data->shader_cache.count; /* Deallocate the shader */ - rdata->glDeleteShader(entry->id); + data->glDeleteShader(entry->id); SDL_free(entry); } static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendMode blendMode) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ShaderCacheEntry *vertex = NULL; GLES2_ShaderCacheEntry *fragment = NULL; GLES2_ShaderType vtype, ftype; @@ -845,9 +926,9 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM goto fault; /* Check if we need to change programs at all */ - if (rdata->current_program && - rdata->current_program->vertex_shader == vertex && - rdata->current_program->fragment_shader == fragment) + if (data->current_program && + data->current_program->vertex_shader == vertex && + data->current_program->fragment_shader == fragment) return 0; /* Generate a matching program */ @@ -856,10 +937,10 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM goto fault; /* Select that program in OpenGL */ - rdata->glUseProgram(program->id); + data->glUseProgram(program->id); /* Set the current program */ - rdata->current_program = program; + data->current_program = program; /* Activate an orthographic projection */ if (GLES2_SetOrthographicProjection(renderer) < 0) @@ -872,14 +953,14 @@ fault: GLES2_EvictShader(renderer, vertex); if (fragment && fragment->references <= 0) GLES2_EvictShader(renderer, fragment); - rdata->current_program = NULL; + data->current_program = NULL; return -1; } static int GLES2_SetOrthographicProjection(SDL_Renderer *renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat projection[4][4]; GLuint locProjection; @@ -914,8 +995,8 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer) projection[3][3] = 1.0f; /* Set the projection matrix */ - locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; - rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); + locProjection = data->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; + data->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); return 0; } @@ -942,88 +1023,88 @@ static void GLES2_RenderPresent(SDL_Renderer *renderer); static int GLES2_RenderClear(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ActivateRenderer(renderer); - rdata->glClearColor((GLfloat) renderer->r * inv255f, + data->glClearColor((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); - rdata->glClear(GL_COLOR_BUFFER_BIT); + data->glClear(GL_COLOR_BUFFER_BIT); return 0; } static void -GLES2_SetBlendMode(GLES2_DriverContext *rdata, int blendMode) +GLES2_SetBlendMode(GLES2_DriverContext *data, int blendMode) { - if (blendMode != rdata->current.blendMode) { + if (blendMode != data->current.blendMode) { switch (blendMode) { default: case SDL_BLENDMODE_NONE: - rdata->glDisable(GL_BLEND); + data->glDisable(GL_BLEND); break; case SDL_BLENDMODE_BLEND: - rdata->glEnable(GL_BLEND); - rdata->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); break; case SDL_BLENDMODE_ADD: - rdata->glEnable(GL_BLEND); - rdata->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); break; case SDL_BLENDMODE_MOD: - rdata->glEnable(GL_BLEND); - rdata->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE); + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE); break; } - rdata->current.blendMode = blendMode; + data->current.blendMode = blendMode; } } static void -GLES2_SetTexCoords(GLES2_DriverContext * rdata, SDL_bool enabled) +GLES2_SetTexCoords(GLES2_DriverContext * data, SDL_bool enabled) { - if (enabled != rdata->current.tex_coords) { + if (enabled != data->current.tex_coords) { if (enabled) { - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); } else { - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); } - rdata->current.tex_coords = enabled; + data->current.tex_coords = enabled; } } static int GLES2_SetDrawingState(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; int blendMode = renderer->blendMode; GLuint locColor; GLES2_ActivateRenderer(renderer); - GLES2_SetBlendMode(rdata, blendMode); + GLES2_SetBlendMode(data, blendMode); - GLES2_SetTexCoords(rdata, SDL_FALSE); + GLES2_SetTexCoords(data, SDL_FALSE); /* Activate an appropriate shader and set the projection matrix */ if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) return -1; /* Select the color to draw with */ - locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR]; + locColor = data->current_program->uniform_locations[GLES2_UNIFORM_COLOR]; if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - rdata->glUniform4f(locColor, + data->glUniform4f(locColor, renderer->b * inv255f, renderer->g * inv255f, renderer->r * inv255f, renderer->a * inv255f); } else { - rdata->glUniform4f(locColor, + data->glUniform4f(locColor, renderer->r * inv255f, renderer->g * inv255f, renderer->b * inv255f, @@ -1035,7 +1116,7 @@ GLES2_SetDrawingState(SDL_Renderer * renderer) static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat *vertices; int idx; @@ -1052,8 +1133,8 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - rdata->glDrawArrays(GL_POINTS, 0, count); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glDrawArrays(GL_POINTS, 0, count); SDL_stack_free(vertices); return 0; } @@ -1061,7 +1142,7 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat *vertices; int idx; @@ -1078,22 +1159,23 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - rdata->glDrawArrays(GL_LINE_STRIP, 0, count); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glDrawArrays(GL_LINE_STRIP, 0, count); /* We need to close the endpoint of the line */ if (count == 2 || points[0].x != points[count-1].x || points[0].y != points[count-1].y) { - rdata->glDrawArrays(GL_POINTS, count-1, 1); + data->glDrawArrays(GL_POINTS, count-1, 1); } SDL_stack_free(vertices); - return 0; + + return GL_CheckError("", renderer); } static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat vertices[8]; int idx; @@ -1118,17 +1200,17 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) vertices[5] = yMax; vertices[6] = xMax; vertices[7] = yMax; - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } - return 0; + return GL_CheckError("", renderer); } static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_BlendMode blendMode; @@ -1225,23 +1307,23 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s return -1; /* Select the target texture */ - locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glUniform1i(locTexture, 0); + locTexture = data->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; + data->glActiveTexture(GL_TEXTURE0); + data->glBindTexture(tdata->texture_type, tdata->texture); + data->glUniform1i(locTexture, 0); /* Configure color modulation */ - locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + locModulation = data->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - rdata->glUniform4f(locModulation, + data->glUniform4f(locModulation, texture->b * inv255f, texture->g * inv255f, texture->r * inv255f, texture->a * inv255f); } else { - rdata->glUniform4f(locModulation, + data->glUniform4f(locModulation, texture->r * inv255f, texture->g * inv255f, texture->b * inv255f, @@ -1249,9 +1331,9 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s } /* Configure texture blending */ - GLES2_SetBlendMode(rdata, blendMode); + GLES2_SetBlendMode(data, blendMode); - GLES2_SetTexCoords(rdata, SDL_TRUE); + GLES2_SetTexCoords(data, SDL_TRUE); /* Emit the textured quad */ vertices[0] = dstrect->x; @@ -1262,7 +1344,7 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s vertices[5] = (dstrect->y + dstrect->h); vertices[6] = (dstrect->x + dstrect->w); vertices[7] = (dstrect->y + dstrect->h); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); texCoords[0] = srcrect->x / (GLfloat)texture->w; texCoords[1] = srcrect->y / (GLfloat)texture->h; texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; @@ -1271,16 +1353,17 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); - rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - return 0; + data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + return GL_CheckError("", renderer); } static int GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_BlendMode blendMode; @@ -1294,8 +1377,8 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect GLES2_ActivateRenderer(renderer); - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)(360.0f - angle); /* Calculate the center of rotation */ translate[0] = translate[2] = translate[4] = translate[6] = (center->x + dstrect->x); @@ -1387,23 +1470,23 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect return -1; /* Select the target texture */ - locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glUniform1i(locTexture, 0); + locTexture = data->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; + data->glActiveTexture(GL_TEXTURE0); + data->glBindTexture(tdata->texture_type, tdata->texture); + data->glUniform1i(locTexture, 0); /* Configure color modulation */ - locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + locModulation = data->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - rdata->glUniform4f(locModulation, + data->glUniform4f(locModulation, texture->b * inv255f, texture->g * inv255f, texture->r * inv255f, texture->a * inv255f); } else { - rdata->glUniform4f(locModulation, + data->glUniform4f(locModulation, texture->r * inv255f, texture->g * inv255f, texture->b * inv255f, @@ -1411,9 +1494,9 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect } /* Configure texture blending */ - GLES2_SetBlendMode(rdata, blendMode); + GLES2_SetBlendMode(data, blendMode); - GLES2_SetTexCoords(rdata, SDL_TRUE); + GLES2_SetTexCoords(data, SDL_TRUE); /* Emit the textured quad */ vertices[0] = dstrect->x; @@ -1435,9 +1518,9 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect vertices[5] = vertices[7] = tmp; } - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); texCoords[0] = srcrect->x / (GLfloat)texture->w; texCoords[1] = srcrect->y / (GLfloat)texture->h; @@ -1447,18 +1530,19 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); - rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); - return 0; + data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); + + return GL_CheckError("", renderer); } static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 pixel_format, void * pixels, int pitch) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888; void *temp_pixels; int temp_pitch; @@ -1476,10 +1560,13 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, SDL_GetRendererOutputSize(renderer, &w, &h); - rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1); + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); - rdata->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + if (GL_CheckError("glReadPixels()", renderer) < 0) { + return -1; + } /* Flip the rows to be top-down */ length = rect->w * SDL_BYTESPERPIXEL(temp_format); @@ -1520,7 +1607,8 @@ GLES2_RenderPresent(SDL_Renderer *renderer) static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture); -static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) { +static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +{ GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; GLES2_ActivateRenderer(renderer); @@ -1533,7 +1621,8 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo return 0; } -static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) { +static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +{ GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; GLES2_ActivateRenderer(renderer); @@ -1553,26 +1642,28 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) { static void GLES2_ResetState(SDL_Renderer *renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *) renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; - if (SDL_CurrentContext == rdata->context) { + if (SDL_CurrentContext == data->context) { GLES2_UpdateViewport(renderer); } else { GLES2_ActivateRenderer(renderer); } - rdata->current.blendMode = -1; - rdata->current.tex_coords = SDL_FALSE; + data->current.blendMode = -1; + data->current.tex_coords = SDL_FALSE; - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + + GL_CheckError("", renderer); } static SDL_Renderer * GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; - GLES2_DriverContext *rdata; + GLES2_DriverContext *data; GLint nFormats; #ifndef ZUNE_HD GLboolean hasCompiler; @@ -1601,30 +1692,30 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) return NULL; } - rdata = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext)); - if (!rdata) { + data = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext)); + if (!data) { GLES2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; } renderer->info = GLES2_RenderDriver.info; renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; - renderer->driverdata = rdata; + renderer->driverdata = data; renderer->window = window; /* Create an OpenGL ES 2.0 context */ - rdata->context = SDL_GL_CreateContext(window); - if (!rdata->context) + data->context = SDL_GL_CreateContext(window); + if (!data->context) { GLES2_DestroyRenderer(renderer); return NULL; } - if (SDL_GL_MakeCurrent(window, rdata->context) < 0) { + if (SDL_GL_MakeCurrent(window, data->context) < 0) { GLES2_DestroyRenderer(renderer); return NULL; } - if (GLES2_LoadFunctions(rdata) < 0) { + if (GLES2_LoadFunctions(data) < 0) { GLES2_DestroyRenderer(renderer); return NULL; } @@ -1638,11 +1729,17 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } + /* Check for debug output support */ + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && + (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { + data->debug_enabled = SDL_TRUE; + } + value = 0; - rdata->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_width = value; value = 0; - rdata->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_height = value; /* Determine supported shader formats */ @@ -1650,30 +1747,30 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) #ifdef ZUNE_HD nFormats = 1; #else /* !ZUNE_HD */ - rdata->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); - rdata->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); + data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); + data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); if (hasCompiler) ++nFormats; #endif /* ZUNE_HD */ - rdata->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); - if (!rdata->shader_formats) + data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); + if (!data->shader_formats) { GLES2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; } - rdata->shader_format_count = nFormats; + data->shader_format_count = nFormats; #ifdef ZUNE_HD - rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; + data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; #else /* !ZUNE_HD */ - rdata->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats); + data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats); if (hasCompiler) - rdata->shader_formats[nFormats - 1] = (GLenum)-1; + data->shader_formats[nFormats - 1] = (GLenum)-1; #endif /* ZUNE_HD */ - rdata->framebuffers = NULL; - rdata->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer); - rdata->window_framebuffer = (GLuint)window_framebuffer; + data->framebuffers = NULL; + data->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer); + data->window_framebuffer = (GLuint)window_framebuffer; /* Populate the function pointers for the module */ renderer->WindowEvent = &GLES2_WindowEvent; From 75add5589650636f1ae575c75cd551636a5ad635 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 3 Oct 2013 21:41:09 -0700 Subject: [PATCH 147/258] Report an error if creating a render target fails --- test/testrendertarget.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 03e8df19e..4f49dce75 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -87,7 +87,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) return texture; } -void +SDL_bool DrawComposite(DrawState *s) { SDL_Rect viewport, R; @@ -167,9 +167,10 @@ DrawComposite(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); + return SDL_TRUE; } -void +SDL_bool Draw(DrawState *s) { SDL_Rect viewport; @@ -178,6 +179,10 @@ Draw(DrawState *s) SDL_RenderGetViewport(s->renderer, &viewport); target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); + if (!target) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError()); + return SDL_FALSE; + } SDL_SetRenderTarget(s->renderer, target); /* Draw the background */ @@ -206,6 +211,7 @@ Draw(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); + return SDL_TRUE; } int @@ -280,9 +286,9 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { if (test_composite) { - DrawComposite(&drawstates[i]); + if (!DrawComposite(&drawstates[i])) done = 1; } else { - Draw(&drawstates[i]); + if (!Draw(&drawstates[i])) done = 1; } } } From 4d80960781479a194c827602a2543144bca62fc7 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Fri, 4 Oct 2013 08:23:37 -0300 Subject: [PATCH 148/258] Fix EGL/OpenGL ES paths --- src/video/SDL_egl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 1501a748a..39d94daac 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -25,12 +25,23 @@ #include "SDL_sysvideo.h" #include "SDL_egl.h" + #if SDL_VIDEO_DRIVER_RPI +/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */ #define DEFAULT_EGL "/opt/vc/lib/libEGL.so" #define DEFAULT_OGL_ES2 "/opt/vc/lib/libGLESv2.so" #define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so" #define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so" + +#elif SDL_VIDEO_DRIVER_ANDROID +/* Android */ +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" + #else +/* Desktop Linux */ #define DEFAULT_EGL "libEGL.so.1" #define DEFAULT_OGL_ES2 "libGLESv2.so.2" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1" From 4cba5706bf09118daef90a8dd9bf003329571d70 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 4 Oct 2013 11:25:14 -0400 Subject: [PATCH 149/258] Removed "u_colorTable" uniform from the GLES2 renderer. It's not used anywhere. --HG-- extra : rebase_source : 52e7f708617733fe957c15f2ad752bf79b7c14cb --- src/render/opengles2/SDL_render_gles2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 4b7e645b1..6f798022e 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -122,8 +122,7 @@ typedef enum GLES2_UNIFORM_PROJECTION, GLES2_UNIFORM_TEXTURE, GLES2_UNIFORM_MODULATION, - GLES2_UNIFORM_COLOR, - GLES2_UNIFORM_COLORTABLE + GLES2_UNIFORM_COLOR } GLES2_Uniform; typedef enum @@ -721,9 +720,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, entry->uniform_locations[GLES2_UNIFORM_MODULATION] = data->glGetUniformLocation(entry->id, "u_modulation"); entry->uniform_locations[GLES2_UNIFORM_COLOR] = - data->glGetUniformLocation(entry->id, "u_color"); - entry->uniform_locations[GLES2_UNIFORM_COLORTABLE] = - data->glGetUniformLocation(entry->id, "u_colorTable"); + rdata->glGetUniformLocation(entry->id, "u_color"); /* Cache the linked program */ if (data->program_cache.head) From 0a999e88d17569a8ac3e498a5fb0941c168d6f60 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 5 Oct 2013 00:29:57 -0400 Subject: [PATCH 150/258] Avoid redundant state changes in the GLES2 renderer. --- src/render/opengles2/SDL_render_gles2.c | 175 +++++++++++++++--------- src/video/uikit/SDL_uikitopenglview.m | 8 +- 2 files changed, 119 insertions(+), 64 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 6f798022e..536fec90b 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -81,6 +81,7 @@ typedef struct GLES2_ShaderCacheEntry GLES2_ShaderType type; const GLES2_ShaderInstance *instance; int references; + Uint8 modulation_r, modulation_g, modulation_b, modulation_a; struct GLES2_ShaderCacheEntry *prev; struct GLES2_ShaderCacheEntry *next; } GLES2_ShaderCacheEntry; @@ -98,6 +99,9 @@ typedef struct GLES2_ProgramCacheEntry GLES2_ShaderCacheEntry *vertex_shader; GLES2_ShaderCacheEntry *fragment_shader; GLuint uniform_locations[16]; + Uint8 color_r, color_g, color_b, color_a; + Uint8 modulation_r, modulation_g, modulation_b, modulation_a; + GLfloat projection[4][4]; struct GLES2_ProgramCacheEntry *prev; struct GLES2_ProgramCacheEntry *next; } GLES2_ProgramCacheEntry; @@ -156,6 +160,7 @@ typedef struct GLES2_DriverContext GLES2_ShaderCache shader_cache; GLES2_ProgramCache program_cache; GLES2_ProgramCacheEntry *current_program; + Uint8 clear_r, clear_g, clear_b, clear_a; } GLES2_DriverContext; #define GLES2_MAX_CACHED_PROGRAMS 8 @@ -492,8 +497,6 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) return -1; } texture->driverdata = data; - - renderdata->glActiveTexture(GL_TEXTURE0); renderdata->glBindTexture(data->texture_type, data->texture); renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); @@ -549,9 +552,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect } /* Create a texture subimage with the supplied data */ - data->glActiveTexture(GL_TEXTURE0); data->glBindTexture(tdata->texture_type, tdata->texture); - data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); data->glTexSubImage2D(tdata->texture_type, 0, rect->x, @@ -720,7 +721,16 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, entry->uniform_locations[GLES2_UNIFORM_MODULATION] = data->glGetUniformLocation(entry->id, "u_modulation"); entry->uniform_locations[GLES2_UNIFORM_COLOR] = - rdata->glGetUniformLocation(entry->id, "u_color"); + data->glGetUniformLocation(entry->id, "u_color"); + + entry->modulation_r = entry->modulation_g = entry->modulation_b = entry->modulation_a = 1.0f; + entry->color_r = entry->color_g = entry->color_b = entry->color_a = 1.0f; + + data->glUseProgram(entry->id); + data->glUniformMatrix4fv(entry->uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)entry->projection); + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ + data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_MODULATION], 1.0f, 1.0f, 1.0f, 1.0f); + data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f); /* Cache the linked program */ if (data->program_cache.head) @@ -959,7 +969,6 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer) { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat projection[4][4]; - GLuint locProjection; if (!renderer->viewport.w || !renderer->viewport.h) { return 0; @@ -992,8 +1001,12 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer) projection[3][3] = 1.0f; /* Set the projection matrix */ - locProjection = data->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; - data->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); + if (SDL_memcmp(data->current_program->projection, projection, sizeof (projection)) != 0) { + const GLuint locProjection = data->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; + data->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); + SDL_memcpy(data->current_program->projection, projection, sizeof (projection)); + } + return 0; } @@ -1024,10 +1037,18 @@ GLES2_RenderClear(SDL_Renderer * renderer) GLES2_ActivateRenderer(renderer); - data->glClearColor((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); + /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ + if ( (data->clear_r != renderer->r) || (data->clear_g != renderer->g) || + (data->clear_b != renderer->b) || (data->clear_a != renderer->a) ) { + data->glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + data->clear_r = renderer->r; + data->clear_g = renderer->g; + data->clear_b = renderer->b; + data->clear_a = renderer->a; + } data->glClear(GL_COLOR_BUFFER_BIT); @@ -1077,8 +1098,9 @@ static int GLES2_SetDrawingState(SDL_Renderer * renderer) { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - int blendMode = renderer->blendMode; - GLuint locColor; + const int blendMode = renderer->blendMode; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; GLES2_ActivateRenderer(renderer); @@ -1087,26 +1109,35 @@ GLES2_SetDrawingState(SDL_Renderer * renderer) GLES2_SetTexCoords(data, SDL_FALSE); /* Activate an appropriate shader and set the projection matrix */ - if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) + if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) { return -1; + } /* Select the color to draw with */ - locColor = data->current_program->uniform_locations[GLES2_UNIFORM_COLOR]; + g = renderer->g; + a = renderer->a; + if (renderer->target && - (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || + (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - data->glUniform4f(locColor, - renderer->b * inv255f, - renderer->g * inv255f, - renderer->r * inv255f, - renderer->a * inv255f); - } else { - data->glUniform4f(locColor, - renderer->r * inv255f, - renderer->g * inv255f, - renderer->b * inv255f, - renderer->a * inv255f); + r = renderer->b; + b = renderer->r; + } else { + r = renderer->r; + b = renderer->b; + } + + program = data->current_program; + /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ + if ( (program->color_r != r) || (program->color_g != g) || (program->color_b != b) || (program->color_a != a) ) { + /* Select the color to draw with */ + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_COLOR], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->color_r = r; + program->color_g = g; + program->color_b = b; + program->color_a = a; } + return 0; } @@ -1213,8 +1244,8 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; - GLuint locTexture; - GLuint locModulation; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; GLES2_ActivateRenderer(renderer); @@ -1300,31 +1331,37 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s return -1; } } - if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) + + if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) { return -1; + } /* Select the target texture */ - locTexture = data->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - data->glActiveTexture(GL_TEXTURE0); data->glBindTexture(tdata->texture_type, tdata->texture); - data->glUniform1i(locTexture, 0); /* Configure color modulation */ - locModulation = data->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + g = texture->g; + a = texture->a; + if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - data->glUniform4f(locModulation, - texture->b * inv255f, - texture->g * inv255f, - texture->r * inv255f, - texture->a * inv255f); + r = texture->b; + b = texture->r; } else { - data->glUniform4f(locModulation, - texture->r * inv255f, - texture->g * inv255f, - texture->b * inv255f, - texture->a * inv255f); + r = texture->r; + b = texture->b; + } + + program = data->current_program; + + /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ + if ( (program->modulation_r != r) || (program->modulation_g != g) || (program->modulation_b != b) || (program->modulation_a != a) ) { + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->modulation_r = r; + program->modulation_g = g; + program->modulation_b = b; + program->modulation_a = a; } /* Configure texture blending */ @@ -1363,11 +1400,11 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; - GLuint locTexture; - GLuint locModulation; GLfloat translate[8]; GLfloat fAngle[4]; GLfloat tmp; @@ -1467,27 +1504,32 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect return -1; /* Select the target texture */ - locTexture = data->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - data->glActiveTexture(GL_TEXTURE0); data->glBindTexture(tdata->texture_type, tdata->texture); - data->glUniform1i(locTexture, 0); /* Configure color modulation */ - locModulation = data->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + /* !!! FIXME: grep for glUniform4f(), move that stuff to a subroutine, it's a lot of copy/paste. */ + g = texture->g; + a = texture->a; + if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - data->glUniform4f(locModulation, - texture->b * inv255f, - texture->g * inv255f, - texture->r * inv255f, - texture->a * inv255f); + r = texture->b; + b = texture->r; } else { - data->glUniform4f(locModulation, - texture->r * inv255f, - texture->g * inv255f, - texture->b * inv255f, - texture->a * inv255f); + r = texture->r; + b = texture->b; + } + + program = data->current_program; + + /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ + if ( (program->modulation_r != r) || (program->modulation_g != g) || (program->modulation_b != b) || (program->modulation_a != a) ) { + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->modulation_r = r; + program->modulation_g = g; + program->modulation_b = b; + program->modulation_a = a; } /* Configure texture blending */ @@ -1557,8 +1599,6 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, SDL_GetRendererOutputSize(renderer, &w, &h); - data->glPixelStorei(GL_PACK_ALIGNMENT, 1); - data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); if (GL_CheckError("glReadPixels()", renderer) < 0) { @@ -1650,6 +1690,15 @@ GLES2_ResetState(SDL_Renderer *renderer) data->current.blendMode = -1; data->current.tex_coords = SDL_FALSE; + data->glActiveTexture(GL_TEXTURE0); + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); + data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + data->glClearColor((GLfloat) data->clear_r * inv255f, + (GLfloat) data->clear_g * inv255f, + (GLfloat) data->clear_b * inv255f, + (GLfloat) data->clear_a * inv255f); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index 9f3dc136a..b43f3455f 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -121,6 +121,8 @@ if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { return NO; } + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); /* end create buffers */ self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); @@ -148,6 +150,8 @@ glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); } + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); } - (void)setAnimationCallback:(int)interval @@ -197,7 +201,9 @@ - (void)swapBuffers { - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + /* viewRenderbuffer should always be bound here. Code that binds something + else is responsible for rebinding viewRenderbuffer, to reduce + duplicate state changes. */ [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } From 31db3ac3c80757a432891fd3c28a3399ae88ca3e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 5 Oct 2013 12:29:05 -0700 Subject: [PATCH 151/258] Do a 32-bit compare on RGBA values. Thsi should be inlined in optimized builds. --- src/render/opengles2/SDL_render_gles2.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 536fec90b..31a1598c0 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -25,6 +25,7 @@ #include "SDL_hints.h" #include "SDL_opengles2.h" #include "../SDL_sysrender.h" +#include "../../video/SDL_blit.h" #include "SDL_shaders_gles2.h" /* Used to re-create the window with OpenGL ES capability */ @@ -1029,6 +1030,15 @@ static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect Uint32 pixel_format, void * pixels, int pitch); static void GLES2_RenderPresent(SDL_Renderer *renderer); +static SDL_bool +CompareColors(Uint8 r1, Uint8 g1, Uint8 b1, Uint8 a1, + Uint8 r2, Uint8 g2, Uint8 b2, Uint8 a2) +{ + Uint32 Pixel1, Pixel2; + RGBA8888_FROM_RGBA(Pixel1, r1, g1, b1, a1); + RGBA8888_FROM_RGBA(Pixel2, r2, g2, b2, a2); + return (Pixel1 == Pixel2); +} static int GLES2_RenderClear(SDL_Renderer * renderer) @@ -1037,9 +1047,8 @@ GLES2_RenderClear(SDL_Renderer * renderer) GLES2_ActivateRenderer(renderer); - /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ - if ( (data->clear_r != renderer->r) || (data->clear_g != renderer->g) || - (data->clear_b != renderer->b) || (data->clear_a != renderer->a) ) { + if (!CompareColors(data->clear_r, data->clear_g, data->clear_b, data->clear_a, + renderer->r, renderer->g, renderer->b, renderer->a)) { data->glClearColor((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, @@ -1128,8 +1137,7 @@ GLES2_SetDrawingState(SDL_Renderer * renderer) } program = data->current_program; - /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ - if ( (program->color_r != r) || (program->color_g != g) || (program->color_b != b) || (program->color_a != a) ) { + if (!CompareColors(program->color_r, program->color_g, program->color_b, program->color_a, r, g, b, a)) { /* Select the color to draw with */ data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_COLOR], r * inv255f, g * inv255f, b * inv255f, a * inv255f); program->color_r = r; @@ -1355,8 +1363,7 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s program = data->current_program; - /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ - if ( (program->modulation_r != r) || (program->modulation_g != g) || (program->modulation_b != b) || (program->modulation_a != a) ) { + if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) { data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); program->modulation_r = r; program->modulation_g = g; @@ -1523,8 +1530,7 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect program = data->current_program; - /* !!! FIXME: it'd be nice to do a single 32-bit compare here. */ - if ( (program->modulation_r != r) || (program->modulation_g != g) || (program->modulation_b != b) || (program->modulation_a != a) ) { + if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) { data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); program->modulation_r = r; program->modulation_g = g; From 20b394d0722ce581b164b76d205c1d1c2a2d8d9c Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sat, 5 Oct 2013 17:08:19 +0200 Subject: [PATCH 152/258] Added detection of touch devices before first touch events happen on Android. On Android available touch devices are now added with video initialization (like the keyboard). This fixes SDL_GetNumTouchDevices() returning 0 before any touch events happened although there is a touch screen available. The adding of touch devices after a touch event was received is still active to allow connecting devices later (if this is possible) and to provide a fallback if the new init did not work somehow. For the implementation JNI was used and API level 9 is required. There seems to be nothing in the Android NDK's input header (input.h) to implement everything on C side without communication with Java side. --- .../src/org/libsdl/app/SDLActivity.java | 20 ++++++++++++++ src/core/android/SDL_android.c | 26 +++++++++++++++++++ src/core/android/SDL_android.h | 3 +++ src/video/android/SDL_androidtouch.c | 14 ++++++++++ src/video/android/SDL_androidtouch.h | 1 + src/video/android/SDL_androidvideo.c | 3 +++ 6 files changed, 67 insertions(+) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 52e48e236..1e194fa3d 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -1,5 +1,7 @@ package org.libsdl.app; +import java.util.Arrays; + import android.app.*; import android.content.*; import android.view.*; @@ -386,6 +388,24 @@ public class SDLActivity extends Activity { mAudioTrack = null; } } + + // Input + + /** + * @return an array which may be empty but is never null. + */ + public static int[] inputGetInputDeviceIds(int sources) { + int[] ids = InputDevice.getDeviceIds(); + int[] filtered = new int[ids.length]; + int used = 0; + for (int i = 0; i < ids.length; ++i) { + InputDevice device = InputDevice.getDevice(ids[i]); + if ((device != null) && ((device.getSources() & sources) != 0)) { + filtered[used++] = device.getId(); + } + } + return Arrays.copyOf(filtered, used); + } } /** diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 00592e87a..688055bbf 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -1186,6 +1186,32 @@ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seco return 0; } +/* returns number of found touch devices as return value and ids in parameter ids */ +int Android_JNI_GetTouchDeviceIds(int **ids) { + JNIEnv *env = Android_JNI_GetEnv(); + jint sources = 4098; /* == InputDevice.SOURCE_TOUCHSCREEN */ + jmethodID mid = (*env)->GetStaticMethodID(env, mActivityClass, "inputGetInputDeviceIds", "(I)[I"); + jintArray array = (jintArray) (*env)->CallStaticObjectMethod(env, mActivityClass, mid, sources); + int number = 0; + *ids = NULL; + if (array) { + number = (int) (*env)->GetArrayLength(env, array); + if (0 < number) { + jint* elements = (*env)->GetIntArrayElements(env, array, NULL); + if (elements) { + int i; + *ids = SDL_malloc(number * sizeof (*ids[0])); + for (i = 0; i < number; ++i) { /* not assuming sizeof (jint) == sizeof (int) */ + *ids[i] = elements[i]; + } + (*env)->ReleaseIntArrayElements(env, array, elements, JNI_ABORT); + } + } + (*env)->DeleteLocalRef(env, array); + } + return number; +} + /* sends message to be handled on the UI event dispatch thread */ int Android_JNI_SendMessage(int command, int param) { diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index feb7a6023..6181a15db 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -65,6 +65,9 @@ SDL_bool Android_JNI_HasClipboardText(); /* Power support */ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent); +/* Touch support */ +int Android_JNI_GetTouchDeviceIds(int **ids); + /* Threads */ #include JNIEnv *Android_JNI_GetEnv(void); diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 3265b54eb..6ad26e2c9 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -31,6 +31,7 @@ #include "SDL_androidtouch.h" +#include "../../core/android/SDL_android.h" #define ACTION_DOWN 0 #define ACTION_UP 1 @@ -53,6 +54,19 @@ static void Android_GetWindowCoordinates(float x, float y, *window_y = (int)(y * window_h); } +void Android_InitTouch(void) +{ + int i; + int* ids; + int number = Android_JNI_GetTouchDeviceIds(&ids); + if (0 < number) { + for (i = 0; i < number; ++i) { + SDL_AddTouch((SDL_TouchID) ids[i], ""); /* no error handling */ + } + SDL_free(ids); + } +} + void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) { SDL_TouchID touchDeviceId = 0; diff --git a/src/video/android/SDL_androidtouch.h b/src/video/android/SDL_androidtouch.h index 50a3ebdc8..346d73a66 100644 --- a/src/video/android/SDL_androidtouch.h +++ b/src/video/android/SDL_androidtouch.h @@ -22,6 +22,7 @@ #include "SDL_androidvideo.h" +extern void Android_InitTouch(void); extern void Android_OnTouch( int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 0bf3a2ce9..fc766ece7 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -36,6 +36,7 @@ #include "SDL_androidclipboard.h" #include "SDL_androidevents.h" #include "SDL_androidkeyboard.h" +#include "SDL_androidtouch.h" #include "SDL_androidwindow.h" #define ANDROID_VID_DRIVER_NAME "Android" @@ -165,6 +166,8 @@ Android_VideoInit(_THIS) Android_InitKeyboard(); + Android_InitTouch(); + /* We're done! */ return 0; } From 583198f72ee4f668d20eff435b3ec4439406baa7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 5 Oct 2013 19:09:03 -0700 Subject: [PATCH 153/258] Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed norfanin Some of the tests keep using the pointers of a destroyed SDL_Window when the common event handling handled the close event. The event handler itself does not NULL the pointer after the destruction. The attached patch adds a loop in the handler that will assign NULL to the destroyed window. It also adds checks to some of the tests so they skip those windows by checking for NULL. --- src/test/SDL_test_common.c | 6 ++++++ test/testdraw2.c | 2 ++ test/testgl2.c | 2 ++ test/testgles.c | 2 ++ test/testime.c | 2 ++ test/testintersections.c | 2 ++ test/testrelative.c | 2 ++ test/testrendercopyex.c | 2 ++ test/testrendertarget.c | 2 ++ test/testscale.c | 2 ++ test/testsprite2.c | 2 ++ 11 files changed, 26 insertions(+) diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 05d72a278..4e9429e63 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1200,6 +1200,12 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { SDL_DestroyWindow(window); + for (i = 0; i < state->num_windows; ++i) { + if (window == state->windows[i]) { + state->windows[i] = NULL; + break; + } + } } } break; diff --git a/test/testdraw2.c b/test/testdraw2.c index 926294bfe..62e2dbf64 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -253,6 +253,8 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); diff --git a/test/testgl2.c b/test/testgl2.c index 642fe47c6..19685eae1 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -340,6 +340,8 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { int w, h; + if (state->windows[i] == NULL) + continue; SDL_GL_MakeCurrent(state->windows[i], context); SDL_GL_GetDrawableSize(state->windows[i], &w, &h); glViewport(0, 0, w, h); diff --git a/test/testgles.c b/test/testgles.c index 7a790bd9d..daaa28c7c 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -312,6 +312,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); diff --git a/test/testime.c b/test/testime.c index 93b33e0c6..3d9789ad6 100644 --- a/test/testime.c +++ b/test/testime.c @@ -196,6 +196,8 @@ void Redraw() { int i; for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); SDL_RenderClear(renderer); diff --git a/test/testintersections.c b/test/testintersections.c index 237bd3511..b4deeecd0 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -310,6 +310,8 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); diff --git a/test/testrelative.c b/test/testrelative.c index 478d3bf77..9e8e1e2d0 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -84,6 +84,8 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 5033c1c5f..0c8ad7def 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -188,6 +188,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; Draw(&drawstates[i]); } } diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 4f49dce75..ac4aa5004 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -285,6 +285,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; if (test_composite) { if (!DrawComposite(&drawstates[i])) done = 1; } else { diff --git a/test/testscale.c b/test/testscale.c index f81ccdc24..8449f233d 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -178,6 +178,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; Draw(&drawstates[i]); } } diff --git a/test/testsprite2.c b/test/testsprite2.c index b40efd3f8..e0e1cf493 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -360,6 +360,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; MoveSprites(state->renderers[i], sprites[i]); } } From 5c03a1488feb2678448cc80dfeb5b74ff909ac12 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 5 Oct 2013 21:15:55 -0700 Subject: [PATCH 154/258] Fixed bug where a Logitech wireless keyboard with built-in mouse touchpad didn't get recongized as both devices. --- src/core/linux/SDL_udev.c | 32 ++-- src/core/linux/SDL_udev.h | 13 +- src/input/evdev/SDL_evdev.c | 264 +++++++++++---------------- src/input/evdev/SDL_evdev.h | 7 - src/joystick/linux/SDL_sysjoystick.c | 6 +- 5 files changed, 134 insertions(+), 188 deletions(-) diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 82f3e6636..c08c287e8 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -279,7 +279,7 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) { const char *subsystem; const char *val = NULL; - SDL_UDEV_deviceclass devclass = 0; + int devclass = 0; const char *path; SDL_UDEV_CallbackList *item; @@ -291,32 +291,26 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) subsystem = _this->udev_device_get_subsystem(dev); if (SDL_strcmp(subsystem, "sound") == 0) { devclass = SDL_UDEV_DEVICE_SOUND; - } - else if (SDL_strcmp(subsystem, "input") == 0) { + } else if (SDL_strcmp(subsystem, "input") == 0) { val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); if (val != NULL && SDL_strcmp(val, "1") == 0 ) { - devclass = SDL_UDEV_DEVICE_JOYSTICK; + devclass |= SDL_UDEV_DEVICE_JOYSTICK; } - if (devclass == 0) { - val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); - if (val != NULL && SDL_strcmp(val, "1") == 0 ) { - devclass = SDL_UDEV_DEVICE_MOUSE; - } + val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass |= SDL_UDEV_DEVICE_MOUSE; } - - if (devclass == 0) { - val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"); - if (val != NULL && SDL_strcmp(val, "1") == 0 ) { - devclass = SDL_UDEV_DEVICE_KEYBOARD; - } + + val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass |= SDL_UDEV_DEVICE_KEYBOARD; } - + if (devclass == 0) { return; } - } - else { + } else { return; } @@ -401,4 +395,4 @@ SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) } -#endif /* SDL_USE_LIBUDEV */ \ No newline at end of file +#endif /* SDL_USE_LIBUDEV */ diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h index 0ec86db1c..1c26f1104 100644 --- a/src/core/linux/SDL_udev.h +++ b/src/core/linux/SDL_udev.h @@ -46,15 +46,16 @@ typedef enum SDL_UDEV_DEVICEREMOVED } SDL_UDEV_deviceevent; +/* A device can be any combination of these classes */ typedef enum { - SDL_UDEV_DEVICE_MOUSE = 0x0001, - SDL_UDEV_DEVICE_KEYBOARD, - SDL_UDEV_DEVICE_JOYSTICK, - SDL_UDEV_DEVICE_SOUND + SDL_UDEV_DEVICE_MOUSE = 0x0001, + SDL_UDEV_DEVICE_KEYBOARD = 0x0002, + SDL_UDEV_DEVICE_JOYSTICK = 0x0004, + SDL_UDEV_DEVICE_SOUND = 0x0008 } SDL_UDEV_deviceclass; -typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); +typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); typedef struct SDL_UDEV_CallbackList { SDL_UDEV_Callback callback; @@ -111,4 +112,4 @@ extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); #endif /* HAVE_LIBUDEV_H */ -#endif /* _SDL_udev_h */ \ No newline at end of file +#endif /* _SDL_udev_h */ diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c index b9b647306..497cd40d1 100644 --- a/src/input/evdev/SDL_evdev.c +++ b/src/input/evdev/SDL_evdev.c @@ -62,8 +62,8 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); static int SDL_EVDEV_device_removed(const char *devpath); #if SDL_USE_LIBUDEV -static int SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath); -void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); +static int SDL_EVDEV_device_added(const char *devpath); +void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); #endif /* SDL_USE_LIBUDEV */ static SDL_Scancode EVDEV_Keycodes[] = { @@ -403,7 +403,6 @@ SDL_EVDEV_Init(void) /* We need a physical terminal (not PTS) to be able to translate key code to symbols via the kernel tables */ _this->console_fd = SDL_EVDEV_get_console_fd(); - } _this->ref_count += 1; @@ -445,43 +444,28 @@ SDL_EVDEV_Quit(void) } #if SDL_USE_LIBUDEV -void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath) +void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - SDL_EVDEV_deviceclass devclass; - if (devpath == NULL) { return; } - switch( udev_class ) - { - case SDL_UDEV_DEVICE_MOUSE: - devclass = SDL_EVDEV_DEVICE_MOUSE; - break; - - case SDL_UDEV_DEVICE_KEYBOARD: - devclass = SDL_EVDEV_DEVICE_KEYBOARD; - break; - - default: - return; + if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE|SDL_UDEV_DEVICE_KEYBOARD))) { + return; } - - switch( udev_type ) - { - case SDL_UDEV_DEVICEADDED: - SDL_EVDEV_device_added(devclass, devpath); - break; + + switch( udev_type ) { + case SDL_UDEV_DEVICEADDED: + SDL_EVDEV_device_added(devpath); + break; - case SDL_UDEV_DEVICEREMOVED: - SDL_EVDEV_device_removed(devpath); - break; - - default: - break; + case SDL_UDEV_DEVICEREMOVED: + SDL_EVDEV_device_removed(devpath); + break; + default: + break; } - } #endif /* SDL_USE_LIBUDEV */ @@ -507,137 +491,114 @@ SDL_EVDEV_Poll(void) SDL_UDEV_Poll(); #endif + mouse = SDL_GetMouse(); + for (item = _this->first; item != NULL; item = item->next) { while ((len = read(item->fd, events, (sizeof events))) > 0) { len /= sizeof(events[0]); for (i = 0; i < len; ++i) { - switch(item->devclass) { - case SDL_EVDEV_DEVICE_KEYBOARD: - switch (events[i].type) { - case EV_KEY: - scan_code = SDL_EVDEV_translate_keycode(events[i].code); - if (scan_code != SDL_SCANCODE_UNKNOWN) { - if (events[i].value == 0) { - SDL_SendKeyboardKey(SDL_RELEASED, scan_code); - } - else if (events[i].value == 1 || events[i].value == 2 /* Key repeated */ ) { - SDL_SendKeyboardKey(SDL_PRESSED, scan_code); -#ifdef SDL_INPUT_LINUXKD - if (_this->console_fd >= 0) { - kbe.kb_index = events[i].code; - /* Convert the key to an UTF-8 char */ - /* Ref: http://www.linuxjournal.com/article/2783 */ - modstate = SDL_GetModState(); - kbe.kb_table = 0; - - /* Ref: http://graphics.stanford.edu/~seander/bithacks.html#ConditionalSetOrClearBitsWithoutBranching */ - kbe.kb_table |= -( (modstate & KMOD_LCTRL) != 0) & (1 << KG_CTRLL | 1 << KG_CTRL); - kbe.kb_table |= -( (modstate & KMOD_RCTRL) != 0) & (1 << KG_CTRLR | 1 << KG_CTRL); - kbe.kb_table |= -( (modstate & KMOD_LSHIFT) != 0) & (1 << KG_SHIFTL | 1 << KG_SHIFT); - kbe.kb_table |= -( (modstate & KMOD_RSHIFT) != 0) & (1 << KG_SHIFTR | 1 << KG_SHIFT); - kbe.kb_table |= -( (modstate & KMOD_LALT) != 0) & (1 << KG_ALT); - kbe.kb_table |= -( (modstate & KMOD_RALT) != 0) & (1 << KG_ALTGR); + switch (events[i].type) { + case EV_KEY: + if (events[i].code >= BTN_MOUSE && events[i].code < BTN_MOUSE + SDL_arraysize(EVDEV_MouseButtons)) { + mouse_button = events[i].code - BTN_MOUSE; + if (events[i].value == 0) { + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, EVDEV_MouseButtons[mouse_button]); + } else if (events[i].value == 1) { + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, EVDEV_MouseButtons[mouse_button]); + } + break; + } - if(ioctl(_this->console_fd, KDGKBENT, (unsigned long)&kbe) == 0 && - ( (KTYP(kbe.kb_value) == KT_LATIN) || (KTYP(kbe.kb_value) == KT_ASCII) || (KTYP(kbe.kb_value) == KT_LETTER) )) - { - kval = KVAL(kbe.kb_value); - - /* While there's a KG_CAPSSHIFT symbol, it's not useful to build the table index with it - * because 1 << KG_CAPSSHIFT overflows the 8 bits of kb_table - * So, we do the CAPS LOCK logic here. Note that isalpha depends on the locale! - */ - if ( modstate & KMOD_CAPS && isalpha(kval) ) { - if ( isupper(kval) ) { - kval = tolower(kval); - } - else { - kval = toupper(kval); - } - } - - /* Convert to UTF-8 and send */ - end = SDL_UCS4ToUTF8( kval, keysym); - *end = '\0'; - SDL_SendKeyboardText(keysym); + /* Probably keyboard */ + scan_code = SDL_EVDEV_translate_keycode(events[i].code); + if (scan_code != SDL_SCANCODE_UNKNOWN) { + if (events[i].value == 0) { + SDL_SendKeyboardKey(SDL_RELEASED, scan_code); + } else if (events[i].value == 1 || events[i].value == 2 /* Key repeated */ ) { + SDL_SendKeyboardKey(SDL_PRESSED, scan_code); +#ifdef SDL_INPUT_LINUXKD + if (_this->console_fd >= 0) { + kbe.kb_index = events[i].code; + /* Convert the key to an UTF-8 char */ + /* Ref: http://www.linuxjournal.com/article/2783 */ + modstate = SDL_GetModState(); + kbe.kb_table = 0; + + /* Ref: http://graphics.stanford.edu/~seander/bithacks.html#ConditionalSetOrClearBitsWithoutBranching */ + kbe.kb_table |= -( (modstate & KMOD_LCTRL) != 0) & (1 << KG_CTRLL | 1 << KG_CTRL); + kbe.kb_table |= -( (modstate & KMOD_RCTRL) != 0) & (1 << KG_CTRLR | 1 << KG_CTRL); + kbe.kb_table |= -( (modstate & KMOD_LSHIFT) != 0) & (1 << KG_SHIFTL | 1 << KG_SHIFT); + kbe.kb_table |= -( (modstate & KMOD_RSHIFT) != 0) & (1 << KG_SHIFTR | 1 << KG_SHIFT); + kbe.kb_table |= -( (modstate & KMOD_LALT) != 0) & (1 << KG_ALT); + kbe.kb_table |= -( (modstate & KMOD_RALT) != 0) & (1 << KG_ALTGR); + + if (ioctl(_this->console_fd, KDGKBENT, (unsigned long)&kbe) == 0 && + ((KTYP(kbe.kb_value) == KT_LATIN) || (KTYP(kbe.kb_value) == KT_ASCII) || (KTYP(kbe.kb_value) == KT_LETTER))) + { + kval = KVAL(kbe.kb_value); + + /* While there's a KG_CAPSSHIFT symbol, it's not useful to build the table index with it + * because 1 << KG_CAPSSHIFT overflows the 8 bits of kb_table + * So, we do the CAPS LOCK logic here. Note that isalpha depends on the locale! + */ + if ( modstate & KMOD_CAPS && isalpha(kval) ) { + if ( isupper(kval) ) { + kval = tolower(kval); + } else { + kval = toupper(kval); } } -#endif + + /* Convert to UTF-8 and send */ + end = SDL_UCS4ToUTF8( kval, keysym); + *end = '\0'; + SDL_SendKeyboardText(keysym); } } - break; - - default: - break; +#endif /* SDL_INPUT_LINUXKD */ } - break; /* SDL_EVDEV_DEVICE_KEYBOARD */ - - case SDL_EVDEV_DEVICE_MOUSE: - mouse = SDL_GetMouse(); - switch (events[i].type) { - case EV_KEY: - mouse_button = events[i].code - BTN_MOUSE; - if (mouse_button >= 0 && mouse_button < SDL_arraysize(EVDEV_MouseButtons)) { - if (events[i].value == 0) { - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, EVDEV_MouseButtons[mouse_button]); - } - else if (events[i].value == 1) { - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, EVDEV_MouseButtons[mouse_button]); - } - } - break; - case EV_ABS: - switch(events[i].code) { - case ABS_X: - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, events[i].value, mouse->y); - break; - case ABS_Y: - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, mouse->x, events[i].value); - break; - default: - break; - } - break; - case EV_REL: - switch(events[i].code) { - case REL_X: - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, events[i].value, 0); - break; - case REL_Y: - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value); - break; - case REL_WHEEL: - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value); - break; - case REL_HWHEEL: - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0); - break; - default: - break; - } - break; - default: - break; - } - break; /* SDL_EVDEV_DEVICE_MOUSE */ - + } + break; + case EV_ABS: + switch(events[i].code) { + case ABS_X: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, events[i].value, mouse->y); + break; + case ABS_Y: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, mouse->x, events[i].value); + break; default: break; + } + break; + case EV_REL: + switch(events[i].code) { + case REL_X: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, events[i].value, 0); + break; + case REL_Y: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value); + break; + case REL_WHEEL: + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value); + break; + case REL_HWHEEL: + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0); + break; + default: + break; + } + break; + case EV_SYN: + switch (events[i].code) { + case SYN_DROPPED: + SDL_EVDEV_sync_device(item); + break; + default: + break; + } + break; } - - - /* Handle events not specific to any type of device */ - switch (events[i].type) { - case EV_SYN: - switch (events[i].code) { - case SYN_DROPPED : - SDL_EVDEV_sync_device(item); - break; - default: - break; - } - } - } } } @@ -665,7 +626,7 @@ SDL_EVDEV_sync_device(SDL_evdevlist_item *item) #if SDL_USE_LIBUDEV static int -SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath) +SDL_EVDEV_device_added(const char *devpath) { SDL_evdevlist_item *item; @@ -681,9 +642,6 @@ SDL_EVDEV_device_added(const SDL_UDEV_deviceclass devclass, const char *devpath) return SDL_OutOfMemory(); } - item->devclass = devclass; - - item->fd = open(devpath, O_RDONLY, 0); if (item->fd < 0) { SDL_free(item); diff --git a/src/input/evdev/SDL_evdev.h b/src/input/evdev/SDL_evdev.h index d63b87f7a..34f369d28 100644 --- a/src/input/evdev/SDL_evdev.h +++ b/src/input/evdev/SDL_evdev.h @@ -29,17 +29,10 @@ #include "SDL_events.h" #include -typedef enum -{ - SDL_EVDEV_DEVICE_MOUSE = 0x0001, - SDL_EVDEV_DEVICE_KEYBOARD -} SDL_EVDEV_deviceclass; - typedef struct SDL_evdevlist_item { char *path; int fd; - SDL_EVDEV_deviceclass devclass; struct SDL_evdevlist_item *next; } SDL_evdevlist_item; diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 686731397..93a374e5d 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -57,7 +57,7 @@ static int MaybeAddDevice(const char *path); #if SDL_USE_LIBUDEV static int MaybeRemoveDevice(const char *path); -void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath); +void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); #endif /* SDL_USE_LIBUDEV */ @@ -136,11 +136,11 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui } #if SDL_USE_LIBUDEV -void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, SDL_UDEV_deviceclass udev_class, const char *devpath) +void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { int instance; - if (devpath == NULL || udev_class != SDL_UDEV_DEVICE_JOYSTICK) { + if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { return; } From ff55c5a474fb6d969d83e2332fa5510792248b6b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 6 Oct 2013 13:49:23 -0700 Subject: [PATCH 155/258] Check for NULL joystick in SDL_JoystickGetGUID() --- src/joystick/SDL_joystick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 805eb5e2f..175aaef5a 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -763,6 +763,11 @@ SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index) /* return the guid for this opened device */ SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick) { + if (!SDL_PrivateJoystickValid(joystick)) { + SDL_JoystickGUID emptyGUID; + SDL_zero( emptyGUID ); + return emptyGUID; + } return SDL_SYS_JoystickGetGUID( joystick ); } From 677f0174823ac563baccdaf2f93ab72b6b900838 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 6 Oct 2013 13:50:36 -0700 Subject: [PATCH 156/258] Removed unused variables (thanks Joseph!) --- src/video/SDL_blit_A.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index ca08876e3..46d46136f 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -334,7 +334,6 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) Uint32 *dstp = (Uint32 *) info->dst; int dstskip = info->dst_skip >> 2; SDL_PixelFormat *sf = info->src_fmt; - Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; Uint32 amask = sf->Amask; Uint32 ashift = sf->Ashift; Uint64 multmask, multmask2; @@ -522,7 +521,6 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) Uint32 *dstp = (Uint32 *) info->dst; int dstskip = info->dst_skip >> 2; SDL_PixelFormat *sf = info->src_fmt; - Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; Uint32 amask = sf->Amask; Uint32 ashift = sf->Ashift; Uint64 multmask, multmask2; From 6c7a5899649b82a55919532809c85d4c5de86a75 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 6 Oct 2013 20:39:23 -0700 Subject: [PATCH 157/258] Only allocate a joystick instance ID once we know it's a joystick. This fixes compatibility with code that assumes 0 based joystick instance IDs. --- src/joystick/darwin/SDL_sysjoystick.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index 6a75e0819..55ec41ed8 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -589,7 +589,6 @@ HIDBuildDevice(io_object_t hidDevice) if (kIOReturnSuccess == result) { HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */ HIDGetCollectionElements(hidProperties, pDevice); - pDevice->instance_id = ++s_joystick_instance_id; } else { DisposePtr((Ptr) pDevice); pDevice = NULL; @@ -678,6 +677,9 @@ AddDeviceHelper( io_object_t ioHIDDeviceObject ) return 0; } + /* Allocate an instance ID for this device */ + device->instance_id = ++s_joystick_instance_id; + /* We have to do some storage of the io_service_t for * SDL_HapticOpenFromJoystick */ if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) { From f06b10a5df35b10b9a8825f293ae7a1516f49737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 7 Oct 2013 14:16:38 -0700 Subject: [PATCH 158/258] Fix SDL_SetWindowPosition on fullscreen windows. This reverts http://hg.libsdl.org/SDL/rev/7cdeb64faa72 and fixes it in the correct way. If you call SDL_SetWindowPosition on a fullscreen window, it would update the x & y variables for the window, but not actually move the window (since it was fullscreen). That would make the internal state of the SDL_Window incorrect, causing SDL_WarpMouseInWindow to offset incorrectly. This makes it so SDL_SetWindowPosition updates the `windowed' x & y coordinates, which take effect when you revert from fullscreen. --- src/video/SDL_video.c | 21 ++++++++++++++------- src/video/cocoa/SDL_cocoamouse.m | 8 +------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index cd40aeb48..4088afe81 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1551,14 +1551,21 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) } } - if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { - window->x = x; - } - if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { - window->y = y; - } + if ((window->flags & SDL_WINDOW_FULLSCREEN)) { + if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { + window->windowed.x = x; + } + if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { + window->windowed.y = y; + } + } else { + if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { + window->x = x; + } + if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { + window->y = y; + } - if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { if (_this->SetWindowPosition) { _this->SetWindowPosition(_this, window); } diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index faba9618e..e83442346 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -204,13 +204,7 @@ static void Cocoa_WarpMouse(SDL_Window * window, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); - CGPoint point = CGPointMake(x, y); - - if (!(window->flags & SDL_WINDOW_FULLSCREEN)) - { - point.x += window->x; - point.y += window->y; - } + CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y); { /* This makes Cocoa_HandleMouseEvent ignore this delta in the next From 3e171ab36eaffb7f5558403a0dea34baea0f676b Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 9 Oct 2013 10:29:01 -0300 Subject: [PATCH 159/258] Adds test framework to Android.mk and a simple utility to build Android projects --- Android.mk | 3 +- README-android.txt | 28 ++++++++- build-scripts/androidbuild.sh | 114 ++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 2 deletions(-) create mode 100755 build-scripts/androidbuild.sh diff --git a/Android.mk b/Android.mk index f3fcb3a19..3cb1e3155 100755 --- a/Android.mk +++ b/Android.mk @@ -42,7 +42,8 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/timer/*.c) \ $(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \ $(wildcard $(LOCAL_PATH)/src/video/*.c) \ - $(wildcard $(LOCAL_PATH)/src/video/android/*.c)) + $(wildcard $(LOCAL_PATH)/src/video/android/*.c) \ + $(wildcard $(LOCAL_PATH)/src/test/*.c)) LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid diff --git a/README-android.txt b/README-android.txt index ecd31ae1b..adf3f6465 100644 --- a/README-android.txt +++ b/README-android.txt @@ -38,7 +38,33 @@ src/main/android/SDL_android_main.c Building an app ================================================================================ -Instructions: +For simple projects you can use the script located at build-scripts/androidbuild.sh + +There's two ways of using it: + +androidbuild.sh com.yourcompany.yourapp < sources.list +androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c + +sources.list should be a text file with a source file name in each line +Filenames should be specified relative to the current directory, for example if +you are in the build-scripts directory and want to create the testgles.c test, you'll +run: + +./androidbuild.sh org.libsdl.testgles ../test/testgles.c + +One limitation of this script is that all sources provided will be aggregated into +a single directory, thus all your source files should have a unique name. + +Once the project is complete the script will tell you where the debug APK is located. +If you want to create a signed release APK, you can use the project created by this +utility to generate it. + +Finally, a word of caution: re running androidbuild.sh wipes any changes you may have +done in the build directory for the app! + + +For more complex projects, follow these instructions: + 1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project. 2. Move or symlink this SDL directory into the /jni directory diff --git a/build-scripts/androidbuild.sh b/build-scripts/androidbuild.sh new file mode 100755 index 000000000..b4a83234c --- /dev/null +++ b/build-scripts/androidbuild.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +SOURCES=() +MKSOURCES="" +CURDIR=`pwd -P` + +# Fetch sources +if [[ $# -ge 2 ]]; then + for src in ${@:2} + do + SOURCES+=($src) + MKSOURCES="$MKSOURCES $(basename $src)" + done +else + if [ -n "$1" ]; then + while read src + do + SOURCES+=($src) + MKSOURCES="$MKSOURCES $(basename $src)" + done + fi +fi + +if [ -z "$1" ] || [ -z "$SOURCES" ]; then + echo "Usage: androidbuild.sh com.yourcompany.yourapp < sources.list" + echo "Usage: androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c" + exit 1 +fi + + + +SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )" + +NDKBUILD=`which ndk-build` +if [ -z "$NDKBUILD" ];then + echo "Could not find the ndk-build utility, install Android's NDK and add it to the path" + exit 1 +fi + +ANDROID=`which android` +if [ -z "$ANDROID" ];then + echo "Could not find the android utility, install Android's SDK and add it to the path" + exit 1 +fi + +ANT=`which ant` + +if [ -z "$ANT" ];then + echo "Could not find the ant utility, install Android's SDK and add it to the path" + exit 1 +fi + +APP="$1" +APPARR=(${APP//./ }) +BUILDPATH="$SDLPATH/build/$APP" + +# Start Building + +rm -rf $BUILDPATH +mkdir -p $BUILDPATH + +cp -r $SDLPATH/android-project/* $BUILDPATH + +# Copy SDL sources +mkdir -p $BUILDPATH/jni/SDL +cp -r $SDLPATH/src $BUILDPATH/jni/SDL +cp -r $SDLPATH/include $BUILDPATH/jni/SDL +cp $SDLPATH/Android.mk $BUILDPATH/jni/SDL +sed -i "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/jni/src/Android.mk +sed -i "s|org\.libsdl\.app|$APP|g" $BUILDPATH/AndroidManifest.xml + +# Copy user sources +for src in "${SOURCES[@]}" +do + cp $src $BUILDPATH/jni/src +done + +# Create an inherited Activity +cd $BUILDPATH/src +for folder in "${APPARR[@]}" +do + mkdir -p $folder + cd $folder +done + +ACTIVITY="${folder}Activity" +sed -i "s|SDLActivity|$ACTIVITY|g" $BUILDPATH/AndroidManifest.xml +sed -i "s|SDLActivity|$APP|g" $BUILDPATH/build.xml + +# Fill in a default Activity +echo "package $APP;" > "$ACTIVITY.java" +echo "import org.libsdl.app.SDLActivity;" >> "$ACTIVITY.java" +echo "public class $ACTIVITY extends SDLActivity {}" >> "$ACTIVITY.java" + +# Update project and build +cd $BUILDPATH +android update project --path $BUILDPATH +$NDKBUILD +$ANT debug + +cd $CURDIR + +APK="$BUILDPATH/bin/$APP-debug.apk" + +if [ -f "$APK" ]; then + echo "Your APK is ready at $APK" + echo "To install to your device: " + echo "cd $BUILDPATH" + echo "ant debug install" + exit 0 +fi + +echo "There was an error building the APK" +exit 1 \ No newline at end of file From dca7c7b00d13f9aff48d31ae4059df9a568ccf64 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Wed, 9 Oct 2013 11:30:01 -0300 Subject: [PATCH 160/258] Fixes testgles and testgl --- test/Makefile.in | 2 +- test/configure | 14 ++++++++------ test/configure.in | 14 ++++++++------ test/testgles.c | 4 ++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/test/Makefile.in b/test/Makefile.in index ed0fce36a..12c3f0dab 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -124,7 +124,7 @@ testgl2$(EXE): $(srcdir)/testgl2.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@ testgles$(EXE): $(srcdir)/testgles.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@ + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLESLIB@ @MATHLIB@ testhaptic$(EXE): $(srcdir)/testhaptic.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/test/configure b/test/configure index d69cb4359..1e33409ab 100755 --- a/test/configure +++ b/test/configure @@ -587,6 +587,7 @@ LIBOBJS SDL_TTF_LIB XLIB GLLIB +GLESLIB CPP XMKMF SDL_CONFIG @@ -3785,7 +3786,7 @@ $as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi if test x$have_x = xyes; then - if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then : else CFLAGS="$CFLAGS -I$ac_x_includes" @@ -3793,10 +3794,11 @@ if test x$have_x = xyes; then if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then : else - XPATH="-L$ac_x_libraries" if test "x$ac_x_libraries" = x; then + XPATH="" XLIB="-lX11" else + XPATH="-L$ac_x_libraries" XLIB="-L$ac_x_libraries -lX11" fi fi @@ -3859,14 +3861,14 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext $as_echo "$have_opengles" >&6; } GLLIB="" +GLESLIB="" if test x$have_opengles = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGLES" - GLLIB="$XPATH -lGLESv1_CM" -elif test x$have_opengl = xyes; then + GLESLIB="$XPATH -lGLESv1_CM" +fi +if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" GLLIB="$XPATH $SYS_GL_LIBS" -else - GLLIB="" fi diff --git a/test/configure.in b/test/configure.in index 7fb496ad6..a18609715 100644 --- a/test/configure.in +++ b/test/configure.in @@ -91,7 +91,7 @@ LIBS="$LIBS $SDL_LIBS -lSDL2_test" dnl Check for X11 path, needed for OpenGL on some systems AC_PATH_X if test x$have_x = xyes; then - if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then : else CFLAGS="$CFLAGS -I$ac_x_includes" @@ -99,10 +99,11 @@ if test x$have_x = xyes; then if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then : else - XPATH="-L$ac_x_libraries" if test "x$ac_x_libraries" = x; then + XPATH="" XLIB="-lX11" else + XPATH="-L$ac_x_libraries" XLIB="-L$ac_x_libraries -lX11" fi fi @@ -135,17 +136,18 @@ have_opengles=yes AC_MSG_RESULT($have_opengles) GLLIB="" +GLESLIB="" if test x$have_opengles = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGLES" - GLLIB="$XPATH -lGLESv1_CM" -elif test x$have_opengl = xyes; then + GLESLIB="$XPATH -lGLESv1_CM" +fi +if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" GLLIB="$XPATH $SYS_GL_LIBS" -else - GLLIB="" fi AC_SUBST(GLLIB) +AC_SUBST(GLESLIB) AC_SUBST(XLIB) dnl Check for SDL_ttf diff --git a/test/testgles.c b/test/testgles.c index daaa28c7c..69322a234 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -159,6 +159,8 @@ main(int argc, char *argv[]) state->gl_green_size = 5; state->gl_blue_size = 5; state->gl_depth_size = depth; + state->gl_major_version = 1; + state->gl_minor_version = 1; if (fsaa) { state->gl_multisamplebuffers=1; state->gl_multisamplesamples=fsaa; @@ -177,6 +179,8 @@ main(int argc, char *argv[]) } /* Create OpenGL ES contexts */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); if (!context[i]) { From f67950da0c44d4d3a8df22221ecadc428ef8e972 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 10 Oct 2013 00:30:03 -0300 Subject: [PATCH 161/258] Fixes Bug 2134 - [Android] Black screen after resume (sometimes) --- src/video/android/SDL_androidevents.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 03573973e..9be49cf4f 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -72,6 +72,8 @@ Android_PumpEvents(_THIS) #if SDL_ANDROID_BLOCK_ON_PAUSE if (isPaused && !isPausing) { + /* Make sure this is the last thing we do before pausing */ + android_egl_context_backup(); if(SDL_SemWait(Android_ResumeSem) == 0) { #else if (isPaused) { @@ -92,7 +94,6 @@ Android_PumpEvents(_THIS) isPausing = 1; } else { - android_egl_context_backup(); isPausing = 0; isPaused = 1; } From c51c4c07330a8da1e4a8fea1c27798b04c7279f7 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 10 Oct 2013 00:49:57 -0300 Subject: [PATCH 162/258] Adds gl_profile_mask to test framework, uses it in testgles --- include/SDL_test_common.h | 1 + src/test/SDL_test_common.c | 3 +++ test/testgles.c | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/SDL_test_common.h b/include/SDL_test_common.h index f07acf7c1..57f31146e 100644 --- a/include/SDL_test_common.h +++ b/include/SDL_test_common.h @@ -108,6 +108,7 @@ typedef struct int gl_major_version; int gl_minor_version; int gl_debug; + int gl_profile_mask; } SDLTest_CommonState; #include "begin_code.h" diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 4e9429e63..981e3cdcb 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -695,6 +695,9 @@ SDLTest_CommonInit(SDLTest_CommonState * state) if (state->gl_debug) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); } + if (state->gl_profile_mask) { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, state->gl_profile_mask); + } if (state->verbose & VERBOSE_MODES) { SDL_Rect bounds; diff --git a/test/testgles.c b/test/testgles.c index 69322a234..4e1bc074c 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -161,6 +161,7 @@ main(int argc, char *argv[]) state->gl_depth_size = depth; state->gl_major_version = 1; state->gl_minor_version = 1; + state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; if (fsaa) { state->gl_multisamplebuffers=1; state->gl_multisamplesamples=fsaa; @@ -179,8 +180,6 @@ main(int argc, char *argv[]) } /* Create OpenGL ES contexts */ - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); if (!context[i]) { From e1f08f566158789a1ca036fbe8f3213ca8d7ca52 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 10 Oct 2013 01:46:39 -0400 Subject: [PATCH 163/258] Added script that the buildbot will use for cross-compiling to Raspberry Pi. --- build-scripts/raspberrypi-buildbot.sh | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 build-scripts/raspberrypi-buildbot.sh diff --git a/build-scripts/raspberrypi-buildbot.sh b/build-scripts/raspberrypi-buildbot.sh new file mode 100755 index 000000000..c87e1368c --- /dev/null +++ b/build-scripts/raspberrypi-buildbot.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from +# x86 Linux to Raspberry Pi. + +# The final tarball can be unpacked in the root directory of a RPi, +# so the SDL2 install lands in /usr/local. Run ldconfig, and then +# you should be able to build and run SDL2-based software on your +# Pi. Standard configure scripts should be able to find SDL and +# build against it, and sdl2-config should work correctly on the +# actual device. + +TARBALL=sdl2-raspberrypi-`hg tip --template '{rev}'`.tar.bz2 + +OSTYPE=`uname -s` +if [ "$OSTYPE" != "Linux" ]; then + # !!! FIXME + echo "This only works on x86 or x64-64 Linux at the moment." 1>&2 + exit 1 +fi + +if [ "x$MAKE" == "x" ]; then + NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` + let NCPU=$NCPU+1 + MAKE="make -j$NCPU" +fi + +BUILDBOTDIR="raspberrypi-buildbot" +PARENTDIR="$PWD" + +set -e +set -x +rm -f $TARBALL +rm -rf $BUILDBOTDIR +mkdir -p $BUILDBOTDIR +pushd $BUILDBOTDIR + +export CC=/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc +# !!! FIXME: shouldn't have to --disable-* things here. +../configure --host=arm-raspberry-linux-gnueabihf --disable-pulseaudio --disable-esd --prefix="$PWD/rpi-sdl2-installed" +$MAKE +$MAKE install +# Fix up a few things to a real install path on a real Raspberry Pi... +perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config +mkdir -p ./usr +mv ./rpi-sdl2-installed ./usr/local + +tar -cjvvf $PARENTDIR/$TARBALL usr +popd +rm -rf $BUILDBOTDIR + +set +x +echo "All done. Final installable is in $TARBALL ..."; + + From c0ea35c35482b5045e0c006f5e78dfc85572aeef Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 10 Oct 2013 02:06:14 -0400 Subject: [PATCH 164/258] Fixed tarball name in Raspberry Pi build script. --- build-scripts/raspberrypi-buildbot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-scripts/raspberrypi-buildbot.sh b/build-scripts/raspberrypi-buildbot.sh index c87e1368c..bfb34e05a 100755 --- a/build-scripts/raspberrypi-buildbot.sh +++ b/build-scripts/raspberrypi-buildbot.sh @@ -10,7 +10,7 @@ # build against it, and sdl2-config should work correctly on the # actual device. -TARBALL=sdl2-raspberrypi-`hg tip --template '{rev}'`.tar.bz2 +TARBALL=sdl-raspberrypi-`hg tip --template '{rev}'`.tar.bz2 OSTYPE=`uname -s` if [ "$OSTYPE" != "Linux" ]; then From 3a6e0fe33f3cb5204251666af73b7bb130f6e14c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 10 Oct 2013 02:21:41 -0400 Subject: [PATCH 165/258] Patched to compile in C90 mode. --- src/video/raspberry/SDL_rpivideo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index ae9dc7dc4..dfad9ba76 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -144,6 +144,7 @@ RPI_VideoInit(_THIS) { SDL_VideoDisplay display; SDL_DisplayMode current_mode; + SDL_DisplayData *data; uint32_t w,h; /* Initialize BCM Host */ @@ -168,8 +169,6 @@ RPI_VideoInit(_THIS) display.desktop_mode = current_mode; display.current_mode = current_mode; - SDL_DisplayData *data; - /* Allocate display internal data */ data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); if (data == NULL) { From 0631b5a7a88571ca6c2fb8c06e380259f2594dca Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 10 Oct 2013 02:37:36 -0400 Subject: [PATCH 166/258] Raspberry Pi build script: let caller specify final tarball name. --- build-scripts/raspberrypi-buildbot.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-scripts/raspberrypi-buildbot.sh b/build-scripts/raspberrypi-buildbot.sh index bfb34e05a..0257091a5 100755 --- a/build-scripts/raspberrypi-buildbot.sh +++ b/build-scripts/raspberrypi-buildbot.sh @@ -10,7 +10,10 @@ # build against it, and sdl2-config should work correctly on the # actual device. -TARBALL=sdl-raspberrypi-`hg tip --template '{rev}'`.tar.bz2 +TARBALL="$1" +if [ -z $1 ]; then + TARBALL=sdl-raspberrypi.tar.bz2 +fi OSTYPE=`uname -s` if [ "$OSTYPE" != "Linux" ]; then @@ -45,8 +48,8 @@ perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/li mkdir -p ./usr mv ./rpi-sdl2-installed ./usr/local -tar -cjvvf $PARENTDIR/$TARBALL usr popd +tar -cjvvf $TARBALL -C $BUILDBOTDIR usr rm -rf $BUILDBOTDIR set +x From daf4ca1ac2b6270c8ea740e0af468754b00b3c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 7 Oct 2013 16:01:40 -0700 Subject: [PATCH 167/258] Mac: Better handling when someone else is the app delegate. --HG-- extra : rebase_source : a2d99f3c2d93c0a6adeaf04fccec23799cc52de9 --- README-macosx.txt | 36 +++++++++++++++++++++++++++++++ src/video/cocoa/SDL_cocoaevents.m | 30 +++++++++++++++++++++----- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/README-macosx.txt b/README-macosx.txt index c5cc89b5b..021b14021 100644 --- a/README-macosx.txt +++ b/README-macosx.txt @@ -29,6 +29,42 @@ gcc to make this easy is provided in test/gcc-fat.sh To use the library once it's built, you essential have two possibilities: use the traditional autoconf/automake/make method, or use Xcode. +============================================================================== +Caveats for using SDL with Mac OS X +============================================================================== + +Some things you have to be aware of when using SDL on Mac OS X: + +- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]), + SDL will not register its own. This means that SDL will not terminate using + SDL_Quit if it receives a termination request, it will terminate like a + normal app, and it will not send a SDL_DROPFILE when you request to open a + file with the app. To solve these issues, put the following code in your + NSApplicationDelegate implementation: + + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender + { + if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); + } + + return NSTerminateCancel; + } + + - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename + { + if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DROPFILE; + event.drop.file = SDL_strdup([filename UTF8String]); + return (SDL_PushEvent(&event) > 0); + } + + return NO; + } + ============================================================================== Using the Simple DirectMedia Layer with a traditional Makefile ============================================================================== diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 6a673c3d3..1dc0ca625 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -42,12 +42,11 @@ @end @interface SDLAppDelegate : NSObject { +@public BOOL seenFirstActivate; } - (id)init; -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -- (void)applicationDidBecomeActive:(NSNotification *)aNotification; @end @implementation SDLAppDelegate : NSObject @@ -57,18 +56,28 @@ if (self) { seenFirstActivate = NO; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(focusSomeWindow:) + name:NSApplicationDidBecomeActiveNotification + object:nil]; } return self; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { SDL_SendQuit(); return NSTerminateCancel; } -- (void)applicationDidBecomeActive:(NSNotification *)aNotification +- (void)focusSomeWindow:(NSNotification *)aNotification { /* HACK: Ignore the first call. The application gets a * applicationDidBecomeActive: a little bit after the first window is @@ -111,6 +120,8 @@ } @end +static SDLAppDelegate *appDelegate = nil; + static NSString * GetApplicationName(void) { @@ -235,8 +246,17 @@ Cocoa_RegisterApp(void) [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; } - if (NSApp && ![NSApp delegate]) { - [NSApp setDelegate:[[SDLAppDelegate alloc] init]]; + if (NSApp && !appDelegate) { + appDelegate = [[SDLAppDelegate alloc] init]; + + /* If someone else has an app delegate, it means we can't turn a + * termination into SDL_Quit, and we can't handle application:openFile: + */ + if (![NSApp delegate]) { + [NSApp setDelegate:appDelegate]; + } else { + appDelegate->seenFirstActivate = YES; + } } [pool release]; } From e63559cffd85bd8fa13d192fa323cd16fa5bb1bd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 10 Oct 2013 20:58:20 -0700 Subject: [PATCH 168/258] Report joystick added/removed events even if we don't have udev. T. Joseph Carter As discussed (possibly to death), the Linux joystick driver does not actually report events for added or removed joysticks when you haven't got udev support. We simply cannot know about removed joysticks without udev. But we can (and we should) report adding them. This brings the legacy case in line with pretty much the rest of SDL's joystick drivers. --- src/joystick/linux/SDL_sysjoystick.c | 69 ++++++++++++++-------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 93a374e5d..23a5a4c98 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -138,8 +138,6 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui #if SDL_USE_LIBUDEV void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - int instance; - if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { return; } @@ -147,41 +145,11 @@ void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, cons switch( udev_type ) { case SDL_UDEV_DEVICEADDED: - instance = MaybeAddDevice(devpath); - if (instance != -1) { - /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceAdded() function? */ - #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEADDED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = instance; - if ( (SDL_EventOK == NULL) || - (*SDL_EventOK) (SDL_EventOKParam, &event) ) { - SDL_PushEvent(&event); - } - } - #endif /* !SDL_EVENTS_DISABLED */ - } + MaybeAddDevice(devpath); break; case SDL_UDEV_DEVICEREMOVED: - instance = MaybeRemoveDevice(devpath); - if (instance != -1) { - /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceRemoved() function? */ - #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = instance; - if ( (SDL_EventOK == NULL) || - (*SDL_EventOK) (SDL_EventOKParam, &event) ) { - SDL_PushEvent(&event); - } - } - #endif /* !SDL_EVENTS_DISABLED */ - } + MaybeRemoveDevice(devpath); break; default: @@ -202,6 +170,9 @@ MaybeAddDevice(const char *path) char namebuf[128]; SDL_JoystickGUID guid; SDL_joylist_item *item; +#if !SDL_EVENTS_DISABLED + SDL_Event event; +#endif if (path == NULL) { return -1; @@ -259,6 +230,19 @@ MaybeAddDevice(const char *path) SDL_joylist_tail = item; } + /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceAdded() function? */ +#if !SDL_EVENTS_DISABLED + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = numjoysticks; + if ( (SDL_EventOK == NULL) || + (*SDL_EventOK) (SDL_EventOKParam, &event) ) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + return numjoysticks++; } @@ -269,6 +253,9 @@ MaybeRemoveDevice(const char *path) { SDL_joylist_item *item; SDL_joylist_item *prev = NULL; +#if !SDL_EVENTS_DISABLED + SDL_Event event; +#endif if (path == NULL) { return -1; @@ -290,6 +277,20 @@ MaybeRemoveDevice(const char *path) if (item == SDL_joylist_tail) { SDL_joylist_tail = prev; } + + /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceRemoved() function? */ +#if !SDL_EVENTS_DISABLED + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = item->device_instance; + if ( (SDL_EventOK == NULL) || + (*SDL_EventOK) (SDL_EventOKParam, &event) ) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + SDL_free(item->path); SDL_free(item->name); SDL_free(item); From 1c7ed8eef6215d9a129424b71916f83ae5d98f6e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 10 Oct 2013 21:50:25 -0700 Subject: [PATCH 169/258] Updated SDL to version 2.0.1 --- CMakeLists.txt | 4 ++-- Xcode/SDL/Info-Framework.plist | 8 ++++---- configure | 4 ++-- configure.in | 4 ++-- include/SDL_version.h | 2 +- src/main/windows/version.rc | 10 +++++----- test/configure | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eca0c6b1..578742efe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake) # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0. set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 0) -set(SDL_MICRO_VERSION 0) +set(SDL_MICRO_VERSION 1) set(SDL_INTERFACE_AGE 0) -set(SDL_BINARY_AGE 0) +set(SDL_BINARY_AGE 1) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Calculate a libtool-like version number diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index 0ab4b25e3..696ef99d9 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion English + CFBundleExecutable + ${EXECUTABLE_NAME} CFBundleGetInfoString http://www.libsdl.org CFBundleIconFile @@ -17,12 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleSignature SDLX CFBundleVersion - 2.0.0 - CFBundleExecutable - ${EXECUTABLE_NAME} + 2.0.1 diff --git a/configure b/configure index 68b62c537..dae19ac1c 100755 --- a/configure +++ b/configure @@ -2660,9 +2660,9 @@ orig_CFLAGS="$CFLAGS" # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=0 +SDL_MICRO_VERSION=1 SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=0 +SDL_BINARY_AGE=1 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION diff --git a/configure.in b/configure.in index f6810cbba..890503cda 100644 --- a/configure.in +++ b/configure.in @@ -20,9 +20,9 @@ dnl Set various version strings - taken gratefully from the GTk sources # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=0 +SDL_MICRO_VERSION=1 SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=0 +SDL_BINARY_AGE=1 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION AC_SUBST(SDL_MAJOR_VERSION) diff --git a/include/SDL_version.h b/include/SDL_version.h index a9ced804d..dc52c85c0 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 0 +#define SDL_PATCHLEVEL 1 /** * \brief Macro to determine SDL version program was compiled against. diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index 129a1f5dd..b096a9149 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,0,0 - PRODUCTVERSION 2,0,0,0 + FILEVERSION 2,0,1,0 + PRODUCTVERSION 2,0,1,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 0, 0, 0\0" + VALUE "FileVersion", "2, 0, 1, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright 2013 Sam Lantinga\0" - VALUE "OriginalFilename", "SDL.dll\0" + VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 0, 0, 0\0" + VALUE "ProductVersion", "2, 0, 1, 0\0" END END BLOCK "VarFileInfo" diff --git a/test/configure b/test/configure index 1e33409ab..57da5548a 100755 --- a/test/configure +++ b/test/configure @@ -3452,7 +3452,7 @@ rm -f core conftest.err conftest.$ac_objext \ rm -f conf.sdltest CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS $SDL_LIBS -lSDL2_test" +LIBS="$LIBS $SDL_LIBS -lSDL2_test" ac_ext=c ac_cpp='$CPP $CPPFLAGS' From e7dba74084d810ff766f20e0f885c8b3099787c7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 10 Oct 2013 21:51:39 -0700 Subject: [PATCH 170/258] Fixed bug 2146 - Enable static linking of libSDL on Android Denis Bernard This patch to Android.mk adds support for static linking of libSDL for Android applications. A patched readme with static build instructions is also provided. It does not break existing build environments setup according to the README-android.txt since the static library version will not be built in not required. The static build uses the Android NDK module system (see docs/IMPORT-MODULE.html in the NDK folder and step 5 in the instructions below). Instructions: 1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project. 2. Create a symlink to SDL/src/main/android/SDL_android_main.c as /jni/src/SDL_android_main.c 3. Rename /jni/src/Android_static.mk to /jni/src/Android.mk (overwrite the existing one) 4. Edit /jni/src/Android.mk to include your source files 5. create and export an environment variable named NDK_MODULE_PATH that points to the parent directory of this SDL directory. e.g.: export NDK_MODULE_PATH="$PWD"/.. 6. Edit /src/org/libsdl/app/SDLActivity.java and remove the call to System.loadLibrary("SDL2") line 42. 7. Run 'ndk-build' (a script provided by the NDK). This compiles the C source Although this requires an environment variable to be setup, it can be added once and for all to the main Android.mk of the project. --- Android.mk | 17 +++++++++++++++++ README-android.txt | 22 ++++++++++++++++++++++ android-project/jni/src/Android_static.mk | 12 ++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 android-project/jni/src/Android_static.mk diff --git a/Android.mk b/Android.mk index 3cb1e3155..c8e67da7b 100755 --- a/Android.mk +++ b/Android.mk @@ -49,3 +49,20 @@ LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid include $(BUILD_SHARED_LIBRARY) + +########################### +# +# SDL static library +# +########################### + +LOCAL_MODULE := SDL2_static + +LOCAL_MODULE_FILENAME := libSDL2 + +LOCAL_SRC_FILES += $(LOCAL_PATH)/src/main/android/SDL_android_main.c + +LOCAL_LDLIBS := +LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid + +include $(BUILD_STATIC_LIBRARY) diff --git a/README-android.txt b/README-android.txt index adf3f6465..a161c8407 100644 --- a/README-android.txt +++ b/README-android.txt @@ -110,6 +110,28 @@ android-project/ on this implementation. +================================================================================ + Build an app with static linking of libSDL +================================================================================ + +This build uses the Android NDK module system. + +Instructions: +1. Copy the android-project directory wherever you want to keep your projects + and rename it to the name of your project. +2. Rename /jni/src/Android_static.mk to /jni/src/Android.mk + (overwrite the existing one) +3. Edit /jni/src/Android.mk to include your source files +4. create and export an environment variable named NDK_MODULE_PATH that points + to the parent directory of this SDL directory. e.g.: + + export NDK_MODULE_PATH="$PWD"/.. + +5. Edit /src/org/libsdl/app/SDLActivity.java and remove the call to + System.loadLibrary("SDL2") line 42. +6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source + + ================================================================================ Customizing your application name ================================================================================ diff --git a/android-project/jni/src/Android_static.mk b/android-project/jni/src/Android_static.mk new file mode 100644 index 000000000..faed669c0 --- /dev/null +++ b/android-project/jni/src/Android_static.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := main + +LOCAL_SRC_FILES := YourSourceHere.c + +LOCAL_STATIC_LIBRARIES := SDL2_static + +include $(BUILD_SHARED_LIBRARY) +$(call import-module,SDL)LOCAL_PATH := $(call my-dir) From 08c4ea17ef32354514923f7bb4ab35c42a667941 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 11 Oct 2013 10:58:05 -0400 Subject: [PATCH 171/258] Do a full sysroot for the Raspberry Pi buildbot. This gets us ALSA and X11, etc. --HG-- extra : rebase_source : ddc88cb2db83afe6bbecf793f37fec87ac2b7fa8 --- build-scripts/raspberrypi-buildbot.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-scripts/raspberrypi-buildbot.sh b/build-scripts/raspberrypi-buildbot.sh index 0257091a5..4c746c014 100755 --- a/build-scripts/raspberrypi-buildbot.sh +++ b/build-scripts/raspberrypi-buildbot.sh @@ -38,9 +38,11 @@ rm -rf $BUILDBOTDIR mkdir -p $BUILDBOTDIR pushd $BUILDBOTDIR -export CC=/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc +SYSROOT="/opt/rpi-sysroot" +export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux" +# -L$SYSROOT/usr/lib/arm-linux-gnueabihf" # !!! FIXME: shouldn't have to --disable-* things here. -../configure --host=arm-raspberry-linux-gnueabihf --disable-pulseaudio --disable-esd --prefix="$PWD/rpi-sdl2-installed" +../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd $MAKE $MAKE install # Fix up a few things to a real install path on a real Raspberry Pi... From 0a6199a91844205ef5d988e13fdae7d184f9218c Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sat, 12 Oct 2013 11:35:47 -0300 Subject: [PATCH 172/258] Updates the Raspberry Pi README --- README-raspberrypi.txt | 63 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/README-raspberrypi.txt b/README-raspberrypi.txt index b0f0b25b2..aa19511c2 100644 --- a/README-raspberrypi.txt +++ b/README-raspberrypi.txt @@ -27,6 +27,65 @@ OpenGL ES 2.x, it usually comes pre installed, but in any case: sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev +================================================================================ + Cross compiling from x86 Linux +================================================================================ + +To cross compile SDL for Raspbian from your desktop machine, you'll need a +Raspbian system root and the cross compilation tools. We'll assume these tools +will be placed in /opt/rpi-tools + + sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools + +You'll also need a Rasbian binary image. +Get it from: http://downloads.raspberrypi.org/raspbian_latest +After unzipping, you'll get file with a name like: -wheezy-raspbian.img +Let's assume the sysroot will be built in /opt/rpi-sysroot. + + export SYSROOT=/opt/rpi-sysroot + sudo kpartx -a -v .img + sudo mount -o loop /dev/mapper/loop0p2 /mnt + sudo cp -r /mnt $SYSROOT + sudo apt-get install qemu binfmt-support qemu-user-static + sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin + sudo mount --bind /dev $SYSROOT/dev + sudo mount --bind /proc $SYSROOT/proc + sudo mount --bind /sys $SYSROOT/sys + +Now, before chrooting into the ARM sysroot, you'll need to apply a workaround, +edit $SYSROOT/etc/ld.so.preload and comment out all lines in it. + + sudo chroot $SYSROOT + apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev + exit + sudo umount $SYSROOT/dev + sudo umount $SYSROOT/proc + sudo umount $SYSROOT/sys + sudo umount /mnt + +The final step is compiling SDL itself. + + export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux" + cd + mkdir -p build;cd build + ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd + +================================================================================ + Apps don't work or poor video/audio performance +================================================================================ + +If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to +update the RPi's firmware. Note that doing so will fix these problems, but it +will also render the CMA - Dynamic Memory Split functionality useless. + +Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too +low in general, specially if a 1080p TV is hooked up. + +See here how to configure this setting: http://elinux.org/RPiconfig + +Using a fixed gpu_mem=128 is the best option (specially if you updated the +firmware, using CMA probably won't work, at least it's the current case). + ================================================================================ No input ================================================================================ @@ -83,5 +142,5 @@ this determining the CAPS LOCK behavior: Notes ================================================================================ -* Building has only been tested natively (i.e. not cross compiled). Cross - compilation might work though, feedback is welcome! +* Input events from the keyboard leak through to the console + From 02263d41488252928e96177cab0a583ee66581c2 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Sat, 12 Oct 2013 11:21:40 -0400 Subject: [PATCH 173/258] added simple Drag & drop test --HG-- extra : rebase_source : e72b921485c5fc5ad1b7c7849802c020d49a06d3 --- test/Makefile.in | 6 +++- test/testdropfile.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 test/testdropfile.c diff --git a/test/Makefile.in b/test/Makefile.in index 12c3f0dab..f57c46029 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -4,7 +4,7 @@ srcdir = @srcdir@ CC = @CC@ EXE = @EXE@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ -g LIBS = @LIBS@ TARGETS = \ @@ -14,6 +14,7 @@ TARGETS = \ testautomation$(EXE) \ testdraw2$(EXE) \ testdrawchessboard$(EXE) \ + testdropfile$(EXE) \ testerror$(EXE) \ testfile$(EXE) \ testgamecontroller$(EXE) \ @@ -108,6 +109,9 @@ testdraw2$(EXE): $(srcdir)/testdraw2.c testdrawchessboard$(EXE): $(srcdir)/testdrawchessboard.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +testdropfile$(EXE): $(srcdir)/testdropfile.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + testerror$(EXE): $(srcdir)/testerror.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/test/testdropfile.c b/test/testdropfile.c new file mode 100644 index 000000000..9f4fa7b6a --- /dev/null +++ b/test/testdropfile.c @@ -0,0 +1,87 @@ +/* + Copyright (C) 1997-2013 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 + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely. +*/ + +#include +#include + +#include "SDL_test_common.h" + +static SDLTest_CommonState *state; + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + SDLTest_CommonQuit(state); + exit(rc); +} + +int +main(int argc, char *argv[]) +{ + int i, done; + SDL_Event event; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + /* Initialize test framework */ + state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); + if (!state) { + return 1; + } + + for (i = 1; i < argc;) { + int consumed; + + consumed = SDLTest_CommonArg(state, i); + if (consumed == 0) { + consumed = -1; + } + if (consumed < 0) { + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + quit(1); + } + i += consumed; + } + if (!SDLTest_CommonInit(state)) { + quit(2); + } + + for (i = 0; i < state->num_windows; ++i) { + SDL_Renderer *renderer = state->renderers[i]; + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + } + + /* Main render loop */ + done = 0; + while (!done) { + /* Check for events */ + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &done); + + if (event.type == SDL_DROPFILE) { + char *dropped_filedir = event.drop.file; + SDL_Log("File dropped on window: %s", dropped_filedir); + SDL_free(dropped_filedir); + } + } + } + + quit(0); + /* keep the compiler happy ... */ + return(0); +} + +/* vi: set ts=4 sw=4 expandtab: */ From 146a3bc32496297230a23454cf5669ebacb8c477 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sat, 12 Oct 2013 16:29:34 -0300 Subject: [PATCH 174/258] Fixes X11 video backend compilation when no GL is available For example, in our Raspberry Pi sysroot. --- README-raspberrypi.txt | 6 ++++++ src/video/x11/SDL_x11window.c | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README-raspberrypi.txt b/README-raspberrypi.txt index aa19511c2..744fd89df 100644 --- a/README-raspberrypi.txt +++ b/README-raspberrypi.txt @@ -69,7 +69,13 @@ The final step is compiling SDL itself. cd mkdir -p build;cd build ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd + make + make install +To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths: + + perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config + ================================================================================ Apps don't work or poor video/audio performance ================================================================================ diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 07e863bc8..18ff443ad 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -370,8 +370,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) XVisualInfo *vinfo = NULL; #if SDL_VIDEO_OPENGL_EGL - if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && - ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile )) { + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES +#if SDL_VIDEO_OPENGL_GLX + && ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) +#endif + ){ vinfo = X11_GLES_GetVisual(_this, display, screen); } else #endif @@ -555,8 +558,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 if ((window->flags & SDL_WINDOW_OPENGL) && - _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && - (!_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile) ) { + _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES +#if SDL_VIDEO_OPENGL_GLX + && ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) +#endif + ) { if (!_this->egl_data) { XDestroyWindow(display, w); return -1; From dd7e8526a2f820fba8012ddb14da7ef56251395b Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Sun, 13 Oct 2013 17:15:43 -0300 Subject: [PATCH 175/258] Prevent keystrokes from leaking through to the console when using evdev. This uses the same method Weston and X use. Sadly, to be fully effective when launching remotely, this needs root permissions. --- README-raspberrypi.txt | 5 +- src/input/evdev/SDL_evdev.c | 97 +++++++++++++++++++++++++++++++++++++ src/input/evdev/SDL_evdev.h | 2 + 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/README-raspberrypi.txt b/README-raspberrypi.txt index 744fd89df..0724a8c90 100644 --- a/README-raspberrypi.txt +++ b/README-raspberrypi.txt @@ -148,5 +148,8 @@ this determining the CAPS LOCK behavior: Notes ================================================================================ -* Input events from the keyboard leak through to the console +* When launching apps remotely (via SSH), SDL can prevent local keystrokes from + leaking into the console only if it has root privileges. Launching apps locally + does not suffer from this issue. + diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c index 497cd40d1..92dc4fed7 100644 --- a/src/input/evdev/SDL_evdev.c +++ b/src/input/evdev/SDL_evdev.c @@ -45,6 +45,18 @@ static _THIS = NULL; #include #endif + +/* We need this to prevent keystrokes from appear in the console */ +#ifndef KDSKBMUTE +#define KDSKBMUTE 0x4B51 +#endif +#ifndef KDSKBMODE +#define KDSKBMODE 0x4B45 +#endif +#ifndef K_OFF +#define K_OFF 0x04 +#endif + #include "SDL.h" #include "SDL_assert.h" #include "SDL_endian.h" @@ -370,6 +382,72 @@ static int SDL_EVDEV_get_console_fd(void) return -1; } +/* Prevent keystrokes from reaching the tty */ +static int SDL_EVDEV_mute_keyboard(int tty, int *kb_mode) +{ + char arg; + + *kb_mode = 0; /* FIXME: Is this a sane default in case KDGKBMODE fails? */ + if (!IS_CONSOLE(tty)) { + return SDL_SetError("Tried to mute an invalid tty"); + } + ioctl(tty, KDGKBMODE, kb_mode); /* It's not fatal if this fails */ + if (ioctl(tty, KDSKBMUTE, 1) && ioctl(tty, KDSKBMODE, K_OFF)) { + return SDL_SetError("EVDEV: Failed muting keyboard"); + } + + return 0; +} + +/* Restore the keyboard mode for given tty */ +static void SDL_EVDEV_unmute_keyboard(int tty, int kb_mode) +{ + if (ioctl(tty, KDSKBMUTE, 0) && ioctl(tty, KDSKBMODE, kb_mode)) { + SDL_Log("EVDEV: Failed restoring keyboard mode"); + } +} + +/* Read /sys/class/tty/tty0/active and open the tty */ +static int SDL_EVDEV_get_active_tty() +{ + int fd, len; + char ttyname[NAME_MAX + 1]; + char ttypath[PATH_MAX+1] = "/dev/"; + char arg; + + fd = open("/sys/class/tty/tty0/active", O_RDONLY); + if (fd < 0) { + return SDL_SetError("Could not determine which tty is active"); + } + + len = read(fd, ttyname, NAME_MAX); + close(fd); + + if (len <= 0) { + return SDL_SetError("Could not read which tty is active"); + } + + if (ttyname[len-1] == '\n') { + ttyname[len-1] = '\0'; + } + else { + ttyname[len] = '\0'; + } + + SDL_strlcat(ttypath, ttyname, PATH_MAX); + fd = open(ttypath, O_RDWR | O_NOCTTY); + if (fd < 0) { + return SDL_SetError("Could not open tty: %s", ttypath); + } + + if (!IS_CONSOLE(fd)) { + close(fd); + return SDL_SetError("Invalid tty obtained: %s", ttypath); + } + + return fd; +} + int SDL_EVDEV_Init(void) { @@ -403,6 +481,19 @@ SDL_EVDEV_Init(void) /* We need a physical terminal (not PTS) to be able to translate key code to symbols via the kernel tables */ _this->console_fd = SDL_EVDEV_get_console_fd(); + + /* Mute the keyboard so keystrokes only generate evdev events and do not leak through to the console */ + _this->tty = STDIN_FILENO; + if (SDL_EVDEV_mute_keyboard(_this->tty, &_this->kb_mode) < 0) { + /* stdin is not a tty, probably we were launched remotely, so we try to disable the active tty */ + _this->tty = SDL_EVDEV_get_active_tty(); + if (_this->tty >= 0) { + if (SDL_EVDEV_mute_keyboard(_this->tty, &_this->kb_mode) < 0) { + close(_this->tty); + _this->tty = -1; + } + } + } } _this->ref_count += 1; @@ -429,6 +520,12 @@ SDL_EVDEV_Quit(void) if (_this->console_fd >= 0) { close(_this->console_fd); } + + if (_this->tty >= 0) { + SDL_EVDEV_unmute_keyboard(_this->tty, _this->kb_mode); + close(_this->tty); + } + /* Remove existing devices */ while(_this->first != NULL) { SDL_EVDEV_device_removed(_this->first->path); diff --git a/src/input/evdev/SDL_evdev.h b/src/input/evdev/SDL_evdev.h index 34f369d28..b9311d4f3 100644 --- a/src/input/evdev/SDL_evdev.h +++ b/src/input/evdev/SDL_evdev.h @@ -43,6 +43,8 @@ typedef struct SDL_EVDEV_PrivateData int numdevices; int ref_count; int console_fd; + int kb_mode; + int tty; } SDL_EVDEV_PrivateData; extern int SDL_EVDEV_Init(void); From 394abb4298f35aa5c28334a3fddebe0ac640099b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 13 Oct 2013 19:48:45 -0700 Subject: [PATCH 176/258] Added an assert to catch init/quit call mismatch that might bite people. --- src/SDL.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SDL.c b/src/SDL.c index d8c05fb5b..b1111159a 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -65,6 +65,8 @@ static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) { int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); + /* If this assert triggers there is a mismatch between init and quit calls */ + SDL_assert(SDL_SubsystemRefCount[subsystem_index] > 0); if (SDL_SubsystemRefCount[subsystem_index] > 0) { --SDL_SubsystemRefCount[subsystem_index]; } From 2ba754fbe6cf80111b8159d04cb742bdc64065eb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 13 Oct 2013 19:49:45 -0700 Subject: [PATCH 177/258] Fixed bug 2149 - Don't search for libusbhid except on BSD Joseph Carter There's a whole set of configure tests for BSD's libusbhid, and they only matter on BSD. However, if you have the library on Linux, it gets pulled in as library bloat. And it's bloat of the highest order since not a single function call to the library is ever made unless you're on a *BSD. --- configure | 228 +++++++++++++++++++++--------------------- configure.in | 262 +++++++++++++++++++++++++------------------------ test/configure | 3 +- 3 files changed, 251 insertions(+), 242 deletions(-) diff --git a/configure b/configure index dae19ac1c..ba2489430 100755 --- a/configure +++ b/configure @@ -21634,8 +21634,10 @@ $as_echo "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h CheckUSBHID() { - if test x$enable_joystick = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5 + case "$host" in + *-*-*bsd*) + if test x$enable_joystick = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5 $as_echo_n "checking for hid_init in -lusbhid... " >&6; } if ${ac_cv_lib_usbhid_hid_init+:} false; then : $as_echo_n "(cached) " >&6 @@ -21675,34 +21677,34 @@ if test "x$ac_cv_lib_usbhid_hid_init" = xyes; then : have_libusbhid=yes fi - if test x$have_libusbhid = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default" + if test x$have_libusbhid = xyes; then + ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default" if test "x$ac_cv_header_usbhid_h" = xyes; then : USB_CFLAGS="-DHAVE_USBHID_H" fi - ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default" + ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default" if test "x$ac_cv_header_libusbhid_h" = xyes; then : USB_CFLAGS="-DHAVE_LIBUSBHID_H" fi - USB_LIBS="$USB_LIBS -lusbhid" - else - ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" + USB_LIBS="$USB_LIBS -lusbhid" + else + ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : USB_CFLAGS="-DHAVE_USB_H" fi - ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" + ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_h" = xyes; then : USB_CFLAGS="-DHAVE_LIBUSB_H" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5 $as_echo_n "checking for hid_init in -lusb... " >&6; } if ${ac_cv_lib_usb_hid_init+:} false; then : $as_echo_n "(cached) " >&6 @@ -21742,43 +21744,43 @@ if test "x$ac_cv_lib_usb_hid_init" = xyes; then : USB_LIBS="$USB_LIBS -lusb" fi - fi + fi - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $USB_CFLAGS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $USB_CFLAGS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5 $as_echo_n "checking for usbhid... " >&6; } - have_usbhid=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_usbhid=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif int main () { - struct report_desc *repdesc; - struct usb_ctl_report *repbuf; - hid_kind_t hidkind; + struct report_desc *repdesc; + struct usb_ctl_report *repbuf; + hid_kind_t hidkind; ; return 0; @@ -21786,45 +21788,45 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_usbhid=yes + have_usbhid=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 $as_echo "$have_usbhid" >&6; } - if test x$have_usbhid = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5 + if test x$have_usbhid = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5 $as_echo_n "checking for ucr_data member of usb_ctl_report... " >&6; } - have_usbhid_ucr_data=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_usbhid_ucr_data=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif int main () { - struct usb_ctl_report buf; - if (buf.ucr_data) { } + struct usb_ctl_report buf; + if (buf.ucr_data) { } ; return 0; @@ -21832,47 +21834,47 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_usbhid_ucr_data=yes + have_usbhid_ucr_data=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$have_usbhid_ucr_data = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5 + if test x$have_usbhid_ucr_data = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5 $as_echo "$have_usbhid_ucr_data" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5 $as_echo_n "checking for new usbhid API... " >&6; } - have_usbhid_new=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_usbhid_new=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - #include - #include - #else - #include - #include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + #include + #include + #else + #include + #include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif int main () { - report_desc_t d; - hid_start_parse(d, 1, 1); + report_desc_t d; + hid_start_parse(d, 1, 1); ; return 0; @@ -21880,29 +21882,29 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_usbhid_new=yes + have_usbhid_new=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$have_usbhid_new = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5 + if test x$have_usbhid_new = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5 $as_echo "$have_usbhid_new" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5 $as_echo_n "checking for struct joystick in machine/joystick.h... " >&6; } - have_machine_joystick=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_machine_joystick=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include + #include int main () { - struct joystick t; + struct joystick t; ; return 0; @@ -21910,28 +21912,30 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_machine_joystick=yes + have_machine_joystick=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$have_machine_joystick = xyes; then + if test x$have_machine_joystick = xyes; then $as_echo "#define SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1" >>confdefs.h - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 $as_echo "$have_machine_joystick" >&6; } $as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h - SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" - have_joystick=yes - fi - CFLAGS="$save_CFLAGS" - fi + SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" + have_joystick=yes + fi + CFLAGS="$save_CFLAGS" + fi + ;; + esac } CheckClockGettime() diff --git a/configure.in b/configure.in index 890503cda..5c56f0080 100644 --- a/configure.in +++ b/configure.in @@ -2189,138 +2189,142 @@ AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[de dnl Check for the usbhid(3) library on *BSD CheckUSBHID() { - if test x$enable_joystick = xyes; then - AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes) - if test x$have_libusbhid = xyes; then - AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"]) - AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"]) - USB_LIBS="$USB_LIBS -lusbhid" - else - AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"]) - AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"]) - AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"]) - fi - - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $USB_CFLAGS" + case "$host" in + *-*-*bsd*) + if test x$enable_joystick = xyes; then + AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes) + if test x$have_libusbhid = xyes; then + AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"]) + AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"]) + USB_LIBS="$USB_LIBS -lusbhid" + else + AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"]) + AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"]) + AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"]) + fi + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $USB_CFLAGS" - AC_MSG_CHECKING(for usbhid) - have_usbhid=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif - ],[ - struct report_desc *repdesc; - struct usb_ctl_report *repbuf; - hid_kind_t hidkind; - ],[ - have_usbhid=yes - ]) - AC_MSG_RESULT($have_usbhid) + AC_MSG_CHECKING(for usbhid) + have_usbhid=no + AC_TRY_COMPILE([ + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif + ],[ + struct report_desc *repdesc; + struct usb_ctl_report *repbuf; + hid_kind_t hidkind; + ],[ + have_usbhid=yes + ]) + AC_MSG_RESULT($have_usbhid) - if test x$have_usbhid = xyes; then - AC_MSG_CHECKING(for ucr_data member of usb_ctl_report) - have_usbhid_ucr_data=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif - ],[ - struct usb_ctl_report buf; - if (buf.ucr_data) { } - ],[ - have_usbhid_ucr_data=yes - ]) - if test x$have_usbhid_ucr_data = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" + if test x$have_usbhid = xyes; then + AC_MSG_CHECKING(for ucr_data member of usb_ctl_report) + have_usbhid_ucr_data=no + AC_TRY_COMPILE([ + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif + ],[ + struct usb_ctl_report buf; + if (buf.ucr_data) { } + ],[ + have_usbhid_ucr_data=yes + ]) + if test x$have_usbhid_ucr_data = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" + fi + AC_MSG_RESULT($have_usbhid_ucr_data) + + AC_MSG_CHECKING(for new usbhid API) + have_usbhid_new=no + AC_TRY_COMPILE([ + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + #include + #include + #else + #include + #include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif + ],[ + report_desc_t d; + hid_start_parse(d, 1, 1); + ],[ + have_usbhid_new=yes + ]) + if test x$have_usbhid_new = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" + fi + AC_MSG_RESULT($have_usbhid_new) + + AC_MSG_CHECKING(for struct joystick in machine/joystick.h) + have_machine_joystick=no + AC_TRY_COMPILE([ + #include + ],[ + struct joystick t; + ],[ + have_machine_joystick=yes + ]) + if test x$have_machine_joystick = xyes; then + AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ]) + fi + AC_MSG_RESULT($have_machine_joystick) + + AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" + have_joystick=yes + fi + CFLAGS="$save_CFLAGS" fi - AC_MSG_RESULT($have_usbhid_ucr_data) - - AC_MSG_CHECKING(for new usbhid API) - have_usbhid_new=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - #include - #include - #else - #include - #include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif - ],[ - report_desc_t d; - hid_start_parse(d, 1, 1); - ],[ - have_usbhid_new=yes - ]) - if test x$have_usbhid_new = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" - fi - AC_MSG_RESULT($have_usbhid_new) - - AC_MSG_CHECKING(for struct joystick in machine/joystick.h) - have_machine_joystick=no - AC_TRY_COMPILE([ - #include - ],[ - struct joystick t; - ],[ - have_machine_joystick=yes - ]) - if test x$have_machine_joystick = xyes; then - AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ]) - fi - AC_MSG_RESULT($have_machine_joystick) - - AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ]) - SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" - have_joystick=yes - fi - CFLAGS="$save_CFLAGS" - fi + ;; + esac } dnl Check for clock_gettime() diff --git a/test/configure b/test/configure index 57da5548a..94a2f1394 100755 --- a/test/configure +++ b/test/configure @@ -586,8 +586,8 @@ ac_subst_vars='LTLIBOBJS LIBOBJS SDL_TTF_LIB XLIB -GLLIB GLESLIB +GLLIB CPP XMKMF SDL_CONFIG @@ -3874,6 +3874,7 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5 $as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; } if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then : From be18d2d0075a5dc4e0d115a79b365251c3244526 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 13 Oct 2013 19:51:58 -0700 Subject: [PATCH 178/258] Fixed function feature test for Visual Studio 2012 norfanin Fixes the version check for some functions that are only present with the MSVC 2013 CRT libraries. I did my testing wrong and failed to see that 2012 doesn't have these functions. Microsoft implemented them in their upcoming 2013 version, though. The attached patch changes it to the check for the next version. I also removed the HAVE_ITOA because that would require linking with oldnames.lib and it's easier to just let the SDL implementation take over. --- include/SDL_config_windows.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 7307763f2..4d5c7c293 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -128,8 +128,7 @@ typedef unsigned int uintptr_t; #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 -#if _MSC_VER >= 1700 -#define HAVE_ITOA 1 +#if _MSC_VER >= 1800 #define HAVE_STRTOLL 1 #define HAVE_SSCANF 1 #define HAVE_COPYSIGN 1 From 097878a78ede318366a586578f5ebd91bb3f9f39 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 13 Oct 2013 19:59:40 -0700 Subject: [PATCH 179/258] Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000 --- src/video/windows/SDL_windowsevents.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index c33dabfdd..7a3ceb392 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -466,10 +466,20 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_MOUSEWHEEL: { - /* FIXME: This may need to accumulate deltas up to WHEEL_DELTA */ - short motion = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; + static short s_AccumulatedMotion; - SDL_SendMouseWheel(data->window, 0, 0, motion); + s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam); + if (s_AccumulatedMotion > 0) { + while (s_AccumulatedMotion >= WHEEL_DELTA) { + SDL_SendMouseWheel(data->window, 0, 0, 1); + s_AccumulatedMotion -= WHEEL_DELTA; + } + } else { + while (s_AccumulatedMotion <= -WHEEL_DELTA) { + SDL_SendMouseWheel(data->window, 0, 0, -1); + s_AccumulatedMotion += WHEEL_DELTA; + } + } break; } From 8d7b3cb52148245452789b4dc77cc2b668a588ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Oct 2013 08:56:37 -0700 Subject: [PATCH 180/258] Added support for SDL_PIXELFORMAT_UYVY surfaces on Mac OS X --- src/render/opengl/SDL_render_gl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 8a61f788f..82cceed25 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -514,6 +514,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; } +#ifdef __MACOSX__ + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_UYVY; +#endif + if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object")) { data->GL_EXT_framebuffer_object_supported = SDL_TRUE; data->glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) @@ -582,6 +586,13 @@ convert_format(GL_RenderData *renderdata, Uint32 pixel_format, *format = GL_LUMINANCE; *type = GL_UNSIGNED_BYTE; break; +#ifdef __MACOSX__ + case SDL_PIXELFORMAT_UYVY: + *internalFormat = GL_RGB8; + *format = GL_YCBCR_422_APPLE; + *type = GL_UNSIGNED_SHORT_8_8_APPLE; + break; +#endif default: return SDL_FALSE; } From dca068eb06447adbd2314a2c0776d592ccb5d6d7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Oct 2013 08:56:45 -0700 Subject: [PATCH 181/258] Adding static lib to SDL builds on Windows. CR: SamL --- VisualC/SDL_VS2010.sln | 672 +++++++++++++++++++++++++---------------- 1 file changed, 417 insertions(+), 255 deletions(-) diff --git a/VisualC/SDL_VS2010.sln b/VisualC/SDL_VS2010.sln index fb5d873f2..3a493acd3 100644 --- a/VisualC/SDL_VS2010.sln +++ b/VisualC/SDL_VS2010.sln @@ -1,255 +1,417 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "SDL\SDL_VS2010.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "SDLmain\SDLmain_VS2010.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loopwave", "tests\loopwave\loopwave_VS2010.vcxproj", "{AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testplatform", "tests\testplatform\testplatform_VS2010.vcxproj", "{26932B24-EFC6-4E3A-B277-ED653DA37968}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testfile", "tests\testfile\testfile_VS2010.vcxproj", "{CAE4F1D0-314F-4B10-805B-0EFD670133A0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgl2", "tests\testgl2\testgl2_VS2010.vcxproj", "{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checkkeys", "tests\checkkeys\checkkeys_VS2010.vcxproj", "{26828762-C95D-4637-9CB1-7F0979523813}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsprite2", "tests\testsprite2\testsprite2_VS2010.vcxproj", "{40FB7794-D3C3-4CFE-BCF4-A80C96635682}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testshape", "tests\testshape\testshape_VS2010.vcxproj", "{EDEA9D00-AF64-45DE-8F60-5957048F2F0F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testdraw2", "tests\testdraw2\testdraw2_VS2010.vcxproj", "{8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpower\testpower_VS2010.vcxproj", "{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2test", "SDLtest\SDLtest_VS2010.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testautomation", "tests\testautomation\testautomation_vs2010.vcxproj", "{FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testatomic", "tests\testatomic\testatomic_VS2010.vcxproj", "{2271060E-98B4-4596-8172-A041E4B2EC7A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testscale", "tests\testscale\testscale_VS2010.vcxproj", "{E7A6C41C-E059-4C9C-8CCC-73586A540B62}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testrendertarget", "tests\testrendertarget\testrendertarget_VS2010.vcxproj", "{43A06713-A52D-4008-AD7E-A69DF3FCFFA8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgamecontroller", "tests\testgamecontroller\testgamecontroller_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08336}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgesture", "tests\testgesture\testgesture_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08996}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjoystick", "tests\testjoystick\testjoystick_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08BCC}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay2", "tests\testoverlay2\testoverlay2_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08AAD}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.ActiveCfg = Debug|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.Build.0 = Debug|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.ActiveCfg = Debug|x64 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.Build.0 = Debug|x64 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.ActiveCfg = Release|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.Build.0 = Release|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.ActiveCfg = Release|x64 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.Build.0 = Release|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.Build.0 = Debug|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.ActiveCfg = Debug|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.Build.0 = Debug|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.ActiveCfg = Release|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.Build.0 = Release|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.ActiveCfg = Release|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.Build.0 = Release|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.ActiveCfg = Debug|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.Build.0 = Debug|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.ActiveCfg = Debug|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.Build.0 = Debug|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.ActiveCfg = Release|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.Build.0 = Release|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.ActiveCfg = Release|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.Build.0 = Release|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.ActiveCfg = Debug|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.Build.0 = Debug|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.ActiveCfg = Debug|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.Build.0 = Debug|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.ActiveCfg = Release|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.Build.0 = Release|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.ActiveCfg = Release|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.Build.0 = Release|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.ActiveCfg = Debug|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.Build.0 = Debug|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.ActiveCfg = Debug|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.Build.0 = Debug|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.ActiveCfg = Release|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.Build.0 = Release|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.ActiveCfg = Release|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.Build.0 = Release|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.ActiveCfg = Debug|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.Build.0 = Debug|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.ActiveCfg = Debug|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.Build.0 = Debug|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.ActiveCfg = Release|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.Build.0 = Release|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.ActiveCfg = Release|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.Build.0 = Release|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.ActiveCfg = Debug|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.Build.0 = Debug|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.ActiveCfg = Debug|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.Build.0 = Debug|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.ActiveCfg = Release|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.Build.0 = Release|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.ActiveCfg = Release|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.Build.0 = Release|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.ActiveCfg = Debug|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.Build.0 = Debug|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.ActiveCfg = Debug|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.Build.0 = Debug|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.ActiveCfg = Release|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.Build.0 = Release|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.ActiveCfg = Release|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.Build.0 = Release|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.ActiveCfg = Debug|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.Build.0 = Debug|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.ActiveCfg = Debug|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.Build.0 = Debug|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.ActiveCfg = Release|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.Build.0 = Release|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.ActiveCfg = Release|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.Build.0 = Release|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.Build.0 = Debug|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.ActiveCfg = Debug|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.Build.0 = Debug|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.ActiveCfg = Release|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.Build.0 = Release|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.ActiveCfg = Release|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.Build.0 = Release|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.Build.0 = Debug|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.ActiveCfg = Debug|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.Build.0 = Debug|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.Build.0 = Release|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.ActiveCfg = Debug|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.Build.0 = Debug|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.ActiveCfg = Debug|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.Build.0 = Debug|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.ActiveCfg = Release|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.Build.0 = Release|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.ActiveCfg = Release|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.Build.0 = Release|x64 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.ActiveCfg = Debug|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.Build.0 = Debug|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|x64.ActiveCfg = Debug|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.ActiveCfg = Release|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.Build.0 = Release|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|x64.ActiveCfg = Release|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.ActiveCfg = Debug|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.Build.0 = Debug|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.ActiveCfg = Debug|x64 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.Build.0 = Debug|x64 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.ActiveCfg = Release|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.Build.0 = Release|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.ActiveCfg = Release|x64 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.Build.0 = Release|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.ActiveCfg = Debug|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.Build.0 = Debug|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.ActiveCfg = Debug|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.Build.0 = Debug|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.ActiveCfg = Release|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.Build.0 = Release|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.ActiveCfg = Release|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {26932B24-EFC6-4E3A-B277-ED653DA37968} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {CAE4F1D0-314F-4B10-805B-0EFD670133A0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {26828762-C95D-4637-9CB1-7F0979523813} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {40FB7794-D3C3-4CFE-BCF4-A80C96635682} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {2271060E-98B4-4596-8172-A041E4B2EC7A} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {E7A6C41C-E059-4C9C-8CCC-73586A540B62} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08336} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08996} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08BCC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08AAD} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "SDL\SDL_VS2010.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "SDLmain\SDLmain_VS2010.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loopwave", "tests\loopwave\loopwave_VS2010.vcxproj", "{AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testplatform", "tests\testplatform\testplatform_VS2010.vcxproj", "{26932B24-EFC6-4E3A-B277-ED653DA37968}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testfile", "tests\testfile\testfile_VS2010.vcxproj", "{CAE4F1D0-314F-4B10-805B-0EFD670133A0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgl2", "tests\testgl2\testgl2_VS2010.vcxproj", "{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checkkeys", "tests\checkkeys\checkkeys_VS2010.vcxproj", "{26828762-C95D-4637-9CB1-7F0979523813}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsprite2", "tests\testsprite2\testsprite2_VS2010.vcxproj", "{40FB7794-D3C3-4CFE-BCF4-A80C96635682}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testshape", "tests\testshape\testshape_VS2010.vcxproj", "{EDEA9D00-AF64-45DE-8F60-5957048F2F0F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testdraw2", "tests\testdraw2\testdraw2_VS2010.vcxproj", "{8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpower\testpower_VS2010.vcxproj", "{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2test", "SDLtest\SDLtest_VS2010.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testautomation", "tests\testautomation\testautomation_vs2010.vcxproj", "{FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testatomic", "tests\testatomic\testatomic_VS2010.vcxproj", "{2271060E-98B4-4596-8172-A041E4B2EC7A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testscale", "tests\testscale\testscale_VS2010.vcxproj", "{E7A6C41C-E059-4C9C-8CCC-73586A540B62}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testrendertarget", "tests\testrendertarget\testrendertarget_VS2010.vcxproj", "{43A06713-A52D-4008-AD7E-A69DF3FCFFA8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgamecontroller", "tests\testgamecontroller\testgamecontroller_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08336}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgesture", "tests\testgesture\testgesture_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08996}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjoystick", "tests\testjoystick\testjoystick_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08BCC}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay2", "tests\testoverlay2\testoverlay2_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08AAD}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_static|Win32 = Debug_static|Win32 + Debug_static|x64 = Debug_static|x64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release_static|Win32 = Release_static|Win32 + Release_static|x64 = Release_static|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|Win32.ActiveCfg = Debug_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|Win32.Build.0 = Debug_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|x64.ActiveCfg = Debug_static|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|x64.Build.0 = Debug_static|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.ActiveCfg = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.Build.0 = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.ActiveCfg = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.Build.0 = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|Win32.ActiveCfg = Release_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|Win32.Build.0 = Release_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|x64.ActiveCfg = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|x64.Build.0 = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.ActiveCfg = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.Build.0 = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.ActiveCfg = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.Build.0 = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|Win32.Build.0 = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|x64.ActiveCfg = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|x64.Build.0 = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.Build.0 = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.ActiveCfg = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.Build.0 = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|Win32.Build.0 = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|x64.ActiveCfg = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|x64.Build.0 = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.Build.0 = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.ActiveCfg = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.Build.0 = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|Win32.Build.0 = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|x64.ActiveCfg = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|x64.Build.0 = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.ActiveCfg = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.Build.0 = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.ActiveCfg = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.Build.0 = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|Win32.ActiveCfg = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|Win32.Build.0 = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|x64.ActiveCfg = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|x64.Build.0 = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.ActiveCfg = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.Build.0 = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.ActiveCfg = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.Build.0 = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|Win32.Build.0 = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|x64.ActiveCfg = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|x64.Build.0 = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.ActiveCfg = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.Build.0 = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.ActiveCfg = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.Build.0 = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|Win32.ActiveCfg = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|Win32.Build.0 = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|x64.ActiveCfg = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|x64.Build.0 = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.ActiveCfg = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.Build.0 = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.ActiveCfg = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.Build.0 = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|Win32.Build.0 = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|x64.ActiveCfg = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|x64.Build.0 = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.ActiveCfg = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.Build.0 = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.ActiveCfg = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.Build.0 = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|Win32.ActiveCfg = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|Win32.Build.0 = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|x64.ActiveCfg = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|x64.Build.0 = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.ActiveCfg = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.Build.0 = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.ActiveCfg = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.Build.0 = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|Win32.Build.0 = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|x64.ActiveCfg = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|x64.Build.0 = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.ActiveCfg = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.Build.0 = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.ActiveCfg = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.Build.0 = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|Win32.ActiveCfg = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|Win32.Build.0 = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|x64.ActiveCfg = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|x64.Build.0 = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.ActiveCfg = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.Build.0 = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.ActiveCfg = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.Build.0 = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|Win32.Build.0 = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|x64.ActiveCfg = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|x64.Build.0 = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.ActiveCfg = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.Build.0 = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.ActiveCfg = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.Build.0 = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|Win32.ActiveCfg = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|Win32.Build.0 = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|x64.ActiveCfg = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|x64.Build.0 = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.ActiveCfg = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.Build.0 = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.ActiveCfg = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.Build.0 = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|Win32.Build.0 = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|x64.ActiveCfg = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|x64.Build.0 = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.ActiveCfg = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.Build.0 = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.ActiveCfg = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.Build.0 = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|Win32.ActiveCfg = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|Win32.Build.0 = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|x64.ActiveCfg = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|x64.Build.0 = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.ActiveCfg = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.Build.0 = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.ActiveCfg = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.Build.0 = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|Win32.Build.0 = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|x64.ActiveCfg = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|x64.Build.0 = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.ActiveCfg = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.Build.0 = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.ActiveCfg = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.Build.0 = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|Win32.ActiveCfg = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|Win32.Build.0 = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|x64.ActiveCfg = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|x64.Build.0 = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.ActiveCfg = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.Build.0 = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.ActiveCfg = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.Build.0 = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|Win32.Build.0 = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|x64.ActiveCfg = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|x64.Build.0 = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.ActiveCfg = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.Build.0 = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.ActiveCfg = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.Build.0 = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|Win32.ActiveCfg = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|Win32.Build.0 = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|x64.ActiveCfg = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|x64.Build.0 = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.ActiveCfg = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.Build.0 = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.ActiveCfg = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.Build.0 = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|Win32.Build.0 = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|x64.ActiveCfg = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|x64.Build.0 = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.Build.0 = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.ActiveCfg = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.Build.0 = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|Win32.ActiveCfg = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|Win32.Build.0 = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|x64.ActiveCfg = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|x64.Build.0 = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.Build.0 = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|Win32.Build.0 = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|x64.ActiveCfg = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|x64.Build.0 = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|Win32.Build.0 = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|x64.ActiveCfg = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|x64.Build.0 = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|Win32.Build.0 = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|x64.ActiveCfg = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|x64.Build.0 = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.ActiveCfg = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.Build.0 = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.ActiveCfg = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.Build.0 = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|Win32.ActiveCfg = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|Win32.Build.0 = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|x64.ActiveCfg = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|x64.Build.0 = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.ActiveCfg = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.Build.0 = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.ActiveCfg = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.Build.0 = Release|x64 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug_static|Win32.Build.0 = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug_static|x64.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.Build.0 = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|x64.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release_static|Win32.ActiveCfg = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release_static|Win32.Build.0 = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release_static|x64.ActiveCfg = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.ActiveCfg = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.Build.0 = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|x64.ActiveCfg = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|Win32.Build.0 = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|x64.ActiveCfg = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|x64.Build.0 = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.ActiveCfg = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.Build.0 = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.ActiveCfg = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.Build.0 = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|Win32.ActiveCfg = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|Win32.Build.0 = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|x64.ActiveCfg = Release|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|x64.Build.0 = Release|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.ActiveCfg = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.Build.0 = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.ActiveCfg = Release|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.Build.0 = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|Win32.Build.0 = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|x64.ActiveCfg = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|x64.Build.0 = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.ActiveCfg = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.Build.0 = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.ActiveCfg = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.Build.0 = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|Win32.ActiveCfg = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|Win32.Build.0 = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|x64.ActiveCfg = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|x64.Build.0 = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.ActiveCfg = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.Build.0 = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.ActiveCfg = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {26932B24-EFC6-4E3A-B277-ED653DA37968} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {CAE4F1D0-314F-4B10-805B-0EFD670133A0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {26828762-C95D-4637-9CB1-7F0979523813} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {40FB7794-D3C3-4CFE-BCF4-A80C96635682} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {2271060E-98B4-4596-8172-A041E4B2EC7A} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {E7A6C41C-E059-4C9C-8CCC-73586A540B62} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08336} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08996} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08BCC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08AAD} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + EndGlobalSection +EndGlobal From 0b7df3428629bcd5b70ca9cb3771db722f628498 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Oct 2013 08:56:50 -0700 Subject: [PATCH 182/258] Fixed the windows message debug output so it works without HAVE_LIBC --- src/video/windows/SDL_windowsevents.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 7a3ceb392..1826258c8 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -309,18 +309,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } #ifdef WMMSG_DEBUG - { - FILE *log = fopen("wmmsg.txt", "a"); - fprintf(log, "Received windows message: %p ", hwnd); - if (msg > MAX_WMMSG) { - fprintf(log, "%d", msg); - } else { - fprintf(log, "%s", wmtab[msg]); - } - fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam); - fclose(log); - } -#endif + { + char message[1024]; + if (msg > MAX_WMMSG) { + SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%X, 0x%X\n", hwnd, msg, wParam, lParam); + } else { + SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%X, 0x%X\n", hwnd, wmtab[msg], wParam, lParam); + } + OutputDebugStringA(message); + } +#endif /* WMMSG_DEBUG */ if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata)) return 0; From 73bc021063ec6aeca3a79be80740db5311946405 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Oct 2013 08:56:55 -0700 Subject: [PATCH 183/258] For some reason, trying to raise the window programmatically while it's alt-tabbed away will minimize it. Added a workaround for this. --- src/video/windows/SDL_windowswindow.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 07b873f7f..0c5e5bbed 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -403,6 +403,9 @@ void WIN_RaiseWindow(_THIS, SDL_Window * window) { WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE); + + /* Raising the window while alt-tabbed can cause it to be minimized for some reason? */ + WIN_RestoreWindow(_this, window); } void From 23a6f738e7e99d1fd5e99a464ff7643f9d168c23 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Oct 2013 09:12:30 -0700 Subject: [PATCH 184/258] Backed out revision d4a39491577f, the platform specific messagebox functions don't have the right prototype since they're designed to be used standalone. --- src/video/cocoa/SDL_cocoavideo.m | 3 --- src/video/uikit/SDL_uikitvideo.m | 4 ---- src/video/windows/SDL_windowsvideo.c | 3 --- src/video/x11/SDL_x11video.c | 3 --- 4 files changed, 13 deletions(-) diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index e6de2ff56..d1b958768 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -33,7 +33,6 @@ #include "SDL_endian.h" #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" -#include "SDL_cocoamessagebox.h" #include "SDL_assert.h" /* Initialization/Query functions */ @@ -135,8 +134,6 @@ Cocoa_CreateDevice(int devindex) device->GetClipboardText = Cocoa_GetClipboardText; device->HasClipboardText = Cocoa_HasClipboardText; - device->ShowMessageBox = Cocoa_ShowMessageBox; - device->free = Cocoa_DeleteDevice; return device; diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index e90172806..74b24b8da 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -35,7 +35,6 @@ #include "SDL_uikitmodes.h" #include "SDL_uikitwindow.h" #include "SDL_uikitopengles.h" -#include "SDL_uikitmessagebox.h" #define UIKITVID_DRIVER_NAME "uikit" @@ -99,9 +98,6 @@ UIKit_CreateDevice(int devindex) device->GL_DeleteContext = UIKit_GL_DeleteContext; device->GL_GetProcAddress = UIKit_GL_GetProcAddress; device->GL_LoadLibrary = UIKit_GL_LoadLibrary; - - device->ShowMessageBox = UIKit_ShowMessageBox; - device->free = UIKit_DeleteDevice; device->gl_config.accelerated = 1; diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 1a0ad55c2..8f708cf0d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -32,7 +32,6 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsframebuffer.h" #include "SDL_windowsshape.h" -#include "SDL_windowsmessagebox.h" /* Initialization/Query functions */ static int WIN_VideoInit(_THIS); @@ -146,8 +145,6 @@ WIN_CreateDevice(int devindex) device->GetClipboardText = WIN_GetClipboardText; device->HasClipboardText = WIN_HasClipboardText; - device->ShowMessageBox = WIN_ShowMessageBox; - device->free = WIN_DeleteDevice; return device; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 020bba019..5ed47d5e8 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -34,7 +34,6 @@ #include "SDL_x11shape.h" #include "SDL_x11touch.h" #include "SDL_x11xinput2.h" -#include "SDL_x11messagebox.h" #if SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" @@ -412,8 +411,6 @@ X11_CreateDevice(int devindex) device->GetClipboardText = X11_GetClipboardText; device->HasClipboardText = X11_HasClipboardText; - device->ShowMessageBox = X11_ShowMessageBox; - device->free = X11_DeleteDevice; return device; From 4abff3bd75ceef77cac61d0315b13feb64fd5a0f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Oct 2013 09:14:09 -0700 Subject: [PATCH 185/258] Fixed project conflict during commit --- VisualC/SDL/SDL_VS2010.vcxproj | 1143 +++++++++++++++++++------------- 1 file changed, 678 insertions(+), 465 deletions(-) diff --git a/VisualC/SDL/SDL_VS2010.vcxproj b/VisualC/SDL/SDL_VS2010.vcxproj index 58807a5af..d9ca5aff7 100644 --- a/VisualC/SDL/SDL_VS2010.vcxproj +++ b/VisualC/SDL/SDL_VS2010.vcxproj @@ -1,466 +1,679 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - SDL2 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - SDL - - - - DynamicLibrary - false - - - DynamicLibrary - false - - - DynamicLibrary - false - - - DynamicLibrary - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - - - Level3 - true - EditAndContinue - Default - false - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - true - Windows - false - $(DXSDK_DIR)\lib\x86 - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - - - Level3 - EditAndContinue - false - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - true - Windows - false - $(DXSDK_DIR)\lib\x64 - - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - - - OnlyExplicitInline - false - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - true - - - Level3 - true - Default - false - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - Windows - $(DXSDK_DIR)\lib\x86 - true - true - true - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - - - OnlyExplicitInline - false - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - true - - - Level3 - false - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - Windows - $(DXSDK_DIR)\lib\x64 - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug_static + Win32 + + + Debug_static + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release_static + Win32 + + + Release_static + x64 + + + Release + Win32 + + + Release + x64 + + + + SDL2 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + SDL + + + + DynamicLibrary + false + + + StaticLibrary + false + + + DynamicLibrary + false + + + StaticLibrary + false + + + DynamicLibrary + false + + + StaticLibrary + false + + + DynamicLibrary + false + MultiByte + + + StaticLibrary + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(ProjectName)_static + $(ProjectName)_static + $(ProjectName)_static + $(ProjectName)_static + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + false + + + Level3 + true + EditAndContinue + Default + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x86 + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + true + OldStyle + Default + false + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x86 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + false + + + Level3 + EditAndContinue + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x64 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + OldStyle + false + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x64 + + + /MACHINE:X64 %(AdditionalOptions) + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + true + + + Level3 + true + Default + false + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x86 + true + true + true + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + + + Level3 + true + Default + false + OldStyle + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x86 + true + true + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + true + + + Level3 + false + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x64 + true + true + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + + + Level3 + false + OldStyle + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x64 + true + true + true + + + /MACHINE:X64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From a04ca13c2d7829ee9c0e4f5689f51ab779164ec1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 11:32:56 -0700 Subject: [PATCH 186/258] Added an API to get the amount of system RAM --- include/SDL_cpuinfo.h | 5 ++++ src/cpuinfo/SDL_cpuinfo.c | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index dde3074f0..6d72bbb81 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -134,6 +134,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); +/** + * This function returns the amount of RAM configured in the system, in MB. + */ +extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 30549852d..f6f4542e9 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -607,6 +607,60 @@ SDL_HasSSE42(void) return SDL_FALSE; } +static int SDL_SystemRAM = 0; + +int +SDL_GetSystemRAM(void) +{ + if (!SDL_SystemRAM) { +#if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) + if (SDL_SystemRAM <= 0) { + SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024)); + } +#endif +#ifdef HAVE_SYSCTLBYNAME + if (SDL_SystemRAM <= 0) { + int mib[2] = {CTL_HW, HW_MEMSIZE}; + uint64 memsize = 0; + size_t len = sizeof(memsize); + + if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) { + SDL_SystemRAM = (int)(memsize / (1024*1024)); + } + } +#endif +#ifdef __WIN32__ + if (SDL_SystemRAM <= 0) { + MEMORYSTATUSEX stat; + if (GlobalMemoryStatusEx(&stat)) { + SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024)); + } + } +#endif +#if 0 //def __LINUX__ + FILE *fpMemInfo = fopen("/proc/meminfo", "r"); + if (fpMemInfo) { + char line[1024]; + const char *search = "MemTotal:"; + const size_t searchlen = SDL_strlen(search); + while (fgets(line, sizeof(line), fpMemInfo)) { + if (SDL_strncasecmp(search, line, searchlen) == 0) { + char *val = line+searchlen; + while (SDL_isspace(*val)) { + ++val; + } + SDL_SystemRAM = SDL_atoi(val) / 1024; /* convert from kB to MB */ + break; + } + } + fclose(fpMemInfo); + } +#endif + } + return SDL_SystemRAM; +} + + #ifdef TEST_MAIN #include @@ -627,6 +681,7 @@ main() printf("SSE3: %d\n", SDL_HasSSE3()); printf("SSE4.1: %d\n", SDL_HasSSE41()); printf("SSE4.2: %d\n", SDL_HasSSE42()); + printf("RAM: %d MB\n", SDL_GetSystemRAM()); return 0; } From 73ef0c776e2120358d2099267b2637f373ab3002 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 11:32:14 -0700 Subject: [PATCH 187/258] The _SC_PHYS_PAGES method of calculating RAM works on Linux. --- src/cpuinfo/SDL_cpuinfo.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index f6f4542e9..c59b51b87 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -636,25 +636,6 @@ SDL_GetSystemRAM(void) SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024)); } } -#endif -#if 0 //def __LINUX__ - FILE *fpMemInfo = fopen("/proc/meminfo", "r"); - if (fpMemInfo) { - char line[1024]; - const char *search = "MemTotal:"; - const size_t searchlen = SDL_strlen(search); - while (fgets(line, sizeof(line), fpMemInfo)) { - if (SDL_strncasecmp(search, line, searchlen) == 0) { - char *val = line+searchlen; - while (SDL_isspace(*val)) { - ++val; - } - SDL_SystemRAM = SDL_atoi(val) / 1024; /* convert from kB to MB */ - break; - } - } - fclose(fpMemInfo); - } #endif } return SDL_SystemRAM; From 308e51f9a233a4c81afa6bcce5024de566075f46 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 11:56:33 -0700 Subject: [PATCH 188/258] Fixed compiling on Mac OS X, added a system RAM test --- src/cpuinfo/SDL_cpuinfo.c | 2 +- test/testplatform.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index c59b51b87..d39075f15 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -621,7 +621,7 @@ SDL_GetSystemRAM(void) #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { int mib[2] = {CTL_HW, HW_MEMSIZE}; - uint64 memsize = 0; + Uint64 memsize = 0; size_t len = sizeof(memsize); if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) { diff --git a/test/testplatform.c b/test/testplatform.c index 2f32e1f4e..a8ed39dd2 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -153,6 +153,7 @@ TestCPUInfo(SDL_bool verbose) SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); + SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM()); } return (0); } From 277d7b5c2c9d9cad0c6b39554f5b11745c28ff48 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 17:37:23 -0700 Subject: [PATCH 189/258] Fixed using the wrong variable when reporting a missing SDL scancode mapping. --HG-- extra : rebase_source : addd6c5ccfe203f744ba50a120ebe5a1ca77476e --- src/video/x11/SDL_x11keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 5c5f5bcf1..6bc7ebbfa 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -271,7 +271,7 @@ X11_InitKeyboard(_THIS) if (scancode == SDL_SCANCODE_UNKNOWN) { printf("scancode not found\n"); } else { - printf("scancode = %d (%s)\n", j, SDL_GetScancodeName(j)); + printf("scancode = %d (%s)\n", scancode, SDL_GetScancodeName(scancode)); } } } From 0e2c364251c856cf280d9acd2882e20ebf0e6ed6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 17:38:55 -0700 Subject: [PATCH 190/258] Fixed compiler warning if dynamic X11 loading isn't enabled. --HG-- extra : rebase_source : fa6d88273a5c3ab0f501f90bb98340bfedf5a086 --- src/video/x11/SDL_x11dyn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index ab0eafb4d..f9a2fa68c 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -131,7 +131,9 @@ SDL_DYNX11FN_XGetICValues pXGetICValues = NULL; #undef SDL_X11_SYM +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC static int x11_load_refcount = 0; +#endif void SDL_X11_UnloadSymbols(void) From 22648bd3344c6cce341cf14bd23d0994b6c682c7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 20:49:30 -0700 Subject: [PATCH 191/258] Fix to unbreak SDL_GetSystemRAM() on FreeBSD Marcus von Appen Revision c47ae79f0de8 of the SDL hg repo introduces the new SDL_GetSystemRAM() function, which breaks the build on FreeBSD. Find attached a patch, which unbreaks the build and also should (for most cases) properly implement the sysctl support it. --- src/cpuinfo/SDL_cpuinfo.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index d39075f15..5e048f9c3 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -620,7 +620,16 @@ SDL_GetSystemRAM(void) #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { +#ifdef __FreeBSD__ +#ifdef HW_REALMEM + int mib[2] = {CTL_HW, HW_REALMEM}; +#else + /* might only report up to 2 GiB */ + int mib[2] = {CTL_HW, HW_PHYSMEM}; +#endif /* HW_REALMEM */ +#else int mib[2] = {CTL_HW, HW_MEMSIZE}; +#endif /* __FreeBSD__ */ Uint64 memsize = 0; size_t len = sizeof(memsize); From bf877ba6918fcecb574b2e917675119b143e5e40 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 18 Oct 2013 01:36:41 -0400 Subject: [PATCH 192/258] Don't supply duplicate X11 symbols inside SDL. Fixes static linking when something else also uses X11. --HG-- extra : rebase_source : 8b913c842dd9793a3dbad68f070878d5931a8a94 --- src/video/x11/SDL_x11clipboard.c | 26 +-- src/video/x11/SDL_x11dyn.c | 46 ++--- src/video/x11/SDL_x11dyn.h | 40 ++-- src/video/x11/SDL_x11events.c | 108 +++++----- src/video/x11/SDL_x11framebuffer.c | 34 ++-- src/video/x11/SDL_x11keyboard.c | 14 +- src/video/x11/SDL_x11messagebox.c | 90 ++++----- src/video/x11/SDL_x11modes.c | 116 +++++------ src/video/x11/SDL_x11mouse.c | 38 ++-- src/video/x11/SDL_x11opengl.c | 26 +-- src/video/x11/SDL_x11opengles.c | 8 +- src/video/x11/SDL_x11shape.c | 8 +- src/video/x11/SDL_x11video.c | 44 ++-- src/video/x11/SDL_x11window.c | 314 ++++++++++++++--------------- src/video/x11/SDL_x11xinput2.c | 12 +- 15 files changed, 458 insertions(+), 466 deletions(-) diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 970aeaf15..e6ca86bc3 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -31,7 +31,7 @@ /* If you don't support UTF-8, you might use XA_STRING here */ #ifdef X_HAVE_UTF8_STRING -#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False) +#define TEXT_FORMAT X11_XInternAtom(display, "UTF8_STRING", False) #else #define TEXT_FORMAT XA_STRING #endif @@ -55,7 +55,7 @@ X11_SetClipboardText(_THIS, const char *text) Display *display = ((SDL_VideoData *) _this->driverdata)->display; Atom format; Window window; - Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0); + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); /* Get the SDL window that will own the selection */ window = GetWindow(_this); @@ -65,17 +65,17 @@ X11_SetClipboardText(_THIS, const char *text) /* Save the selection on the root window */ format = TEXT_FORMAT; - XChangeProperty(display, DefaultRootWindow(display), + X11_XChangeProperty(display, DefaultRootWindow(display), XA_CUT_BUFFER0, format, 8, PropModeReplace, (const unsigned char *)text, SDL_strlen(text)); if (XA_CLIPBOARD != None && - XGetSelectionOwner(display, XA_CLIPBOARD) != window) { - XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime); + X11_XGetSelectionOwner(display, XA_CLIPBOARD) != window) { + X11_XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime); } - if (XGetSelectionOwner(display, XA_PRIMARY) != window) { - XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime); + if (X11_XGetSelectionOwner(display, XA_PRIMARY) != window) { + X11_XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime); } return 0; } @@ -97,7 +97,7 @@ X11_GetClipboardText(_THIS) char *text; Uint32 waitStart; Uint32 waitElapsed; - Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0); + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); if (XA_CLIPBOARD == None) { SDL_SetError("Couldn't access X clipboard"); return SDL_strdup(""); @@ -108,15 +108,15 @@ X11_GetClipboardText(_THIS) /* Get the window that holds the selection */ window = GetWindow(_this); format = TEXT_FORMAT; - owner = XGetSelectionOwner(display, XA_CLIPBOARD); + owner = X11_XGetSelectionOwner(display, XA_CLIPBOARD); if ((owner == None) || (owner == window)) { owner = DefaultRootWindow(display); selection = XA_CUT_BUFFER0; } else { /* Request that the selection owner copy the data to our window */ owner = window; - selection = XInternAtom(display, "SDL_SELECTION", False); - XConvertSelection(display, XA_CLIPBOARD, format, selection, owner, + selection = X11_XInternAtom(display, "SDL_SELECTION", False); + X11_XConvertSelection(display, XA_CLIPBOARD, format, selection, owner, CurrentTime); /* When using synergy on Linux and when data has been put in the clipboard @@ -139,7 +139,7 @@ X11_GetClipboardText(_THIS) } } - if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False, + if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False, format, &seln_type, &seln_format, &nbytes, &overflow, &src) == Success) { if (seln_type == format) { @@ -149,7 +149,7 @@ X11_GetClipboardText(_THIS) text[nbytes] = '\0'; } } - XFree(src); + X11_XFree(src); } if (!text) { diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index f9a2fa68c..24caea49f 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -103,24 +103,19 @@ X11_GetSym(const char *fnname, int *pHasModule) return fn; } +#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Define all the function pointers and wrappers... */ #define SDL_X11_MODULE(modname) -#define SDL_X11_SYM(rc,fn,params,args,ret) \ - typedef rc (*SDL_DYNX11FN_##fn) params; \ - static SDL_DYNX11FN_##fn p##fn = NULL; \ - rc fn params { ret p##fn args ; } +#define SDL_X11_SYM(rc,fn,params,args,ret) SDL_DYNX11FN_##fn X11_##fn = NULL; #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM -#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Annoying varargs entry point... */ #ifdef X_HAVE_UTF8_STRING -typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...); -SDL_DYNX11FN_XCreateIC pXCreateIC = NULL; -typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...); -SDL_DYNX11FN_XGetICValues pXGetICValues = NULL; +SDL_DYNX11FN_XCreateIC X11_XCreateIC = NULL; +SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL; #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ @@ -130,15 +125,11 @@ SDL_DYNX11FN_XGetICValues pXGetICValues = NULL; #undef SDL_X11_MODULE #undef SDL_X11_SYM - -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC static int x11_load_refcount = 0; -#endif void SDL_X11_UnloadSymbols(void) { -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* Don't actually unload if more than one module is using the libs... */ if (x11_load_refcount > 0) { if (--x11_load_refcount == 0) { @@ -146,25 +137,26 @@ SDL_X11_UnloadSymbols(void) /* set all the function pointers to NULL. */ #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0; -#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL; +#define SDL_X11_SYM(rc,fn,params,args,ret) X11_##fn = NULL; #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = NULL; - pXGetICValues = NULL; + X11_XCreateIC = NULL; + X11_XGetICValues = NULL; #endif +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].lib != NULL) { SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } } +#endif } } -#endif } /* returns non-zero if all needed symbols were loaded. */ @@ -173,9 +165,9 @@ SDL_X11_LoadSymbols(void) { int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* deal with multiple modules (dga, x11, etc) needing these symbols... */ if (x11_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { @@ -191,15 +183,15 @@ SDL_X11_LoadSymbols(void) #undef SDL_X11_SYM #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; -#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod); +#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod); #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = (SDL_DYNX11FN_XCreateIC) + X11_XCreateIC = (SDL_DYNX11FN_XCreateIC) X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); - pXGetICValues = (SDL_DYNX11FN_XGetICValues) + X11_XGetICValues = (SDL_DYNX11FN_XGetICValues) X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); #endif @@ -211,19 +203,21 @@ SDL_X11_LoadSymbols(void) SDL_X11_UnloadSymbols(); rc = 0; } - } -#else + +#else /* no dynamic X11 */ + #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ -#define SDL_X11_SYM(a,fn,x,y,z) +#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = fn; #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = XCreateIC; - pXGetICValues = XGetICValues; + X11_XCreateIC = XCreateIC; + X11_XGetICValues = XGetICValues; #endif #endif + } return rc; } diff --git a/src/video/x11/SDL_x11dyn.h b/src/video/x11/SDL_x11dyn.h index 2cebf3b8b..168c07e22 100644 --- a/src/video/x11/SDL_x11dyn.h +++ b/src/video/x11/SDL_x11dyn.h @@ -69,35 +69,34 @@ #include #endif -/* - * When using the "dynamic X11" functionality, we duplicate all the Xlib - * symbols that would be referenced by SDL inside of SDL itself. - * These duplicated symbols just serve as passthroughs to the functions - * in Xlib, that was dynamically loaded. - * - * This allows us to use Xlib as-is when linking against it directly, but - * also handles all the strange cases where there was code in the Xlib - * headers that may or may not exist or vary on a given platform. - */ #ifdef __cplusplus extern "C" { #endif /* evil function signatures... */ - typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, - xEvent *); - typedef int (*SDL_X11_XSynchronizeRetType) (Display *); - typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, - xEvent *); +typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, xEvent *); +typedef int (*SDL_X11_XSynchronizeRetType) (Display *); +typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, xEvent *); - int SDL_X11_LoadSymbols(void); - void SDL_X11_UnloadSymbols(void); +int SDL_X11_LoadSymbols(void); +void SDL_X11_UnloadSymbols(void); -/* That's really annoying...make these function pointers no matter what. */ +/* Declare all the function pointers and wrappers... */ +#define SDL_X11_MODULE(modname) +#define SDL_X11_SYM(rc,fn,params,args,ret) \ + typedef rc (*SDL_DYNX11FN_##fn) params; \ + extern SDL_DYNX11FN_##fn X11_##fn; +#include "SDL_x11sym.h" +#undef SDL_X11_MODULE +#undef SDL_X11_SYM + +/* Annoying varargs entry point... */ #ifdef X_HAVE_UTF8_STRING - extern XIC(*pXCreateIC) (XIM, ...); - extern char *(*pXGetICValues) (XIC, ...); +typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...); +typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...); +extern SDL_DYNX11FN_XCreateIC X11_XCreateIC; +extern SDL_DYNX11FN_XGetICValues X11_XGetICValues; #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ @@ -107,7 +106,6 @@ extern "C" #undef SDL_X11_MODULE #undef SDL_X11_SYM - #ifdef __cplusplus } #endif diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index c260019c6..593b2bee1 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -48,7 +48,7 @@ typedef struct { } SDL_x11Prop; /* Reads property - Must call XFree on results + Must call X11_XFree on results */ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) { @@ -60,8 +60,8 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != 0) XFree(ret); - XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); + if (ret != 0) X11_XFree(ret); + X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); bytes_fetch += bytes_left; } while (bytes_left != 0); @@ -79,9 +79,9 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) char *name; int i; for (i=0; i < list_count && request == None; i++) { - name = XGetAtomName(disp, list[i]); + name = X11_XGetAtomName(disp, list[i]); if (strcmp("text/uri-list", name)==0) request = list[i]; - XFree(name); + X11_XFree(name); } return request; } @@ -125,8 +125,8 @@ static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) struct KeyRepeatCheckData d; d.event = event; d.found = SDL_FALSE; - if (XPending(display)) - XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, + if (X11_XPending(display)) + X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, (XPointer) &d); return d.found; } @@ -147,7 +147,7 @@ static Bool X11_IsWheelCheckIfEvent(Display *display, XEvent *chkev, static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) { XEvent relevent; - if (XPending(display)) { + if (X11_XPending(display)) { /* according to the xlib docs, no specific mouse wheel events exist. however, mouse wheel events trigger a button press and a button release immediately. thus, checking if the same button was released at the same @@ -158,7 +158,7 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) generated (or synthesised) immediately. - False negative: a wheel which, when rolled, doesn't have a release event generated immediately. */ - if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, + if (X11_XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, (XPointer) event)) { /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse, @@ -217,9 +217,9 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event) { /* event is a union, so cookie == &event, but this is type safe. */ XGenericEventCookie *cookie = &event.xcookie; - if (XGetEventData(videodata->display, cookie)) { + if (X11_XGetEventData(videodata->display, cookie)) { X11_HandleXinput2Event(videodata, cookie); - XFreeEventData(videodata->display, cookie); + X11_XFreeEventData(videodata->display, cookie); } } #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */ @@ -234,7 +234,7 @@ X11_DispatchFocusIn(SDL_WindowData *data) SDL_SetKeyboardFocus(data->window); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XSetICFocus(data->ic); + X11_XSetICFocus(data->ic); } #endif } @@ -248,7 +248,7 @@ X11_DispatchFocusOut(SDL_WindowData *data) SDL_SetKeyboardFocus(NULL); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XUnsetICFocus(data->ic); + X11_XUnsetICFocus(data->ic); } #endif } @@ -278,11 +278,11 @@ X11_DispatchEvent(_THIS) XClientMessageEvent m; SDL_zero(xevent); /* valgrind fix. --ryan. */ - XNextEvent(display, &xevent); + X11_XNextEvent(display, &xevent); /* filter events catchs XIM events and sends them to the correct handler */ - if (XFilterEvent(&xevent, None) == True) { + if (X11_XFilterEvent(&xevent, None) == True) { #if 0 printf("Filtered event type = %d display = %d window = %d\n", xevent.type, xevent.xany.display, xevent.xany.window); @@ -451,23 +451,23 @@ X11_DispatchEvent(_THIS) #if 1 if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) { int min_keycode, max_keycode; - XDisplayKeycodes(display, &min_keycode, &max_keycode); + X11_XDisplayKeycodes(display, &min_keycode, &max_keycode); #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n", keycode, keycode - min_keycode, keysym, - XKeysymToString(keysym)); + X11_XKeysymToString(keysym)); } #endif /* */ SDL_zero(text); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), + X11_Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), &keysym, &status); } #else @@ -549,7 +549,7 @@ X11_DispatchEvent(_THIS) X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); /* pick one */ data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count); - XFree(p.data); + X11_XFree(p.data); } else { /* pick from list of three */ data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]); @@ -570,8 +570,8 @@ X11_DispatchEvent(_THIS) m.data.l[3] = 0; m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ - XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); - XFlush(display); + X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); + X11_XFlush(display); } else if(xevent.xclient.message_type == videodata->XdndDrop) { if (data->xdnd_req == None) { @@ -585,13 +585,13 @@ X11_DispatchEvent(_THIS) m.data.l[0] = data->xwindow; m.data.l[1] = 0; m.data.l[2] = None; /* fail! */ - XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); + X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); } else { /* convert */ if(xdnd_version >= 1) { - XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); + X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); } else { - XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); + X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); } } } @@ -604,7 +604,7 @@ X11_DispatchEvent(_THIS) printf("window %p: _NET_WM_PING\n", data); #endif xevent.xclient.window = root; - XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); + X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); break; } @@ -664,13 +664,13 @@ X11_DispatchEvent(_THIS) Atom real_type; unsigned long items_read, items_left, i; - char *name = XGetAtomName(display, xevent.xproperty.atom); + char *name = X11_XGetAtomName(display, xevent.xproperty.atom); if (name) { printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed"); - XFree(name); + X11_XFree(name); } - status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); + status = X11_XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && items_read > 0) { if (real_type == XA_INTEGER) { int *values = (int *)propdata; @@ -714,23 +714,23 @@ X11_DispatchEvent(_THIS) printf("{"); for (i = 0; i < items_read; i++) { - char *name = XGetAtomName(display, atoms[i]); + char *name = X11_XGetAtomName(display, atoms[i]); if (name) { printf(" %s", name); - XFree(name); + X11_XFree(name); } } printf(" }\n"); } else { - char *name = XGetAtomName(display, real_type); + char *name = X11_XGetAtomName(display, real_type); printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN"); if (name) { - XFree(name); + X11_XFree(name); } } } if (status == Success) { - XFree(propdata); + X11_XFree(propdata); } #endif /* DEBUG_XEVENTS */ @@ -774,28 +774,28 @@ X11_DispatchEvent(_THIS) sevent.xselection.property = None; sevent.xselection.requestor = req->requestor; sevent.xselection.time = req->time; - if (XGetWindowProperty(display, DefaultRootWindow(display), + if (X11_XGetWindowProperty(display, DefaultRootWindow(display), XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, &sevent.xselection.target, &seln_format, &nbytes, &overflow, &seln_data) == Success) { - Atom XA_TARGETS = XInternAtom(display, "TARGETS", 0); + Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0); if (sevent.xselection.target == req->target) { - XChangeProperty(display, req->requestor, req->property, + X11_XChangeProperty(display, req->requestor, req->property, sevent.xselection.target, seln_format, PropModeReplace, seln_data, nbytes); sevent.xselection.property = req->property; } else if (XA_TARGETS == req->target) { Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS }; - XChangeProperty(display, req->requestor, req->property, + X11_XChangeProperty(display, req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char*)SupportedFormats, sizeof(SupportedFormats)/sizeof(*SupportedFormats)); sevent.xselection.property = req->property; } - XFree(seln_data); + X11_XFree(seln_data); } - XSendEvent(display, req->requestor, False, 0, &sevent); - XSync(display, False); + X11_XSendEvent(display, req->requestor, False, 0, &sevent); + X11_XSync(display, False); } break; @@ -845,7 +845,7 @@ X11_DispatchEvent(_THIS) } } - XFree(p.data); + X11_XFree(p.data); /* send reply */ SDL_memset(&m, 0, sizeof(XClientMessageEvent)); @@ -857,9 +857,9 @@ X11_DispatchEvent(_THIS) m.data.l[0] = data->xwindow; m.data.l[1] = 1; m.data.l[2] = videodata->XdndActionCopy; - XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); + X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); - XSync(display, False); + X11_XSync(display, False); } else { videodata->selection_waiting = SDL_FALSE; @@ -899,13 +899,13 @@ X11_HandleFocusChanges(_THIS) } } } -/* Ack! XPending() actually performs a blocking read if no events available */ +/* Ack! X11_XPending() actually performs a blocking read if no events available */ static int X11_Pending(Display * display) { /* Flush the display connection and look to see if events are queued */ - XFlush(display); - if (XEventsQueued(display, QueuedAlready)) { + X11_XFlush(display); + if (X11_XEventsQueued(display, QueuedAlready)) { return (1); } @@ -919,7 +919,7 @@ X11_Pending(Display * display) FD_ZERO(&fdset); FD_SET(x11_fd, &fdset); if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) { - return (XPending(display)); + return (X11_XPending(display)); } } @@ -942,7 +942,7 @@ X11_PumpEvents(_THIS) Uint32 now = SDL_GetTicks(); if (!data->screensaver_activity || (int) (now - data->screensaver_activity) >= 30000) { - XResetScreenSaver(data->display); + X11_XResetScreenSaver(data->display); #if SDL_USE_LIBDBUS SDL_dbus_screensaver_tickle(_this); @@ -971,16 +971,16 @@ X11_SuspendScreenSaver(_THIS) int major_version, minor_version; if (SDL_X11_HAVE_XSS) { - /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ - if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) || - !XScreenSaverQueryVersion(data->display, + /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ + if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) || + !X11_XScreenSaverQueryVersion(data->display, &major_version, &minor_version) || major_version < 1 || (major_version == 1 && minor_version < 1)) { return; } - XScreenSaverSuspend(data->display, _this->suspend_screensaver); - XResetScreenSaver(data->display); + X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver); + X11_XResetScreenSaver(data->display); } #endif diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 4dfe0d174..af39147f4 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -43,8 +43,8 @@ static int shm_errhandler(Display *d, XErrorEvent *e) static SDL_bool have_mitshm(void) { /* Only use shared memory on local X servers */ - if ( (SDL_strncmp(XDisplayName(NULL), ":", 1) == 0) || - (SDL_strncmp(XDisplayName(NULL), "unix:", 5) == 0) ) { + if ( (SDL_strncmp(X11_XDisplayName(NULL), ":", 1) == 0) || + (SDL_strncmp(X11_XDisplayName(NULL), "unix:", 5) == 0) ) { return SDL_X11_HAVE_SHM; } return SDL_FALSE; @@ -66,7 +66,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, /* Create the graphics context for drawing */ gcv.graphics_exposures = False; - data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); + data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); if (!data->gc) { return SDL_SetError("Couldn't create graphics context"); } @@ -95,10 +95,10 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, shminfo->readOnly = False; if ( shminfo->shmaddr != (char *)-1 ) { shm_error = False; - X_handler = XSetErrorHandler(shm_errhandler); - XShmAttach(display, shminfo); - XSync(display, True); - XSetErrorHandler(X_handler); + X_handler = X11_XSetErrorHandler(shm_errhandler); + X11_XShmAttach(display, shminfo); + X11_XSync(display, True); + X11_XSetErrorHandler(X_handler); if ( shm_error ) shmdt(shminfo->shmaddr); } else { @@ -109,13 +109,13 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, shm_error = True; } if (!shm_error) { - data->ximage = XShmCreateImage(display, data->visual, + data->ximage = X11_XShmCreateImage(display, data->visual, vinfo.depth, ZPixmap, shminfo->shmaddr, shminfo, window->w, window->h); if (!data->ximage) { - XShmDetach(display, shminfo); - XSync(display, False); + X11_XShmDetach(display, shminfo); + X11_XSync(display, False); shmdt(shminfo->shmaddr); } else { /* Done! */ @@ -132,7 +132,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, return SDL_OutOfMemory(); } - data->ximage = XCreateImage(display, data->visual, + data->ximage = X11_XCreateImage(display, data->visual, vinfo.depth, ZPixmap, 0, (char *)(*pixels), window->w, window->h, 32, 0); if (!data->ximage) { @@ -177,7 +177,7 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, if (y + h > window->h) h = window->h - y; - XShmPutImage(display, data->xwindow, data->gc, data->ximage, + X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage, x, y, x, y, w, h, False); } } @@ -209,12 +209,12 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, if (y + h > window->h) h = window->h - y; - XPutImage(display, data->xwindow, data->gc, data->ximage, + X11_XPutImage(display, data->xwindow, data->gc, data->ximage, x, y, x, y, w, h); } } - XSync(display, False); + X11_XSync(display, False); return 0; } @@ -237,8 +237,8 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) #ifndef NO_SHARED_MEMORY if (data->use_mitshm) { - XShmDetach(display, &data->shminfo); - XSync(display, False); + X11_XShmDetach(display, &data->shminfo); + X11_XSync(display, False); shmdt(data->shminfo.shmaddr); data->use_mitshm = SDL_FALSE; } @@ -247,7 +247,7 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) data->ximage = NULL; } if (data->gc) { - XFreeGC(display, data->gc); + X11_XFreeGC(display, data->gc); data->gc = NULL; } } diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 6bc7ebbfa..9a2de45a0 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -152,7 +152,7 @@ X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode) int i; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif @@ -182,7 +182,7 @@ X11_KeyCodeToUcs4(Display *display, KeyCode keycode) KeySym keysym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif @@ -211,14 +211,14 @@ X11_InitKeyboard(_THIS) }; SDL_bool fingerprint_detected; - XAutoRepeatOn(data->display); + X11_XAutoRepeatOn(data->display); /* Try to determine which scancodes are being used based on fingerprint */ fingerprint_detected = SDL_FALSE; - XDisplayKeycodes(data->display, &min_keycode, &max_keycode); + X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode); for (i = 0; i < SDL_arraysize(fingerprint); ++i) { fingerprint[i].value = - XKeysymToKeycode(data->display, fingerprint[i].keysym) - + X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) - min_keycode; } for (i = 0; i < SDL_arraysize(scancode_set); ++i) { @@ -258,14 +258,14 @@ X11_InitKeyboard(_THIS) for (i = min_keycode; i <= max_keycode; ++i) { KeySym sym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - sym = XkbKeycodeToKeysym(data->display, i, 0, 0); + sym = X11_XkbKeycodeToKeysym(data->display, i, 0, 0); #else sym = XKeycodeToKeysym(data->display, i, 0); #endif if (sym != NoSymbol) { SDL_Scancode scancode; printf("code = %d, sym = 0x%X (%s) ", i - min_keycode, - (unsigned int) sym, XKeysymToString(sym)); + (unsigned int) sym, X11_XKeysymToString(sym)); scancode = X11_KeyCodeToSDLScancode(data->display, i); data->key_layout[i] = scancode; if (scancode == SDL_SCANCODE_UNKNOWN) { diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index f938ded8b..0d0ffb75e 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -124,13 +124,13 @@ GetTextWidthHeight( SDL_MessageBoxDataX11 *data, const char *str, int nbytes, in { if (SDL_X11_HAVE_UTF8) { XRectangle overall_ink, overall_logical; - Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical); + X11_Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical); *pwidth = overall_logical.width; *pheight = overall_logical.height; } else { XCharStruct text_structure; int font_direction, font_ascent, font_descent; - XTextExtents( data->font_struct, str, nbytes, + X11_XTextExtents( data->font_struct, str, nbytes, &font_direction, &font_ascent, &font_descent, &text_structure ); *pwidth = text_structure.width; @@ -180,7 +180,7 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess data->numbuttons = numbuttons; data->pbuttonid = pbuttonid; - data->display = XOpenDisplay( NULL ); + data->display = X11_XOpenDisplay( NULL ); if ( !data->display ) { return SDL_SetError("Couldn't open X11 display"); } @@ -188,16 +188,16 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess if (SDL_X11_HAVE_UTF8) { char **missing = NULL; int num_missing = 0; - data->font_set = XCreateFontSet(data->display, g_MessageBoxFont, + data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont, &missing, &num_missing, NULL); if ( missing != NULL ) { - XFreeStringList(missing); + X11_XFreeStringList(missing); } if ( data->font_set == NULL ) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { - data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); + data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); if ( data->font_struct == NULL ) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } @@ -338,23 +338,23 @@ static void X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data ) { if ( data->font_set != NULL ) { - XFreeFontSet( data->display, data->font_set ); + X11_XFreeFontSet( data->display, data->font_set ); data->font_set = NULL; } if ( data->font_struct != NULL ) { - XFreeFont( data->display, data->font_struct ); + X11_XFreeFont( data->display, data->font_struct ); data->font_struct = NULL; } if ( data->display ) { if ( data->window != None ) { - XWithdrawWindow( data->display, data->window, data->screen ); - XDestroyWindow( data->display, data->window ); + X11_XWithdrawWindow( data->display, data->window, data->screen ); + X11_XDestroyWindow( data->display, data->window ); data->window = None; } - XCloseDisplay( data->display ); + X11_XCloseDisplay( data->display ); data->display = NULL; } } @@ -384,7 +384,7 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) StructureNotifyMask | FocusChangeMask | PointerMotionMask; wnd_attr.event_mask = data->event_mask; - data->window = XCreateWindow( + data->window = X11_XCreateWindow( display, RootWindow(display, data->screen), 0, 0, data->dialog_width, data->dialog_height, @@ -396,31 +396,31 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) if ( windowdata ) { /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */ - XSetTransientForHint( display, data->window, windowdata->xwindow ); + X11_XSetTransientForHint( display, data->window, windowdata->xwindow ); } - XStoreName( display, data->window, messageboxdata->title ); + X11_XStoreName( display, data->window, messageboxdata->title ); /* Allow the window to be deleted by the window manager */ - data->wm_protocols = XInternAtom( display, "WM_PROTOCOLS", False ); - data->wm_delete_message = XInternAtom( display, "WM_DELETE_WINDOW", False ); - XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 ); + data->wm_protocols = X11_XInternAtom( display, "WM_PROTOCOLS", False ); + data->wm_delete_message = X11_XInternAtom( display, "WM_DELETE_WINDOW", False ); + X11_XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 ); if ( windowdata ) { XWindowAttributes attrib; Window dummy; - XGetWindowAttributes(display, windowdata->xwindow, &attrib); + X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib); x = attrib.x + ( attrib.width - data->dialog_width ) / 2; y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ; - XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy); + X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy); } else { x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2; y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ; } - XMoveWindow( display, data->window, x, y ); + X11_XMoveWindow( display, data->window, x, y ); - sizehints = XAllocSizeHints(); + sizehints = X11_XAllocSizeHints(); if ( sizehints ) { sizehints->flags = USPosition | USSize | PMaxSize | PMinSize; sizehints->x = x; @@ -431,12 +431,12 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) sizehints->min_width = sizehints->max_width = data->dialog_width; sizehints->min_height = sizehints->max_height = data->dialog_height; - XSetWMNormalHints( display, data->window, sizehints ); + X11_XSetWMNormalHints( display, data->window, sizehints ); - XFree( sizehints ); + X11_XFree( sizehints ); } - XMapRaised( display, data->window ); + X11_XMapRaised( display, data->window ); return 0; } @@ -448,19 +448,19 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) Window window = data->window; Display *display = data->display; - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); - XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); + X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); for ( i = 0; i < data->numlines; i++ ) { TextLineData *plinedata = &data->linedata[ i ]; if (SDL_X11_HAVE_UTF8) { - Xutf8DrawString( display, window, data->font_set, ctx, + X11_Xutf8DrawString( display, window, data->font_set, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } else { - XDrawString( display, window, ctx, + X11_XDrawString( display, window, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } @@ -472,27 +472,27 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0; int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0; - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); - XFillRectangle( display, window, ctx, + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); + X11_XFillRectangle( display, window, ctx, buttondatax11->rect.x - border, buttondatax11->rect.y - border, buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border ); - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); - XDrawRectangle( display, window, ctx, + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); + X11_XDrawRectangle( display, window, ctx, buttondatax11->rect.x, buttondatax11->rect.y, buttondatax11->rect.w, buttondatax11->rect.h ); - XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? + X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] : data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); if (SDL_X11_HAVE_UTF8) { - Xutf8DrawString( display, window, data->font_set, ctx, + X11_Xutf8DrawString( display, window, data->font_set, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } else { - XDrawString( display, window, ctx, + X11_XDrawString( display, window, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } @@ -519,7 +519,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) ctx_vals.font = data->font_struct->fid; } - ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals ); + ctx = X11_XCreateGC( data->display, data->window, gcflags, &ctx_vals ); if ( ctx == None ) { return SDL_SetError("Couldn't create graphics context"); } @@ -531,11 +531,11 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) XEvent e; SDL_bool draw = SDL_TRUE; - XWindowEvent( data->display, data->window, data->event_mask, &e ); + X11_XWindowEvent( data->display, data->window, data->event_mask, &e ); - /* If XFilterEvent returns True, then some input method has filtered the + /* If X11_XFilterEvent returns True, then some input method has filtered the event, and the client should discard the event. */ - if ( ( e.type != Expose ) && XFilterEvent( &e, None ) ) + if ( ( e.type != Expose ) && X11_XFilterEvent( &e, None ) ) continue; switch( e.type ) { @@ -574,12 +574,12 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) case KeyPress: /* Store key press - we make sure in key release that we got both. */ - last_key_pressed = XLookupKeysym( &e.xkey, 0 ); + last_key_pressed = X11_XLookupKeysym( &e.xkey, 0 ); break; case KeyRelease: { Uint32 mask = 0; - KeySym key = XLookupKeysym( &e.xkey, 0 ); + KeySym key = X11_XLookupKeysym( &e.xkey, 0 ); /* If this is a key release for something we didn't get the key down for, then bail. */ if ( key != last_key_pressed ) @@ -637,7 +637,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) } } - XFreeGC( data->display, ctx ); + X11_XFreeGC( data->display, ctx ); return 0; } @@ -667,7 +667,7 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) #endif /* This code could get called from multiple threads maybe? */ - XInitThreads(); + X11_XInitThreads(); /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */ *buttonid = -1; @@ -707,7 +707,7 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) int status = 0; /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */ - XFlush(data->display); + X11_XFlush(data->display); if (pipe(fds) == -1) { return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */ diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 472416ccd..a4c242cdc 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -54,20 +54,20 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) SDL_zero(template); template.visualid = SDL_strtol(visual_id, NULL, 0); - vi = XGetVisualInfo(display, VisualIDMask, &template, &nvis); + vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis); if (vi) { *vinfo = *vi; - XFree(vi); + X11_XFree(vi); return 0; } } depth = DefaultDepth(display, screen); if ((X11_UseDirectColorVisuals() && - XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) || - XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) || - XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) || - XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) { + X11_XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) || + X11_XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) || + X11_XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) || + X11_XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) { return 0; } return -1; @@ -79,11 +79,11 @@ X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vi XVisualInfo *vi; int nvis; - vinfo->visualid = XVisualIDFromVisual(visual); - vi = XGetVisualInfo(display, VisualIDMask, vinfo, &nvis); + vinfo->visualid = X11_XVisualIDFromVisual(visual); + vi = X11_XGetVisualInfo(display, VisualIDMask, vinfo, &nvis); if (vi) { *vinfo = *vi; - XFree(vi); + X11_XFree(vi); return 0; } return -1; @@ -108,7 +108,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) bpp = vinfo->depth; if (bpp == 24) { int i, n; - XPixmapFormatValues *p = XListPixmapFormats(display, &n); + XPixmapFormatValues *p = X11_XListPixmapFormats(display, &n); if (p) { for (i = 0; i < n; ++i) { if (p[i].depth == 24) { @@ -116,7 +116,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) break; } } - XFree(p); + X11_XFree(p); } } @@ -178,9 +178,9 @@ CheckXinerama(Display * display, int *major, int *minor) } /* Query the extension version */ - if (!XineramaQueryExtension(display, &event_base, &error_base) || - !XineramaQueryVersion(display, major, minor) || - !XineramaIsActive(display)) { + if (!X11_XineramaQueryExtension(display, &event_base, &error_base) || + !X11_XineramaQueryVersion(display, major, minor) || + !X11_XineramaIsActive(display)) { #ifdef X11MODES_DEBUG printf("Xinerama not active on the display\n"); #endif @@ -228,7 +228,7 @@ CheckXRandR(Display * display, int *major, int *minor) } /* Query the extension version */ - if (!XRRQueryVersion(display, major, minor)) { + if (!X11_XRRQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XRandR not active on the display\n"); #endif @@ -261,10 +261,10 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, XRROutputInfo *outp Rotation rotation = 0; const XRRModeInfo *info = &res->modes[i]; - crtc = XRRGetCrtcInfo(display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); if (crtc) { rotation = crtc->rotation; - XRRFreeCrtcInfo(crtc); + X11_XRRFreeCrtcInfo(crtc); } if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) { @@ -313,8 +313,8 @@ CheckVidMode(Display * display, int *major, int *minor) /* Query the extension version */ vm_error = -1; - if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error) - || !XF86VidModeQueryVersion(display, major, minor)) { + if (!X11_XF86VidModeQueryExtension(display, &vm_event, &vm_error) + || !X11_XF86VidModeQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XVidMode not active on the display\n"); #endif @@ -335,7 +335,7 @@ Bool XF86VidModeGetModeInfo(Display * dpy, int scr, XF86VidModeModeLine l; SDL_zerop(info); SDL_zero(l); - retval = XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); + retval = X11_XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); info->dotclock = dotclock; info->hdisplay = l.hdisplay; info->hsyncstart = l.hsyncstart; @@ -397,7 +397,7 @@ X11_InitModes(_THIS) * or newer of the Nvidia binary drivers */ if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) { - xinerama = XineramaQueryScreens(data->display, &screencount); + xinerama = X11_XineramaQueryScreens(data->display, &screencount); if (xinerama) { use_xinerama = xinerama_major * 100 + xinerama_minor; } @@ -501,7 +501,7 @@ X11_InitModes(_THIS) displaydata->depth = vinfo.depth; displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8; - pixmapFormats = XListPixmapFormats(data->display, &n); + pixmapFormats = X11_XListPixmapFormats(data->display, &n); if (pixmapFormats) { for (i = 0; i < n; ++i) { if (pixmapFormats[i].depth == displaydata->depth) { @@ -509,7 +509,7 @@ X11_InitModes(_THIS) break; } } - XFree(pixmapFormats); + X11_XFree(pixmapFormats); } #if SDL_VIDEO_DRIVER_X11_XINERAMA @@ -526,13 +526,13 @@ X11_InitModes(_THIS) #if SDL_VIDEO_DRIVER_X11_XRANDR if (use_xrandr) { - res = XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen)); + res = X11_XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen)); } if (res) { XRROutputInfo *output_info; XRRCrtcInfo *crtc; int output; - Atom EDID = XInternAtom(data->display, "EDID", False); + Atom EDID = X11_XInternAtom(data->display, "EDID", False); Atom *props; int nprop; unsigned long width_mm; @@ -540,10 +540,10 @@ X11_InitModes(_THIS) int inches = 0; for (output = 0; output < res->noutput; output++) { - output_info = XRRGetOutputInfo(data->display, res, res->outputs[output]); + output_info = X11_XRRGetOutputInfo(data->display, res, res->outputs[output]); if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { - XRRFreeOutputInfo(output_info); + X11_XRRFreeOutputInfo(output_info); continue; } @@ -551,10 +551,10 @@ X11_InitModes(_THIS) We're checking the crtc position, but that may not be a valid test in all cases. Anybody want to give this some love? */ - crtc = XRRGetCrtcInfo(data->display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(data->display, res, output_info->crtc); if (!crtc || crtc->x != displaydata->x || crtc->y != displaydata->y) { - XRRFreeOutputInfo(output_info); - XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeCrtcInfo(crtc); continue; } @@ -570,7 +570,7 @@ X11_InitModes(_THIS) SDL_strlcpy(display_name, output_info->name, sizeof(display_name)); /* See if we can get the EDID data for the real monitor name */ - props = XRRListOutputProperties(data->display, res->outputs[output], &nprop); + props = X11_XRRListOutputProperties(data->display, res->outputs[output], &nprop); for (i = 0; i < nprop; ++i) { unsigned char *prop; int actual_format; @@ -578,7 +578,7 @@ X11_InitModes(_THIS) Atom actual_type; if (props[i] == EDID) { - if (XRRGetOutputProperty(data->display, + if (X11_XRRGetOutputProperty(data->display, res->outputs[output], props[i], 0, 100, False, False, AnyPropertyType, @@ -593,13 +593,13 @@ X11_InitModes(_THIS) SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name)); free(info); } - XFree(prop); + X11_XFree(prop); } break; } } if (props) { - XFree(props); + X11_XFree(props); } if (*display_name && inches) { @@ -610,8 +610,8 @@ X11_InitModes(_THIS) printf("Display name: %s\n", display_name); #endif - XRRFreeOutputInfo(output_info); - XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeCrtcInfo(crtc); break; } #ifdef X11MODES_DEBUG @@ -619,7 +619,7 @@ X11_InitModes(_THIS) printf("Couldn't find XRandR CRTC at %d,%d\n", displaydata->x, displaydata->y); } #endif - XRRFreeScreenResources(res); + X11_XRRFreeScreenResources(res); } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ @@ -652,7 +652,7 @@ X11_InitModes(_THIS) } #if SDL_VIDEO_DRIVER_X11_XINERAMA - if (xinerama) XFree(xinerama); + if (xinerama) X11_XFree(xinerama); #endif if (_this->num_displays == 0) { @@ -725,13 +725,13 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) if (data->use_xrandr) { XRRScreenResources *res; - res = XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); if (res) { SDL_DisplayModeData *modedata; XRROutputInfo *output_info; int i; - output_info = XRRGetOutputInfo(display, res, data->xrandr_output); + output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); if (output_info && output_info->connection != RR_Disconnected) { for (i = 0; i < output_info->nmode; ++i) { modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData)); @@ -747,8 +747,8 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) } } } - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); } return; } @@ -756,7 +756,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) #if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode && - XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) { + X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) { int i; #ifdef X11MODES_DEBUG @@ -780,7 +780,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) SDL_free(modedata); } } - XFree(modes); + X11_XFree(modes); return; } #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ @@ -811,41 +811,41 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode XRRCrtcInfo *crtc; Status status; - res = XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); if (!res) { return SDL_SetError("Couldn't get XRandR screen resources"); } - output_info = XRRGetOutputInfo(display, res, data->xrandr_output); + output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); if (!output_info || output_info->connection == RR_Disconnected) { - XRRFreeScreenResources(res); + X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR output info"); } - crtc = XRRGetCrtcInfo(display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); if (!crtc) { - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR crtc info"); } - status = XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime, + status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime, crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation, &data->xrandr_output, 1); - XRRFreeCrtcInfo(crtc); - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); if (status != Success) { - return SDL_SetError("XRRSetCrtcConfig failed"); + return SDL_SetError("X11_XRRSetCrtcConfig failed"); } } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ #if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode) { - XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode); + X11_XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode); } #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ @@ -872,11 +872,11 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) if (data->use_xinerama) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; int screencount; - XineramaScreenInfo *xinerama = XineramaQueryScreens(display, &screencount); + XineramaScreenInfo *xinerama = X11_XineramaQueryScreens(display, &screencount); if (xinerama) { rect->x = xinerama[data->xinerama_screen].x_org; rect->y = xinerama[data->xinerama_screen].y_org; - XFree(xinerama); + X11_XFree(xinerama); } } #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 441ecdfe3..4bcd9d6c8 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -50,12 +50,12 @@ X11_CreateEmptyCursor() SDL_zero(data); color.red = color.green = color.blue = 0; - pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), data, 1, 1); if (pixmap) { - x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap, + x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap, &color, &color, 0, 0); - XFreePixmap(display, pixmap); + X11_XFreePixmap(display, pixmap); } } return x11_empty_cursor; @@ -65,7 +65,7 @@ static void X11_DestroyEmptyCursor(void) { if (x11_empty_cursor != None) { - XFreeCursor(GetDisplay(), x11_empty_cursor); + X11_XFreeCursor(GetDisplay(), x11_empty_cursor); x11_empty_cursor = None; } } @@ -94,7 +94,7 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) Cursor cursor = None; XcursorImage *image; - image = XcursorImageCreate(surface->w, surface->h); + image = X11_XcursorImageCreate(surface->w, surface->h); if (!image) { SDL_OutOfMemory(); return None; @@ -107,9 +107,9 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) SDL_assert(surface->pitch == surface->w * 4); SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch); - cursor = XcursorImageLoadCursor(display, image); + cursor = X11_XcursorImageLoadCursor(display, image); - XcursorImageDestroy(image); + X11_XcursorImageDestroy(image); return cursor; } @@ -186,16 +186,16 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) } else bg.red = bg.green = bg.blue = 0; - data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), (char*)data_bits, surface->w, surface->h); - mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), (char*)mask_bits, surface->w, surface->h); - cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap, + cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap, &fg, &bg, hot_x, hot_y); - XFreePixmap(display, data_pixmap); - XFreePixmap(display, mask_pixmap); + X11_XFreePixmap(display, data_pixmap); + X11_XFreePixmap(display, mask_pixmap); return cursor; } @@ -256,7 +256,7 @@ X11_CreateSystemCursor(SDL_SystemCursor id) if (cursor) { Cursor x11_cursor; - x11_cursor = XCreateFontCursor(GetDisplay(), shape); + x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape); cursor->driverdata = (void*)x11_cursor; } else { @@ -272,7 +272,7 @@ X11_FreeCursor(SDL_Cursor * cursor) Cursor x11_cursor = (Cursor)cursor->driverdata; if (x11_cursor != None) { - XFreeCursor(GetDisplay(), x11_cursor); + X11_XFreeCursor(GetDisplay(), x11_cursor); } SDL_free(cursor); } @@ -298,12 +298,12 @@ X11_ShowCursor(SDL_Cursor * cursor) for (window = video->windows; window; window = window->next) { data = (SDL_WindowData *)window->driverdata; if (x11_cursor != None) { - XDefineCursor(display, data->xwindow, x11_cursor); + X11_XDefineCursor(display, data->xwindow, x11_cursor); } else { - XUndefineCursor(display, data->xwindow); + X11_XUndefineCursor(display, data->xwindow); } } - XFlush(display); + X11_XFlush(display); } return 0; } @@ -314,8 +314,8 @@ X11_WarpMouse(SDL_Window * window, int x, int y) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y); - XSync(display, False); + X11_XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y); + X11_XSync(display, False); } static int diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 67a4b06cc..74165f407 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -320,16 +320,16 @@ X11_GL_InitExtensions(_THIS) xattr.background_pixel = 0; xattr.border_pixel = 0; xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), vinfo->visual, + X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual, AllocNone); - w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, + w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } - XFree(vinfo); + X11_XFree(vinfo); glXQueryExtensionsStringFunc = (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, @@ -385,7 +385,7 @@ X11_GL_InitExtensions(_THIS) _this->gl_data->glXMakeCurrent(display, None, NULL); _this->gl_data->glXDestroyContext(display, context); } - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); X11_PumpEvents(_this); } @@ -566,13 +566,13 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) } /* We do this to create a clean separation between X and GLX errors. */ - XSync(display, False); + X11_XSync(display, False); errorBase = _this->gl_data->errorBase; - handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler); - XGetWindowAttributes(display, data->xwindow, &xattr); + handler = X11_XSetErrorHandler(X11_GL_CreateContextErrorHandler); + X11_XGetWindowAttributes(display, data->xwindow, &xattr); v.screen = screen; - v.visualid = XVisualIDFromVisual(xattr.visual); - vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); + v.visualid = X11_XVisualIDFromVisual(xattr.visual); + vinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); if (vinfo) { if (_this->gl_config.major_version < 3 && _this->gl_config.profile_mask == 0 && @@ -656,10 +656,10 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) } } } - XFree(vinfo); + X11_XFree(vinfo); } - XSync(display, False); - XSetErrorHandler(handler); + X11_XSync(display, False); + X11_XSetErrorHandler(handler); if (!context) { SDL_SetError("Could not create GL context"); @@ -801,7 +801,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context) return; } _this->gl_data->glXDestroyContext(display, glx_context); - XSync(display, False); + X11_XSync(display, False); } #endif /* SDL_VIDEO_OPENGL_GLX */ diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 98183258f..f972ceeeb 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -74,13 +74,13 @@ X11_GLES_GetVisual(_THIS, Display * display, int screen) &visual_id) == EGL_FALSE || !visual_id) { /* Use the default visual when all else fails */ vi_in.screen = screen; - egl_visualinfo = XGetVisualInfo(display, + egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask, &vi_in, &out_count); } else { vi_in.screen = screen; vi_in.visualid = visual_id; - egl_visualinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); + egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); } return egl_visualinfo; @@ -93,9 +93,9 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XSync(display, False); + X11_XSync(display, False); context = SDL_EGL_CreateContext(_this, data->egl_surface); - XSync(display, False); + X11_XSync(display, False); return context; } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 67eeade8a..af89851e6 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -106,12 +106,12 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8); windowdata = (SDL_WindowData*)(shaper->window->driverdata); - shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); + shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); - XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); - XSync(windowdata->videodata->display,False); + X11_XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); + X11_XSync(windowdata->videodata->display,False); - XFreePixmap(windowdata->videodata->display,shapemask); + X11_XFreePixmap(windowdata->videodata->display,shapemask); #endif return 0; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 5ed47d5e8..c84d4ec68 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -230,9 +230,9 @@ X11_Available(void) { Display *display = NULL; if (SDL_X11_LoadSymbols()) { - display = XOpenDisplay(NULL); + display = X11_XOpenDisplay(NULL); if (display != NULL) { - XCloseDisplay(display); + X11_XCloseDisplay(display); } SDL_X11_UnloadSymbols(); } @@ -244,7 +244,7 @@ X11_DeleteDevice(SDL_VideoDevice * device) { SDL_VideoData *data = (SDL_VideoData *) device->driverdata; if (data->display) { - XCloseDisplay(data->display); + X11_XCloseDisplay(data->display); } SDL_free(data->windowlist); SDL_free(device->driverdata); @@ -296,7 +296,7 @@ X11_CreateDevice(int devindex) /* Need for threading gl calls. This is also required for the proprietary nVidia driver to be threaded. */ - XInitThreads(); + X11_XInitThreads(); /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); @@ -313,14 +313,14 @@ X11_CreateDevice(int devindex) device->driverdata = data; /* FIXME: Do we need this? - if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) || - (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) { + if ( (SDL_strncmp(X11_XDisplayName(display), ":", 1) == 0) || + (SDL_strncmp(X11_XDisplayName(display), "unix:", 5) == 0) ) { local_X11 = 1; } else { local_X11 = 0; } */ - data->display = XOpenDisplay(display); + data->display = X11_XOpenDisplay(display); #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) /* On Tru64 if linking without -lX11, it fails and you get following message. * Xlib: connection to ":0.0" refused by server @@ -331,7 +331,7 @@ X11_CreateDevice(int devindex) */ if (data->display == NULL) { SDL_Delay(1000); - data->display = XOpenDisplay(display); + data->display = X11_XOpenDisplay(display); } #endif if (data->display == NULL) { @@ -341,12 +341,12 @@ X11_CreateDevice(int devindex) return NULL; } #ifdef X11_DEBUG - XSynchronize(data->display, True); + X11_XSynchronize(data->display, True); #endif /* Hook up an X11 error handler to recover the desktop resolution. */ safety_net_triggered = SDL_FALSE; - orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler); + orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler); /* Set the function pointers */ device->VideoInit = X11_VideoInit; @@ -448,31 +448,31 @@ X11_CheckWindowManager(_THIS) #endif /* Set up a handler to gracefully catch errors */ - XSync(display, False); - handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler); + X11_XSync(display, False); + handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler); - _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); - status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); + status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && items_read) { wm_window = ((Window*)propdata)[0]; } if (propdata) { - XFree(propdata); + X11_XFree(propdata); } if (wm_window) { - status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) { wm_window = None; } if (propdata) { - XFree(propdata); + X11_XFree(propdata); } } /* Reset the error handler, we're done checking */ - XSync(display, False); - XSetErrorHandler(handler); + X11_XSync(display, False); + X11_XSetErrorHandler(handler); if (!wm_window) { #ifdef DEBUG_WINDOW_MANAGER @@ -505,12 +505,12 @@ X11_VideoInit(_THIS) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = - XOpenIM(data->display, NULL, data->classname, data->classname); + X11_XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* Look up some useful Atoms */ -#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) +#define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); @@ -568,7 +568,7 @@ X11_VideoQuit(_THIS) SDL_free(data->classname); #ifdef X_HAVE_UTF8_STRING if (data->im) { - XCloseIM(data->im); + X11_XCloseIM(data->im); } #endif diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 18ff443ad..120b803ca 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -61,11 +61,11 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win) /* static Bool -XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) +X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) { Uint32 start = SDL_GetTicks(); - while (!XCheckIfEvent(display, event_return, predicate, arg)) { + while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) { if ((SDL_GetTicks() - start) >= timeoutMS) { return False; } @@ -88,7 +88,7 @@ X11_IsWindowMapped(_THIS, SDL_Window * window) SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; XWindowAttributes attr; - XGetWindowAttributes(videodata->display, data->xwindow, &attr); + X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr); if (attr.map_state != IsUnmapped) { return SDL_TRUE; } else { @@ -110,7 +110,7 @@ X11_IsActionAllowed(SDL_Window *window, Atom action) Atom *list; SDL_bool ret = SDL_FALSE; - if (XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) + if (X11_XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) { for (i=0; i 0) { - XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32, + X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, count); } else { - XDeleteProperty(display, xwindow, _NET_WM_STATE); + X11_XDeleteProperty(display, xwindow, _NET_WM_STATE); } } @@ -183,7 +183,7 @@ X11_GetNetWMState(_THIS, Window xwindow) long maxLength = 1024; Uint32 flags = 0; - if (XGetWindowProperty(display, xwindow, _NET_WM_STATE, + if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE, 0l, maxLength, False, XA_ATOM, &actualType, &actualFormat, &numItems, &bytesAfter, &propertyValue) == Success) { @@ -209,7 +209,7 @@ X11_GetNetWMState(_THIS, Window xwindow) } else if (fullscreen == 1) { flags |= SDL_WINDOW_FULLSCREEN; } - XFree(propertyValue); + X11_XFree(propertyValue); } /* FIXME, check the size hints for resizable */ @@ -237,7 +237,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8 && videodata->im) { data->ic = - pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, + X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNResourceName, videodata->classname, XNResourceClass, videodata->classname, NULL); @@ -270,7 +270,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { XWindowAttributes attrib; - XGetWindowAttributes(data->videodata->display, w, &attrib); + X11_XGetWindowAttributes(data->videodata->display, w, &attrib); window->x = attrib.x; window->y = attrib.y; window->w = attrib.width; @@ -289,7 +289,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { Window FocalWindow; int RevertTo=0; - XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); + X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); if (FocalWindow==w) { window->flags |= SDL_WINDOW_INPUT_FOCUS; @@ -318,7 +318,7 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) * Gnome is similar: just use the Motif atom. */ - Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); + Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { /* Hints used by Motif compliant window managers */ struct @@ -332,11 +332,11 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) (1L << 1), 0, border ? 1 : 0, 0, 0 }; - XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32, + X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32, PropModeReplace, (unsigned char *) &MWMHints, sizeof(MWMHints) / 4); } else { /* set the transient hints instead, if necessary */ - XSetTransientForHint(display, window, RootWindow(display, screen)); + X11_XSetTransientForHint(display, window, RootWindow(display, screen)); } } @@ -389,7 +389,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } visual = vinfo->visual; depth = vinfo->depth; - XFree(vinfo); + X11_XFree(vinfo); } else #endif { @@ -410,7 +410,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) int rshift, gshift, bshift; xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), + X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocAll); /* If we can't create a colormap, then we must die */ @@ -471,16 +471,16 @@ X11_CreateWindow(_THIS, SDL_Window * window) colorcells[i].flags = DoRed | DoGreen | DoBlue; } - XStoreColors(display, xattr.colormap, colorcells, ncolors); + X11_XStoreColors(display, xattr.colormap, colorcells, ncolors); SDL_free(colorcells); } else { xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), + X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocNone); } - w = XCreateWindow(display, RootWindow(display, screen), + w = X11_XCreateWindow(display, RootWindow(display, screen), window->x, window->y, window->w, window->h, 0, depth, InputOutput, visual, (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | @@ -492,7 +492,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) SetWindowBordered(display, screen, w, (window->flags & SDL_WINDOW_BORDERLESS) == 0); - sizehints = XAllocSizeHints(); + sizehints = X11_XAllocSizeHints(); /* Setup the normal size hints */ sizehints->flags = 0; if (!(window->flags & SDL_WINDOW_RESIZABLE)) { @@ -505,25 +505,25 @@ X11_CreateWindow(_THIS, SDL_Window * window) sizehints->flags |= USPosition; /* Setup the input hints so we get keyboard input */ - wmhints = XAllocWMHints(); + wmhints = X11_XAllocWMHints(); wmhints->input = True; wmhints->flags = InputHint; /* Setup the class hints so we can get an icon (AfterStep) */ - classhints = XAllocClassHint(); + classhints = X11_XAllocClassHint(); classhints->res_name = data->classname; classhints->res_class = data->classname; /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */ - XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints); + X11_XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints); - XFree(sizehints); - XFree(wmhints); - XFree(classhints); + X11_XFree(sizehints); + X11_XFree(wmhints); + X11_XFree(classhints); /* Set the PID related to the window for the given hostname, if possible */ if (data->pid > 0) { - _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False); - XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, + _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False); + X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&data->pid, 1); } @@ -531,14 +531,14 @@ X11_CreateWindow(_THIS, SDL_Window * window) X11_SetNetWMState(_this, w, window->flags); /* Let the window manager know we're a "normal" window */ - _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); - _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); - XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, + _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + _NET_WM_WINDOW_TYPE_NORMAL = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1); - _NET_WM_BYPASS_COMPOSITOR = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); - XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, + _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); + X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1); @@ -547,11 +547,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */ data->_NET_WM_PING, /* Respond so WM knows we're alive */ }; - XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0])); + X11_XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0])); } if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return -1; } windowdata = (SDL_WindowData *) window->driverdata; @@ -564,7 +564,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) #endif ) { if (!_this->egl_data) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return -1; } @@ -572,7 +572,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); if (windowdata->egl_surface == EGL_NO_SURFACE) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return SDL_SetError("Could not create GLES window surface"); } } @@ -581,25 +581,25 @@ X11_CreateWindow(_THIS, SDL_Window * window) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8 && windowdata->ic) { - pXGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL); + X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL); } #endif X11_Xinput2SelectTouch(_this, window); - XSelectInput(display, w, + X11_XSelectInput(display, w, (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask | PropertyChangeMask | StructureNotifyMask | KeymapStateMask | fevent)); - XdndAware = XInternAtom(display, "XdndAware", False); - XChangeProperty(display, w, XdndAware, XA_ATOM, 32, + XdndAware = X11_XInternAtom(display, "XdndAware", False); + X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&xdnd_version, 1); - XFlush(display); + X11_XFlush(display); return 0; } @@ -628,14 +628,14 @@ X11_GetWindowTitle(_THIS, Window xwindow) unsigned char *propdata; char *title = NULL; - status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, + status = X11_XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && propdata) { title = SDL_strdup(SDL_static_cast(char*, propdata)); - XFree(propdata); + X11_XFree(propdata); } else { - status = XGetWindowProperty(display, xwindow, XA_WM_NAME, + status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME, 0L, 8192L, False, XA_STRING, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && propdata) { @@ -668,21 +668,21 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_OutOfMemory(); return; } - status = XStringListToTextProperty(&title_locale, 1, &titleprop); + status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop); SDL_free(title_locale); if (status) { - XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME); - XFree(titleprop.value); + X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME); + X11_XFree(titleprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { status = - Xutf8TextListToTextProperty(display, (char **) &title, 1, + X11_Xutf8TextListToTextProperty(display, (char **) &title, 1, XUTF8StringStyle, &titleprop); if (status == Success) { - XSetTextProperty(display, data->xwindow, &titleprop, + X11_XSetTextProperty(display, data->xwindow, &titleprop, _NET_WM_NAME); - XFree(titleprop.value); + X11_XFree(titleprop.value); } } #endif @@ -693,27 +693,27 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_OutOfMemory(); return; } - status = XStringListToTextProperty(&icon_locale, 1, &iconprop); + status = X11_XStringListToTextProperty(&icon_locale, 1, &iconprop); SDL_free(icon_locale); if (status) { - XSetTextProperty(display, data->xwindow, &iconprop, + X11_XSetTextProperty(display, data->xwindow, &iconprop, XA_WM_ICON_NAME); - XFree(iconprop.value); + X11_XFree(iconprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { status = - Xutf8TextListToTextProperty(display, (char **) &icon, 1, + X11_Xutf8TextListToTextProperty(display, (char **) &icon, 1, XUTF8StringStyle, &iconprop); if (status == Success) { - XSetTextProperty(display, data->xwindow, &iconprop, + X11_XSetTextProperty(display, data->xwindow, &iconprop, _NET_WM_ICON_NAME); - XFree(iconprop.value); + X11_XFree(iconprop.value); } } #endif } - XFlush(display); + X11_XFlush(display); } void @@ -745,15 +745,15 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) *dst++ = *src++; } } - XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, + X11_XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) propdata, propsize); } SDL_free(propdata); } else { - XDeleteProperty(display, data->xwindow, _NET_WM_ICON); + X11_XDeleteProperty(display, data->xwindow, _NET_WM_ICON); } - XFlush(display); + X11_XFlush(display); } void @@ -762,8 +762,8 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XMoveWindow(display, data->xwindow, window->x, window->y); - XFlush(display); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XFlush(display); } void @@ -773,26 +773,26 @@ X11_SetWindowMinimumSize(_THIS, SDL_Window * window) Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->min_width = window->min_w; sizehints->min_height = window->min_h; sizehints->flags |= PMinSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* See comment in X11_SetWindowSize. */ - XResizeWindow(display, data->xwindow, window->w, window->h); - XMoveWindow(display, data->xwindow, window->x, window->y); - XRaiseWindow(display, data->xwindow); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XRaiseWindow(display, data->xwindow); } - XFlush(display); + X11_XFlush(display); } void @@ -802,26 +802,26 @@ X11_SetWindowMaximumSize(_THIS, SDL_Window * window) Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->max_width = window->max_w; sizehints->max_height = window->max_h; sizehints->flags |= PMaxSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* See comment in X11_SetWindowSize. */ - XResizeWindow(display, data->xwindow, window->w, window->h); - XMoveWindow(display, data->xwindow, window->x, window->y); - XRaiseWindow(display, data->xwindow); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XRaiseWindow(display, data->xwindow); } - XFlush(display); + X11_XFlush(display); } void @@ -834,20 +834,20 @@ X11_SetWindowSize(_THIS, SDL_Window * window) X11_ResizeWindowShape(window); } if (!(window->flags & SDL_WINDOW_RESIZABLE)) { - /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus + /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus we must set the size hints to adjust the window size. */ - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->min_width = sizehints->max_width = window->w; sizehints->min_height = sizehints->max_height = window->h; sizehints->flags |= PMinSize | PMaxSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* From Pierre-Loup: WMs each have their little quirks with that. When you change the @@ -865,14 +865,14 @@ X11_SetWindowSize(_THIS, SDL_Window * window) hide/show, because there are supposedly subtle problems with doing so and transitioning from windowed to fullscreen in Unity. */ - XResizeWindow(display, data->xwindow, window->w, window->h); - XMoveWindow(display, data->xwindow, window->x, window->y); - XRaiseWindow(display, data->xwindow); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XRaiseWindow(display, data->xwindow); } else { - XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); } - XFlush(display); + X11_XFlush(display); } void @@ -887,25 +887,25 @@ X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) XEvent event; SetWindowBordered(display, displaydata->screen, data->xwindow, bordered); - XFlush(display); - XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow); + X11_XFlush(display); + X11_XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow); if (visible) { XWindowAttributes attr; do { - XSync(display, False); - XGetWindowAttributes(display, data->xwindow, &attr); + X11_XSync(display, False); + X11_XGetWindowAttributes(display, data->xwindow, &attr); } while (attr.map_state != IsViewable); if (focused) { - XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime); + X11_XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime); } } /* make sure these don't make it to the real event queue if they fired here. */ - XSync(display, False); - XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); - XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); + X11_XSync(display, False); + X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); } void @@ -916,12 +916,12 @@ X11_ShowWindow(_THIS, SDL_Window * window) XEvent event; if (!X11_IsWindowMapped(_this, window)) { - XMapRaised(display, data->xwindow); + X11_XMapRaised(display, data->xwindow); /* Blocking wait for "MapNotify" event. - * We use XIfEvent because XWindowEvent takes a mask rather than a type, + * We use X11_XIfEvent because pXWindowEvent takes a mask rather than a type, * and XCheckTypedWindowEvent doesn't block */ - XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); - XFlush(display); + X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); + X11_XFlush(display); } } @@ -934,10 +934,10 @@ X11_HideWindow(_THIS, SDL_Window * window) XEvent event; if (X11_IsWindowMapped(_this, window)) { - XWithdrawWindow(display, data->xwindow, displaydata->screen); + X11_XWithdrawWindow(display, data->xwindow, displaydata->screen); /* Blocking wait for "UnmapNotify" event */ - XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); - XFlush(display); + X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XFlush(display); } } @@ -962,10 +962,10 @@ SetWindowActive(_THIS, SDL_Window * window) e.xclient.data.l[1] = CurrentTime; e.xclient.data.l[2] = 0; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); - XFlush(display); + X11_XFlush(display); } } @@ -975,9 +975,9 @@ X11_RaiseWindow(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XRaiseWindow(display, data->xwindow); + X11_XRaiseWindow(display, data->xwindow); SetWindowActive(_this, window); - XFlush(display); + X11_XFlush(display); } static void @@ -1011,12 +1011,12 @@ SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; e.xclient.data.l[3] = 0l; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { X11_SetNetWMState(_this, data->xwindow, window->flags); } - XFlush(display); + X11_XFlush(display); } void @@ -1033,8 +1033,8 @@ X11_MinimizeWindow(_THIS, SDL_Window * window) (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; - XIconifyWindow(display, data->xwindow, displaydata->screen); - XFlush(display); + X11_XIconifyWindow(display, data->xwindow, displaydata->screen); + X11_XFlush(display); } void @@ -1061,9 +1061,9 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (!(window->flags & SDL_WINDOW_RESIZABLE)) { /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we can be resized to the fullscreen resolution (or reset so we're not resizable again) */ - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long flags = 0; - XGetWMNormalHints(display, data->xwindow, sizehints, &flags); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags); /* set the resize flags on */ if (fullscreen) { /* we are going fullscreen so turn the flags off */ @@ -1074,8 +1074,8 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis sizehints->min_width = sizehints->max_width = window->windowed.w; sizehints->min_height = sizehints->max_height = window->windowed.h; } - XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XFree(sizehints); } SDL_zero(e); @@ -1088,7 +1088,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; e.xclient.data.l[3] = 0l; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { Uint32 flags; @@ -1104,13 +1104,13 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (data->visual->class == DirectColor) { if ( fullscreen ) { - XInstallColormap(display, data->colormap); + X11_XInstallColormap(display, data->colormap); } else { - XUninstallColormap(display, data->colormap); + X11_XUninstallColormap(display, data->colormap); } } - XFlush(display); + X11_XFlush(display); } /* This handles fullscreen itself, outside the Window Manager. */ @@ -1145,48 +1145,48 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ xattr.colormap = data->colormap; xattrmask |= CWColormap; - data->fswindow = XCreateWindow(display, root, + data->fswindow = X11_XCreateWindow(display, root, rect.x, rect.y, rect.w, rect.h, 0, displaydata->depth, InputOutput, visual, xattrmask, &xattr); - XSelectInput(display, data->fswindow, StructureNotifyMask); - XSetWindowBackground(display, data->fswindow, 0); - XInstallColormap(display, data->colormap); - XClearWindow(display, data->fswindow); - XMapRaised(display, data->fswindow); + X11_XSelectInput(display, data->fswindow, StructureNotifyMask); + X11_XSetWindowBackground(display, data->fswindow, 0); + X11_XInstallColormap(display, data->colormap); + X11_XClearWindow(display, data->fswindow); + X11_XMapRaised(display, data->fswindow); /* Make sure the fswindow is in view by warping mouse to the corner */ - XUngrabPointer(display, CurrentTime); - XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); + X11_XUngrabPointer(display, CurrentTime); + X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Wait to be mapped, filter Unmap event out if it arrives. */ - XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow); - XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow); + X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow); + X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow); #if SDL_VIDEO_DRIVER_X11_XVIDMODE if ( displaydata->use_vidmode ) { - XF86VidModeLockModeSwitch(display, screen, True); + X11_XF86VidModeLockModeSwitch(display, screen, True); } #endif SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE); /* Center actual window within our cover-the-screen window. */ - XReparentWindow(display, data->xwindow, data->fswindow, + X11_XReparentWindow(display, data->xwindow, data->fswindow, (rect.w - window->w) / 2, (rect.h - window->h) / 2); /* Move the mouse to the upper left to make sure it's on-screen */ - XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); + X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Center mouse in the fullscreen window. */ rect.x += (rect.w / 2); rect.y += (rect.h / 2); - XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); + X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Wait to be mapped, filter Unmap event out if it arrives. */ - XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); - XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); SDL_UpdateWindowGrab(window); } @@ -1210,27 +1210,27 @@ X11_EndWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _di #if SDL_VIDEO_DRIVER_X11_VIDMODE if ( displaydata->use_vidmode ) { - XF86VidModeLockModeSwitch(display, screen, False); + X11_XF86VidModeLockModeSwitch(display, screen, False); } #endif SDL_UpdateWindowGrab(window); - XReparentWindow(display, data->xwindow, root, window->x, window->y); + X11_XReparentWindow(display, data->xwindow, root, window->x, window->y); /* flush these events so they don't confuse normal event handling */ - XSync(display, False); - XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); - XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XSync(display, False); + X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); SetWindowBordered(display, screen, data->xwindow, (window->flags & SDL_WINDOW_BORDERLESS) == 0); - XWithdrawWindow(display, fswindow, screen); + X11_XWithdrawWindow(display, fswindow, screen); /* Wait to be unmapped. */ - XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow); - XDestroyWindow(display, fswindow); + X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow); + X11_XDestroyWindow(display, fswindow); } @@ -1328,8 +1328,8 @@ X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) colorcells[i].flags = DoRed | DoGreen | DoBlue; } - XStoreColors(display, colormap, colorcells, ncolors); - XFlush(display); + X11_XStoreColors(display, colormap, colorcells, ncolors); + X11_XFlush(display); SDL_free(colorcells); return 0; @@ -1354,7 +1354,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) /* Try to grab the mouse */ for (;;) { int result = - XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, + X11_XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, GrabModeAsync, data->xwindow, None, CurrentTime); if (result == GrabSuccess) { break; @@ -1363,7 +1363,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) } /* Raise the window if we grab the mouse */ - XRaiseWindow(display, data->xwindow); + X11_XRaiseWindow(display, data->xwindow); /* Now grab the keyboard */ hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD); @@ -1376,14 +1376,14 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) grab_keyboard = oldstyle_fullscreen; } if (grab_keyboard) { - XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, + X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, GrabModeAsync, CurrentTime); } } else { - XUngrabPointer(display, CurrentTime); - XUngrabKeyboard(display, CurrentTime); + X11_XUngrabPointer(display, CurrentTime); + X11_XUngrabKeyboard(display, CurrentTime); } - XSync(display, False); + X11_XSync(display, False); } void @@ -1411,12 +1411,12 @@ X11_DestroyWindow(_THIS, SDL_Window * window) } #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XDestroyIC(data->ic); + X11_XDestroyIC(data->ic); } #endif if (data->created) { - XDestroyWindow(display, data->xwindow); - XFlush(display); + X11_XDestroyWindow(display, data->xwindow); + X11_XFlush(display); } SDL_free(data); } diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 10b422882..3f84bbd77 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -36,7 +36,7 @@ static int xinput2_initialized = 0; static int xinput2_multitouch_supported = 0; #endif -/* Opcode returned XQueryExtension +/* Opcode returned X11_XQueryExtension * It will be used in event processing * to know that the event came from * this extension */ @@ -82,16 +82,16 @@ X11_InitXinput2(_THIS) * "As XI2 progresses it becomes important that you use this call as the server may treat the client * differently depending on the supported version". * - * FIXME:event and err are not needed but if not passed XQueryExtension returns SegmentationFault + * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault */ if (!SDL_X11_HAVE_XINPUT2 || - !XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { + !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { return; } outmajor = major; outminor = minor; - if (XIQueryVersion(data->display, &outmajor, &outminor) != Success) { + if (X11_XIQueryVersion(data->display, &outmajor, &outminor) != Success) { return; } @@ -115,7 +115,7 @@ X11_InitXinput2(_THIS) XISetMask(mask, XI_RawMotion); - if (XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) { + if (X11_XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) { return; } #endif @@ -226,7 +226,7 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window) XISetMask(mask, XI_TouchUpdate); XISetMask(mask, XI_TouchEnd); - XISelectEvents(data->display,window_data->xwindow,&eventmask,1); + X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1); #endif } From a999af88e9757d71697480ad027dd074ee470d28 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 23:02:29 -0700 Subject: [PATCH 193/258] Fixed building using MinGW Our SDL_windows.h needed to be included before anything else so UNICODE is defined. --- src/SDL.c | 5 ++++- src/SDL_assert.c | 6 ++++-- src/SDL_log.c | 8 +++++--- src/atomic/SDL_spinlock.c | 8 ++++---- src/core/windows/SDL_windows.c | 2 +- src/cpuinfo/SDL_cpuinfo.c | 7 ++++--- src/file/SDL_rwops.c | 7 +++++-- src/joystick/windows/SDL_mmjoystick.c | 11 ++++++++--- src/main/windows/SDL_windows_main.c | 6 +++--- src/render/direct3d/SDL_render_d3d.c | 1 - src/render/software/SDL_rotate.c | 4 ++-- src/stdlib/SDL_getenv.c | 5 ++++- src/test/SDL_test_common.c | 6 +++--- src/thread/windows/SDL_systhread.c | 4 ++-- src/thread/windows/SDL_systls.c | 4 ++-- src/video/windows/SDL_windowsmessagebox.c | 6 +++++- src/video/windows/SDL_windowsvideo.h | 4 ++-- src/video/windows/SDL_windowswindow.c | 2 ++ test/configure | 2 +- test/configure.in | 2 +- 20 files changed, 62 insertions(+), 38 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index b1111159a..619a0c1f8 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#endif + /* Initialization code for SDL */ #include "SDL.h" @@ -443,7 +447,6 @@ SDL_GetPlatform() #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) /* Need to include DllMain() on Watcom C for some reason.. */ -#include "core/windows/SDL_windows.h" BOOL APIENTRY _DllMainCRTStartup(HANDLE hModule, diff --git a/src/SDL_assert.c b/src/SDL_assert.c index a4cf6434f..41c6ad6c0 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#endif + #include "SDL.h" #include "SDL_atomic.h" #include "SDL_messagebox.h" @@ -29,8 +33,6 @@ #include "video/SDL_sysvideo.h" #ifdef __WIN32__ -#include "core/windows/SDL_windows.h" - #ifndef WS_OVERLAPPEDWINDOW #define WS_OVERLAPPEDWINDOW 0 #endif diff --git a/src/SDL_log.c b/src/SDL_log.c index 802a6f25c..18611ca9b 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#endif + /* Simple log messages in SDL */ #include "SDL_log.h" @@ -28,9 +32,7 @@ #include #endif -#if defined(__WIN32__) -#include "core/windows/SDL_windows.h" -#elif defined(__ANDROID__) +#if defined(__ANDROID__) #include #endif diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index f3aeea0e2..0826a3f92 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -20,14 +20,14 @@ */ #include "SDL_config.h" +#ifdef __WIN32__ +#include "../core/windows/SDL_windows.h" +#endif + #include "SDL_atomic.h" #include "SDL_mutex.h" #include "SDL_timer.h" -/* Don't do the check for Visual Studio 2005, it's safe here */ -#ifdef __WIN32__ -#include "../core/windows/SDL_windows.h" -#endif /* This function is where all the magic happens... */ SDL_bool diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index e69d25793..6ac86a6e6 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -22,8 +22,8 @@ #ifdef __WIN32__ -#include "SDL_error.h" #include "SDL_windows.h" +#include "SDL_error.h" #include "SDL_assert.h" #include /* for CoInitialize/CoUninitialize */ diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 5e048f9c3..2b81f9117 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "../core/windows/SDL_windows.h" +#endif + /* CPU feature detection for SDL */ #include "SDL_cpuinfo.h" @@ -41,9 +45,6 @@ #include #include #endif -#ifdef __WIN32__ -#include "../core/windows/SDL_windows.h" -#endif #define CPU_HAS_RDTSC 0x00000001 #define CPU_HAS_ALTIVEC 0x00000002 diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index dc89e22fb..d71dbfdf3 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -22,6 +22,11 @@ #define _LARGEFILE64_SOURCE #include "SDL_config.h" +#if defined(__WIN32__) +#include "../core/windows/SDL_windows.h" +#endif + + /* This file provides a general interface for SDL to read and write data sources. It can easily be extended to files, memory, etc. */ @@ -42,8 +47,6 @@ /* Functions to read/write Win32 API file pointers */ -#include "../core/windows/SDL_windows.h" - #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER 0xFFFFFFFF #endif diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c index f236dff96..e012d4466 100644 --- a/src/joystick/windows/SDL_mmjoystick.c +++ b/src/joystick/windows/SDL_mmjoystick.c @@ -33,6 +33,11 @@ #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" +#ifdef REGSTR_VAL_JOYOEMNAME +#undef REGSTR_VAL_JOYOEMNAME +#endif +#define REGSTR_VAL_JOYOEMNAME "OEMName" + #define MAX_JOYSTICKS 16 #define MAX_AXES 6 /* each joystick can have up to 6 axes */ #define MAX_BUTTONS 32 /* and 32 buttons */ @@ -45,7 +50,7 @@ /* array to hold joystick ID values */ static UINT SYS_JoystickID[MAX_JOYSTICKS]; -static JOYCAPS SYS_Joystick[MAX_JOYSTICKS]; +static JOYCAPSA SYS_Joystick[MAX_JOYSTICKS]; static char *SYS_JoystickName[MAX_JOYSTICKS]; /* The private structure used to keep track of a joystick */ @@ -148,7 +153,7 @@ SDL_SYS_JoystickInit(void) int i; int maxdevs; JOYINFOEX joyinfo; - JOYCAPS joycaps; + JOYCAPSA joycaps; MMRESULT result; /* Reset the joystick ID & name mapping tables */ @@ -166,7 +171,7 @@ SDL_SYS_JoystickInit(void) joyinfo.dwFlags = JOY_RETURNALL; result = joyGetPosEx(i, &joyinfo); if (result == JOYERR_NOERROR) { - result = joyGetDevCaps(i, &joycaps, sizeof(joycaps)); + result = joyGetDevCapsA(i, &joycaps, sizeof(joycaps)); if (result == JOYERR_NOERROR) { SYS_JoystickID[SDL_SYS_numjoysticks] = i; SYS_Joystick[SDL_SYS_numjoysticks] = joycaps; diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 519ce14b8..4e8e3f2f4 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -7,12 +7,12 @@ #ifdef __WIN32__ +/* Include this so we define UNICODE properly */ +#include "../../core/windows/SDL_windows.h" + #include #include -#define WIN32_LEAN_AND_MEAN -#include - /* Include the SDL main definition header */ #include "SDL.h" #include "SDL_main.h" diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 33665e370..67cddb387 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -22,7 +22,6 @@ #if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED - #include "../../core/windows/SDL_windows.h" #include "SDL_hints.h" diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 628c8d534..44678cba5 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -30,8 +30,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net */ #include "SDL_config.h" -#ifdef WIN32 -#include +#if defined(__WIN32__) +#include "../../core/windows/SDL_windows.h" #endif #include diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 0cd440549..10fa7c5c1 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -20,10 +20,13 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "../core/windows/SDL_windows.h" +#endif + #include "SDL_stdinc.h" #if !defined(SDL_setenv) && defined(__WIN32__) -#include "../core/windows/SDL_windows.h" /* Note this isn't thread-safe! */ static char *SDL_envmem = NULL; /* Ugh, memory leak */ static size_t SDL_envmemlen = 0; diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 981e3cdcb..3bb2f0a7c 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1107,10 +1107,10 @@ SDLTest_PrintEvent(SDL_Event * event) case SDL_FINGERDOWN: case SDL_FINGERUP: - fprintf(stderr, "Finger: %s touch=%lld, finger=%lld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f", + fprintf(stderr, "Finger: %s touch=%ld, finger=%ld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f", (event->type == SDL_FINGERDOWN) ? "down" : "up", - (long long) event->tfinger.touchId, - (long long) event->tfinger.fingerId, + (long) event->tfinger.touchId, + (long) event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure); break; diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 8efcd5089..4386e841f 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -116,8 +116,8 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) int SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { - pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex; - pfnSDL_CurrentEndThread pfnEndThread = _endthreadex; + pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex; + pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex; #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ pThreadStartParms pThreadParms = (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 0ece77dd0..90941ee62 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -20,13 +20,13 @@ */ #include "SDL_config.h" -#include "SDL_thread.h" -#include "../SDL_thread_c.h" #if SDL_THREAD_WINDOWS #include "../../core/windows/SDL_windows.h" +#include "SDL_thread.h" +#include "../SDL_thread_c.h" static DWORD thread_local_storage = TLS_OUT_OF_INDEXES; static SDL_bool generic_local_storage = SDL_FALSE; diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index f54425902..e50c542ed 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -22,7 +22,11 @@ #if SDL_VIDEO_DRIVER_WINDOWS -#include "SDL.h" +#if defined(__WIN32__) +#include "../../core/windows/SDL_windows.h" +#endif + +#include "SDL_assert.h" #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index b00d71375..ff2b4a2ac 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -23,10 +23,10 @@ #ifndef _SDL_windowsvideo_h #define _SDL_windowsvideo_h -#include "../SDL_sysvideo.h" - #include "../../core/windows/SDL_windows.h" +#include "../SDL_sysvideo.h" + #if defined(_MSC_VER) #include #else diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 0c5e5bbed..cd53975d1 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -22,6 +22,8 @@ #if SDL_VIDEO_DRIVER_WINDOWS +#include "../../core/windows/SDL_windows.h" + #include "SDL_assert.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" diff --git a/test/configure b/test/configure index 94a2f1394..136606c77 100755 --- a/test/configure +++ b/test/configure @@ -3452,7 +3452,7 @@ rm -f core conftest.err conftest.$ac_objext \ rm -f conf.sdltest CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS $SDL_LIBS -lSDL2_test" +LIBS="$LIBS -lSDL2_test $SDL_LIBS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' diff --git a/test/configure.in b/test/configure.in index a18609715..eb3028747 100644 --- a/test/configure.in +++ b/test/configure.in @@ -86,7 +86,7 @@ AM_PATH_SDL2($SDL_VERSION, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) ) CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS $SDL_LIBS -lSDL2_test" +LIBS="$LIBS -lSDL2_test $SDL_LIBS" dnl Check for X11 path, needed for OpenGL on some systems AC_PATH_X From 26b26c8f01dc39d120ce316296f1420558f5aba8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 23:05:40 -0700 Subject: [PATCH 194/258] Removed redundant #ifdef --- src/video/windows/SDL_windowsmessagebox.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index e50c542ed..b2a59532a 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -22,9 +22,7 @@ #if SDL_VIDEO_DRIVER_WINDOWS -#if defined(__WIN32__) #include "../../core/windows/SDL_windows.h" -#endif #include "SDL_assert.h" #include "SDL_windowsvideo.h" From 6c8cb100a0591c43f6e9742e02a9eac427326ade Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 23:15:27 -0700 Subject: [PATCH 195/258] Fixed 1598 - Mingwin build fails on src/audio/xaudio2/SDL_xaudio2.c --- src/audio/xaudio2/SDL_xaudio2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index 4f378ea3d..557c3bb9a 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -48,6 +48,18 @@ /* Hidden "this" pointer for the audio functions */ #define _THIS SDL_AudioDevice *this +/* Fixes bug 1210 where some versions of gcc need named parameters */ +#ifdef __GNUC__ +#ifdef THIS +#undef THIS +#endif +#define THIS INTERFACE *p +#ifdef THIS_ +#undef THIS_ +#endif +#define THIS_ INTERFACE *p, +#endif + struct SDL_PrivateAudioData { IXAudio2 *ixa2; From 4a8f77da844a95924a1a07aa944f8e84d0fdf2fa Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 23:40:13 -0700 Subject: [PATCH 196/258] Fixed bug 2069 - Device addition/removal queries all USB devices rather than only HID devices. Andreas Ertelt SDL_dxjoystick.c is setting the classguid for device (dis)connect events to USB Devices in general: dbh.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; Wouldn't it make more sense to have it just subscribe to Hid device events? This would mean less meaningless events reaching the application. --- src/joystick/windows/SDL_dxjoystick.c | 5 +++-- src/joystick/windows/SDL_dxjoystick_c.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 54d54d26d..69393279e 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -53,6 +53,8 @@ #define DIDFT_OPTIONAL 0x80000000 #endif +DEFINE_GUID(GUID_DEVINTERFACE_HID, 0x4D1E55B2L, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30); + #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ #define AXIS_MIN -32768 /* minimum value for axis coordinate */ @@ -387,7 +389,6 @@ SDL_IsXInputDevice( const GUID* pGuidProductFromDirectInput ) }; size_t iDevice; - SDL_bool retval = SDL_FALSE; UINT i; if (!s_bXInputEnabled) { @@ -507,7 +508,7 @@ SDL_JoystickThread(void *_data) dbh.dbcc_size = sizeof(dbh); dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; - dbh.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; + dbh.dbcc_classguid = GUID_DEVINTERFACE_HID; hNotify = RegisterDeviceNotification( messageWindow, &dbh, DEVICE_NOTIFY_WINDOW_HANDLE ); if ( !hNotify ) diff --git a/src/joystick/windows/SDL_dxjoystick_c.h b/src/joystick/windows/SDL_dxjoystick_c.h index 1b2717216..1a4703e5e 100644 --- a/src/joystick/windows/SDL_dxjoystick_c.h +++ b/src/joystick/windows/SDL_dxjoystick_c.h @@ -42,7 +42,7 @@ #include #include #include -#include + #ifndef XUSER_MAX_COUNT #define XUSER_MAX_COUNT 4 From 84d31202577fe33026347bdae8623d0dd7e72e23 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 17 Oct 2013 23:44:30 -0700 Subject: [PATCH 197/258] Fixed bug 2155 - automatically remap accelerometer coordinates according to screen orientation on Android Denis Bernard Background information: http://android-developers.blogspot.fr/2010/09/one-screen-turn-deserves-another.html and http://developer.android.com/reference/android/hardware/SensorEvent.html Right now, the Android accelerometer event handler feeds raw accelerometer data to the SDL Joystick driver. The result is that for landscape-only applications, the axis need to be swapped if running on a portrait device (like a phone), and vice-versa: running a portrait only app on a landscape device like a tablet. The purpose of this patch is to perform coordinate remapping of the accelerometer data before feeding it to the SDL joystick driver so that the X axis of the joystick is always aligned with the X axis of the display, same for the Y axis. This has been tested on applications that support screen orientation changes as well as applications with fixed screen orientations, both on phones and tablets. --- .../src/org/libsdl/app/SDLActivity.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 1e194fa3d..02b6ebd61 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -433,6 +433,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // Sensors protected static SensorManager mSensorManager; + protected static Display mDisplay; // Keep track of the surface size to normalize touch events protected static float mWidth, mHeight; @@ -448,6 +449,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, setOnKeyListener(this); setOnTouchListener(this); + mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); // Some arbitrary defaults to avoid a potential division by zero @@ -621,8 +623,27 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - SDLActivity.onNativeAccel(event.values[0] / SensorManager.GRAVITY_EARTH, - event.values[1] / SensorManager.GRAVITY_EARTH, + float x, y; + switch (mDisplay.getRotation()) { + case Surface.ROTATION_90: + x = -event.values[1]; + y = event.values[0]; + break; + case Surface.ROTATION_270: + x = event.values[1]; + y = -event.values[0]; + break; + case Surface.ROTATION_180: + x = -event.values[1]; + y = -event.values[0]; + break; + default: + x = event.values[0]; + y = event.values[1]; + break; + } + SDLActivity.onNativeAccel(x / SensorManager.GRAVITY_EARTH, + y / SensorManager.GRAVITY_EARTH, event.values[2] / SensorManager.GRAVITY_EARTH); } } From 6cdb720c6775a4c2d8837467139ad22e2f28f5ed Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 18 Oct 2013 00:13:51 -0700 Subject: [PATCH 198/258] Fixed bug 2139 - SDL_CreateWindow/WIN_GL_LoadLibrary fails due to external iconv not being able to convert path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jānis Rūcis Brief history: We recently ported a game from SDL 1.2 to SDL 2. While doing Windows testing, I soon discovered that the game exits without opening a window with my cross-compiled SDL2.dll, but works great with the SDL2.dll from the MinGW SDK on libsdl.org. It was as simple as swapping out the DLLs to make it work. Running the game in Wine showed that the game actually does run, up until the call to SDL_CreateWindow, which fails and leads the game to print out an error: Failure to create window (LoadLibrary("OPENGL32.DLL"): (null)) Which basically says that there was no error, but maybe that's a Wine quirk. The error string originates in SDL_windowsopengl.c, in WIN_GL_LoadLibrary, which contains this piece of code: wpath = WIN_UTF8ToString(path); _this->gl_config.dll_handle = LoadLibrary(wpath); SDL_free(wpath); if (!_this->gl_config.dll_handle) { char message[1024]; SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")", path); return WIN_SetError(message); } After some digging, I discovered the culprit: WIN_UTF8ToString returns NULL. Why? Because it calls iconv_open from an iconv.dll that does not support the UCS-2-INTERNAL encoding. Why does the official SDL2.dll work? Because it calls no external iconv functions at all. It turns out that the Fedora MinGW infrastructure (from which I obtained the conventiently prebuilt iconv.dll) does not provide a DLL from libiconv, but instead provides a DLL from a minimal Windows library called win-iconv. Which knows a good bit, but doesn't know anything about UCS-2-INTERNAL: http://code.google.com/p/win-iconv/source/browse/trunk/win_iconv.c#155 So there are two problems here: 1) The error message is clearly useless, because LoadLibrary is an innocent bystander. Instead wpath should probably checked for NULL, and a more appropriate error should be set. Ideally something that makes it clear than an external iconv is causing trouble. 2) SDL doomed itself at the ./configure step, by finding an existing iconv and happily using it without confirming support for the mandatory encodings required by SDL. There are certainly a few easy ways out of the situation (although I didn't yet manage to figure out how to prevent ./configure from looking for external iconv), but this had me completely stomped for a good while, so I figured it's worth writing down if anything. (Search also found this, which talks a little about using UTF-16LE instead of UCS-2-INTERNAL: https://bugzilla.libsdl.org/show_bug.cgi?id=2075) --- src/core/windows/SDL_windows.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 91a7f4614..90cd6b2ab 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -35,11 +35,9 @@ #include /* Routines to convert from UTF8 to native Windows text */ -/* !!! FIXME: should we force Unicode at this point? */ #if UNICODE -/* !!! FIXME: UCS-2 should be UTF-16 on Windows. */ -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", (char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) #else /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) From ef02b8a4ce6a422c653c2de88f3aed2281b9e4b8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 18 Oct 2013 00:47:22 -0700 Subject: [PATCH 199/258] Fixed bug 2123 - SDL_BlitScaled crashes in src/video/SDL_blit_N.c:2145 We need to reset the blit function when switching between scaled and unscaled blits. --- src/video/SDL_surface.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 1c4631c40..8418bc302 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -596,6 +596,12 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, h -= dy; } + /* Switch back to a fast blit if we were previously stretching */ + if (src->map->info.flags & SDL_COPY_NEAREST) { + src->map->info.flags &= ~SDL_COPY_NEAREST; + SDL_InvalidateMap(src->map); + } + if (w > 0 && h > 0) { SDL_Rect sr; sr.x = srcx; @@ -747,7 +753,10 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, return 0; } - src->map->info.flags |= SDL_COPY_NEAREST; + if (!(src->map->info.flags & SDL_COPY_NEAREST)) { + src->map->info.flags |= SDL_COPY_NEAREST; + SDL_InvalidateMap(src->map); + } if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format && From 8f23826dccb7cd9c9d491d15e76560448182b08f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 18 Oct 2013 00:49:59 -0700 Subject: [PATCH 200/258] Fixed bug 2108 - CMake does not set X11 includes properly for sdl2-config and friends Marcus von Appen The autotools-based code uses X_CFLAGS and some hackish x_includes code to add some necessary includes to SDL_CFLAGS for proper X11 and OpenGL include handling. At the moment, the cmake-baed build code does not do that. Below is a patch, which provides the necessary changes to add a proper include to the SDL_CFLAGS. --- cmake/sdlchecks.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 5666f52fc..fe763785c 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -304,6 +304,11 @@ macro(CheckX11) endif() endforeach() + find_path(X_INCLUDEDIR X11/Xlib.h) + if(X_INCLUDEDIR) + set(X_CFLAGS "-I${X_INCLUDEDIR}") + endif() + check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H) check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H) check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H) @@ -345,6 +350,7 @@ macro(CheckX11) endif(HAVE_SHMAT) if(NOT HAVE_SHMAT) add_definitions(-DNO_SHARED_MEMORY) + set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY") endif(NOT HAVE_SHMAT) endif(NOT HAVE_SHMAT) @@ -367,6 +373,8 @@ macro(CheckX11) endif(HAVE_X11_SHARED) endif(X11_SHARED) + set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}") + set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB}) check_c_source_compiles(" #include From 54a9270523df4c1e145fe5fe5fa14b7693dae5e6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 18 Oct 2013 10:56:45 -0400 Subject: [PATCH 201/258] Fixed the XInput2 X11 symbols. --- src/video/x11/SDL_x11xinput2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 3f84bbd77..719d2e351 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -179,7 +179,7 @@ X11_InitXinput2Multitouch(_THIS) SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; XIDeviceInfo *info; int ndevices,i,j; - info = XIQueryDevice(data->display, XIAllMasterDevices, &ndevices); + info = X11_XIQueryDevice(data->display, XIAllMasterDevices, &ndevices); for (i = 0; i < ndevices; i++) { XIDeviceInfo *dev = &info[i]; @@ -198,7 +198,7 @@ X11_InitXinput2Multitouch(_THIS) } } } - XIFreeDeviceInfo(info); + X11_XIFreeDeviceInfo(info); #endif } From 473d52d0928176e0de2cfefea214dfe2692ca878 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 19 Oct 2013 01:29:23 -0700 Subject: [PATCH 202/258] Fixed bug 2162 - SDL_RenderClear not clearing entire render target Kevin Wells Overview: SDL_RenderClear is only clearing part of a texture when it is the render target and a different size than the screen. Steps to Reproduce: 1) This only occurs with the render driver set to direct3d, so: SDL_SetHint(SDL_HINT_RENDER_DRIVER,"direct3d") Also, my window was 1280x720. 2) Create a texture for a render target with a resolution of 1024x1024: texture=SDL_CreateTexture(main_window.renderer,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_TARGET,1024,1024); SDL_SetTextureBlendMode(texture,SDL_BLENDMODE_BLEND); 3) Target the texture for rendering: SDL_SetRenderTarget(main_window.renderer,texture); 4) Set the draw color to whatever you want (problem occurs with both 0,0,0,0 and 0,0,0,255 among others) and then clear the render target: SDL_SetRenderDrawColor(main_window.renderer,0,0,0,0); SDL_RenderClear(main_window.renderer); Actual Results: Only about the top 3/4s of the texture gets cleared on calling SDL_RenderClear. The bottom 1/4 or so does not clear. Expected Results: Entire render target should be cleared. --- src/render/direct3d/SDL_render_d3d.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 67cddb387..285ddb761 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1216,6 +1216,7 @@ D3D_RenderClear(SDL_Renderer * renderer) D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; DWORD color; HRESULT result; + int BackBufferWidth, BackBufferHeight; if (D3D_ActivateRenderer(renderer) < 0) { return -1; @@ -1223,10 +1224,18 @@ D3D_RenderClear(SDL_Renderer * renderer) color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + if (renderer->target) { + BackBufferWidth = renderer->target->w; + BackBufferHeight = renderer->target->h; + } else { + BackBufferWidth = data->pparams.BackBufferWidth; + BackBufferHeight = data->pparams.BackBufferHeight; + } + /* Don't reset the viewport if we don't have to! */ if (!renderer->viewport.x && !renderer->viewport.y && - renderer->viewport.w == data->pparams.BackBufferWidth && - renderer->viewport.h == data->pparams.BackBufferHeight) { + renderer->viewport.w == BackBufferWidth && + renderer->viewport.h == BackBufferHeight) { result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); } else { D3DVIEWPORT9 viewport; @@ -1234,8 +1243,8 @@ D3D_RenderClear(SDL_Renderer * renderer) /* Clear is defined to clear the entire render target */ viewport.X = 0; viewport.Y = 0; - viewport.Width = data->pparams.BackBufferWidth; - viewport.Height = data->pparams.BackBufferHeight; + viewport.Width = BackBufferWidth; + viewport.Height = BackBufferHeight; viewport.MinZ = 0.0f; viewport.MaxZ = 1.0f; IDirect3DDevice9_SetViewport(data->device, &viewport); From 4d8c9bdc1f318881f6e37950b05ac65b6f4490bc Mon Sep 17 00:00:00 2001 From: Stefanos Apostolopoulos Date: Sun, 20 Oct 2013 17:23:43 +0200 Subject: [PATCH 203/258] Fix bug 1300 by querying current border size in ConfigureNotify, and adjusting window coordinates accordingly. --- src/video/x11/SDL_x11events.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 593b2bee1..e425212bb 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -519,10 +519,32 @@ X11_DispatchEvent(_THIS) xevent.xconfigure.x, xevent.xconfigure.y, xevent.xconfigure.width, xevent.xconfigure.height); #endif + long border_left = 0; + long border_right = 0; + long border_top = 0; + long border_bottom = 0; + if (data->xwindow) { + Atom _net_frame_extents = XInternAtom(display, "_NET_FRAME_EXTENTS", 0); + Atom type; + int format; + unsigned long nitems, bytes_after; + unsigned char *property; + XGetWindowProperty(display, data->xwindow, + _net_frame_extents, 0, 16, 0, + XA_CARDINAL, &type, &format, + &nitems, &bytes_after, &property); + + border_left = ((long*)property)[0]; + border_right = ((long*)property)[1]; + border_top = ((long*)property)[2]; + border_bottom = ((long*)property)[3]; + } + if (xevent.xconfigure.x != data->last_xconfigure.x || xevent.xconfigure.y != data->last_xconfigure.y) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, - xevent.xconfigure.x, xevent.xconfigure.y); + xevent.xconfigure.x - border_left, + xevent.xconfigure.y - border_top); } if (xevent.xconfigure.width != data->last_xconfigure.width || xevent.xconfigure.height != data->last_xconfigure.height) { From d914072403561ff14d338613edc812c5de6b38f8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 09:58:37 -0700 Subject: [PATCH 204/258] Fixed compiling with the new X11 symbol wrapping --- src/video/x11/SDL_x11events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index e425212bb..df5a04e7e 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -524,12 +524,12 @@ X11_DispatchEvent(_THIS) long border_top = 0; long border_bottom = 0; if (data->xwindow) { - Atom _net_frame_extents = XInternAtom(display, "_NET_FRAME_EXTENTS", 0); + Atom _net_frame_extents = X11_XInternAtom(display, "_NET_FRAME_EXTENTS", 0); Atom type; int format; unsigned long nitems, bytes_after; unsigned char *property; - XGetWindowProperty(display, data->xwindow, + X11_XGetWindowProperty(display, data->xwindow, _net_frame_extents, 0, 16, 0, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &property); From 2a5e664b39c9cb95c1bbcd0dfb48ed51e31ad18b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 10:10:14 -0700 Subject: [PATCH 205/258] Fixed bug 2158 - Pixel missing in SDL_RenderDrawLines Sean McKean I am running Ubuntu 12.04 (GL version 1.4 Mesa 8.0.4) , and on drawing a set of lines through the renderer through SDL_RenderDrawLines() (looped or not) or SDL_RenderDrawRect() I notice a pixel missing. For RenderDrawLines() it seems to be the second point in the sequence; for RenderDrawRect() it is the lower-right. This can be fixed by specifying SDL_RenderDrawPoint(s), but wouldn't it be easier to specify each pixel in a GL_POINTS glBegin/End loop in the OpenGL code, just to make sure? I also ran the same program on Android; the rendering seemed to be correct, which uses glDrawArrays. --- src/render/opengl/SDL_glfuncs.h | 8 ++-- src/render/opengl/SDL_render_gl.c | 61 +++++++------------------------ 2 files changed, 18 insertions(+), 51 deletions(-) diff --git a/src/render/opengl/SDL_glfuncs.h b/src/render/opengl/SDL_glfuncs.h index 7544929fc..4915c64bc 100644 --- a/src/render/opengl/SDL_glfuncs.h +++ b/src/render/opengl/SDL_glfuncs.h @@ -89,8 +89,8 @@ SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func)) SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar)) SDL_PROC(void, glDisable, (GLenum cap)) -SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array)) -SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) +SDL_PROC(void, glDisableClientState, (GLenum array)) +SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode)) SDL_PROC_UNUSED(void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, @@ -103,7 +103,7 @@ SDL_PROC_UNUSED(void, glEdgeFlagPointer, (GLsizei stride, const GLvoid * pointer)) SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag)) SDL_PROC(void, glEnable, (GLenum cap)) -SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array)) +SDL_PROC(void, glEnableClientState, (GLenum array)) SDL_PROC(void, glEnd, (void)) SDL_PROC_UNUSED(void, glEndList, (void)) SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u)) @@ -448,7 +448,7 @@ SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v)) SDL_PROC_UNUSED(void, glVertex4s, (GLshort x, GLshort y, GLshort z, GLshort w)) SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v)) -SDL_PROC_UNUSED(void, glVertexPointer, +SDL_PROC(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 82cceed25..2c219eea0 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1066,61 +1066,28 @@ GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; GL_SetDrawingState(renderer); + data->glTranslatef(0.5f, 0.5f, 0.0f); + data->glVertexPointer(2, GL_FLOAT, 0, points); + data->glEnableClientState(GL_VERTEX_ARRAY); + if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { - data->glBegin(GL_LINE_LOOP); /* GL_LINE_LOOP takes care of the final segment */ - --count; - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); + data->glDrawArrays(GL_LINE_LOOP, 0, count-1); } else { -#if defined(__APPLE__) || defined(__WIN32__) -#else - int x1, y1, x2, y2; -#endif - - data->glBegin(GL_LINE_STRIP); - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); - - /* The line is half open, so we need one more point to complete it. - * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html - * If we have to, we can use vertical line and horizontal line textures - * for vertical and horizontal lines, and then create custom textures - * for diagonal lines and software render those. It's terrible, but at - * least it would be pixel perfect. - */ - data->glBegin(GL_POINTS); -#if defined(__APPLE__) || defined(__WIN32__) - /* Mac OS X and Windows seem to always leave the second point open */ - data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y); -#else - /* Linux seems to leave the right-most or bottom-most point open */ - x1 = points[0].x; - y1 = points[0].y; - x2 = points[count-1].x; - y2 = points[count-1].y; - - if (x1 > x2) { - data->glVertex2f(0.5f + x1, 0.5f + y1); - } else if (x2 > x1) { - data->glVertex2f(0.5f + x2, 0.5f + y2); - } else if (y1 > y2) { - data->glVertex2f(0.5f + x1, 0.5f + y1); - } else if (y2 > y1) { - data->glVertex2f(0.5f + x2, 0.5f + y2); - } -#endif - data->glEnd(); + data->glDrawArrays(GL_LINE_STRIP, 0, count); } + /* Make sure all the line endpoints are closed. + * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html + * Which points need to be drawn varies by driver, so just draw all of them. + */ + data->glDrawArrays(GL_POINTS, 0, count); + data->glDisableClientState(GL_VERTEX_ARRAY); + data->glTranslatef(-0.5f, -0.5f, 0.0f); + return GL_CheckError("", renderer); } From bf136121dad1a8f700d4c287bc4b4d45ba7219ac Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 10:19:51 -0700 Subject: [PATCH 206/258] Fixed bug 1392 - Debian patch: do not propagate -lpthread manuel.montezelo Since the bug report[1] in 2006 Debian is shipping the patch attached. [1] http://bugs.debian.org/375822 Maybe nowadays you don't propagate that library for linking, so maybe the patch should be dropped, but at the moment I do not have an easy/quick way to check it. So I am submitting this report in the case that you consider it useful (even if maybe the patch itself has to be reworked), or otherwise learn if the patch is unneeded or even harmful. --- sdl2-config.in | 2 +- sdl2.pc.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdl2-config.in b/sdl2-config.in index 254a345e6..912de788f 100644 --- a/sdl2-config.in +++ b/sdl2-config.in @@ -45,7 +45,7 @@ while test $# -gt 0; do echo -I@includedir@/SDL2 @SDL_CFLAGS@ ;; @ENABLE_SHARED_TRUE@ --libs) -@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@ +@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ -lSDL2 @ENABLE_SHARED_TRUE@ ;; @ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs) @ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs) diff --git a/sdl2.pc.in b/sdl2.pc.in index b11667dc6..e37c73ebd 100644 --- a/sdl2.pc.in +++ b/sdl2.pc.in @@ -10,6 +10,6 @@ Description: Simple DirectMedia Layer is a cross-platform multimedia library des Version: @SDL_VERSION@ Requires: Conflicts: -Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ +Libs: -L${libdir} @SDL_RLD_FLAGS@ -lSDL2 Libs.private: @SDL_STATIC_LIBS@ Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@ From c3ae637f377d572c09b8d1adc8f30d5290f55f24 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 10:35:51 -0700 Subject: [PATCH 207/258] Use vertex arrays for drawing points in addition to lines --- src/render/opengl/SDL_render_gl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 2c219eea0..51fc9ad73 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1048,15 +1048,17 @@ GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; GL_SetDrawingState(renderer); - data->glBegin(GL_POINTS); - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); + data->glTranslatef(0.5f, 0.5f, 0.0f); + data->glVertexPointer(2, GL_FLOAT, 0, points); + data->glEnableClientState(GL_VERTEX_ARRAY); + + data->glDrawArrays(GL_POINTS, 0, count); + + data->glDisableClientState(GL_VERTEX_ARRAY); + data->glTranslatef(-0.5f, -0.5f, 0.0f); return 0; } From 58b54606920a0d6fbfabd5f35b81a7fe08b0fe07 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 10:39:26 -0700 Subject: [PATCH 208/258] It's okay to quit things more than once. --- src/SDL.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index 619a0c1f8..0f6de9fe6 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -69,8 +69,6 @@ static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) { int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); - /* If this assert triggers there is a mismatch between init and quit calls */ - SDL_assert(SDL_SubsystemRefCount[subsystem_index] > 0); if (SDL_SubsystemRefCount[subsystem_index] > 0) { --SDL_SubsystemRefCount[subsystem_index]; } From cc7596fc7e523ff9db1ca257a428be8c1fc670d3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 15:40:20 -0400 Subject: [PATCH 209/258] Fix adding of XInput devices (thanks, Mitchell!) Partially fixes Bugzilla #2126. --- src/joystick/windows/SDL_dxjoystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 69393279e..d8149a301 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -733,11 +733,11 @@ AddXInputDevice(const Uint8 userid, JoyStick_DeviceData **pContext) pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; + return; /* already in the list. */ } pPrevJoystick = pNewJoystick; pNewJoystick = pNewJoystick->pNext; - return; /* already in the list. */ } pNewJoystick = (JoyStick_DeviceData *) SDL_malloc(sizeof (JoyStick_DeviceData)); From da32e8f576e9542b34b1de95e038da871dff9417 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 15:45:48 -0400 Subject: [PATCH 210/258] Don't bother calling SDL_SYS_HapticEffectType() at all for XInput devices. --- src/haptic/windows/SDL_syshaptic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index f8b909627..c8cbd5989 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1202,10 +1202,13 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { HRESULT ret; - REFGUID type = SDL_SYS_HapticEffectType(base); + REFGUID type = NULL; - if ((type == NULL) && (!haptic->hwdata->bXInputHaptic)) { - goto err_hweffect; + if (!haptic->hwdata->bXInputHaptic) { + type = SDL_SYS_HapticEffectType(base); + if (type == NULL) { + goto err_hweffect; + } } /* Alloc the effect. */ From 0c739575a3355a6875b4a1a4ce507849290d4399 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 15:49:52 -0400 Subject: [PATCH 211/258] Fixed goofy logic in haptic device comparison code. Mitchell Keith Bloch did the research on this bug, and came up with a slightly different patch than this. Partially fixes Bugzilla #2126. --- src/haptic/windows/SDL_syshaptic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index c8cbd5989..09cca96e4 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -636,9 +636,11 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { - if ((joystick->hwdata->bXInputHaptic == haptic->hwdata->bXInputHaptic) && (haptic->hwdata->userid == joystick->hwdata->userid)) { - return 1; - } else { + if ((joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) { + return 0; /* one is XInput, one is not; not the same device. */ + } else if (joystick->hwdata->bXInputHaptic) { /* XInput */ + return (haptic->hwdata->userid == joystick->hwdata->userid); + } else { /* DirectInput */ HRESULT ret; DIDEVICEINSTANCE hap_instance, joy_instance; From 4d56787378a0df982d0d00c0ded2a045b08f298c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 15:55:47 -0400 Subject: [PATCH 212/258] Allow XInput haptics to run for SDL_HAPTIC_INFINITY time (thanks, Mitchell!). Partially fixes Bugzilla #2126. --- src/haptic/windows/SDL_syshaptic.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 09cca96e4..e798cfdb4 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1327,7 +1327,11 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, XINPUT_VIBRATION *vib = &effect->hweffect->vibration; SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ SDL_LockMutex(haptic->hwdata->mutex); - haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); + if(effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) { + haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY; + } else { + haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); + } SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1; } @@ -1560,10 +1564,13 @@ SDL_RunXInputHaptic(void *arg) SDL_Delay(50); SDL_LockMutex(hwdata->mutex); /* If we're currently running and need to stop... */ - if ((hwdata->stopTicks) && (hwdata->stopTicks < SDL_GetTicks())) { - XINPUT_VIBRATION vibration = { 0, 0 }; - hwdata->stopTicks = 0; - XINPUTSETSTATE(hwdata->userid, &vibration); + const Uint32 stopTicks = hwdata->stopTicks; + if (stopTicks) { + if ((stopTicks != SDL_HAPTIC_INFINITY) && (stopTicks < SDL_GetTicks())) { + XINPUT_VIBRATION vibration = { 0, 0 }; + hwdata->stopTicks = 0; + XINPUTSETSTATE(hwdata->userid, &vibration); + } } SDL_UnlockMutex(hwdata->mutex); } From 613246f860b239b5ed4085f47f527426ec2b11ec Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 16:01:10 -0400 Subject: [PATCH 213/258] Patched to compile on Windows. --- src/haptic/windows/SDL_syshaptic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index e798cfdb4..2f29fedca 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -636,7 +636,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { - if ((joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) { + if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) { return 0; /* one is XInput, one is not; not the same device. */ } else if (joystick->hwdata->bXInputHaptic) { /* XInput */ return (haptic->hwdata->userid == joystick->hwdata->userid); From ed8a93559398e16d9eed22356b7e72f72601fffd Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 16:02:24 -0400 Subject: [PATCH 214/258] Patched to compile on non-C99 Microsoft compiler. --- src/haptic/windows/SDL_syshaptic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 2f29fedca..fa03afed1 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1564,9 +1564,8 @@ SDL_RunXInputHaptic(void *arg) SDL_Delay(50); SDL_LockMutex(hwdata->mutex); /* If we're currently running and need to stop... */ - const Uint32 stopTicks = hwdata->stopTicks; - if (stopTicks) { - if ((stopTicks != SDL_HAPTIC_INFINITY) && (stopTicks < SDL_GetTicks())) { + if (hwdata->stopTicks) { + if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && (hwdata->stopTicks < SDL_GetTicks())) { XINPUT_VIBRATION vibration = { 0, 0 }; hwdata->stopTicks = 0; XINPUTSETSTATE(hwdata->userid, &vibration); From e9b771e52a5daa38a2def0953a5a1824b59f31fc Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 16:03:11 -0400 Subject: [PATCH 215/258] Backed out hg changeset b92b8c52946c. REFGUID is apparently a const type. --- src/haptic/windows/SDL_syshaptic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index fa03afed1..e8867bc68 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1204,13 +1204,10 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { HRESULT ret; - REFGUID type = NULL; + REFGUID type = SDL_SYS_HapticEffectType(base); - if (!haptic->hwdata->bXInputHaptic) { - type = SDL_SYS_HapticEffectType(base); - if (type == NULL) { - goto err_hweffect; - } + if ((type == NULL) && (!haptic->hwdata->bXInputHaptic)) { + goto err_hweffect; } /* Alloc the effect. */ From cfcf5384b7212cefc18e414a3df3171e8725ad2e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 20:02:02 -0400 Subject: [PATCH 216/258] Intentionally breaking Windows and Raspberry Pi builds to test Buildbot change. --- src/main/windows/SDL_windows_main.c | 3 +++ src/video/raspberry/SDL_rpievents.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 4e8e3f2f4..11b9a051b 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -7,6 +7,9 @@ #ifdef __WIN32__ +sdfsdfdsf + + /* Include this so we define UNICODE properly */ #include "../../core/windows/SDL_windows.h" diff --git a/src/video/raspberry/SDL_rpievents.c b/src/video/raspberry/SDL_rpievents.c index 8c420fe71..195d39e9d 100644 --- a/src/video/raspberry/SDL_rpievents.c +++ b/src/video/raspberry/SDL_rpievents.c @@ -23,6 +23,8 @@ #if SDL_VIDEO_DRIVER_RPI +sdfsdfdsf + #include "../../events/SDL_sysevents.h" #include "../../events/SDL_events_c.h" #include "../../events/SDL_keyboard_c.h" From 197b270ca8dc33f4ae77ac18bd86a315c8d3eac5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 20:24:00 -0400 Subject: [PATCH 217/258] Backed out changeset c8a0b7c05db8, done testing Buildbot changes. --- src/main/windows/SDL_windows_main.c | 3 --- src/video/raspberry/SDL_rpievents.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 11b9a051b..4e8e3f2f4 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -7,9 +7,6 @@ #ifdef __WIN32__ -sdfsdfdsf - - /* Include this so we define UNICODE properly */ #include "../../core/windows/SDL_windows.h" diff --git a/src/video/raspberry/SDL_rpievents.c b/src/video/raspberry/SDL_rpievents.c index 195d39e9d..8c420fe71 100644 --- a/src/video/raspberry/SDL_rpievents.c +++ b/src/video/raspberry/SDL_rpievents.c @@ -23,8 +23,6 @@ #if SDL_VIDEO_DRIVER_RPI -sdfsdfdsf - #include "../../events/SDL_sysevents.h" #include "../../events/SDL_events_c.h" #include "../../events/SDL_keyboard_c.h" From 7a0350ba091500b90cbd4bae00791b4157b2822f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 21:18:05 -0400 Subject: [PATCH 218/258] Added SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (thanks, David!). Fixes Bugzilla #1985. --- include/SDL_video.h | 3 ++- src/video/SDL_sysvideo.h | 1 + src/video/SDL_video.c | 10 +++++++++- src/video/windows/SDL_windowsopengl.c | 10 ++++++++++ src/video/x11/SDL_x11opengl.c | 14 ++++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/SDL_video.h b/include/SDL_video.h index aa2dc692d..4a53f9b34 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -187,7 +187,8 @@ typedef enum SDL_GL_CONTEXT_EGL, SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_PROFILE_MASK, - SDL_GL_SHARE_WITH_CURRENT_CONTEXT + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE } SDL_GLattr; typedef enum diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index beedc7474..2d41234aa 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -293,6 +293,7 @@ struct SDL_VideoDevice int flags; int profile_mask; int share_with_current_context; + int framebuffer_srgb_capable; int retained_backing; int driver_loaded; char driver_path[256]; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 4088afe81..a2078a7af 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2570,7 +2570,10 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) break; case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: _this->gl_config.share_with_current_context = value; - break; + break; + case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: + _this->gl_config.framebuffer_srgb_capable = value; + break; default: retval = SDL_SetError("Unknown OpenGL attribute"); break; @@ -2741,6 +2744,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) *value = _this->gl_config.share_with_current_context; return 0; } + case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: + { + *value = _this->gl_config.framebuffer_srgb_capable; + return 0; + } default: return SDL_SetError("Unknown OpenGL attribute"); } diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 9cda41596..3cc6737a1 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -67,6 +67,11 @@ #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 #endif +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif + typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, @@ -495,6 +500,11 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window) *iAttr++ = _this->gl_config.multisamplesamples; } + if (_this->gl_config.framebuffer_srgb_capable) { + *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; + *iAttr++ = _this->gl_config.framebuffer_srgb_capable; + } + /* We always choose either FULL or NO accel on Windows, because of flaky drivers. If the app didn't specify, we use FULL, because that's probably what they wanted (and if you didn't care and got FULL, that's diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 74165f407..a41033a70 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -106,6 +106,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, #endif #endif +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB +#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#endif +#endif + #ifndef GLX_EXT_swap_control #define GLX_SWAP_INTERVAL_EXT 0x20F1 #define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 @@ -472,6 +479,13 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si attribs[i++] = _this->gl_config.multisamplesamples; } + if (_this->gl_config.framebuffer_srgb_capable) { + attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB; + if( for_FBConfig ) { + attribs[i++] = True; + } + } + if (_this->gl_config.accelerated >= 0 && _this->gl_data->HAS_GLX_EXT_visual_rating) { attribs[i++] = GLX_VISUAL_CAVEAT_EXT; From a8de1da24d14156b9b926a2bbb0e95acb3b39b0d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 23:08:45 -0400 Subject: [PATCH 219/258] Disable Win32 thread naming again. See Bugzilla #2089. --- src/thread/windows/SDL_systhread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 4386e841f..06e23abd0 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -145,6 +145,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) return 0; } +#if 0 /* !!! FIXME: revisit this later. See https://bugzilla.libsdl.org/show_bug.cgi?id=2089 */ #ifdef _MSC_VER #pragma warning(disable : 4733) #pragma pack(push,8) @@ -163,11 +164,13 @@ ignore_exception(void *a, void *b, void *c, void *d) return ExceptionContinueExecution; } #endif +#endif void SDL_SYS_SetupThread(const char *name) { if (name != NULL) { + #if 0 /* !!! FIXME: revisit this later. See https://bugzilla.libsdl.org/show_bug.cgi?id=2089 */ #if (defined(_MSC_VER) && defined(_M_IX86)) /* This magic tells the debugger to name a thread if it's listening. The inline asm sets up SEH (__try/__except) without C runtime @@ -196,6 +199,7 @@ SDL_SYS_SetupThread(const char *name) add esp, 8 } #endif + #endif } } From 8d51830d7bd63361afc2cfb563a8b6668a054f4c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 23:38:19 -0400 Subject: [PATCH 220/258] Fix some edge cases in XInput haptic timing. --- src/haptic/windows/SDL_syshaptic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index e8867bc68..68447a9b1 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1326,8 +1326,13 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_LockMutex(haptic->hwdata->mutex); if(effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) { haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY; + } else if ((!effect->effect.leftright.length) || (!iterations)) { + /* do nothing. Effect runs for zero milliseconds. */ } else { haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); + if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) { + haptic->hwdata->stopTicks = 1; /* fix edge cases. */ + } } SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1; From 84561c952a9b0c6af63f3d1889f51472d266877d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 20:41:30 -0700 Subject: [PATCH 221/258] Added __WINDOWS__ to reflect both 32 and 64-bit windows platforms --- TODO.txt | 5 ----- include/SDL_platform.h | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index 14c47d0eb..89637ebdb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,15 +1,10 @@ Future work roadmap: * http://wiki.libsdl.org/moin.cgi/Roadmap - * See why windows are being rearranged. Is the shield window not up? - * Add __WINDOWS__ in addition to __WIN32__ - * Write test for fullscreen gamma to check X11 colormap handling - * Check 1.2 revisions: 3554 - Need to resolve semantics for locking keys on different platforms 4874 - Do we want screen rotation? At what level? 4974 - Windows file code needs to convert UTF-8 to Unicode, but we don't need to tap dance for Windows 95/98 - 4484, 4485 - Verify that SDL's Windows keyboard handling works correctly 4865 - See if this is still needed (mouse coordinate clamping) 4866 - See if this is still needed (blocking window repositioning) diff --git a/include/SDL_platform.h b/include/SDL_platform.h index b4849afec..a40c41e26 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -121,8 +121,12 @@ #define __SOLARIS__ 1 #endif #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) +#undef __WINDOWS__ +#define __WINDOWS__ 1 +#endif +#if defined(__WINDOWS__) #undef __WIN32__ -#define __WIN32__ 1 +#define __WIN32__ 1 #endif #if defined(__PSP__) #undef __PSP__ From 367ffcc3af1ce35b16f36afaeeb4a681592e45e2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 20:42:55 -0700 Subject: [PATCH 222/258] Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values. Went through the code and used the macro and fixed a couple places that were using incorrect timestamp comparisons. --- include/SDL_timer.h | 11 +++++++++++ src/audio/arts/SDL_artsaudio.c | 2 +- src/audio/bsd/SDL_bsdaudio.c | 4 +--- src/audio/esd/SDL_esdaudio.c | 3 +-- src/audio/paudio/SDL_paudio.c | 4 +--- src/events/SDL_events.c | 2 +- src/haptic/windows/SDL_syshaptic.c | 2 +- src/power/uikit/SDL_syspower.m | 6 +----- src/thread/pthread/SDL_syssem.c | 2 +- src/video/cocoa/SDL_cocoaevents.m | 2 +- src/video/x11/SDL_x11events.c | 4 ++-- src/video/x11/SDL_x11window.c | 2 +- 12 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/SDL_timer.h b/include/SDL_timer.h index e065cf4f9..28ab415b4 100644 --- a/include/SDL_timer.h +++ b/include/SDL_timer.h @@ -44,6 +44,17 @@ extern "C" { */ extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); +/** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. if you want to wait 100 ms, you could do this: + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * ... do work until timeout has elapsed + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + /** * \brief Get the current value of the high resolution counter */ diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index bd8064326..7e835c18a 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -220,7 +220,7 @@ static int ARTS_Suspend(void) { const Uint32 abortms = SDL_GetTicks() + 3000; /* give up after 3 secs */ - while ( (!SDL_NAME(arts_suspended)()) && (SDL_GetTicks() < abortms) ) { + while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) { if ( SDL_NAME(arts_suspend)() ) { break; } diff --git a/src/audio/bsd/SDL_bsdaudio.c b/src/audio/bsd/SDL_bsdaudio.c index ad51dc387..6694683bd 100644 --- a/src/audio/bsd/SDL_bsdaudio.c +++ b/src/audio/bsd/SDL_bsdaudio.c @@ -125,9 +125,7 @@ BSDAUDIO_WaitDevice(_THIS) /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = - ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - - FUDGE_TICKS; + ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { SDL_Delay(ticks); } diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index c63056562..8bba64098 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -135,8 +135,7 @@ ESD_WaitDevice(_THIS) } /* Use timer for general audio synchronization */ - ticks = - ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; + ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { SDL_Delay(ticks); } diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 6584ddd86..8a248af4e 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -133,9 +133,7 @@ PAUDIO_WaitDevice(_THIS) /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = - ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - - FUDGE_TICKS; + ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { SDL_Delay(ticks); } diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 9213dae57..53ba23fb2 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -443,7 +443,7 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout) /* Polling and no events, just return */ return 0; } - if (timeout > 0 && ((int) (SDL_GetTicks() - expiration) >= 0)) { + if (timeout > 0 && SDL_TICKS_PASSED(SDL_GetTicks(), expiration)) { /* Timeout expired and no events */ return 0; } diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 68447a9b1..d7edf0fac 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1567,7 +1567,7 @@ SDL_RunXInputHaptic(void *arg) SDL_LockMutex(hwdata->mutex); /* If we're currently running and need to stop... */ if (hwdata->stopTicks) { - if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && (hwdata->stopTicks < SDL_GetTicks())) { + if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && SDL_TIMESTAMP_PASSED(SDL_GetTicks(), hwdata->stopTicks)) { XINPUT_VIBRATION vibration = { 0, 0 }; hwdata->stopTicks = 0; XINPUTSETSTATE(hwdata->userid, &vibration); diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index 3364da56e..f870ea2a9 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -38,11 +38,7 @@ void SDL_UIKit_UpdateBatteryMonitoring(void) { if (SDL_UIKitLastPowerInfoQuery) { - const Uint32 prev = SDL_UIKitLastPowerInfoQuery; - const UInt32 now = SDL_GetTicks(); - const UInt32 ticks = now - prev; - /* if timer wrapped (now < prev), shut down, too. */ - if ((now < prev) || (ticks >= BATTERY_MONITORING_TIMEOUT)) { + if (SDL_TICKS_PASSED(SDL_GetTicks(), SDL_UIKitLastPowerInfoQuery + BATTERY_MONITORING_TIMEOUT)) { UIDevice *uidev = [UIDevice currentDevice]; SDL_assert([uidev isBatteryMonitoringEnabled] == YES); [uidev setBatteryMonitoringEnabled:NO]; diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index b10f9b0df..e1613fc30 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -156,7 +156,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) #else end = SDL_GetTicks() + timeout; while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) { - if ((Sint32)(SDL_GetTicks() - end) >= 0) { + if (SDL_TICKS_PASSED(SDL_GetTicks(), end)) { break; } SDL_Delay(1); diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 1dc0ca625..e6b292b0b 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -271,7 +271,7 @@ Cocoa_PumpEvents(_THIS) SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Uint32 now = SDL_GetTicks(); if (!data->screensaver_activity || - (int)(now-data->screensaver_activity) >= 30000) { + SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) { UpdateSystemActivity(UsrActivity); data->screensaver_activity = now; } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index df5a04e7e..ba5eca39d 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -909,7 +909,7 @@ X11_HandleFocusChanges(_THIS) SDL_WindowData *data = videodata->windowlist[i]; if (data && data->pending_focus != PENDING_FOCUS_NONE) { Uint32 now = SDL_GetTicks(); - if ( (int)(data->pending_focus_time-now) <= 0 ) { + if (SDL_TICKS_PASSED(now, data->pending_focus_time)) { if ( data->pending_focus == PENDING_FOCUS_IN ) { X11_DispatchFocusIn(data); } else { @@ -963,7 +963,7 @@ X11_PumpEvents(_THIS) if (_this->suspend_screensaver) { Uint32 now = SDL_GetTicks(); if (!data->screensaver_activity || - (int) (now - data->screensaver_activity) >= 30000) { + SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) { X11_XResetScreenSaver(data->display); #if SDL_USE_LIBDBUS diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 120b803ca..62a7e7305 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -66,7 +66,7 @@ X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), Uint32 start = SDL_GetTicks(); while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) { - if ((SDL_GetTicks() - start) >= timeoutMS) { + if (SDL_TICKS_PASSED(SDL_GetTicks(), start + timeoutMS)) { return False; } } From 4d7a5efe31eaa763994d92d6fa77608251814b09 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 20:49:36 -0700 Subject: [PATCH 223/258] Fixed windows compile --- WhatsNew.txt | 2 ++ src/haptic/windows/SDL_syshaptic.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/WhatsNew.txt b/WhatsNew.txt index c3784deab..929414e0a 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -1,3 +1,5 @@ This is a list of API changes in SDL's version history. +2.0.1 +* diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index d7edf0fac..a9f8d8342 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1567,7 +1567,7 @@ SDL_RunXInputHaptic(void *arg) SDL_LockMutex(hwdata->mutex); /* If we're currently running and need to stop... */ if (hwdata->stopTicks) { - if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && SDL_TIMESTAMP_PASSED(SDL_GetTicks(), hwdata->stopTicks)) { + if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && SDL_TICKS_PASSED(SDL_GetTicks(), hwdata->stopTicks)) { XINPUT_VIBRATION vibration = { 0, 0 }; hwdata->stopTicks = 0; XINPUTSETSTATE(hwdata->userid, &vibration); From 4e8f81ab6e96ccb8ce65dcadaeddcfc2b7ccd700 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 21:34:38 -0700 Subject: [PATCH 224/258] Prevent conflicts when linking both SDL2 and SDL2_gfx --- src/render/software/SDL_render_sw.c | 4 ++-- src/render/software/SDL_rotate.c | 22 ++++++++++++---------- src/render/software/SDL_rotate.h | 4 ++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 348dd98c2..29aab8c8f 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -609,8 +609,8 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, retval = SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect); if (!retval) { - _rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle); - surface_rotated = _rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle); + SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle); + surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle); if(surface_rotated) { /* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */ abscenterx = final_rect.x + (int)center->x; diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 44678cba5..3006eda62 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -84,7 +84,8 @@ to a situation where the program can segfault. /* ! \brief Returns colorkey info for a surface */ -Uint32 _colorkey(SDL_Surface *src) +static Uint32 +_colorkey(SDL_Surface *src) { Uint32 key = 0; SDL_GetColorKey(src, &key); @@ -104,9 +105,10 @@ Uint32 _colorkey(SDL_Surface *src) \param sangle The cosine of the angle */ -void _rotozoomSurfaceSizeTrig(int width, int height, double angle, - int *dstwidth, int *dstheight, - double *cangle, double *sangle) +void +SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, + int *dstwidth, int *dstheight, + double *cangle, double *sangle) { double x, y, cx, cy, sx, sy; double radangle; @@ -153,7 +155,8 @@ Assumes dst surface was allocated with the correct dimensions. \param flipy Flag indicating vertical mirroring should be applied. \param smooth Flag indicating anti-aliasing should be used. */ -void _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth) +static void +_transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth) { int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh; tColorRGBA c00, c01, c10, c11, cswap; @@ -270,7 +273,8 @@ Assumes dst surface was allocated with the correct dimensions. \param flipx Flag indicating horizontal mirroring should be applied. \param flipy Flag indicating vertical mirroring should be applied. */ -void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy) +static void +transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy) { int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay; tColorY *pc, *sp; @@ -315,8 +319,6 @@ void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int } - - /* ! \brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing. @@ -340,7 +342,8 @@ or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. */ -SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle) +SDL_Surface * +SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle) { SDL_Surface *rz_src; SDL_Surface *rz_dst; @@ -496,4 +499,3 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce */ return (rz_dst); } - diff --git a/src/render/software/SDL_rotate.h b/src/render/software/SDL_rotate.h index 26bb8ad1c..31d12a48f 100644 --- a/src/render/software/SDL_rotate.h +++ b/src/render/software/SDL_rotate.h @@ -2,6 +2,6 @@ #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif -extern SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); -extern void _rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); +extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); +extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); From 44dbed38ac807d1f84251be759c6947e766ba0ec Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 21:56:15 -0700 Subject: [PATCH 225/258] Fixed bug 2129 - fix for bug 2121 breaks linking for mingw and throws multiple warnings Andreas Ertelt The problem in question is caused by changeset 7771 (http://hg.libsdl.org/SDL/rev/4434498bf4b9 / https://bugzilla.libsdl.org/show_bug.cgi?id=2121) The redefinition of __inline__ (introduced by the addition of begin_code.h:128's "|| __STRICT_ANSI__") results in mingw's gcc throwing multiple warning: always_inline function might not be inlinable [-Wattributes] as well as a whole bunch of redefinitions of mingw internals which break linking of projects including the SDL2 headers. --- include/begin_code.h | 39 ++++++++---------------- src/atomic/SDL_atomic.c | 4 +-- src/audio/SDL_audiodev.c | 2 +- src/audio/alsa/SDL_alsa_audio.c | 10 +++--- src/audio/pulseaudio/SDL_pulseaudio.c | 6 ++-- src/audio/qsa/SDL_qsa_audio.c | 2 +- src/cpuinfo/SDL_cpuinfo.c | 22 ++++++------- src/events/SDL_events.c | 2 +- src/joystick/linux/SDL_sysjoystick.c | 10 +++--- src/joystick/psp/SDL_sysjoystick.c | 2 +- src/render/opengles/SDL_render_gles.c | 2 +- src/video/SDL_blit_copy.c | 4 +-- src/video/SDL_surface.c | 2 +- src/video/SDL_video.c | 2 +- src/video/bwindow/SDL_bframebuffer.cc | 4 +-- src/video/bwindow/SDL_bmodes.cc | 6 ++-- src/video/bwindow/SDL_bopengl.cc | 4 +-- src/video/bwindow/SDL_bwindow.cc | 4 +-- src/video/directfb/SDL_DirectFB_render.c | 8 ++--- src/video/directfb/SDL_DirectFB_video.h | 2 +- src/video/x11/SDL_x11messagebox.c | 2 +- 21 files changed, 63 insertions(+), 76 deletions(-) diff --git a/include/begin_code.h b/include/begin_code.h index 5261d26c1..3d4377053 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -99,49 +99,36 @@ #endif #endif /* Compiler needs structure packing set */ -#ifndef __inline__ +#ifndef SDL_INLINE /* Set up compiler-specific options for inlining functions */ -#ifndef SDL_INLINE_OKAY -/* Add any special compiler-specific cases here */ #if defined(_MSC_VER) || defined(__BORLANDC__) || \ defined(__DMC__) || defined(__SC__) || \ defined(__WATCOMC__) || defined(__LCC__) || \ defined(__DECC) -#ifndef __inline__ -#define __inline__ __inline -#endif -#define SDL_INLINE_OKAY 1 +#define SDL_INLINE __inline #else -#if !defined(__MRC__) && !defined(_SGI_SOURCE) -#ifndef __inline__ -#define __inline__ inline -#endif -#define SDL_INLINE_OKAY 1 -#endif /* Not a funky compiler */ +#define SDL_INLINE inline #endif /* Visual C++ */ -#endif /* SDL_INLINE_OKAY */ +#endif /* SDL_INLINE not defined */ -/* If inlining isn't supported, remove "__inline__", turning static - inlined functions into static functions (resulting in code bloat - in all files which include the offending header files) +/* If inlining isn't supported, remove SDL_INLINE, turning static + inlined functions into static functions (potentially resulting in + code bloat in all files which include the offending header files) */ -#if !SDL_INLINE_OKAY || __STRICT_ANSI__ -#ifdef __inline__ -#undef __inline__ +#if __STRICT_ANSI__ +#undef SDL_INLINE +#define SDL_INLINE #endif -#define __inline__ -#endif -#endif /* __inline__ not defined */ #ifndef SDL_FORCE_INLINE #if defined(_MSC_VER) #define SDL_FORCE_INLINE __forceinline #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) -#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#define SDL_FORCE_INLINE __attribute__((always_inline)) static SDL_INLINE #else -#define SDL_FORCE_INLINE static __inline__ -#endif +#define SDL_FORCE_INLINE static SDL_INLINE #endif +#endif /* SDL_FORCE_INLINE not defined */ /* Apparently this is needed by several Windows compilers */ #if !defined(__MACH__) diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index c747b12aa..e9b636f30 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -55,7 +55,7 @@ static SDL_SpinLock locks[32]; -static __inline__ void +static SDL_INLINE void enterLock(void *a) { uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); @@ -63,7 +63,7 @@ enterLock(void *a) SDL_AtomicLock(&locks[index]); } -static __inline__ void +static SDL_INLINE void leaveLock(void *a) { uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index 91b60c376..af45a8b90 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -46,7 +46,7 @@ #define _PATH_DEV_AUDIO "/dev/audio" #endif -static inline void +static SDL_INLINE void test_device(const char *fname, int flags, int (*test) (int fd), SDL_AddAudioDevice addfn) { diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 73bdcf284..5ff4cef4c 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -241,25 +241,25 @@ ALSA_WaitDevice(_THIS) tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \ } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_64bit(_THIS) { SWIZ6(Uint64); } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_32bit(_THIS) { SWIZ6(Uint32); } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_16bit(_THIS) { SWIZ6(Uint16); } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_8bit(_THIS) { SWIZ6(Uint8); @@ -272,7 +272,7 @@ swizzle_alsa_channels_6_8bit(_THIS) * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle * channels from Windows/Mac order to the format alsalib will want. */ -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels(_THIS) { if (this->spec.channels == 6) { diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 7bf4accac..5923eaecc 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -49,7 +49,7 @@ #if (PA_API_VERSION < 12) /** Return non-zero if the passed state is one of the connected states */ -static __inline__ int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { +static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || @@ -57,7 +57,7 @@ static __inline__ int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { x == PA_CONTEXT_READY; } /** Return non-zero if the passed state is one of the connected states */ -static __inline__ int PA_STREAM_IS_GOOD(pa_stream_state_t x) { +static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) { return x == PA_STREAM_CREATING || x == PA_STREAM_READY; @@ -322,7 +322,7 @@ PULSEAUDIO_CloseDevice(_THIS) } -static __inline__ int +static SDL_INLINE int squashVersion(const int major, const int minor, const int patch) { return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF); diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index a5286d8cb..78f69c0d8 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c @@ -83,7 +83,7 @@ uint32_t qsa_playback_devices; QSA_Device qsa_capture_device[QSA_MAX_DEVICES]; uint32_t qsa_capture_devices; -static inline int +static SDL_INLINE int QSA_SetError(const char *fn, int status) { return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status)); diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 2b81f9117..f9b764026 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -68,7 +68,7 @@ illegal_instruction(int sig) } #endif /* HAVE_SETJMP */ -static __inline__ int +static SDL_INLINE int CPU_haveCPUID(void) { int has_CPUID = 0; @@ -192,7 +192,7 @@ done: a = b = c = d = 0 #endif -static __inline__ int +static SDL_INLINE int CPU_getCPUIDFeatures(void) { int features = 0; @@ -206,7 +206,7 @@ CPU_getCPUIDFeatures(void) return features; } -static __inline__ int +static SDL_INLINE int CPU_haveRDTSC(void) { if (CPU_haveCPUID()) { @@ -215,7 +215,7 @@ CPU_haveRDTSC(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveAltiVec(void) { volatile int altivec = 0; @@ -242,7 +242,7 @@ CPU_haveAltiVec(void) return altivec; } -static __inline__ int +static SDL_INLINE int CPU_haveMMX(void) { if (CPU_haveCPUID()) { @@ -251,7 +251,7 @@ CPU_haveMMX(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_have3DNow(void) { if (CPU_haveCPUID()) { @@ -266,7 +266,7 @@ CPU_have3DNow(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE(void) { if (CPU_haveCPUID()) { @@ -275,7 +275,7 @@ CPU_haveSSE(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE2(void) { if (CPU_haveCPUID()) { @@ -284,7 +284,7 @@ CPU_haveSSE2(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE3(void) { if (CPU_haveCPUID()) { @@ -299,7 +299,7 @@ CPU_haveSSE3(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE41(void) { if (CPU_haveCPUID()) { @@ -314,7 +314,7 @@ CPU_haveSSE41(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE42(void) { if (CPU_haveCPUID()) { diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 53ba23fb2..99845034a 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -83,7 +83,7 @@ static struct } SDL_EventQ = { NULL, SDL_TRUE }; -static __inline__ SDL_bool +static SDL_INLINE SDL_bool SDL_ShouldPollJoystick() { #if !SDL_JOYSTICK_DISABLED diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 23a5a4c98..72fa52cad 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -617,7 +617,7 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) return !joystick->closed && (joystick->hwdata->item != NULL); } -static __inline__ void +static SDL_INLINE void HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) { struct hwdata_hat *the_hat; @@ -643,14 +643,14 @@ HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) } } -static __inline__ void +static SDL_INLINE void HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) { stick->hwdata->balls[ball].axis[axis] += value; } -static __inline__ int +static SDL_INLINE int AxisCorrect(SDL_Joystick * joystick, int which, int value) { struct axis_correct *correct; @@ -679,7 +679,7 @@ AxisCorrect(SDL_Joystick * joystick, int which, int value) return value; } -static __inline__ void +static SDL_INLINE void PollAllValues(SDL_Joystick * joystick) { struct input_absinfo absinfo; @@ -717,7 +717,7 @@ PollAllValues(SDL_Joystick * joystick) } } -static __inline__ void +static SDL_INLINE void HandleInputEvents(SDL_Joystick * joystick) { struct input_event events[32]; diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index d6ca6989e..b953372d6 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -60,7 +60,7 @@ static point c = { 78, 32767 }; static point d = { 128, 32767 }; /* simple linear interpolation between two points */ -static __inline__ void lerp (point *dest, point *a, point *b, float t) +static SDL_INLINE void lerp (point *dest, point *a, point *b, float t) { dest->x = a->x + (b->x - a->x)*t; dest->y = a->y + (b->y - a->y)*t; diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index b3ce79096..3be1998d8 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -414,7 +414,7 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } -static __inline__ int +static SDL_INLINE int power_of_2(int input) { int value = 1; diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index 6d286c31f..80519e099 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -27,7 +27,7 @@ #ifdef __SSE__ /* This assumes 16-byte aligned src and dst */ -static __inline__ void +static SDL_INLINE void SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) { int i; @@ -56,7 +56,7 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) #ifdef _MSC_VER #pragma warning(disable:4799) #endif -static __inline__ void +static SDL_INLINE void SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) { const int remain = (len & 63); diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 8418bc302..d4c852a16 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -951,7 +951,7 @@ SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format, /* * Create a surface on the stack for quick blit operations */ -static __inline__ SDL_bool +static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void * pixels, int pitch, SDL_Surface * surface, SDL_PixelFormat * format, SDL_BlitMap * blitmap) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index a2078a7af..201ba535d 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2382,7 +2382,7 @@ SDL_GL_UnloadLibrary(void) } } -static __inline__ SDL_bool +static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) { return ( verstr && (SDL_atoi(verstr) >= 3) ); diff --git a/src/video/bwindow/SDL_bframebuffer.cc b/src/video/bwindow/SDL_bframebuffer.cc index 6e7f8c3f2..69f4a43a1 100644 --- a/src/video/bwindow/SDL_bframebuffer.cc +++ b/src/video/bwindow/SDL_bframebuffer.cc @@ -37,11 +37,11 @@ extern "C" { int32 BE_UpdateOnce(SDL_Window *window); -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } diff --git a/src/video/bwindow/SDL_bmodes.cc b/src/video/bwindow/SDL_bmodes.cc index 41894fb78..44e19dc7e 100644 --- a/src/video/bwindow/SDL_bmodes.cc +++ b/src/video/bwindow/SDL_bmodes.cc @@ -48,15 +48,15 @@ typedef struct SDL_DisplayModeData { }; #endif -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } -static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) { +static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) { #if WRAP_BMODE return ((SDL_DisplayModeData*)mode->driverdata)->bmode; #else diff --git a/src/video/bwindow/SDL_bopengl.cc b/src/video/bwindow/SDL_bopengl.cc index 5acefe2cd..13b90ad97 100644 --- a/src/video/bwindow/SDL_bopengl.cc +++ b/src/video/bwindow/SDL_bopengl.cc @@ -37,11 +37,11 @@ extern "C" { #define BGL_FLAGS BGL_RGB | BGL_DOUBLE -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } diff --git a/src/video/bwindow/SDL_bwindow.cc b/src/video/bwindow/SDL_bwindow.cc index c6eb3aa1a..c898be6ba 100644 --- a/src/video/bwindow/SDL_bwindow.cc +++ b/src/video/bwindow/SDL_bwindow.cc @@ -31,11 +31,11 @@ extern "C" { #endif -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 3e8ba4759..219f52070 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -167,7 +167,7 @@ typedef struct #endif } DirectFB_TextureData; -static __inline__ void +static SDL_INLINE void SDLtoDFBRect(const SDL_Rect * sr, DFBRectangle * dr) { dr->x = sr->x; @@ -175,7 +175,7 @@ SDLtoDFBRect(const SDL_Rect * sr, DFBRectangle * dr) dr->h = sr->h; dr->w = sr->w; } -static __inline__ void +static SDL_INLINE void SDLtoDFBRect_Float(const SDL_FRect * sr, DFBRectangle * dr) { dr->x = sr->x; @@ -211,7 +211,7 @@ TextureHasAlpha(DirectFB_TextureData * data) #endif } -static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) +static SDL_INLINE IDirectFBSurface *get_dfb_surface(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo)); @@ -222,7 +222,7 @@ static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) return wm_info.info.dfb.surface; } -static inline IDirectFBWindow *get_dfb_window(SDL_Window *window) +static SDL_INLINE IDirectFBWindow *get_dfb_window(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo)); diff --git a/src/video/directfb/SDL_DirectFB_video.h b/src/video/directfb/SDL_DirectFB_video.h index c3630fd8f..b40bac0d5 100644 --- a/src/video/directfb/SDL_DirectFB_video.h +++ b/src/video/directfb/SDL_DirectFB_video.h @@ -88,7 +88,7 @@ #define SDL_DFB_DEBUG(x...) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, x) -static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { +static SDL_INLINE DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { if (ret != DFB_OK) { SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) ); SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) ); diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index 0d0ffb75e..81c148005 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -112,7 +112,7 @@ typedef struct SDL_MessageBoxDataX11 } SDL_MessageBoxDataX11; /* Maximum helper for ints. */ -static __inline__ int +static SDL_INLINE int IntMax( int a, int b ) { return ( a > b ) ? a : b; From d3ebd009781e772dc23d213465b942221aa71f6e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 22:23:09 -0700 Subject: [PATCH 226/258] Fixed Y axis inversion on iOS; positive is up, negative is down. --- Xcode-iOS/Demos/src/accelerometer.c | 19 +++++++++++-------- src/joystick/iphoneos/SDL_sysjoystick.m | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 115de627f..bf3b86a04 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -31,19 +31,19 @@ static SDL_Texture *ship = 0; /* texture for spaceship */ static SDL_Texture *space = 0; /* texture for space (background */ void -render(SDL_Renderer *renderer) +render(SDL_Renderer *renderer, int w, int h) { /* get joystick (accelerometer) axis values and normalize them */ float ax = SDL_JoystickGetAxis(accelerometer, 0); - float ay = -SDL_JoystickGetAxis(accelerometer, 1); + float ay = SDL_JoystickGetAxis(accelerometer, 1); /* ship screen constraints */ Uint32 minx = 0.0f; - Uint32 maxx = SCREEN_WIDTH - shipData.rect.w; + Uint32 maxx = w - shipData.rect.w; Uint32 miny = 0.0f; - Uint32 maxy = SCREEN_HEIGHT - shipData.rect.h; + Uint32 maxy = h - shipData.rect.h; #define SINT16_MAX ((float)(0x7FFF)) @@ -162,8 +162,9 @@ main(int argc, char *argv[]) SDL_Renderer *renderer; Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ - Uint32 delay; /* time to pause waiting to draw next frame */ + Sint32 delay; /* time to pause waiting to draw next frame */ int done; /* should we clean up and exit? */ + int w, h; /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { @@ -175,6 +176,8 @@ main(int argc, char *argv[]) SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS); renderer = SDL_CreateRenderer(window, 0, 0); + + SDL_GetWindowSize(window, &w, &h); /* print out some info about joysticks and try to open accelerometer for use */ printf("There are %d joysticks available\n", SDL_NumJoysticks()); @@ -196,8 +199,8 @@ main(int argc, char *argv[]) initializeTextures(renderer); /* setup ship */ - shipData.x = (SCREEN_WIDTH - shipData.rect.w) / 2; - shipData.y = (SCREEN_HEIGHT - shipData.rect.h) / 2; + shipData.x = (w - shipData.rect.w) / 2; + shipData.y = (h - shipData.rect.h) / 2; shipData.vx = 0.0f; shipData.vy = 0.0f; @@ -211,7 +214,7 @@ main(int argc, char *argv[]) done = 1; } } - render(renderer); + render(renderer, w, h); endFrame = SDL_GetTicks(); /* figure out how much time we have left, and then sleep */ diff --git a/src/joystick/iphoneos/SDL_sysjoystick.m b/src/joystick/iphoneos/SDL_sysjoystick.m index 231c851cf..6082389ff 100644 --- a/src/joystick/iphoneos/SDL_sysjoystick.m +++ b/src/joystick/iphoneos/SDL_sysjoystick.m @@ -106,7 +106,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) [[SDLUIAccelerationDelegate sharedDelegate] setHasNewData: NO]; SDL_PrivateJoystickAxis(joystick, 0, orientation[0]); - SDL_PrivateJoystickAxis(joystick, 1, orientation[1]); + SDL_PrivateJoystickAxis(joystick, 1, -orientation[1]); SDL_PrivateJoystickAxis(joystick, 2, orientation[2]); } From 042962f130773462f4de3f33a73b2f0033d7a8cd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 23:05:53 -0700 Subject: [PATCH 227/258] Fixed the status bar visibility in iOS 7 --- src/video/uikit/SDL_uikitviewcontroller.h | 1 + src/video/uikit/SDL_uikitviewcontroller.m | 9 +++++++++ src/video/uikit/SDL_uikitwindow.m | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h index 2bc664d6c..a69c1e117 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.h +++ b/src/video/uikit/SDL_uikitviewcontroller.h @@ -35,5 +35,6 @@ - (void)viewDidLayoutSubviews; - (NSUInteger)supportedInterfaceOrientations; - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient; +- (BOOL)prefersStatusBarHidden; @end diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 157b70aa0..077c160da 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -119,6 +119,15 @@ return (orientationMask & (1 << orient)); } +- (BOOL)prefersStatusBarHidden +{ + if (self->window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { + return YES; + } else { + return NO; + } +} + @end #endif /* SDL_VIDEO_DRIVER_UIKIT */ diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index b3f7ac9f4..a8b8e6772 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -99,11 +99,13 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo if (displaydata->uiscreen == [UIScreen mainScreen]) { window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + /* This was setup earlier for our window, and in iOS 7 is controlled by the view, not the application if ([UIApplication sharedApplication].statusBarHidden) { window->flags |= SDL_WINDOW_BORDERLESS; } else { window->flags &= ~SDL_WINDOW_BORDERLESS; } + */ } else { window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */ From 5548931ed64c697fd5ef65dbd89416ab2d59e9b9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 23:23:25 -0700 Subject: [PATCH 228/258] Fixed a crash initializing Android touch IDs --- src/core/android/SDL_android.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 688055bbf..763715e68 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -1200,9 +1200,9 @@ int Android_JNI_GetTouchDeviceIds(int **ids) { jint* elements = (*env)->GetIntArrayElements(env, array, NULL); if (elements) { int i; - *ids = SDL_malloc(number * sizeof (*ids[0])); + *ids = SDL_malloc(number * sizeof (**ids)); for (i = 0; i < number; ++i) { /* not assuming sizeof (jint) == sizeof (int) */ - *ids[i] = elements[i]; + (*ids)[i] = elements[i]; } (*env)->ReleaseIntArrayElements(env, array, elements, JNI_ABORT); } From e8d2a8b3b87af22c959586af1115dac80705ee6e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Oct 2013 23:52:02 -0700 Subject: [PATCH 229/258] Fixed bug 2156 - Android: Accelerometer values fed to joystick driver are inverted for the X axis and wrong for Z Denis Bernard Background information: http://developer.android.com/reference/android/hardware/SensorEvent.html#values Steps to reproduce: compile testjoystick.c as an android app (change screen size according to your device). While running the app, also run: adb logcat -c; adb logcat -s 'SDL:*' 'SDL/APP:*' When tilting the device left/right, the joystick moves in the opposite direction of what one would expect. Or at least, the behaviour is not consistent with the Y axis. Also when the device sits on a table (obviously not moving), the Z axis value oscillates between -32000 and +32000 (by overflow): I/SDL/APP ( 1994): Joystick 0 axis 2 value: 32511 I/SDL/APP ( 1994): Joystick 0 axis 2 value: 32575 I/SDL/APP ( 1994): Joystick 0 axis 2 value: 32383 I/SDL/APP ( 1994): Joystick 0 axis 2 value: -32386 I/SDL/APP ( 1994): Joystick 0 axis 2 value: -32450 I/SDL/APP ( 1994): Joystick 0 axis 2 value: -32578 This is caused by the accelerometer yielding a constant value around 9.81 for Z and feeding something like 0.9 to 1.1 to the joystick driver, resulting in the overflow. Proposed fix in SDLActivity.java (swap X and subtract G from Z reading) --- android-project/src/org/libsdl/app/SDLActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 02b6ebd61..49b014ce1 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -642,9 +642,9 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, y = event.values[1]; break; } - SDLActivity.onNativeAccel(x / SensorManager.GRAVITY_EARTH, + SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH, y / SensorManager.GRAVITY_EARTH, - event.values[2] / SensorManager.GRAVITY_EARTH); + event.values[2] / SensorManager.GRAVITY_EARTH - 1); } } From f00b8b1fb4b3788acaf31e28eb0f56a5802591df Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 00:15:24 -0700 Subject: [PATCH 230/258] Better cleanup if OpenGL initialization fails --- src/video/SDL_egl.c | 52 ++++++++++++++------------- src/video/SDL_video.c | 6 +++- src/video/windows/SDL_windowsopengl.c | 31 ++++++---------- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 39d94daac..ccfb92e18 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -91,17 +91,23 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc) void SDL_EGL_UnloadLibrary(_THIS) { - if ((_this->egl_data) && (_this->gl_config.driver_loaded)) { - _this->egl_data->eglTerminate(_this->egl_data->egl_display); - - dlclose(_this->gl_config.dll_handle); - dlclose(_this->egl_data->egl_dll_handle); + if (_this->egl_data) { + if (_this->egl_data->egl_display) { + _this->egl_data->eglTerminate(_this->egl_data->egl_display); + _this->egl_data->egl_display = NULL; + } + + if (_this->gl_config.dll_handle) { + dlclose(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + } + if (_this->egl_data->egl_dll_handle) { + dlclose(_this->egl_data->egl_dll_handle); + _this->egl_data->egl_dll_handle = NULL; + } SDL_free(_this->egl_data); _this->egl_data = NULL; - - _this->gl_config.dll_handle = NULL; - _this->gl_config.driver_loaded = 0; } } @@ -115,16 +121,18 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa if (_this->egl_data) { return SDL_SetError("OpenGL ES context already created"); } - - /* Unload the old driver and reset the pointers */ - SDL_EGL_UnloadLibrary(_this); - - #ifdef RTLD_GLOBAL + + _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData)); + if (!_this->egl_data) { + return SDL_OutOfMemory(); + } + +#ifdef RTLD_GLOBAL dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; - #else +#else dlopen_flags = RTLD_LAZY; - #endif - +#endif + /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ path = getenv("SDL_VIDEO_GL_DRIVER"); egl_dll_handle = dlopen(path, dlopen_flags); @@ -141,6 +149,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa } } } + _this->egl_data->egl_dll_handle = egl_dll_handle; if (egl_dll_handle == NULL) { return SDL_SetError("Could not initialize OpenGL ES library: %s", dlerror()); @@ -157,16 +166,12 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa } dll_handle = dlopen(path, dlopen_flags); } - + _this->gl_config.dll_handle = dll_handle; + if (dll_handle == NULL) { return SDL_SetError("Could not load EGL library: %s", dlerror()); } - _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData)); - if (!_this->egl_data) { - return SDL_OutOfMemory(); - } - /* Load new function pointers */ LOAD_FUNC(eglGetDisplay); LOAD_FUNC(eglInitialize); @@ -185,7 +190,6 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa LOAD_FUNC(eglWaitGL); _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); - if (!_this->egl_data->egl_display) { return SDL_SetError("Could not get EGL display"); } @@ -424,4 +428,4 @@ SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface) #endif /* SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ - \ No newline at end of file + diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 201ba535d..613bf4cf6 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2333,12 +2333,16 @@ SDL_GL_LoadLibrary(const char *path) retval = 0; } else { if (!_this->GL_LoadLibrary) { - return SDL_SetError("No dynamic GL support in video driver"); + return SDL_SetError("No dynamic GL support in video driver"); } retval = _this->GL_LoadLibrary(_this, path); } if (retval == 0) { ++_this->gl_config.driver_loaded; + } else { + if (_this->GL_UnloadLibrary) { + _this->GL_UnloadLibrary(_this); + } } return (retval); } diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 3cc6737a1..20d9913d8 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -23,6 +23,7 @@ #if SDL_VIDEO_DRIVER_WINDOWS #include "SDL_assert.h" +#include "SDL_loadso.h" #include "SDL_windowsvideo.h" /* WGL implementation of SDL OpenGL support */ @@ -81,8 +82,7 @@ typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, int WIN_GL_LoadLibrary(_THIS, const char *path) { - LPTSTR wpath; - HANDLE handle; + void *handle; if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); @@ -90,23 +90,15 @@ WIN_GL_LoadLibrary(_THIS, const char *path) if (path == NULL) { path = DEFAULT_OPENGL; } - wpath = WIN_UTF8ToString(path); - _this->gl_config.dll_handle = LoadLibrary(wpath); - SDL_free(wpath); + _this->gl_config.dll_handle = SDL_LoadObject(path); if (!_this->gl_config.dll_handle) { - char message[1024]; - SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")", - path); - return WIN_SetError(message); + return -1; } SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); /* Allocate OpenGL memory */ - _this->gl_data = - (struct SDL_GLDriverData *) SDL_calloc(1, - sizeof(struct - SDL_GLDriverData)); + _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData)); if (!_this->gl_data) { return SDL_OutOfMemory(); } @@ -114,21 +106,20 @@ WIN_GL_LoadLibrary(_THIS, const char *path) /* Load function pointers */ handle = _this->gl_config.dll_handle; _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) - GetProcAddress(handle, "wglGetProcAddress"); + SDL_LoadFunction(handle, "wglGetProcAddress"); _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC)) - GetProcAddress(handle, "wglCreateContext"); + SDL_LoadFunction(handle, "wglCreateContext"); _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC)) - GetProcAddress(handle, "wglDeleteContext"); + SDL_LoadFunction(handle, "wglDeleteContext"); _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC)) - GetProcAddress(handle, "wglMakeCurrent"); + SDL_LoadFunction(handle, "wglMakeCurrent"); _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC)) - GetProcAddress(handle, "wglShareLists"); + SDL_LoadFunction(handle, "wglShareLists"); if (!_this->gl_data->wglGetProcAddress || !_this->gl_data->wglCreateContext || !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent) { - SDL_UnloadObject(handle); return SDL_SetError("Could not retrieve OpenGL functions"); } @@ -152,7 +143,7 @@ WIN_GL_GetProcAddress(_THIS, const char *proc) void WIN_GL_UnloadLibrary(_THIS) { - FreeLibrary((HMODULE) _this->gl_config.dll_handle); + SDL_UnloadObject(_this->gl_config.dll_handle); _this->gl_config.dll_handle = NULL; /* Free OpenGL memory */ From 9eaceb18a06662e1223abecb4480403ce7e58cf8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 00:20:27 -0700 Subject: [PATCH 231/258] Fixed bug 2072 - Make OS X's filesystem calls use -[NSString fileSystemRepresentation] C.W. Betts The recommended way of getting a file name that POSIX file APIs can open in OS X when using an NSString is -[NSString fileSystemRepresentation]. However, the current filesystem API in hg uses -[NSString UTF8String]. --- src/filesystem/cocoa/SDL_sysfilesystem.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 43e024c2b..67ae24a58 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -45,12 +45,12 @@ SDL_GetBasePath(void) baseType = "resource"; } if (SDL_strcasecmp(baseType, "bundle")==0) { - base = [[bundle bundlePath] UTF8String]; + base = [[bundle bundlePath] fileSystemRepresentation]; } else if (SDL_strcasecmp(baseType, "parent")==0) { - base = [[[bundle bundlePath] stringByDeletingLastPathComponent] UTF8String]; + base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation]; } else { /* this returns the exedir for non-bundled and the resourceDir for bundled apps */ - base = [[bundle resourcePath] UTF8String]; + base = [[bundle resourcePath] fileSystemRepresentation]; } if (base) { const size_t len = SDL_strlen(base) + 2; @@ -77,7 +77,7 @@ SDL_GetPrefPath(const char *org, const char *app) if ([array count] > 0) { /* we only want the first item in the list. */ NSString *str = [array objectAtIndex:0]; - const char *base = [str UTF8String]; + const char *base = [str fileSystemRepresentation]; if (base) { const size_t len = SDL_strlen(base) + SDL_strlen(app) + 3; retval = (char *) SDL_malloc(len); From 01cfa82f08b105855e81b3b055d5933c4bc4797a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 00:22:07 -0700 Subject: [PATCH 232/258] Fixed bug 2061 - SDL_filesystem API not built using cmake Marcus von Appen The SDL_filesystem API does not get built properly on Unix and BeOS using cmake due to not including the correct C files. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 578742efe..1a1607fac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -716,7 +716,7 @@ if(UNIX AND NOT APPLE) if(SDL_FILESYSTEM) set(SDL_FILESYSTEM_UNIX 1) - file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/unix/*.c) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) set(HAVE_SDL_FILESYSTEM TRUE) endif(SDL_FILESYSTEM) @@ -995,7 +995,7 @@ elseif(BEOS) set(HAVE_SDL_VIDEO TRUE) set(SDL_FILESYSTEM_BEOS 1) - file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/beos/*.cc) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/beos/*.cc) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) set(HAVE_SDL_FILESYSTEM TRUE) From 297b7e9f3b995b15657692830da4db7c9292c2b3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 00:25:43 -0700 Subject: [PATCH 233/258] Fixed bug 2012 - Algorithm logic getting wrong in ComputeOutCode Nitz I was going through the SDL_IntersectRectAndLine function and wondered to see the ComputeOutCode function implementation. The problem in this algo is, x and y axis are getting check with respect to 0, Which is wrong, it should be get checked with respect to rectangle x and y axis. --- src/video/SDL_rect.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 8dcb5b651..b6393fb2d 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -296,15 +296,16 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, #define CODE_LEFT 4 #define CODE_RIGHT 8 -static int ComputeOutCode(const SDL_Rect * rect, int x, int y) +static int +ComputeOutCode(const SDL_Rect * rect, int x, int y) { int code = 0; - if (y < 0) { + if (y < rect->y) { code |= CODE_TOP; } else if (y >= rect->y + rect->h) { code |= CODE_BOTTOM; } - if (x < 0) { + if (x < rect->x) { code |= CODE_LEFT; } else if (x >= rect->x + rect->w) { code |= CODE_RIGHT; From 165ad7a5e611e198851d9fd2b2b0be6eeffec660 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 00:30:05 -0700 Subject: [PATCH 234/258] Fixed bug 2015 - surface getting leak in SDLTest_ScreenShot function Nitz 2013-08-06 03:53:41 UTC In function SDLTest_ScreenShot() surface pointer getting leak while return --- src/test/SDL_test_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 3bb2f0a7c..c117a93a9 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1154,11 +1154,13 @@ SDLTest_ScreenShot(SDL_Renderer *renderer) if (SDL_RenderReadPixels(renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) { fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError()); + SDL_free(surface); return; } if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) { fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError()); + SDL_free(surface); return; } } From 20e65317fa39cf03ab37cc0bee77684f939e33d2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 01:16:16 -0700 Subject: [PATCH 235/258] Fixed some warnings building for 64-bit Windows --- src/joystick/SDL_gamecontroller.c | 2 +- src/joystick/SDL_joystick.c | 2 +- src/video/windows/SDL_windowskeyboard.c | 4 ++-- src/video/windows/SDL_windowsmessagebox.c | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 0a4ad6b0d..603d4db38 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -758,7 +758,7 @@ SDL_GameControllerLoadHints() { const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG); if ( hint && hint[0] ) { - int nchHints = SDL_strlen( hint ); + size_t nchHints = SDL_strlen( hint ); char *pUserMappings = SDL_malloc( nchHints + 1 ); char *pTempMappings = pUserMappings; SDL_memcpy( pUserMappings, hint, nchHints ); diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 175aaef5a..3906ec2b9 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -830,7 +830,7 @@ SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID) { SDL_JoystickGUID guid; int maxoutputbytes= sizeof(guid); - int len = SDL_strlen( pchGUID ); + size_t len = SDL_strlen( pchGUID ); Uint8 *p; int i; diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index de5848043..17d4eed45 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -758,10 +758,10 @@ IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata) if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) { const UINT maxcandchar = 18; UINT i = 0; - UINT cchars = 0; + size_t cchars = 0; for (; i < videodata->ime_candcount; ++i) { - UINT len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1; + size_t len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1; if (len + cchars > maxcandchar) { if (i > cand_list->dwSelection) break; diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index b2a59532a..06937adba 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -342,7 +342,8 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { WIN_DialogData *dialog; - int i, x, y, which; + int i, x, y; + UINT_PTR which; const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons; HFONT DialogFont; SIZE Size; From 900cb419ce924a8eba20e1086e5a196d3cee98a1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 02:20:39 -0700 Subject: [PATCH 236/258] Fixed bug 2168 - Mac: SDL_filesystem.h not exported to public header folder when building framework --- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 1ec78cae5..b5f183717 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -1752,6 +1752,7 @@ AA7558101595D4D800BBD41B /* SDL_endian.h in Headers */, AA7558121595D4D800BBD41B /* SDL_error.h in Headers */, AA7558141595D4D800BBD41B /* SDL_events.h in Headers */, + 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */, A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */, AA7558161595D4D800BBD41B /* SDL_gesture.h in Headers */, AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */, @@ -1876,7 +1877,6 @@ AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */, AABCC38D164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, D55A1B81179F262300625D7C /* SDL_cocoamousetap.h in Headers */, - 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; From a68bc09ed978d15930ab9b83a79d8eb6f26b4672 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 02:32:34 -0700 Subject: [PATCH 237/258] Better fix for bug 2129 - fix for bug 2121 breaks linking for mingw and throws multiple warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jānis Rūcis Reopening as compilation with ANSI C throws lots of unnecessary warnings, both using MinGW and using Linux GCC. (BTW, what happened? MinGW is broken to all hell. sdl2-config does not even link SDLMain anymore?) I think this may have been lost somewhere, so again: GCC supports inlining via __inline__ in all known versions of GCC, regardless of the C standard in use. Please don't assume that __STRICT_ANSI__ implies no inlining support. --- include/begin_code.h | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/include/begin_code.h b/include/begin_code.h index 3d4377053..7adddedf2 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -100,31 +100,23 @@ #endif /* Compiler needs structure packing set */ #ifndef SDL_INLINE -/* Set up compiler-specific options for inlining functions */ -#if defined(_MSC_VER) || defined(__BORLANDC__) || \ - defined(__DMC__) || defined(__SC__) || \ - defined(__WATCOMC__) || defined(__LCC__) || \ - defined(__DECC) -#define SDL_INLINE __inline +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) +#define SDL_INLINE __inline #else #define SDL_INLINE inline -#endif /* Visual C++ */ -#endif /* SDL_INLINE not defined */ - -/* If inlining isn't supported, remove SDL_INLINE, turning static - inlined functions into static functions (potentially resulting in - code bloat in all files which include the offending header files) -*/ -#if __STRICT_ANSI__ -#undef SDL_INLINE -#define SDL_INLINE #endif +#endif /* SDL_INLINE not defined */ #ifndef SDL_FORCE_INLINE #if defined(_MSC_VER) #define SDL_FORCE_INLINE __forceinline #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) -#define SDL_FORCE_INLINE __attribute__((always_inline)) static SDL_INLINE +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ #else #define SDL_FORCE_INLINE static SDL_INLINE #endif From 5544901ec18866619ba8dd22b5507024036216bc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 02:37:03 -0700 Subject: [PATCH 238/258] Fixed bug 2073 - Mac: window moves unexpectedly when exiting SDL_WINDOW_FULLSCREEN_DESKTOP mode Alex Szpakowski In Mac OS X, when SDL_SetWindowFullscreen(window, 0) is called on a window which was in SDL_WINDOW_FULLSCREEN_DESKTOP mode, its original size is restored but its position is moved to the bottom of the screen. I tracked down the issue to these two lines: http://hg.libsdl.org/SDL/file/66b5b8446275/src/video/cocoa/SDL_cocoawindow.m#l1034 I believe [nswindow setFrameOrigin:rect.origin] implicitly calls [nswindow constrainFrameRect:rect toScreen:screen], which will attempt to constrain the window to the screen, but at that point the window size is still full-screen rather than the restored window size, so the constrainFrameRect function operates on the wrong window size. https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/constrainFrameRect:toScreen: I resolved the issue by swapping the order of the function calls, like so: [nswindow setContentSize:rect.size]; [nswindow setFrameOrigin:rect.origin]; --- src/video/cocoa/SDL_cocoawindow.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 923cd51c5..552998306 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1058,8 +1058,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display } s_moveHack = 0; - [nswindow setFrameOrigin:rect.origin]; [nswindow setContentSize:rect.size]; + [nswindow setFrameOrigin:rect.origin]; s_moveHack = SDL_GetTicks(); /* When the window style changes the title is cleared */ From 0c257d4b668118718f74552c416b6a7736a718ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 02:38:23 -0700 Subject: [PATCH 239/258] We don't have API changes documented yet. --- WhatsNew.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/WhatsNew.txt b/WhatsNew.txt index 929414e0a..c3784deab 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -1,5 +1,3 @@ This is a list of API changes in SDL's version history. -2.0.1 -* From eb284ee46d41cfdde6f658fd258a019ce3c91806 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 02:46:16 -0700 Subject: [PATCH 240/258] Fixed bug 2168 - Mac: SDL_filesystem.h not exported to public header folder when building framework Alex Szpakowski I actually made a mistake when creating the previous patch file... I forgot to include a crucial line which changed. I've attached a new patch which just changes the line I forgot, since the other part has already been applied to the repository. I tested this one by doing a clean rebuild of SDL, and it works with the new patch. --- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index b5f183717..9002cc656 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -392,7 +392,7 @@ 566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */; }; 566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; }; 567E2F1C17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; - 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; }; + 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; settings = {ATTRIBUTES = (Public, ); }; }; A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; }; From 69b29580350d2e79fd7700defef1f397fc78af9e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 10:28:57 -0700 Subject: [PATCH 241/258] Revert fix for bug 1392 because it breaks linking with mingw32 --- sdl2-config.in | 2 +- sdl2.pc.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdl2-config.in b/sdl2-config.in index 912de788f..254a345e6 100644 --- a/sdl2-config.in +++ b/sdl2-config.in @@ -45,7 +45,7 @@ while test $# -gt 0; do echo -I@includedir@/SDL2 @SDL_CFLAGS@ ;; @ENABLE_SHARED_TRUE@ --libs) -@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ -lSDL2 +@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@ @ENABLE_SHARED_TRUE@ ;; @ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs) @ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs) diff --git a/sdl2.pc.in b/sdl2.pc.in index e37c73ebd..b11667dc6 100644 --- a/sdl2.pc.in +++ b/sdl2.pc.in @@ -10,6 +10,6 @@ Description: Simple DirectMedia Layer is a cross-platform multimedia library des Version: @SDL_VERSION@ Requires: Conflicts: -Libs: -L${libdir} @SDL_RLD_FLAGS@ -lSDL2 +Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ Libs.private: @SDL_STATIC_LIBS@ Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@ From a161479693a905666975d74dd4f86028b11e57a9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 22:08:56 -0700 Subject: [PATCH 242/258] Fixed whitespace --HG-- extra : rebase_source : 0d52de2be0171755128dd1e06b4722b4bad418a1 --- src/render/direct3d/SDL_render_d3d.c | 90 ++++++++++++++-------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 285ddb761..a4c602757 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -543,17 +543,17 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) D3D_RenderData *data; SDL_SysWMinfo windowinfo; HRESULT result; - const char *hint; + const char *hint; D3DPRESENT_PARAMETERS pparams; IDirect3DSwapChain9 *chain; D3DCAPS9 caps; - DWORD device_flags; + DWORD device_flags; Uint32 window_flags; int w, h; SDL_DisplayMode fullscreen_mode; int d3dxVersion; char d3dxDLLFile[50]; - int displayIndex; + int displayIndex; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); if (!renderer) { @@ -568,7 +568,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } - if( D3D_LoadDLL( &data->d3dDLL, &data->d3d ) ) { + if( D3D_LoadDLL( &data->d3dDLL, &data->d3d ) ) { for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) { LPTSTR dllName; SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion); @@ -600,7 +600,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->WindowEvent = D3D_WindowEvent; renderer->CreateTexture = D3D_CreateTexture; renderer->UpdateTexture = D3D_UpdateTexture; - renderer->UpdateTextureYUV = D3D_UpdateTextureYUV; + renderer->UpdateTextureYUV = D3D_UpdateTextureYUV; renderer->LockTexture = D3D_LockTexture; renderer->UnlockTexture = D3D_UnlockTexture; renderer->SetRenderTarget = D3D_SetRenderTarget; @@ -661,22 +661,22 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) } /* Get the adapter for the display that the window is on */ - displayIndex = SDL_GetWindowDisplayIndex( window ); + displayIndex = SDL_GetWindowDisplayIndex( window ); data->adapter = SDL_Direct3D9GetAdapterIndex( displayIndex ); IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); - device_flags = D3DCREATE_FPU_PRESERVE; - if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { - device_flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; - } else { - device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; - } + device_flags = D3DCREATE_FPU_PRESERVE; + if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { + device_flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; + } else { + device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; + } - hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE); - if (hint && SDL_atoi(hint)) { - device_flags |= D3DCREATE_MULTITHREADED; - } + hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE); + if (hint && SDL_atoi(hint)) { + device_flags |= D3DCREATE_MULTITHREADED; + } result = IDirect3D9_CreateDevice(data->d3d, data->adapter, D3DDEVTYPE_HAL, @@ -1033,27 +1033,27 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch) { - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - SDL_bool full_texture = SDL_FALSE; + D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + SDL_bool full_texture = SDL_FALSE; #ifdef USE_DYNAMIC_TEXTURE - if (texture->access == SDL_TEXTUREACCESS_STREAMING && - rect->x == 0 && rect->y == 0 && - rect->w == texture->w && rect->h == texture->h) { - full_texture = SDL_TRUE; - } + if (texture->access == SDL_TEXTUREACCESS_STREAMING && + rect->x == 0 && rect->y == 0 && + rect->w == texture->w && rect->h == texture->h) { + full_texture = SDL_TRUE; + } #endif - if (D3D_UpdateTextureInternal(data->texture, texture->format, full_texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { - return -1; - } - if (D3D_UpdateTextureInternal(data->utexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) { - return -1; - } - if (D3D_UpdateTextureInternal(data->vtexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) { - return -1; - } - return 0; + if (D3D_UpdateTextureInternal(data->texture, texture->format, full_texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + if (D3D_UpdateTextureInternal(data->utexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) { + return -1; + } + if (D3D_UpdateTextureInternal(data->vtexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) { + return -1; + } + return 0; } static int @@ -1894,20 +1894,20 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) IDirect3DDevice9 * SDL_RenderGetD3D9Device(SDL_Renderer * renderer) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - IDirect3DDevice9 *device; + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + IDirect3DDevice9 *device; - // Make sure that this is a D3D renderer - if (renderer->DestroyRenderer != D3D_DestroyRenderer) { - SDL_SetError("Renderer is not a D3D renderer"); - return NULL; - } + // Make sure that this is a D3D renderer + if (renderer->DestroyRenderer != D3D_DestroyRenderer) { + SDL_SetError("Renderer is not a D3D renderer"); + return NULL; + } - device = data->device; - if (device) { - IDirect3DDevice9_AddRef( device ); - } - return device; + device = data->device; + if (device) { + IDirect3DDevice9_AddRef( device ); + } + return device; } #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ From dc404e11c969466a681b9ec827be3fd664fcbd7a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 21 Oct 2013 22:27:07 -0700 Subject: [PATCH 243/258] Added patch notes for 2.0.1 --- WhatsNew.txt | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/WhatsNew.txt b/WhatsNew.txt index c3784deab..5ac78c513 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -1,3 +1,57 @@ -This is a list of API changes in SDL's version history. +This is a list of major changes in SDL's version history. +--------------------------------------------------------------------------- +2.0.1: +--------------------------------------------------------------------------- + +General: +* Added an API to get common filesystem paths in SDL_filesystem.h: + SDL_GetBasePath(), SDL_GetPrefPath() +* Added an API to do optimized YV12 and IYUV texture updates: + SDL_UpdateYUVTexture() +* Added an API to get the amount of RAM on the system: + SDL_GetSystemRAM() +* Added a macro to perform timestamp comparisons with SDL_GetTicks(): + SDL_TICKS_PASSED() +* Dramatically improved OpenGL ES 2.0 rendering performance +* Added OpenGL attribute SDL_GL_FRAMEBUFFER_SRGB_CAPABLE + +Windows: +* Created a static library configuration for the Visual Studio 2010 project +* Added a hint to create the Direct3D device with support for multi-threading: + SDL_HINT_RENDER_DIRECT3D_THREADSAFE +* Added a function to get the D3D9 adapter index for a display: + SDL_Direct3D9GetAdapterIndex() +* Added a function to get the D3D9 device for a D3D9 renderer: + SDL_RenderGetD3D9Device() +* Fixed building SDL with the mingw32 toolchain (mingw-w64 is preferred) +* Fixed crash when using two XInput controllers at the same time +* Fixed detecting a mixture of XInput and DirectInput controllers +* Fixed clearing a D3D render target larger than the window +* Improved support for format specifiers in SDL_snprintf() + +Mac OS X: +* Added support for retina displays: + Create your window with the SDL_WINDOW_ALLOW_HIGHDPI flag, and then use SDL_GL_GetDrawableSize() to find the actual drawable size. You are responsible for scaling mouse and drawing coordinates appropriately. +* Fixed mouse warping in fullscreen mode +* Right mouse click is emulated by holding the Ctrl key while left clicking + +Linux: +* Fixed float audio support with the PulseAudio driver +* Fixed missing line endpoints in the OpenGL renderer on some drivers +* X11 symbols are no longer defined to avoid collisions when linking statically + +iOS: +* Fixed status bar visibility on iOS 7 +* Flipped the accelerometer Y axis to match expected values + +Android: +IMPORTANT: You MUST get the updated SDLActivity.java to match C code +* Moved EGL initialization to native code +* Fixed the accelerometer axis rotation relative to the device rotation +* Fixed race conditions when handling the EGL context on pause/resume +* Touch devices are available for enumeration immediately after init + +Raspberry Pi: +* Added support for the Raspberry Pi, see README-raspberrypi.txt for details From 55dd45663143205fb22900ab480a5c7c9fa7a9c2 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Mon, 21 Oct 2013 23:17:37 -0700 Subject: [PATCH 244/258] Fix error assert for negative cases of pixels_getPixelFormatName test --- test/testautomation_pixels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c index 5112333cd..04e00deb2 100644 --- a/test/testautomation_pixels.c +++ b/test/testautomation_pixels.c @@ -297,7 +297,7 @@ pixels_getPixelFormatName(void *arg) } error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message is empty"); + SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty"); } return TEST_COMPLETED; From dec06dbca4ab9bf0ccb958962639a88e44d37283 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 22 Oct 2013 21:53:42 -0700 Subject: [PATCH 245/258] Testing fullscreen window in the accelerometer test. --HG-- extra : rebase_source : 891b1c0b53e6a9d509c9ba86f4fc5943fafe0ec1 --- Xcode-iOS/Demos/src/accelerometer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index bf3b86a04..3b7985faa 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -174,7 +174,7 @@ main(int argc, char *argv[]) /* create main window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | - SDL_WINDOW_BORDERLESS); + SDL_WINDOW_FULLSCREEN); renderer = SDL_CreateRenderer(window, 0, 0); SDL_GetWindowSize(window, &w, &h); From 274b054ac3c98f5097d702e7cae9bd898fd0b15a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 22 Oct 2013 21:53:58 -0700 Subject: [PATCH 246/258] SDL 2.0.0 defined __inline__ and some code relies on it now. --HG-- extra : rebase_source : b16922234216c3e66aac75ff77bcb8b041eeb729 --- include/begin_code.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/begin_code.h b/include/begin_code.h index 7adddedf2..968a540a4 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -107,8 +107,14 @@ defined(__WATCOMC__) || defined(__LCC__) || \ defined(__DECC) #define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif #else #define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif #endif #endif /* SDL_INLINE not defined */ From 0fc9b5bcf79d71a0735ebb4b14aab1d20375293f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 22 Oct 2013 21:54:52 -0700 Subject: [PATCH 247/258] Fixed duplicate const warning --HG-- extra : rebase_source : 4529dd9d2bd4eb18a194d81f300cf47553ef2044 --- src/video/x11/SDL_x11keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 9a2de45a0..f3b83c968 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -135,7 +135,7 @@ static const struct { static const struct { - const SDL_Scancode const *table; + SDL_Scancode const *table; int table_size; } scancode_set[] = { { darwin_scancode_table, SDL_arraysize(darwin_scancode_table) }, From 10fee3747620468db194aa056219547402677fcd Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 23 Oct 2013 00:58:20 -0400 Subject: [PATCH 248/258] SDL_GetPrefPath() now uses the organization on all platforms. Even if that's not the general convention for a given platform. --HG-- extra : rebase_source : f3a8035be94bd416fca5bda09d1d93101bc4b688 --- src/filesystem/beos/SDL_sysfilesystem.cc | 4 ++-- src/filesystem/cocoa/SDL_sysfilesystem.m | 6 ++---- src/filesystem/unix/SDL_sysfilesystem.c | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/filesystem/beos/SDL_sysfilesystem.cc b/src/filesystem/beos/SDL_sysfilesystem.cc index decf84cc0..dc7a97064 100644 --- a/src/filesystem/beos/SDL_sysfilesystem.cc +++ b/src/filesystem/beos/SDL_sysfilesystem.cc @@ -76,12 +76,12 @@ SDL_GetPrefPath(const char *org, const char *app) // !!! FIXME: is there a better way to do this? const char *home = SDL_getenv("HOME"); const char *append = "config/settings/"; - const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) + 2; + const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; char *retval = (char *) SDL_malloc(len); if (!retval) { SDL_OutOfMemory(); } else { - SDL_snprintf(retval, len, "%s%s%s/", home, append, app); + SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app); create_directory(retval, 0700); // BeOS api: creates missing dirs } diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 67ae24a58..760830a7f 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -73,19 +73,17 @@ SDL_GetPrefPath(const char *org, const char *app) NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); char *retval = NULL; - (void) org; /* unused on Mac OS X and iOS. */ - if ([array count] > 0) { /* we only want the first item in the list. */ NSString *str = [array objectAtIndex:0]; const char *base = [str fileSystemRepresentation]; if (base) { - const size_t len = SDL_strlen(base) + SDL_strlen(app) + 3; + const size_t len = SDL_strlen(base) + SDL_strlen(app) + 4; retval = (char *) SDL_malloc(len); if (retval == NULL) { SDL_OutOfMemory(); } else { char *ptr; - SDL_snprintf(retval, len, "%s/%s/", base, app); + SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app); for (ptr = retval+1; *ptr; ptr++) { if (*ptr == '/') { *ptr = '\0'; diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index e1d06c449..0f6e62e24 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -178,14 +178,14 @@ SDL_GetPrefPath(const char *org, const char *app) if (envr[len - 1] == '/') append += 1; - len += SDL_strlen(append) + SDL_strlen(app) + 2; + len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *) SDL_malloc(len); if (!retval) { SDL_OutOfMemory(); return NULL; } - SDL_snprintf(retval, len, "%s%s%s/", envr, append, app); + SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app); for (ptr = retval+1; *ptr; ptr++) { if (*ptr == '/') { From d89bf9b9ff787097394e22d9bca3054ca32891e5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 23 Oct 2013 15:54:12 -0400 Subject: [PATCH 249/258] Moved a SDL_SetError() call elsewhere to avoid triggering it needlessly. Otherwise, the XInput path would always trigger it in a harmless manner. --- src/haptic/windows/SDL_syshaptic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index a9f8d8342..1506235e7 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1190,7 +1190,6 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) return &GUID_CustomForce; default: - SDL_SetError("Haptic: Unknown effect type."); return NULL; } } @@ -1207,6 +1206,7 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, REFGUID type = SDL_SYS_HapticEffectType(base); if ((type == NULL) && (!haptic->hwdata->bXInputHaptic)) { + SDL_SetError("Haptic: Unknown effect type."); goto err_hweffect; } From 869a803878cb3e519713e40af8a4164f07211f4b Mon Sep 17 00:00:00 2001 From: "Pierre-Loup A. Griffais" Date: Wed, 23 Oct 2013 13:43:17 -0700 Subject: [PATCH 250/258] Fix regression causing crashes when running without a window manager. --- src/video/x11/SDL_x11events.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index ba5eca39d..d9dcc2dd9 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -525,19 +525,22 @@ X11_DispatchEvent(_THIS) long border_bottom = 0; if (data->xwindow) { Atom _net_frame_extents = X11_XInternAtom(display, "_NET_FRAME_EXTENTS", 0); - Atom type; + Atom type = None; int format; - unsigned long nitems, bytes_after; + unsigned long nitems = 0, bytes_after; unsigned char *property; X11_XGetWindowProperty(display, data->xwindow, _net_frame_extents, 0, 16, 0, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &property); - border_left = ((long*)property)[0]; - border_right = ((long*)property)[1]; - border_top = ((long*)property)[2]; - border_bottom = ((long*)property)[3]; + if (type != None && nitems == 4) + { + border_left = ((long*)property)[0]; + border_right = ((long*)property)[1]; + border_top = ((long*)property)[2]; + border_bottom = ((long*)property)[3]; + } } if (xevent.xconfigure.x != data->last_xconfigure.x || From c9c6126f95dce29752fd61b3a84f4a5a33ea49be Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Oct 2013 16:17:08 -0700 Subject: [PATCH 251/258] Added tag release-2.0.1 for changeset a8bd63b33636 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index f45c716ef..651f5c16d 100644 --- a/.hgtags +++ b/.hgtags @@ -15,3 +15,4 @@ f14cf9d71233934811774f941d0de121d5f96ccf release-1.2.14 39c22a953456f6c9e2c8993c8ff973824104102a pre-touch-removal ccf5fbfa2afabab429ad911308f362201a94d810 macosx_10_4_supported d6a8fa507a45d9de7258e51585eab3e45c415149 release-2.0.0 +a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 From 05187f9ba8de09d7af126a6a6dda134b2694a8fe Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Oct 2013 16:32:56 -0700 Subject: [PATCH 252/258] Updated Debian package version to 2.0.1 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 1065a8a95..8e9dd49bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libsdl2 (2.0.1) UNRELEASED; urgency=low + + * Updated SDL to version 2.0.1 + + -- Sam Lantinga Wed, 23 Oct 2013 16:31:38 -0800 + libsdl2 (2.0.0) UNRELEASED; urgency=low * SDL is now a native debian package. From 678e0517aa7bb29074646408089efd9c7df2b509 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Oct 2013 16:33:15 -0700 Subject: [PATCH 253/258] Added tag release-2.0.1 for changeset 715a01415ac9 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 651f5c16d..004db19aa 100644 --- a/.hgtags +++ b/.hgtags @@ -16,3 +16,5 @@ f14cf9d71233934811774f941d0de121d5f96ccf release-1.2.14 ccf5fbfa2afabab429ad911308f362201a94d810 macosx_10_4_supported d6a8fa507a45d9de7258e51585eab3e45c415149 release-2.0.0 a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 +a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 +715a01415ac9305b9f8ec72b99fcf8cc9dd64dde release-2.0.1 From c7744104c6bb2f0302e43c59748e7d298d048e71 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 23 Oct 2013 19:52:14 -0400 Subject: [PATCH 254/258] Initialize MEMORYSTATUSEX size before GlobalMemoryStatusEx() (thanks, Justin!). Fixes Bugzilla #2177. --- src/cpuinfo/SDL_cpuinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index f9b764026..fcb600656 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -642,6 +642,7 @@ SDL_GetSystemRAM(void) #ifdef __WIN32__ if (SDL_SystemRAM <= 0) { MEMORYSTATUSEX stat; + stat.dwLength = sizeof(stat); if (GlobalMemoryStatusEx(&stat)) { SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024)); } From 0d378c791a7c17ecb92aef7619238db45289eb2c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Oct 2013 17:46:07 -0700 Subject: [PATCH 255/258] Added tag release-2.0.1 for changeset 9ec71e56071c --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 004db19aa..b0d4dac33 100644 --- a/.hgtags +++ b/.hgtags @@ -18,3 +18,5 @@ d6a8fa507a45d9de7258e51585eab3e45c415149 release-2.0.0 a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 715a01415ac9305b9f8ec72b99fcf8cc9dd64dde release-2.0.1 +715a01415ac9305b9f8ec72b99fcf8cc9dd64dde release-2.0.1 +9ec71e56071cc80eda6691a3f8719ed5395dfcfb release-2.0.1 From 84929c222e2dcf39b4427d902b0c78a3b7378db3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 24 Oct 2013 00:00:10 -0400 Subject: [PATCH 256/258] Fixed buffer overflow. --- src/filesystem/cocoa/SDL_sysfilesystem.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 760830a7f..587c35cc0 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -77,7 +77,7 @@ SDL_GetPrefPath(const char *org, const char *app) NSString *str = [array objectAtIndex:0]; const char *base = [str fileSystemRepresentation]; if (base) { - const size_t len = SDL_strlen(base) + SDL_strlen(app) + 4; + const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; retval = (char *) SDL_malloc(len); if (retval == NULL) { SDL_OutOfMemory(); From db7c496f1102b50fcce4ebaf4f1f61eb90057d43 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Oct 2013 20:58:31 -0700 Subject: [PATCH 257/258] Removed tag release-2.0.1 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index b0d4dac33..c7410efd7 100644 --- a/.hgtags +++ b/.hgtags @@ -20,3 +20,5 @@ a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 715a01415ac9305b9f8ec72b99fcf8cc9dd64dde release-2.0.1 715a01415ac9305b9f8ec72b99fcf8cc9dd64dde release-2.0.1 9ec71e56071cc80eda6691a3f8719ed5395dfcfb release-2.0.1 +9ec71e56071cc80eda6691a3f8719ed5395dfcfb release-2.0.1 +0000000000000000000000000000000000000000 release-2.0.1 From f15aed6e5f753f5fde57c6e21b81c487b94db08f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Oct 2013 20:58:39 -0700 Subject: [PATCH 258/258] Added tag release-2.0.1 for changeset b9663c77f5c9 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index c7410efd7..28d0efdfd 100644 --- a/.hgtags +++ b/.hgtags @@ -22,3 +22,5 @@ a8bd63b33636715f2cf6e7d36ab7201acbd478fe release-2.0.1 9ec71e56071cc80eda6691a3f8719ed5395dfcfb release-2.0.1 9ec71e56071cc80eda6691a3f8719ed5395dfcfb release-2.0.1 0000000000000000000000000000000000000000 release-2.0.1 +0000000000000000000000000000000000000000 release-2.0.1 +b9663c77f5c95ebf05f3c18e80619caae8ae1460 release-2.0.1