Alexey Petruchik | 23 Jul 21:01 2014
Picon

[PATCH] Hint for SYSTEM_UI_FLAG_LOW_PROFILE on android

Here is a small patch that adds support of android's SYSTEM_UI_FLAG_LOW_PROFILE that makes games look more immersive.

Regards, Alexey.
# HG changeset patch
# User stopiccot <alexey.petruchik <at> gmail.com>
# Date 1406141828 -10800
# Node ID 0597ac969fec6c62baa0e4bc449b68f51b2d9e0e
# Parent  6d059ed9b6cafdeb276802426880715f2b296a7f
Hint for SYSTEM_UI_FLAG_LOW_PROFILE on android

diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/src/org/libsdl/app/SDLActivity.java
 <at>  <at>  -85,8 +85,15  <at>  <at> 

         // Set up the surface
         mSurface = new SDLSurface(getApplication());
+
+        nativeAddHintCallback(SDL_HINT_ANDROID_USE_UI_LOW_PROFILE, new SDLHintCallback() {
+             <at> Override
+            public void callback(String name, String oldValue, String newValue) {
+                updateLowProfileSettings(newValue);
+            }
+        });

-        if(Build.VERSION.SDK_INT >= 12) {
+        if (Build.VERSION.SDK_INT >= 12) {
             mJoystickHandler = new SDLJoystickHandler_API12();
         }
         else {
 <at>  <at>  -112,9 +119,9  <at>  <at> 
         Log.v("SDL", "onResume()");
         super.onResume();
         SDLActivity.handleResume();
+        updateLowProfileSettings(nativeGetHint(SDL_HINT_ANDROID_USE_UI_LOW_PROFILE));
     }

-
      <at> Override
     public void onWindowFocusChanged(boolean hasFocus) {
         super.onWindowFocusChanged(hasFocus);
 <at>  <at>  -202,6 +209,19  <at>  <at> 
         mSingleton.finish();
     }

+    private static final String SDL_HINT_ANDROID_USE_UI_LOW_PROFILE = "SDL_ANDROID_USE_UI_LOW_PROFILE";
+
+    void updateLowProfileSettings(String value) {
+        if ("1".equals(value)) {
+            runOnUiThread(new Runnable() {
+                 <at> Override
+                public void run() {
+                    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
+                }
+            });
+        }
+    }
+

     // Messages from the SDLMain thread
     static final int COMMAND_CHANGE_TITLE = 1;
 <at>  <at>  -298,7 +318,14  <at>  <at> 
                                                int is_accelerometer, int nbuttons, 
                                                int naxes, int nhats, int nballs);
     public static native int nativeRemoveJoystick(int device_id);
+    
+    interface SDLHintCallback {
+        void callback(String name, String oldValue, String newValue);
+    }
+    
     public static native String nativeGetHint(String name);
+    public static native void nativeAddHintCallback(String name, SDLHintCallback callback);
+

     /**
      * This method is called by SDL using JNI.
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
 <at>  <at>  -477,6 +477,11  <at>  <at> 
  */
 #define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"

+ /**
+ * \brief If set to 1, sets UI_LOW_PROFILE setting for SDLActivity
+ */
+#define SDL_HINT_ANDROID_USE_UI_LOW_PROFILE "SDL_ANDROID_USE_UI_LOW_PROFILE"
+

 /**
  *  \brief  An enumeration of hint priorities
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
 <at>  <at>  -396,6 +396,32  <at>  <at> 
     return result;
 }

+void Android_JNI_HintCallback(void *userdata, const char *name, const char *oldValue, const char
*newValue) {
+    JNIEnv *env = Android_JNI_GetEnv();
+
+    jobject callback = (jobject)userdata;
+    jclass cls = (*env)->GetObjectClass(env, callback);
+    jmethodID method = (*env)->GetMethodID(env, cls, "callback", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+
+    jstring javaName     = (*env)->NewStringUTF(env, name);
+    jstring javaOldValue = (*env)->NewStringUTF(env, oldValue);
+    jstring javaNewValue = (*env)->NewStringUTF(env, newValue);
+
+    (*env)->CallVoidMethod(env, callback, method, javaName, javaOldValue, javaNewValue);
+
+    (*env)->DeleteLocalRef(env, javaName);
+    (*env)->DeleteLocalRef(env, javaOldValue);
+    (*env)->DeleteLocalRef(env, javaNewValue);
+}
+
+void Java_org_libsdl_app_SDLActivity_nativeAddHintCallback(JNIEnv* env, jclass cls, jstring
name, jobject callback) {
+    const char *utfname = (*env)->GetStringUTFChars(env, name, NULL);
+
+    SDL_AddHintCallback(utfname, Android_JNI_HintCallback, (*env)->NewGlobalRef(env, callback));
+
+    (*env)->ReleaseStringUTFChars(env, name, utfname);    
+}
+
 /*******************************************************************************
              Functions called by SDL into Java
 *******************************************************************************/
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
mr_tawan | 23 Jul 18:33 2014
Picon

Re: load bmp returns NULL








DAVIDlavi20091997 wrote:
mr naith and mr tawan tanke you very much to help me dill with this problam the problam just was that the i didnt crated the renderr befure the sdl texture and that i didnt copied the image to the main cpp dirctaury, imn very surry for wasting your time on such an abstract and Trivial matter,tanke you very very much


I know that you're too excited by now. but you might want to consider asking someone to spell check first ^^' It's kinda hard to read.

Glad you get it working (I didn't really help much after all, all the credit goes to Nait.).
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Naith | 23 Jul 18:25 2014
Picon

Re: load bmp returns NULL

And what did you do to make it work?
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Naith | 23 Jul 18:09 2014
Picon

Re: load bmp returns NULL

Listen, you can not download the image and change the file extension from jpg to bmp. The file extension get changed to *.jpg when it is uploaded to tinypic. So what you need to do is download the image, open up the image in, for example Paint, and then save the image as Image.bmp and put the saved image in the two directories you've images in.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Naith | 23 Jul 18:03 2014
Picon

Re: load bmp returns NULL

http://www.speedyshare.com/Xqcfa/SDL.zip
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
mr_tawan | 23 Jul 17:49 2014
Picon

Re: load bmp returns NULL

Well it's probably better if you can just zip your whole project, upload that file, and tell us where's your file. Or may be allow some one to remote to your machine using something like teamviewer .
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Naith | 23 Jul 17:06 2014
Picon

Re: load bmp returns NULL

The first image is correct.

Make sure that your directory structure looks like this: http://oi60.tinypic.com/2ngydlt.jpg

The first picture is the root directory.
In the second picture, the Image.bmp file is in the same directory as the Main.cpp file. When you're executing the program inside Visual Studio, Visual Studio looks for the image file in the same folder as the Main.cpp file and that's the reason why the image is there.
In the third picture, the Image.bmp file is in the same directory as the exe file and SDL will look for the image file in that directory.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Naith | 23 Jul 15:32 2014
Picon

Re: load bmp returns NULL

Really weird.

In your main file, remove all of your code and replace it with the code below.
Do not change anything in the code and do not leave any code left in your main file. Your main file should be completely empty before you're paste'ing in the code below.








Code:

#include

SDL_Window* g_pWindow = NULL;
SDL_Renderer* g_pRenderer = NULL;

SDL_Texture* g_pTexture = NULL;

int main(int argc, char* args[])
{
   // Initialize SDL
   if(SDL_Init(SDL_INIT_EVERYTHING) >= 0)
   {
      // If SDL was successfully initialized, create the SDL window
      g_pWindow = SDL_CreateWindow("Chapter 1: Setting up SDL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);

      // If the SDL window was successfully created
      if(g_pWindow)
      {
         // Create the renderer
         g_pRenderer = SDL_CreateRenderer(g_pWindow, -1, SDL_RENDERER_ACCELERATED);

         // If the renderer was successfully created
         if(g_pRenderer)
         {
            // Set the render draw color
            SDL_SetRenderDrawColor(g_pRenderer, 255, 255, 255, SDL_ALPHA_OPAQUE);

            // Create the temp surface
            SDL_Surface* pTempSurface = SDL_LoadBMP("Image.bmp");

            // If the temp surface was successfully created
            if(pTempSurface)
            {
               // Create the texture
               g_pTexture = SDL_CreateTextureFromSurface(g_pRenderer, pTempSurface);

               // Destroy the temp surface
               SDL_FreeSurface(pTempSurface);
            }
         }
      }
   }

   // If SDL for some reason couldn't initialize
   else
      return 1;



   // Clear the current render target
   SDL_RenderClear(g_pRenderer);

   // Render the texture
   if(g_pTexture)
      SDL_RenderCopy(g_pRenderer, g_pTexture, NULL, NULL);

   // Update the screen
   SDL_RenderPresent(g_pRenderer);

   // Wait 2 seconds and then exit the program
   SDL_Delay(2000);



   // Destroy the texture
   if(g_pTexture)
      SDL_DestroyTexture(g_pTexture);

   // Quit SDL
   SDL_Quit();

   return 0;
}


After that I want you to download this image: http://oi60.tinypic.com/2cqms2c.jpg

If you're building the program as debug, put the image directly in your Debug folder (ergo, put the image at the same place as your exe file).
If you're building the program as release, put the image directly in your Release folder (ergo, put the image at the same place as your exe file).

After that take a screenshot of your Debug / Release folder containing the files and show the screenshot to me.

If this will not solve the problem, there's some problem with your Visual Studio project file and you should create a new blank one. In the new blank project file, after you've set it up correctly and linked in the SDL lib's and so on, create a cpp-file named Main.cpp. In that file (which should be empty), paste in the code above and try to compile and run. If that doesn't work, I'm gonna cry.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Naith | 23 Jul 15:26 2014
Picon

Re: load bmp returns NULL

Really weird.

In your main file, remove all of your code and replace it with the code below.
Do not change anything in the code and do not leave any code left in your main file. Your main file should be completely empty before you're paste'ing in the code below.








Code:

#include

SDL_Window* g_pWindow = NULL;
SDL_Renderer* g_pRenderer = NULL;

SDL_Texture* g_pTexture = NULL;

int main(int argc, char* args[])
{
   // Initialize SDL
   if(SDL_Init(SDL_INIT_EVERYTHING) >= 0)
   {
      // If SDL was successfully initialized, create the SDL window
      g_pWindow = SDL_CreateWindow("Chapter 1: Setting up SDL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);

      // If the SDL window was successfully created
      if(g_pWindow)
      {
         // Create the renderer
         g_pRenderer = SDL_CreateRenderer(g_pWindow, -1, 0);

         // If the renderer was successfully created
         if(g_pRenderer)
         {
            // Set the render draw color
            SDL_SetRenderDrawColor(g_pRenderer, 255, 255, 255, SDL_ALPHA_OPAQUE);

            // Create the temp surface
            SDL_Surface* pTempSurface = SDL_LoadBMP("Image.bmp");

            // If the temp surface was successfully created
            if(pTempSurface)
            {
               // Create the texture
               g_pTexture = SDL_CreateTextureFromSurface(g_pRenderer, pTempSurface);

               // Destroy the temp surface
               SDL_FreeSurface(pTempSurface);
            }
         }
      }
   }

   // If SDL for some reason couldn't initialize
   else
      return 1;



   // Clear the current render target
   SDL_RenderClear(g_pRenderer);

   // Render the texture
   if(g_pTexture)
      SDL_RenderCopy(g_pRenderer, g_pTexture, NULL, NULL);

   // Update the screen
   SDL_RenderPresent(g_pRenderer);

   // Wait 2 seconds and then exit the program
   SDL_Delay(2000);



   // Destroy the texture
   if(g_pTexture)
      SDL_DestroyTexture(g_pTexture);

   // Quit SDL
   SDL_Quit();

   return 0;
}


After that I want you to download this image: http://oi60.tinypic.com/2cqms2c.jpg

If you're building the program as debug, put the image directly in your Debug folder (ergo, put the image at the same place as your exe file).
If you're building the program as release, put the image directly in your Release folder (ergo, put the image at the same place as your exe file).

After that take a screenshot of your Debug / Release folder containing the files and show the screenshot to me.

If this will not solve the problem, I'm gonna cry.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Alex Barry | 23 Jul 03:10 2014
Picon

Anyone want to maintain a chocolatey package?

Hey Guys and Gals,

Has anyone heard of chocolatey, a package manager for Windows?  Just discovered it a few days ago, and see there aren't any SDL packages.  Any thoughts?  I don't mind maintaining it myself, but I don't want to start something that someone else has already taken up.  Any merits or downsides anyone can think of?

-Alex
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
MrTAToad | 23 Jul 01:05 2014

TEXTINPUT & Return/Backspace

I notice that when SDL_TextInput is active, the appropriate event doesn't detect return or backspace being pressed - instead these keys generate a SDL_KEYDOWN event, which is rather odd. It's also a bit cumbersome as you need to detect character presses in two places.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Gmane