Merged default into iOS-improvements iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Tue, 28 Oct 2014 18:36:29 -0300
branchiOS-improvements
changeset 95214c218c80b34d
parent 9520 6a655264dd47
parent 9200 bfdc18891a60
child 9522 0d0026c1805a
Merged default into iOS-improvements
include/SDL_hints.h
include/SDL_syswm.h
src/video/mx6/SDL_mx6events.c
src/video/mx6/SDL_mx6events_c.h
src/video/mx6/SDL_mx6opengles.c
src/video/mx6/SDL_mx6opengles.h
src/video/mx6/SDL_mx6video.c
src/video/mx6/SDL_mx6video.h
     1.1 --- a/CMakeLists.txt	Tue Oct 28 01:34:40 2014 -0300
     1.2 +++ b/CMakeLists.txt	Tue Oct 28 18:36:29 2014 -0300
     1.3 @@ -247,7 +247,7 @@
     1.4  set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
     1.5  set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
     1.6  set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
     1.7 -set_option(VIDEO_MX6           "Use Freescale i.MX6 video driver" OFF)
     1.8 +set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
     1.9  
    1.10  # TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
    1.11  # The options below are for compatibility to configure's default behaviour.
    1.12 @@ -679,7 +679,7 @@
    1.13      CheckOpenGLX11()
    1.14      CheckOpenGLESX11()
    1.15      CheckWayland()
    1.16 -    CheckMX6()
    1.17 +    CheckVivante()
    1.18    endif()
    1.19  
    1.20    if(LINUX)
     2.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Tue Oct 28 01:34:40 2014 -0300
     2.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Tue Oct 28 18:36:29 2014 -0300
     2.3 @@ -17,9 +17,14 @@
     2.4  import android.view.inputmethod.InputConnection;
     2.5  import android.view.inputmethod.InputMethodManager;
     2.6  import android.widget.AbsoluteLayout;
     2.7 +import android.widget.Button;
     2.8 +import android.widget.LinearLayout;
     2.9 +import android.widget.TextView;
    2.10  import android.os.*;
    2.11  import android.util.Log;
    2.12 +import android.util.SparseArray;
    2.13  import android.graphics.*;
    2.14 +import android.graphics.drawable.Drawable;
    2.15  import android.media.*;
    2.16  import android.hardware.*;
    2.17  
    2.18 @@ -33,6 +38,9 @@
    2.19      public static boolean mIsPaused, mIsSurfaceReady, mHasFocus;
    2.20      public static boolean mExitCalledFromJava;
    2.21  
    2.22 +    /** If shared libraries (e.g. SDL or the native application) could not be loaded. */
    2.23 +    public static boolean mBrokenLibraries;
    2.24 +
    2.25      // Main components
    2.26      protected static SDLActivity mSingleton;
    2.27      protected static SDLSurface mSurface;
    2.28 @@ -46,16 +54,42 @@
    2.29      // Audio
    2.30      protected static AudioTrack mAudioTrack;
    2.31  
    2.32 +    /**
    2.33 +     * This method is called by SDL before loading the native shared libraries.
    2.34 +     * It can be overridden to provide names of shared libraries to be loaded.
    2.35 +     * The default implementation returns the defaults. It never returns null.
    2.36 +     * An array returned by a new implementation must at least contain "SDL2".
    2.37 +     * Also keep in mind that the order the libraries are loaded may matter.
    2.38 +     * @return names of shared libraries to be loaded (e.g. "SDL2", "main").
    2.39 +     */
    2.40 +    protected String[] getLibraries() {
    2.41 +        return new String[] {
    2.42 +            "SDL2",
    2.43 +            // "SDL2_image",
    2.44 +            // "SDL2_mixer",
    2.45 +            // "SDL2_net",
    2.46 +            // "SDL2_ttf",
    2.47 +            "main"
    2.48 +        };
    2.49 +    }
    2.50 +
    2.51      // Load the .so
    2.52 -    static {
    2.53 -        System.loadLibrary("SDL2");
    2.54 -        //System.loadLibrary("SDL2_image");
    2.55 -        //System.loadLibrary("SDL2_mixer");
    2.56 -        //System.loadLibrary("SDL2_net");
    2.57 -        //System.loadLibrary("SDL2_ttf");
    2.58 -        System.loadLibrary("main");
    2.59 +    public void loadLibraries() {
    2.60 +       for (String lib : getLibraries()) {
    2.61 +          System.loadLibrary(lib);
    2.62 +       }
    2.63      }
    2.64      
    2.65 +    /**
    2.66 +     * This method is called by SDL using JNI.
    2.67 +     * This method is called by SDL before starting the native application thread.
    2.68 +     * It can be overridden to provide the arguments after the application name.
    2.69 +     * The default implementation returns an empty array. It never returns null.
    2.70 +     * @return arguments for the native application.
    2.71 +     */
    2.72 +    protected String[] getArguments() {
    2.73 +        return new String[0];
    2.74 +    }
    2.75      
    2.76      public static void initialize() {
    2.77          // The static nature of the singleton and Android quirkyness force us to initialize everything here
    2.78 @@ -68,6 +102,7 @@
    2.79          mSDLThread = null;
    2.80          mAudioTrack = null;
    2.81          mExitCalledFromJava = false;
    2.82 +        mBrokenLibraries = false;
    2.83          mIsPaused = false;
    2.84          mIsSurfaceReady = false;
    2.85          mHasFocus = true;
    2.86 @@ -83,6 +118,42 @@
    2.87          // So we can call stuff from static callbacks
    2.88          mSingleton = this;
    2.89  
    2.90 +        // Load shared libraries
    2.91 +        String errorMsgBrokenLib = "";
    2.92 +        try {
    2.93 +            loadLibraries();
    2.94 +        } catch(UnsatisfiedLinkError e) {
    2.95 +            System.err.println(e.getMessage());
    2.96 +            mBrokenLibraries = true;
    2.97 +            errorMsgBrokenLib = e.getMessage();
    2.98 +        } catch(Exception e) {
    2.99 +            System.err.println(e.getMessage());
   2.100 +            mBrokenLibraries = true;
   2.101 +            errorMsgBrokenLib = e.getMessage();
   2.102 +        }
   2.103 +
   2.104 +        if (mBrokenLibraries)
   2.105 +        {
   2.106 +            AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);
   2.107 +            dlgAlert.setMessage("An error occurred while trying to start the application. Please try again and/or reinstall."
   2.108 +                  + System.getProperty("line.separator")
   2.109 +                  + System.getProperty("line.separator")
   2.110 +                  + "Error: " + errorMsgBrokenLib);
   2.111 +            dlgAlert.setTitle("SDL Error");
   2.112 +            dlgAlert.setPositiveButton("Exit",
   2.113 +                new DialogInterface.OnClickListener() {
   2.114 +                    @Override
   2.115 +                    public void onClick(DialogInterface dialog,int id) {
   2.116 +                        // if this button is clicked, close current activity
   2.117 +                        SDLActivity.mSingleton.finish();
   2.118 +                    }
   2.119 +                });
   2.120 +           dlgAlert.setCancelable(false);
   2.121 +           dlgAlert.create().show();
   2.122 +
   2.123 +           return;
   2.124 +        }
   2.125 +
   2.126          // Set up the surface
   2.127          mSurface = new SDLSurface(getApplication());
   2.128          
   2.129 @@ -104,6 +175,11 @@
   2.130      protected void onPause() {
   2.131          Log.v("SDL", "onPause()");
   2.132          super.onPause();
   2.133 +
   2.134 +        if (SDLActivity.mBrokenLibraries) {
   2.135 +           return;
   2.136 +        }
   2.137 +
   2.138          SDLActivity.handlePause();
   2.139      }
   2.140  
   2.141 @@ -111,6 +187,11 @@
   2.142      protected void onResume() {
   2.143          Log.v("SDL", "onResume()");
   2.144          super.onResume();
   2.145 +
   2.146 +        if (SDLActivity.mBrokenLibraries) {
   2.147 +           return;
   2.148 +        }
   2.149 +
   2.150          SDLActivity.handleResume();
   2.151      }
   2.152  
   2.153 @@ -120,6 +201,10 @@
   2.154          super.onWindowFocusChanged(hasFocus);
   2.155          Log.v("SDL", "onWindowFocusChanged(): " + hasFocus);
   2.156  
   2.157 +        if (SDLActivity.mBrokenLibraries) {
   2.158 +           return;
   2.159 +        }
   2.160 +
   2.161          SDLActivity.mHasFocus = hasFocus;
   2.162          if (hasFocus) {
   2.163              SDLActivity.handleResume();
   2.164 @@ -130,12 +215,25 @@
   2.165      public void onLowMemory() {
   2.166          Log.v("SDL", "onLowMemory()");
   2.167          super.onLowMemory();
   2.168 +
   2.169 +        if (SDLActivity.mBrokenLibraries) {
   2.170 +           return;
   2.171 +        }
   2.172 +
   2.173          SDLActivity.nativeLowMemory();
   2.174      }
   2.175  
   2.176      @Override
   2.177      protected void onDestroy() {
   2.178          Log.v("SDL", "onDestroy()");
   2.179 +
   2.180 +        if (SDLActivity.mBrokenLibraries) {
   2.181 +           super.onDestroy();
   2.182 +           // Reset everything in case the user re opens the app
   2.183 +           SDLActivity.initialize();
   2.184 +           return;
   2.185 +        }
   2.186 +
   2.187          // Send a quit message to the application
   2.188          SDLActivity.mExitCalledFromJava = true;
   2.189          SDLActivity.nativeQuit();
   2.190 @@ -159,6 +257,11 @@
   2.191  
   2.192      @Override
   2.193      public boolean dispatchKeyEvent(KeyEvent event) {
   2.194 +
   2.195 +        if (SDLActivity.mBrokenLibraries) {
   2.196 +           return false;
   2.197 +        }
   2.198 +
   2.199          int keyCode = event.getKeyCode();
   2.200          // Ignore certain special keys so they're handled by Android
   2.201          if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
   2.202 @@ -207,6 +310,7 @@
   2.203      static final int COMMAND_CHANGE_TITLE = 1;
   2.204      static final int COMMAND_UNUSED = 2;
   2.205      static final int COMMAND_TEXTEDIT_HIDE = 3;
   2.206 +    static final int COMMAND_SET_KEEP_SCREEN_ON = 5;
   2.207  
   2.208      protected static final int COMMAND_USER = 0x8000;
   2.209  
   2.210 @@ -251,7 +355,18 @@
   2.211                      imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
   2.212                  }
   2.213                  break;
   2.214 -
   2.215 +            case COMMAND_SET_KEEP_SCREEN_ON:
   2.216 +            {
   2.217 +                Window window = ((Activity) context).getWindow();
   2.218 +                if (window != null) {
   2.219 +                    if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
   2.220 +                        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   2.221 +                    } else {
   2.222 +                        window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   2.223 +                    }
   2.224 +                }
   2.225 +                break;
   2.226 +            }
   2.227              default:
   2.228                  if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
   2.229                      Log.e(TAG, "error handling message, command is " + msg.arg1);
   2.230 @@ -272,7 +387,7 @@
   2.231      }
   2.232  
   2.233      // C functions we call
   2.234 -    public static native int nativeInit();
   2.235 +    public static native int nativeInit(Object arguments);
   2.236      public static native void nativeLowMemory();
   2.237      public static native void nativeQuit();
   2.238      public static native void nativePause();
   2.239 @@ -583,6 +698,211 @@
   2.240  
   2.241          return fileStream;
   2.242      }
   2.243 +
   2.244 +    // Messagebox
   2.245 +
   2.246 +    /** Result of current messagebox. Also used for blocking the calling thread. */
   2.247 +    protected final int[] messageboxSelection = new int[1];
   2.248 +
   2.249 +    /** Id of current dialog. */
   2.250 +    protected int dialogs = 0;
   2.251 +
   2.252 +    /**
   2.253 +     * This method is called by SDL using JNI.
   2.254 +     * Shows the messagebox from UI thread and block calling thread.
   2.255 +     * buttonFlags, buttonIds and buttonTexts must have same length.
   2.256 +     * @param buttonFlags array containing flags for every button.
   2.257 +     * @param buttonIds array containing id for every button.
   2.258 +     * @param buttonTexts array containing text for every button.
   2.259 +     * @param colors null for default or array of length 5 containing colors.
   2.260 +     * @return button id or -1.
   2.261 +     */
   2.262 +    public int messageboxShowMessageBox(
   2.263 +            final int flags,
   2.264 +            final String title,
   2.265 +            final String message,
   2.266 +            final int[] buttonFlags,
   2.267 +            final int[] buttonIds,
   2.268 +            final String[] buttonTexts,
   2.269 +            final int[] colors) {
   2.270 +
   2.271 +        messageboxSelection[0] = -1;
   2.272 +
   2.273 +        // sanity checks
   2.274 +
   2.275 +        if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) {
   2.276 +            return -1; // implementation broken
   2.277 +        }
   2.278 +
   2.279 +        // collect arguments for Dialog
   2.280 +
   2.281 +        final Bundle args = new Bundle();
   2.282 +        args.putInt("flags", flags);
   2.283 +        args.putString("title", title);
   2.284 +        args.putString("message", message);
   2.285 +        args.putIntArray("buttonFlags", buttonFlags);
   2.286 +        args.putIntArray("buttonIds", buttonIds);
   2.287 +        args.putStringArray("buttonTexts", buttonTexts);
   2.288 +        args.putIntArray("colors", colors);
   2.289 +
   2.290 +        // trigger Dialog creation on UI thread
   2.291 +
   2.292 +        runOnUiThread(new Runnable() {
   2.293 +            @Override
   2.294 +            public void run() {
   2.295 +                showDialog(dialogs++, args);
   2.296 +            }
   2.297 +        });
   2.298 +
   2.299 +        // block the calling thread
   2.300 +
   2.301 +        synchronized (messageboxSelection) {
   2.302 +            try {
   2.303 +                messageboxSelection.wait();
   2.304 +            } catch (InterruptedException ex) {
   2.305 +                ex.printStackTrace();
   2.306 +                return -1;
   2.307 +            }
   2.308 +        }
   2.309 +
   2.310 +        // return selected value
   2.311 +
   2.312 +        return messageboxSelection[0];
   2.313 +    }
   2.314 +
   2.315 +    @Override
   2.316 +    protected Dialog onCreateDialog(int ignore, Bundle args) {
   2.317 +
   2.318 +        // TODO set values from "flags" to messagebox dialog
   2.319 +
   2.320 +        // get colors
   2.321 +
   2.322 +        int[] colors = args.getIntArray("colors");
   2.323 +        int backgroundColor;
   2.324 +        int textColor;
   2.325 +        int buttonBorderColor;
   2.326 +        int buttonBackgroundColor;
   2.327 +        int buttonSelectedColor;
   2.328 +        if (colors != null) {
   2.329 +            int i = -1;
   2.330 +            backgroundColor = colors[++i];
   2.331 +            textColor = colors[++i];
   2.332 +            buttonBorderColor = colors[++i];
   2.333 +            buttonBackgroundColor = colors[++i];
   2.334 +            buttonSelectedColor = colors[++i];
   2.335 +        } else {
   2.336 +            backgroundColor = Color.TRANSPARENT;
   2.337 +            textColor = Color.TRANSPARENT;
   2.338 +            buttonBorderColor = Color.TRANSPARENT;
   2.339 +            buttonBackgroundColor = Color.TRANSPARENT;
   2.340 +            buttonSelectedColor = Color.TRANSPARENT;
   2.341 +        }
   2.342 +
   2.343 +        // create dialog with title and a listener to wake up calling thread
   2.344 +
   2.345 +        final Dialog dialog = new Dialog(this);
   2.346 +        dialog.setTitle(args.getString("title"));
   2.347 +        dialog.setCancelable(false);
   2.348 +        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
   2.349 +            @Override
   2.350 +            public void onDismiss(DialogInterface unused) {
   2.351 +                synchronized (messageboxSelection) {
   2.352 +                    messageboxSelection.notify();
   2.353 +                }
   2.354 +            }
   2.355 +        });
   2.356 +
   2.357 +        // create text
   2.358 +
   2.359 +        TextView message = new TextView(this);
   2.360 +        message.setGravity(Gravity.CENTER);
   2.361 +        message.setText(args.getString("message"));
   2.362 +        if (textColor != Color.TRANSPARENT) {
   2.363 +            message.setTextColor(textColor);
   2.364 +        }
   2.365 +
   2.366 +        // create buttons
   2.367 +
   2.368 +        int[] buttonFlags = args.getIntArray("buttonFlags");
   2.369 +        int[] buttonIds = args.getIntArray("buttonIds");
   2.370 +        String[] buttonTexts = args.getStringArray("buttonTexts");
   2.371 +
   2.372 +        final SparseArray<Button> mapping = new SparseArray<Button>();
   2.373 +
   2.374 +        LinearLayout buttons = new LinearLayout(this);
   2.375 +        buttons.setOrientation(LinearLayout.HORIZONTAL);
   2.376 +        buttons.setGravity(Gravity.CENTER);
   2.377 +        for (int i = 0; i < buttonTexts.length; ++i) {
   2.378 +            Button button = new Button(this);
   2.379 +            final int id = buttonIds[i];
   2.380 +            button.setOnClickListener(new View.OnClickListener() {
   2.381 +                @Override
   2.382 +                public void onClick(View v) {
   2.383 +                    messageboxSelection[0] = id;
   2.384 +                    dialog.dismiss();
   2.385 +                }
   2.386 +            });
   2.387 +            if (buttonFlags[i] != 0) {
   2.388 +                // see SDL_messagebox.h
   2.389 +                if ((buttonFlags[i] & 0x00000001) != 0) {
   2.390 +                    mapping.put(KeyEvent.KEYCODE_ENTER, button);
   2.391 +                }
   2.392 +                if ((buttonFlags[i] & 0x00000002) != 0) {
   2.393 +                    mapping.put(111, button); /* API 11: KeyEvent.KEYCODE_ESCAPE */
   2.394 +                }
   2.395 +            }
   2.396 +            button.setText(buttonTexts[i]);
   2.397 +            if (textColor != Color.TRANSPARENT) {
   2.398 +                button.setTextColor(textColor);
   2.399 +            }
   2.400 +            if (buttonBorderColor != Color.TRANSPARENT) {
   2.401 +                // TODO set color for border of messagebox button
   2.402 +            }
   2.403 +            if (buttonBackgroundColor != Color.TRANSPARENT) {
   2.404 +                Drawable drawable = button.getBackground();
   2.405 +                if (drawable == null) {
   2.406 +                    // setting the color this way removes the style
   2.407 +                    button.setBackgroundColor(buttonBackgroundColor);
   2.408 +                } else {
   2.409 +                    // setting the color this way keeps the style (gradient, padding, etc.)
   2.410 +                    drawable.setColorFilter(buttonBackgroundColor, PorterDuff.Mode.MULTIPLY);
   2.411 +                }
   2.412 +            }
   2.413 +            if (buttonSelectedColor != Color.TRANSPARENT) {
   2.414 +                // TODO set color for selected messagebox button
   2.415 +            }
   2.416 +            buttons.addView(button);
   2.417 +        }
   2.418 +
   2.419 +        // create content
   2.420 +
   2.421 +        LinearLayout content = new LinearLayout(this);
   2.422 +        content.setOrientation(LinearLayout.VERTICAL);
   2.423 +        content.addView(message);
   2.424 +        content.addView(buttons);
   2.425 +        if (backgroundColor != Color.TRANSPARENT) {
   2.426 +            content.setBackgroundColor(backgroundColor);
   2.427 +        }
   2.428 +
   2.429 +        // add content to dialog and return
   2.430 +
   2.431 +        dialog.setContentView(content);
   2.432 +        dialog.setOnKeyListener(new Dialog.OnKeyListener() {
   2.433 +            @Override
   2.434 +            public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) {
   2.435 +                Button button = mapping.get(keyCode);
   2.436 +                if (button != null) {
   2.437 +                    if (event.getAction() == KeyEvent.ACTION_UP) {
   2.438 +                        button.performClick();
   2.439 +                    }
   2.440 +                    return true; // also for ignored actions
   2.441 +                }
   2.442 +                return false;
   2.443 +            }
   2.444 +        });
   2.445 +
   2.446 +        return dialog;
   2.447 +    }
   2.448  }
   2.449  
   2.450  /**
   2.451 @@ -592,7 +912,7 @@
   2.452      @Override
   2.453      public void run() {
   2.454          // Runs SDL_main()
   2.455 -        SDLActivity.nativeInit();
   2.456 +        SDLActivity.nativeInit(SDLActivity.mSingleton.getArguments());
   2.457  
   2.458          //Log.v("SDL", "SDL thread terminated");
   2.459      }
   2.460 @@ -733,16 +1053,16 @@
   2.461              // This is the entry point to the C app.
   2.462              // Start up the C app thread and enable sensor input for the first time
   2.463  
   2.464 -            SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread");
   2.465 +            final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
   2.466              enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   2.467 -            SDLActivity.mSDLThread.start();
   2.468 +            sdlThread.start();
   2.469              
   2.470              // Set up a listener thread to catch when the native thread ends
   2.471 -            new Thread(new Runnable(){
   2.472 +            SDLActivity.mSDLThread = new Thread(new Runnable(){
   2.473                  @Override
   2.474                  public void run(){
   2.475                      try {
   2.476 -                        SDLActivity.mSDLThread.join();
   2.477 +                        sdlThread.join();
   2.478                      }
   2.479                      catch(Exception e){}
   2.480                      finally{ 
   2.481 @@ -752,7 +1072,8 @@
   2.482                          }
   2.483                      }
   2.484                  }
   2.485 -            }).start();
   2.486 +            });
   2.487 +            SDLActivity.mSDLThread.start();
   2.488          }
   2.489      }
   2.490  
     3.1 --- a/cmake/sdlchecks.cmake	Tue Oct 28 01:34:40 2014 -0300
     3.2 +++ b/cmake/sdlchecks.cmake	Tue Oct 28 18:36:29 2014 -0300
     3.3 @@ -602,22 +602,33 @@
     3.4  
     3.5  # Requires:
     3.6  # - n/a
     3.7 -macro(CheckMX6)
     3.8 -  if(VIDEO_MX6)
     3.9 +macro(CheckVivante)
    3.10 +  if(VIDEO_VIVANTE)
    3.11      check_c_source_compiles("
    3.12 +        #include <gc_vdk.h>
    3.13 +        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_VDK)
    3.14 +    check_c_source_compiles("
    3.15 +        #define LINUX
    3.16          #define EGL_API_FB
    3.17          #include <EGL/eglvivante.h>
    3.18 -        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL_VIVANTE)
    3.19 -    if(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
    3.20 -      set(HAVE_VIDEO_MX6 TRUE)
    3.21 +        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_EGL_FB)
    3.22 +    if(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
    3.23 +      set(HAVE_VIDEO_VIVANTE TRUE)
    3.24        set(HAVE_SDL_VIDEO TRUE)
    3.25  
    3.26 -      file(GLOB MX6_SOURCES ${SDL2_SOURCE_DIR}/src/video/mx6/*.c)
    3.27 -      set(SOURCE_FILES ${SOURCE_FILES} ${MX6_SOURCES})
    3.28 -      set(SDL_VIDEO_DRIVER_MX6 1)
    3.29 -    endif(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
    3.30 -  endif(VIDEO_MX6)
    3.31 -endmacro(CheckMX6)
    3.32 +      file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
    3.33 +      set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
    3.34 +      set(SDL_VIDEO_DRIVER_VIVANTE 1)
    3.35 +      if(HAVE_VIDEO_VIVANTE_VDK)
    3.36 +        set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
    3.37 +        list(APPEND EXTRA_LIBS VDK VIVANTE)
    3.38 +      else()
    3.39 +        set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
    3.40 +        list(APPEND EXTRA_LIBS EGL)
    3.41 +      endif(HAVE_VIDEO_VIVANTE_VDK)
    3.42 +    endif(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
    3.43 +  endif(VIDEO_VIVANTE)
    3.44 +endmacro(CheckVivante)
    3.45  
    3.46  # Requires:
    3.47  # - nada
     4.1 --- a/configure	Tue Oct 28 01:34:40 2014 -0300
     4.2 +++ b/configure	Tue Oct 28 18:36:29 2014 -0300
     4.3 @@ -832,7 +832,7 @@
     4.4  enable_video_x11_scrnsaver
     4.5  enable_video_x11_xshape
     4.6  enable_video_x11_vm
     4.7 -enable_video_mx6
     4.8 +enable_video_vivante
     4.9  enable_video_cocoa
    4.10  enable_video_directfb
    4.11  enable_directfb_shared
    4.12 @@ -841,6 +841,8 @@
    4.13  enable_video_dummy
    4.14  enable_video_opengl
    4.15  enable_video_opengles
    4.16 +enable_video_opengles1
    4.17 +enable_video_opengles2
    4.18  enable_libudev
    4.19  enable_dbus
    4.20  enable_ibus
    4.21 @@ -1562,7 +1564,7 @@
    4.22    --enable-video-x11-xshape
    4.23                            enable X11 XShape support [[default=yes]]
    4.24    --enable-video-x11-vm   use X11 VM extension for fullscreen [[default=yes]]
    4.25 -  --enable-video-mx6      use Freescale i.MX6 video driver [[default=no]]
    4.26 +  --enable-video-vivante  use Vivante EGL video driver [[default=yes]]
    4.27    --enable-video-cocoa    use Cocoa video driver [[default=yes]]
    4.28    --enable-video-directfb use DirectFB video driver [[default=no]]
    4.29    --enable-directfb-shared
    4.30 @@ -1574,6 +1576,10 @@
    4.31    --enable-video-dummy    use dummy video driver [[default=yes]]
    4.32    --enable-video-opengl   include OpenGL support [[default=yes]]
    4.33    --enable-video-opengles include OpenGL ES support [[default=yes]]
    4.34 +  --enable-video-opengles1
    4.35 +                          include OpenGL ES 1.1 support [[default=yes]]
    4.36 +  --enable-video-opengles2
    4.37 +                          include OpenGL ES 2.0 support [[default=yes]]
    4.38    --enable-libudev        enable libudev support [[default=yes]]
    4.39    --enable-dbus           enable D-Bus support [[default=yes]]
    4.40    --enable-ibus           enable IBus support [[default=yes]]
    4.41 @@ -20593,22 +20599,51 @@
    4.42      fi
    4.43  }
    4.44  
    4.45 -CheckMX6Video()
    4.46 -{
    4.47 -    # Check whether --enable-video-mx6 was given.
    4.48 -if test "${enable_video_mx6+set}" = set; then :
    4.49 -  enableval=$enable_video_mx6;
    4.50 -else
    4.51 -  enable_video_mx6=no
    4.52 -fi
    4.53 -
    4.54 -    if test x$enable_video = xyes -a x$enable_video_mx6 = xyes; then
    4.55 -        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante GPU SDK" >&5
    4.56 -$as_echo_n "checking for Vivante GPU SDK... " >&6; }
    4.57 -        have_viv_sdk=no
    4.58 +CheckVivanteVideo()
    4.59 +{
    4.60 +    # Check whether --enable-video-vivante was given.
    4.61 +if test "${enable_video_vivante+set}" = set; then :
    4.62 +  enableval=$enable_video_vivante;
    4.63 +else
    4.64 +  enable_video_vivante=yes
    4.65 +fi
    4.66 +
    4.67 +    if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
    4.68 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante VDK API" >&5
    4.69 +$as_echo_n "checking for Vivante VDK API... " >&6; }
    4.70 +        have_vivante_vdk=no
    4.71          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    4.72  /* end confdefs.h.  */
    4.73  
    4.74 +          #define LINUX
    4.75 +          #define EGL_API_FB
    4.76 +          #include <gc_vdk.h>
    4.77 +
    4.78 +int
    4.79 +main ()
    4.80 +{
    4.81 +
    4.82 +
    4.83 +  ;
    4.84 +  return 0;
    4.85 +}
    4.86 +_ACEOF
    4.87 +if ac_fn_c_try_compile "$LINENO"; then :
    4.88 +
    4.89 +        have_vivante_vdk=yes
    4.90 +
    4.91 +fi
    4.92 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    4.93 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_vdk" >&5
    4.94 +$as_echo "$have_vivante_vdk" >&6; }
    4.95 +
    4.96 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante FB API" >&5
    4.97 +$as_echo_n "checking for Vivante FB API... " >&6; }
    4.98 +        have_vivante_egl=no
    4.99 +        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.100 +/* end confdefs.h.  */
   4.101 +
   4.102 +          #define LINUX
   4.103            #define EGL_API_FB
   4.104            #include <EGL/eglvivante.h>
   4.105  
   4.106 @@ -20623,18 +20658,26 @@
   4.107  _ACEOF
   4.108  if ac_fn_c_try_compile "$LINENO"; then :
   4.109  
   4.110 -        have_viv_sdk=yes
   4.111 -
   4.112 -fi
   4.113 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   4.114 -        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_viv_sdk" >&5
   4.115 -$as_echo "$have_viv_sdk" >&6; }
   4.116 -        if test x$have_viv_sdk = xyes; then
   4.117 -
   4.118 -$as_echo "#define SDL_VIDEO_DRIVER_MX6 1" >>confdefs.h
   4.119 -
   4.120 -            SOURCES="$SOURCES $srcdir/src/video/mx6/*.c"
   4.121 -            SUMMARY_video="${SUMMARY_video} mx6"
   4.122 +        have_vivante_egl=yes
   4.123 +
   4.124 +fi
   4.125 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   4.126 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_egl" >&5
   4.127 +$as_echo "$have_vivante_egl" >&6; }
   4.128 +
   4.129 +        if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
   4.130 +
   4.131 +$as_echo "#define SDL_VIDEO_DRIVER_VIVANTE 1" >>confdefs.h
   4.132 +
   4.133 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
   4.134 +            if test x$have_vivante_vdk = xyes; then
   4.135 +
   4.136 +$as_echo "#define SDL_VIDEO_DRIVER_VIVANTE_VDK 1" >>confdefs.h
   4.137 +
   4.138 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
   4.139 +            fi
   4.140 +            SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
   4.141 +            SUMMARY_video="${SUMMARY_video} vivante"
   4.142              have_video=yes
   4.143          fi
   4.144      fi
   4.145 @@ -21083,6 +21126,20 @@
   4.146    enable_video_opengles=yes
   4.147  fi
   4.148  
   4.149 +# Check whether --enable-video-opengles1 was given.
   4.150 +if test "${enable_video_opengles1+set}" = set; then :
   4.151 +  enableval=$enable_video_opengles1;
   4.152 +else
   4.153 +  enable_video_opengles1=yes
   4.154 +fi
   4.155 +
   4.156 +# Check whether --enable-video-opengles2 was given.
   4.157 +if test "${enable_video_opengles2+set}" = set; then :
   4.158 +  enableval=$enable_video_opengles2;
   4.159 +else
   4.160 +  enable_video_opengles2=yes
   4.161 +fi
   4.162 +
   4.163  
   4.164  CheckOpenGLESX11()
   4.165  {
   4.166 @@ -21093,9 +21150,10 @@
   4.167          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.168  /* end confdefs.h.  */
   4.169  
   4.170 -         #define EGL_API_FB
   4.171 -         #include <EGL/egl.h>
   4.172 -         #include <EGL/eglext.h>
   4.173 +          #define LINUX
   4.174 +          #define EGL_API_FB
   4.175 +          #include <EGL/egl.h>
   4.176 +          #include <EGL/eglext.h>
   4.177  
   4.178  int
   4.179  main ()
   4.180 @@ -21120,76 +21178,80 @@
   4.181  
   4.182          fi
   4.183  
   4.184 -        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5
   4.185 +        if test x$enable_video_opengles1 = xyes; then
   4.186 +            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5
   4.187  $as_echo_n "checking for OpenGL ES v1 headers... " >&6; }
   4.188 -        video_opengles_v1=no
   4.189 -        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.190 -/* end confdefs.h.  */
   4.191 -
   4.192 -         #include <GLES/gl.h>
   4.193 -         #include <GLES/glext.h>
   4.194 -
   4.195 -int
   4.196 -main ()
   4.197 -{
   4.198 -
   4.199 -
   4.200 -  ;
   4.201 -  return 0;
   4.202 -}
   4.203 -_ACEOF
   4.204 -if ac_fn_c_try_compile "$LINENO"; then :
   4.205 -
   4.206 -        video_opengles_v1=yes
   4.207 -
   4.208 -fi
   4.209 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   4.210 -        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5
   4.211 +            video_opengles_v1=no
   4.212 +            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.213 +/* end confdefs.h.  */
   4.214 +
   4.215 +             #include <GLES/gl.h>
   4.216 +             #include <GLES/glext.h>
   4.217 +
   4.218 +int
   4.219 +main ()
   4.220 +{
   4.221 +
   4.222 +
   4.223 +  ;
   4.224 +  return 0;
   4.225 +}
   4.226 +_ACEOF
   4.227 +if ac_fn_c_try_compile "$LINENO"; then :
   4.228 +
   4.229 +            video_opengles_v1=yes
   4.230 +
   4.231 +fi
   4.232 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   4.233 +            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5
   4.234  $as_echo "$video_opengles_v1" >&6; }
   4.235 -        if test x$video_opengles_v1 = xyes; then
   4.236 +            if test x$video_opengles_v1 = xyes; then
   4.237  
   4.238  $as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h
   4.239  
   4.240  
   4.241  $as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h
   4.242  
   4.243 -            SUMMARY_video="${SUMMARY_video} opengl_es1"
   4.244 -        fi
   4.245 -
   4.246 -        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5
   4.247 +                SUMMARY_video="${SUMMARY_video} opengl_es1"
   4.248 +            fi
   4.249 +        fi
   4.250 +
   4.251 +        if test x$enable_video_opengles2 = xyes; then
   4.252 +            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5
   4.253  $as_echo_n "checking for OpenGL ES v2 headers... " >&6; }
   4.254 -        video_opengles_v2=no
   4.255 -        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.256 -/* end confdefs.h.  */
   4.257 -
   4.258 -         #include <GLES2/gl2.h>
   4.259 -         #include <GLES2/gl2ext.h>
   4.260 -
   4.261 -int
   4.262 -main ()
   4.263 -{
   4.264 -
   4.265 -
   4.266 -  ;
   4.267 -  return 0;
   4.268 -}
   4.269 -_ACEOF
   4.270 -if ac_fn_c_try_compile "$LINENO"; then :
   4.271 -
   4.272 -        video_opengles_v2=yes
   4.273 -
   4.274 -fi
   4.275 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   4.276 -        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5
   4.277 +            video_opengles_v2=no
   4.278 +            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.279 +/* end confdefs.h.  */
   4.280 +
   4.281 +             #include <GLES2/gl2.h>
   4.282 +             #include <GLES2/gl2ext.h>
   4.283 +
   4.284 +int
   4.285 +main ()
   4.286 +{
   4.287 +
   4.288 +
   4.289 +  ;
   4.290 +  return 0;
   4.291 +}
   4.292 +_ACEOF
   4.293 +if ac_fn_c_try_compile "$LINENO"; then :
   4.294 +
   4.295 +            video_opengles_v2=yes
   4.296 +
   4.297 +fi
   4.298 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   4.299 +            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5
   4.300  $as_echo "$video_opengles_v2" >&6; }
   4.301 -        if test x$video_opengles_v2 = xyes; then
   4.302 +            if test x$video_opengles_v2 = xyes; then
   4.303  
   4.304  $as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h
   4.305  
   4.306  
   4.307  $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
   4.308  
   4.309 -            SUMMARY_video="${SUMMARY_video} opengl_es2"
   4.310 +                SUMMARY_video="${SUMMARY_video} opengl_es2"
   4.311 +            fi
   4.312          fi
   4.313      fi
   4.314  }
   4.315 @@ -21657,10 +21719,10 @@
   4.316  fi
   4.317  
   4.318      case "$host" in
   4.319 -	 *-*-androideabi*)
   4.320 +         *-*-androideabi*)
   4.321              pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   4.322              pthread_lib=""
   4.323 -	    ;;
   4.324 +            ;;
   4.325          *-*-linux*|*-*-uclinux*)
   4.326              pthread_cflags="-D_REENTRANT"
   4.327              pthread_lib="-lpthread"
   4.328 @@ -22868,7 +22930,7 @@
   4.329          CheckClockGettime
   4.330          CheckLinuxVersion
   4.331          CheckRPATH
   4.332 -        CheckMX6Video
   4.333 +        CheckVivanteVideo
   4.334          # Set up files for the audio library
   4.335          if test x$enable_audio = xyes; then
   4.336            case $ARCH in
     5.1 --- a/configure.in	Tue Oct 28 01:34:40 2014 -0300
     5.2 +++ b/configure.in	Tue Oct 28 18:36:29 2014 -0300
     5.3 @@ -1729,27 +1729,46 @@
     5.4      fi
     5.5  }
     5.6  
     5.7 -dnl Set up the MX6 video driver if enabled
     5.8 -CheckMX6Video()
     5.9 +dnl Set up the Vivante video driver if enabled
    5.10 +CheckVivanteVideo()
    5.11  {
    5.12 -    AC_ARG_ENABLE(video-mx6,
    5.13 -AC_HELP_STRING([--enable-video-mx6], [use Freescale i.MX6 video driver [[default=no]]]),
    5.14 -                  , enable_video_mx6=no)
    5.15 -    if test x$enable_video = xyes -a x$enable_video_mx6 = xyes; then
    5.16 -        AC_MSG_CHECKING(for Vivante GPU SDK)
    5.17 -        have_viv_sdk=no
    5.18 +    AC_ARG_ENABLE(video-vivante,
    5.19 +AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
    5.20 +                  , enable_video_vivante=yes)
    5.21 +    if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
    5.22 +        AC_MSG_CHECKING(for Vivante VDK API)
    5.23 +        have_vivante_vdk=no
    5.24          AC_TRY_COMPILE([
    5.25 +          #define LINUX
    5.26 +          #define EGL_API_FB
    5.27 +          #include <gc_vdk.h>
    5.28 +        ],[
    5.29 +        ],[
    5.30 +        have_vivante_vdk=yes
    5.31 +        ])
    5.32 +        AC_MSG_RESULT($have_vivante_vdk)
    5.33 +
    5.34 +        AC_MSG_CHECKING(for Vivante FB API)
    5.35 +        have_vivante_egl=no
    5.36 +        AC_TRY_COMPILE([
    5.37 +          #define LINUX
    5.38            #define EGL_API_FB
    5.39            #include <EGL/eglvivante.h>
    5.40          ],[
    5.41          ],[
    5.42 -        have_viv_sdk=yes
    5.43 +        have_vivante_egl=yes
    5.44          ])
    5.45 -        AC_MSG_RESULT($have_viv_sdk)
    5.46 -        if test x$have_viv_sdk = xyes; then
    5.47 -            AC_DEFINE(SDL_VIDEO_DRIVER_MX6, 1, [ ])
    5.48 -            SOURCES="$SOURCES $srcdir/src/video/mx6/*.c"
    5.49 -            SUMMARY_video="${SUMMARY_video} mx6"
    5.50 +        AC_MSG_RESULT($have_vivante_egl)
    5.51 +
    5.52 +        if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
    5.53 +            AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
    5.54 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
    5.55 +            if test x$have_vivante_vdk = xyes; then
    5.56 +                AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
    5.57 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
    5.58 +            fi
    5.59 +            SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
    5.60 +            SUMMARY_video="${SUMMARY_video} vivante"
    5.61              have_video=yes
    5.62          fi
    5.63      fi
    5.64 @@ -1973,6 +1992,12 @@
    5.65  AC_ARG_ENABLE(video-opengles,
    5.66  AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
    5.67                , enable_video_opengles=yes)
    5.68 +AC_ARG_ENABLE(video-opengles1,
    5.69 +AC_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]),
    5.70 +              , enable_video_opengles1=yes)
    5.71 +AC_ARG_ENABLE(video-opengles2,
    5.72 +AC_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
    5.73 +              , enable_video_opengles2=yes)
    5.74  
    5.75  dnl Find OpenGL ES
    5.76  CheckOpenGLESX11()
    5.77 @@ -1981,9 +2006,10 @@
    5.78          AC_MSG_CHECKING(for EGL support)
    5.79          video_opengl_egl=no
    5.80          AC_TRY_COMPILE([
    5.81 -         #define EGL_API_FB
    5.82 -         #include <EGL/egl.h>
    5.83 -         #include <EGL/eglext.h>
    5.84 +          #define LINUX
    5.85 +          #define EGL_API_FB
    5.86 +          #include <EGL/egl.h>
    5.87 +          #include <EGL/eglext.h>
    5.88          ],[
    5.89          ],[
    5.90          video_opengl_egl=yes
    5.91 @@ -1993,36 +2019,40 @@
    5.92              AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
    5.93          fi
    5.94              
    5.95 -        AC_MSG_CHECKING(for OpenGL ES v1 headers)
    5.96 -        video_opengles_v1=no
    5.97 -        AC_TRY_COMPILE([
    5.98 -         #include <GLES/gl.h>
    5.99 -         #include <GLES/glext.h>
   5.100 -        ],[
   5.101 -        ],[
   5.102 -        video_opengles_v1=yes
   5.103 -        ])
   5.104 -        AC_MSG_RESULT($video_opengles_v1)
   5.105 -        if test x$video_opengles_v1 = xyes; then
   5.106 -            AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
   5.107 -            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
   5.108 -            SUMMARY_video="${SUMMARY_video} opengl_es1"
   5.109 +        if test x$enable_video_opengles1 = xyes; then
   5.110 +            AC_MSG_CHECKING(for OpenGL ES v1 headers)
   5.111 +            video_opengles_v1=no
   5.112 +            AC_TRY_COMPILE([
   5.113 +             #include <GLES/gl.h>
   5.114 +             #include <GLES/glext.h>
   5.115 +            ],[
   5.116 +            ],[
   5.117 +            video_opengles_v1=yes
   5.118 +            ])
   5.119 +            AC_MSG_RESULT($video_opengles_v1)
   5.120 +            if test x$video_opengles_v1 = xyes; then
   5.121 +                AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
   5.122 +                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
   5.123 +                SUMMARY_video="${SUMMARY_video} opengl_es1"
   5.124 +            fi
   5.125          fi
   5.126          
   5.127 -        AC_MSG_CHECKING(for OpenGL ES v2 headers)
   5.128 -        video_opengles_v2=no
   5.129 -        AC_TRY_COMPILE([
   5.130 -         #include <GLES2/gl2.h>
   5.131 -         #include <GLES2/gl2ext.h>
   5.132 -        ],[
   5.133 -        ],[
   5.134 -        video_opengles_v2=yes
   5.135 -        ])
   5.136 -        AC_MSG_RESULT($video_opengles_v2)
   5.137 -        if test x$video_opengles_v2 = xyes; then
   5.138 -            AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
   5.139 -            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
   5.140 -            SUMMARY_video="${SUMMARY_video} opengl_es2"
   5.141 +        if test x$enable_video_opengles2 = xyes; then
   5.142 +            AC_MSG_CHECKING(for OpenGL ES v2 headers)
   5.143 +            video_opengles_v2=no
   5.144 +            AC_TRY_COMPILE([
   5.145 +             #include <GLES2/gl2.h>
   5.146 +             #include <GLES2/gl2ext.h>
   5.147 +            ],[
   5.148 +            ],[
   5.149 +            video_opengles_v2=yes
   5.150 +            ])
   5.151 +            AC_MSG_RESULT($video_opengles_v2)
   5.152 +            if test x$video_opengles_v2 = xyes; then
   5.153 +                AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
   5.154 +                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
   5.155 +                SUMMARY_video="${SUMMARY_video} opengl_es2"
   5.156 +            fi
   5.157          fi
   5.158      fi
   5.159  }
   5.160 @@ -2258,10 +2288,10 @@
   5.161  AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
   5.162                    , enable_pthread_sem=yes)
   5.163      case "$host" in
   5.164 -	 *-*-androideabi*)
   5.165 +         *-*-androideabi*)
   5.166              pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   5.167              pthread_lib=""
   5.168 -	    ;;
   5.169 +            ;;
   5.170          *-*-linux*|*-*-uclinux*)
   5.171              pthread_cflags="-D_REENTRANT"
   5.172              pthread_lib="-lpthread"
   5.173 @@ -2836,7 +2866,7 @@
   5.174          CheckClockGettime
   5.175          CheckLinuxVersion
   5.176          CheckRPATH
   5.177 -        CheckMX6Video
   5.178 +        CheckVivanteVideo
   5.179          # Set up files for the audio library
   5.180          if test x$enable_audio = xyes; then
   5.181            case $ARCH in
     6.1 --- a/docs/README-raspberrypi.md	Tue Oct 28 01:34:40 2014 -0300
     6.2 +++ b/docs/README-raspberrypi.md	Tue Oct 28 18:36:29 2014 -0300
     6.3 @@ -151,6 +151,23 @@
     6.4      sudo dpkg-reconfigure locales
     6.5  
     6.6  ================================================================================
     6.7 + OpenGL problems
     6.8 +================================================================================
     6.9 +
    6.10 +If you have desktop OpenGL headers installed at build time in your RPi or cross 
    6.11 +compilation environment, support for it will be built in. However, the chipset 
    6.12 +does not actually have support for it, which causes issues in certain SDL apps 
    6.13 +since the presence of OpenGL support supersedes the ES/ES2 variants.
    6.14 +The workaround is to disable OpenGL at configuration time:
    6.15 +
    6.16 +    ./configure --disable-video-opengl
    6.17 +
    6.18 +Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
    6.19 +environment variable:
    6.20 +
    6.21 +    export SDL_RENDER_DRIVER=opengles2
    6.22 +
    6.23 +================================================================================
    6.24   Notes
    6.25  ================================================================================
    6.26  
     7.1 --- a/docs/README-winrt.md	Tue Oct 28 01:34:40 2014 -0300
     7.2 +++ b/docs/README-winrt.md	Tue Oct 28 18:36:29 2014 -0300
     7.3 @@ -1,44 +1,369 @@
     7.4 -WinRT
     7.5 -================================================================================
     7.6 -
     7.7 -SDL/WinRT layer allows SDL2-based applications to run on many of Microsoft's
     7.8 -platforms that utilize the "Windows Runtime" (aka "WinRT") APIs.  WinRT apps
     7.9 -are currently always full-screen apps, run in what Microsoft calls their
    7.10 -"Modern" environment (aka. "Metro"), and are distributed via Microsoft-run
    7.11 -online stores.  Some of the operating systems that support such apps include:
    7.12 -
    7.13 -* Windows 8.x
    7.14 -* Windows RT 8.x (aka. Windows 8.x for ARM processors)
    7.15 -* Windows Phone 8.x
    7.16 -
    7.17 -To note, WinRT applications that run on Windows 8.x and/or Windows RT are often
    7.18 -called "Windows Store" apps.
    7.19 -
    7.20 -
    7.21 ---------------------------------------------------------------------------------
    7.22 -Requirements
    7.23 ---------------------------------------------------------------------------------
    7.24 -- Microsoft Visual C++ 2012 -- Free, "Express" editions may be used, so long
    7.25 -  as they include support for either "Windows Store" or "Windows Phone" apps.
    7.26 -  (NOTE: MSVC 2013 support is pending.  2012 projects may be converted to 2013
    7.27 -  projects by MSVC, in the meantime.)
    7.28 -- A valid Microsoft account -- This requirement is not imposed by SDL, but
    7.29 -  rather by Microsoft's Visual C++ toolchain.
    7.30 -
    7.31 -
    7.32 ---------------------------------------------------------------------------------
    7.33 -TODO
    7.34 ---------------------------------------------------------------------------------
    7.35 -- Finish adding support for MSVC 2013, and "Universal" WinRT apps, which
    7.36 -  support Windows 8.1, Windows Phone 8.1, and in the future, Xbox One and
    7.37 -  Windows Desktop.
    7.38 -- Finish adding support for the SDL satellite libraries (SDL_image, SDL_mixer,
    7.39 -  SDL_ttf, etc.)
    7.40 -- Create templates for both MSVC 2012 and MSVC 2013, and have the corresponding
    7.41 -  VSIX packages either include pre-built copies of SDL, or reference binaries
    7.42 -  available via MSVC's NuGet servers
    7.43 -- Write setup instructions that use MSVC 201x templates
    7.44 -- Write setup instructions that don't use MSVC 201x templates, and use
    7.45 -  MSVC project-to-project references, rather than pre-built binaries
    7.46 -- Write a list of caveats found in SDL/WinRT, such as APIs that don't work due
    7.47 -  to platform restrictions, or things that need further work
    7.48 +WinRT
    7.49 +=====
    7.50 +
    7.51 +This port allows SDL applications to run on Microsoft's platforms that require
    7.52 +use of "Windows Runtime", aka. "WinRT", APIs.  WinRT apps are currently
    7.53 +full-screen only, and run in what Microsoft sometimes refers to as their
    7.54 +"Modern" (formerly, "Metro"), environment.  For Windows 8.x, Microsoft may also
    7.55 +refer to them as "Windows Store" apps, due to them being distributed,
    7.56 +primarily, via a Microsoft-run online store (of the same name).
    7.57 +
    7.58 +Some of the operating systems that include WinRT, are:
    7.59 +
    7.60 +* Windows 8.x
    7.61 +* Windows RT 8.x (aka. Windows 8.x for ARM processors)
    7.62 +* Windows Phone 8.x
    7.63 +
    7.64 +
    7.65 +Requirements
    7.66 +------------
    7.67 +
    7.68 +* Microsoft Visual C++ (aka Visual Studio), either 2013 or 2012 versions
    7.69 +  - Free, "Express" editions may be used, so long as they include support for 
    7.70 +    either "Windows Store" or "Windows Phone" apps.  Versions marked as
    7.71 +    supporting "Windows Desktop" development typically do not include support
    7.72 +    for creating WinRT apps.
    7.73 +  - Visual C++ 2012 can only build apps that target versions 8.0 of Windows, or 
    7.74 +    Windows Phone.  8.0-targetted apps will still run on devices running 
    7.75 +    8.1 editions of Windows, however they will not be able to take advantage of 
    7.76 +    8.1-specific features.
    7.77 +  - Visual C++ 2013 can only create app projects that target 8.1 versions
    7.78 +    of Windows, which do NOT run on 8.0 devices.  An optional Visual Studio
    7.79 +    add-in, "Tools for Maintaining Store apps for Windows 8", allows projects
    7.80 +    that are created with Visual C++ 2012, which can create Windows 8.0 apps,
    7.81 +    to be loaded and built with non-Express editions of Visual C++ 2013.  More
    7.82 +    details on targeting different versions of Windows can found at the
    7.83 +    following web pages:
    7.84 +      - [Develop apps by using Visual Studio 2013](http://msdn.microsoft.com/en-us/library/windows/apps/br211384.aspx)
    7.85 +      - [To add the Tools for Maintaining Store apps for Windows 8](http://msdn.microsoft.com/en-us/library/windows/apps/dn263114.aspx#AddMaintenanceTools)
    7.86 +* A valid Microsoft account - This requirement is not imposed by SDL, but
    7.87 +  rather by Microsoft's Visual C++ toolchain.  This is required to launch or 
    7.88 +  debug apps.
    7.89 +
    7.90 +
    7.91 +Setup, High-Level Steps
    7.92 +-----------------------
    7.93 +
    7.94 +The steps for setting up a project for an SDL/WinRT app looks like the
    7.95 +following, at a high-level:
    7.96 +
    7.97 +1. create a new Visual C++ project using Microsoft's template for a,
    7.98 +   "Direct3D App".
    7.99 +2. remove most of the files from the project.
   7.100 +3. make your app's project directly reference SDL/WinRT's own Visual C++
   7.101 +   project file, via use of Visual C++'s "References" dialog.  This will setup
   7.102 +   the linker, and will copy SDL's .dll files to your app's final output.
   7.103 +4. adjust your app's build settings, at minimum, telling it where to find SDL's
   7.104 +   header files.
   7.105 +5. add a file that contains a WinRT-appropriate main function.
   7.106 +6. add SDL-specific app code.
   7.107 +7. build and run your app.
   7.108 +
   7.109 +
   7.110 +Setup, Detailed Steps
   7.111 +---------------------
   7.112 +
   7.113 +### 1. Create a new project ###
   7.114 +
   7.115 +Create a new project using one of Visual C++'s templates for a plain, non-XAML,
   7.116 +"Direct3D App" (XAML support for SDL/WinRT is not yet ready for use).  If you
   7.117 +don't see one of these templates, in Visual C++'s 'New Project' dialog, try
   7.118 +using the textbox titled, 'Search Installed Templates' to look for one.
   7.119 +
   7.120 +
   7.121 +### 2. Remove unneeded files from the project ###
   7.122 +
   7.123 +In the new project, delete any file that has one of the following extensions:
   7.124 +
   7.125 +- .cpp
   7.126 +- .h
   7.127 +- .hlsl
   7.128 +
   7.129 +When you are done, you should be left with a few files, each of which will be a
   7.130 +necessary part of your app's project.  These files will consist of:
   7.131 +
   7.132 +- an .appxmanifest file, which contains metadata on your WinRT app.  This is
   7.133 +  similar to an Info.plist file on iOS, or an AndroidManifest.xml on Android.
   7.134 +- a few .png files, one of which is a splash screen (displayed when your app
   7.135 +  launches), others are app icons.
   7.136 +- a .pfx file, used for code signing purposes.
   7.137 +
   7.138 +
   7.139 +### 3. Add references to SDL's project files ###
   7.140 +
   7.141 +SDL/WinRT can be built in multiple variations, spanning across three different
   7.142 +CPU architectures (x86, x64, and ARM) and two different configurations
   7.143 +(Debug and Release).  WinRT and Visual C++ do not currently provide a means
   7.144 +for combining multiple variations of one library into a single file.
   7.145 +Furthermore, it does not provide an easy means for copying pre-built .dll files
   7.146 +into your app's final output (via Post-Build steps, for example).  It does,
   7.147 +however, provide a system whereby an app can reference the MSVC projects of
   7.148 +libraries such that, when the app is built:
   7.149 +
   7.150 +1. each library gets built for the appropriate CPU architecture(s) and WinRT
   7.151 +   platform(s).
   7.152 +2. each library's output, such as .dll files, get copied to the app's build 
   7.153 +   output.
   7.154 +
   7.155 +To set this up for SDL/WinRT, you'll need to run through the following steps:
   7.156 +
   7.157 +1. open up the Solution Explorer inside Visual C++ (under the "View" menu, then
   7.158 +   "Solution Explorer")
   7.159 +2. right click on your app's solution.
   7.160 +3. navigate to "Add", then to "Existing Project..."
   7.161 +4. find SDL/WinRT's Visual C++ project file and open it.  Different project
   7.162 +   files exist for different WinRT platforms.  All of them are in SDL's
   7.163 +   source distribution, in the following directories:
   7.164 +    * `VisualC-WinRT/WinPhone80_VS2012/` - for Windows Phone 8.0 apps
   7.165 +    * `VisualC-WinRT/WinPhone81_VS2013/` - for Windows Phone 8.1 apps
   7.166 +    * `VisualC-WinRT/WinRT80_VS2012/` - for Windows 8.0 apps
   7.167 +    * `VisualC-WinRT/WinRT81_VS2013/` - for Windows 8.1 apps
   7.168 +5. once the project has been added, right-click on your app's project and
   7.169 +   select, "References..."
   7.170 +6. click on the button titled, "Add New Reference..."
   7.171 +7. check the box next to SDL
   7.172 +8. click OK to close the dialog
   7.173 +9. SDL will now show up in the list of references.  Click OK to close that
   7.174 +   dialog.
   7.175 +
   7.176 +Your project is now linked to SDL's project, insofar that when the app is
   7.177 +built, SDL will be built as well, with its build output getting included with
   7.178 +your app.
   7.179 +
   7.180 +
   7.181 +### 4. Adjust Your App's Build Settings ###
   7.182 +
   7.183 +Some build settings need to be changed in your app's project.  This guide will
   7.184 +outline the following:
   7.185 +
   7.186 +- making sure that the compiler knows where to find SDL's header files
   7.187 +- **Optional for C++, but NECESSARY for compiling C code:** telling the
   7.188 +  compiler not to use Microsoft's C++ extensions for WinRT development.
   7.189 +- **Optional:** telling the compiler not generate errors due to missing
   7.190 +  precompiled header files.
   7.191 +
   7.192 +To change these settings:
   7.193 +
   7.194 +1. right-click on the project
   7.195 +2. choose "Properties"
   7.196 +3. in the drop-down box next to "Configuration", choose, "All Configurations"
   7.197 +4. in the drop-down box next to "Platform", choose, "All Platforms"
   7.198 +5. in the left-hand list, expand the "C/C++" section
   7.199 +6. select "General"
   7.200 +7. edit the "Additional Include Directories" setting, and add a path to SDL's
   7.201 +   "include" directory
   7.202 +8. **Optional: to enable compilation of C code:** change the setting for
   7.203 +   "Consume Windows Runtime Extension" from "Yes (/ZW)" to "No".  If you're 
   7.204 +   working with a completely C++ based project, this step can usually be 
   7.205 +   omitted.
   7.206 +9. **Optional: to disable precompiled headers (which can produce 
   7.207 +   'stdafx.h'-related build errors, if setup incorrectly:** in the left-hand 
   7.208 +   list, select "Precompiled Headers", then change the setting for "Precompiled 
   7.209 +   Header" from "Use (/Yu)" to "Not Using Precompiled Headers".
   7.210 +10. close the dialog, saving settings, by clicking the "OK" button
   7.211 +
   7.212 +
   7.213 +### 5. Add a WinRT-appropriate main function to the app. ###
   7.214 +
   7.215 +C/C++-based WinRT apps do contain a `main` function that the OS will invoke when 
   7.216 +the app starts launching. The parameters of WinRT main functions are different 
   7.217 +than those found on other platforms, Win32 included.  SDL/WinRT provides a 
   7.218 +platform-appropriate main function that will perform these actions, setup key 
   7.219 +portions of the app, then invoke a classic, C/C++-style main function (that take 
   7.220 +in "argc" and "argv" parameters).  The code for this file is contained inside 
   7.221 +SDL's source distribution, under `src/main/winrt/SDL_winrt_main_NonXAML.cpp`.  
   7.222 +You'll need to add this file, or a copy of it, to your app's project, and make 
   7.223 +sure it gets compiled using a Microsoft-specific set of C++ extensions called 
   7.224 +C++/CX.
   7.225 +
   7.226 +**NOTE: C++/CX compilation is currently required in at least one file of your 
   7.227 +app's project.  This is to make sure that Visual C++'s linker builds a 'Windows 
   7.228 +Metadata' file (.winmd) for your app.  Not doing so can lead to build errors.**
   7.229 +
   7.230 +To include `SDL_winrt_main_NonXAML.cpp`:
   7.231 +
   7.232 +1. right-click on your project (again, in Visual C++'s Solution Explorer), 
   7.233 +   navigate to "Add", then choose "Existing Item...".
   7.234 +2. open `SDL_winrt_main_NonXAML.cpp`, which is found inside SDL's source 
   7.235 +   distribution, under `src/main/winrt/`.  Make sure that the open-file dialog 
   7.236 +   closes, either by double-clicking on the file, or single-clicking on it and 
   7.237 +   then clicking Add.
   7.238 +3. right-click on the file (as listed in your project), then click on 
   7.239 +   "Properties...".
   7.240 +4. in the drop-down box next to "Configuration", choose, "All Configurations"
   7.241 +5. in the drop-down box next to "Platform", choose, "All Platforms"
   7.242 +6. in the left-hand list, click on "C/C++"
   7.243 +7. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)".
   7.244 +8. click the OK button.  This will close the dialog.
   7.245 +
   7.246 +
   7.247 +### 6. Add app code and assets ###
   7.248 +
   7.249 +At this point, you can add in SDL-specific source code.  Be sure to include a 
   7.250 +C-style main function (ie: `int main(int argc, char *argv[])`).  From there you 
   7.251 +should be able to create a single `SDL_Window` (WinRT apps can only have one 
   7.252 +window, at present), as well as an `SDL_Renderer`.  Direct3D will be used to 
   7.253 +draw content.  Events are received via SDL's usual event functions 
   7.254 +(`SDL_PollEvent`, etc.)  If you have a set of existing source files and assets, 
   7.255 +you can start adding them to the project now.  If not, or if you would like to 
   7.256 +make sure that you're setup correctly, some short and simple sample code is 
   7.257 +provided below.
   7.258 +
   7.259 +
   7.260 +#### 6.A. ... when creating a new app ####
   7.261 +
   7.262 +If you are creating a new app (rather than porting an existing SDL-based app), 
   7.263 +or if you would just like a simple app to test SDL/WinRT with before trying to 
   7.264 +get existing code working, some working SDL/WinRT code is provided below.  To 
   7.265 +set this up:
   7.266 +
   7.267 +1. right click on your app's project
   7.268 +2. select Add, then New Item.  An "Add New Item" dialog will show up.
   7.269 +3. from the left-hand list, choose "Visual C++"
   7.270 +4. from the middle/main list, choose "C++ File (.cpp)"
   7.271 +5. near the bottom of the dialog, next to "Name:", type in a name for your 
   7.272 +source file, such as, "main.cpp".
   7.273 +6. click on the Add button.  This will close the dialog, add the new file to 
   7.274 +your project, and open the file in Visual C++'s text editor.
   7.275 +7. Copy and paste the following code into the new file, then save it.
   7.276 +
   7.277 +
   7.278 +    #include <SDL.h>
   7.279 +    
   7.280 +    int main(int argc, char **argv)
   7.281 +    {
   7.282 +        SDL_DisplayMode mode;
   7.283 +        SDL_Window * window = NULL;
   7.284 +        SDL_Renderer * renderer = NULL;
   7.285 +        SDL_Event evt;
   7.286 +    
   7.287 +        if (SDL_Init(SDL_INIT_VIDEO) != 0) {
   7.288 +            return 1;
   7.289 +        }
   7.290 +    
   7.291 +        if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
   7.292 +            return 1;
   7.293 +        }
   7.294 +    
   7.295 +        if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
   7.296 +            return 1;
   7.297 +        }
   7.298 +    
   7.299 +        while (1) {
   7.300 +            while (SDL_PollEvent(&evt)) {
   7.301 +            }
   7.302 +    
   7.303 +            SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
   7.304 +            SDL_RenderClear(renderer);
   7.305 +            SDL_RenderPresent(renderer);
   7.306 +        }
   7.307 +    }
   7.308 +
   7.309 +
   7.310 +#### 6.B. Adding code and assets ####
   7.311 +
   7.312 +If you have existing code and assets that you'd like to add, you should be able 
   7.313 +to add them now.  The process for adding a set of files is as such.
   7.314 +
   7.315 +1. right click on the app's project
   7.316 +2. select Add, then click on "New Item..."
   7.317 +3. open any source, header, or asset files as appropriate.  Support for C and 
   7.318 +C++ is available.
   7.319 +
   7.320 +Do note that WinRT only supports a subset of the APIs that are available to 
   7.321 +Win32-based apps.  Many portions of the Win32 API and the C runtime are not 
   7.322 +available.
   7.323 +
   7.324 +A list of unsupported C APIs can be found at 
   7.325 +<http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx>
   7.326 +
   7.327 +General information on using the C runtime in WinRT can be found at 
   7.328 +<http://msdn.microsoft.com/en-us/LIBRARY/hh972425(v=vs.110).aspx>
   7.329 +
   7.330 +A list of supported Win32 APIs for Windows 8/RT apps can be found at 
   7.331 +<http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx>.  To note, 
   7.332 +the list of supported Win32 APIs for Windows Phone 8 development is different.  
   7.333 +That list can be found at 
   7.334 +<http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662956(v=vs.105).aspx>
   7.335 +
   7.336 +
   7.337 +### 7. Build and run your app ###
   7.338 +
   7.339 +Your app project should now be setup, and you should be ready to build your app.  
   7.340 +To run it on the local machine, open the Debug menu and choose "Start 
   7.341 +Debugging".  This will build your app, then run your app full-screen.  To switch 
   7.342 +out of your app, press the Windows key.  Alternatively, you can choose to run 
   7.343 +your app in a window.  To do this, before building and running your app, find 
   7.344 +the drop-down menu in Visual C++'s toolbar that says, "Local Machine".  Expand 
   7.345 +this by clicking on the arrow on the right side of the list, then click on 
   7.346 +Simulator.  Once you do that, any time you build and run the app, the app will 
   7.347 +launch in window, rather than full-screen.
   7.348 +
   7.349 +
   7.350 +#### 7.A. Running apps on ARM-based devices ####
   7.351 +
   7.352 +To build and run the app on ARM-based, "Windows RT" devices, you'll need to:
   7.353 +
   7.354 +- install Microsoft's "Remote Debugger" on the device.  Visual C++ installs and 
   7.355 +  debugs ARM-based apps via IP networks.
   7.356 +- change a few options on the development machine, both to make sure it builds 
   7.357 +  for ARM (rather than x86 or x64), and to make sure it knows how to find the 
   7.358 +  Windows RT device (on the network).
   7.359 +
   7.360 +Microsoft's Remote Debugger can be found at 
   7.361 +<http://msdn.microsoft.com/en-us/library/vstudio/bt727f1t.aspx>.  Please note 
   7.362 +that separate versions of this debugger exist for different versions of Visual 
   7.363 +C++, one for debugging with MSVC 2012, another for debugging with MSVC 2013.
   7.364 +
   7.365 +To setup Visual C++ to launch your app on an ARM device:
   7.366 +
   7.367 +1. make sure the Remote Debugger is running on your ARM device, and that it's on 
   7.368 +   the same IP network as your development machine.
   7.369 +2. from Visual C++'s toolbar, find a drop-down menu that says, "Win32".  Click 
   7.370 +   it, then change the value to "ARM".
   7.371 +3. make sure Visual C++ knows the hostname or IP address of the ARM device.  To 
   7.372 +   do this:
   7.373 +    1. open the app project's properties
   7.374 +    2. select "Debugging"
   7.375 +    3. next to "Machine Name", enter the hostname or IP address of the ARM 
   7.376 +       device
   7.377 +    4. if, and only if, you've turned off authentication in the Remote Debugger, then change the setting for "Require Authentication" to No
   7.378 +    5. click "OK"
   7.379 +4. build and run the app (from Visual C++).  The first time you do this, a 
   7.380 +   prompt will show up on the ARM device, asking for a Microsoft Account.  You 
   7.381 +   do, unfortunately, need to log in here, and will need to follow the 
   7.382 +   subsequent registration steps in order to launch the app.  After you do so, 
   7.383 +   if the app didn't already launch, try relaunching it again from within Visual 
   7.384 +   C++.
   7.385 +
   7.386 +
   7.387 +Troubleshooting
   7.388 +---------------
   7.389 +
   7.390 +#### Build fails with message, "error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'"
   7.391 +
   7.392 +Try adding the following to your linker flags.  In MSVC, this can be done by
   7.393 +right-clicking on the app project, navigating to Configuration Properties ->
   7.394 +Linker -> Command Line, then adding them to the Additional Options
   7.395 +section.
   7.396 +
   7.397 +* For Release builds / MSVC-Configurations, add:
   7.398 +
   7.399 +    /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib
   7.400 +
   7.401 +* For Debug builds / MSVC-Configurations, add:
   7.402 +
   7.403 +    /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib
   7.404 +
   7.405 +
   7.406 +TODO
   7.407 +----
   7.408 +
   7.409 +- Document details of SDL satellite library support
   7.410 +- Make [NuGet](https://www.nuget.org) packages for SDL/WinRT
   7.411 +- Create templates for both MSVC 2012 and MSVC 2013, and have the corresponding
   7.412 +  VSIX packages either include pre-built copies of SDL, or reference binaries
   7.413 +  available via MSVC's NuGet servers
   7.414 +    - Write setup instructions that use MSVC 201x templates
   7.415 +- Write a list of caveats found in SDL/WinRT, such as APIs that don't work due
   7.416 +  to platform restrictions, or things that need further work
     8.1 --- a/include/SDL_config.h.cmake	Tue Oct 28 01:34:40 2014 -0300
     8.2 +++ b/include/SDL_config.h.cmake	Tue Oct 28 18:36:29 2014 -0300
     8.3 @@ -264,7 +264,8 @@
     8.4  #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
     8.5  #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
     8.6  #cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
     8.7 -#cmakedefine SDL_VIDEO_DRIVER_MX6 @SDL_VIDEO_DRIVER_MX6@
     8.8 +#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
     8.9 +#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
    8.10  
    8.11  #if 0
    8.12  /* !!! FIXME: in configure script version, missing here: */
     9.1 --- a/include/SDL_config.h.in	Tue Oct 28 01:34:40 2014 -0300
     9.2 +++ b/include/SDL_config.h.in	Tue Oct 28 18:36:29 2014 -0300
     9.3 @@ -308,7 +308,8 @@
     9.4  #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
     9.5  #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
     9.6  #undef SDL_VIDEO_DRIVER_NACL
     9.7 -#undef SDL_VIDEO_DRIVER_MX6
     9.8 +#undef SDL_VIDEO_DRIVER_VIVANTE
     9.9 +#undef SDL_VIDEO_DRIVER_VIVANTE_VDK
    9.10  
    9.11  #undef SDL_VIDEO_RENDER_D3D
    9.12  #undef SDL_VIDEO_RENDER_D3D11
    10.1 --- a/include/SDL_haptic.h	Tue Oct 28 01:34:40 2014 -0300
    10.2 +++ b/include/SDL_haptic.h	Tue Oct 28 18:36:29 2014 -0300
    10.3 @@ -492,7 +492,7 @@
    10.4   *  over time.  The type determines the shape of the wave and the parameters
    10.5   *  determine the dimensions of the wave.
    10.6   *
    10.7 - *  Phase is given by hundredth of a cycle meaning that giving the phase a value
    10.8 + *  Phase is given by hundredth of a degree meaning that giving the phase a value
    10.9   *  of 9000 will displace it 25% of its period.  Here are sample values:
   10.10   *   -     0: No phase displacement.
   10.11   *   -  9000: Displaced 25% of its period.
   10.12 @@ -553,9 +553,9 @@
   10.13  
   10.14      /* Periodic */
   10.15      Uint16 period;      /**< Period of the wave. */
   10.16 -    Sint16 magnitude;   /**< Peak value. */
   10.17 +    Sint16 magnitude;   /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */
   10.18      Sint16 offset;      /**< Mean value of the wave. */
   10.19 -    Uint16 phase;       /**< Horizontal shift given by hundredth of a cycle. */
   10.20 +    Uint16 phase;       /**< Horizontal shift given by hundredth of a degree. */
   10.21  
   10.22      /* Envelope */
   10.23      Uint16 attack_length;   /**< Duration of the attack. */
    11.1 --- a/include/SDL_hints.h	Tue Oct 28 01:34:40 2014 -0300
    11.2 +++ b/include/SDL_hints.h	Tue Oct 28 18:36:29 2014 -0300
    11.3 @@ -440,11 +440,54 @@
    11.4   */
    11.5  #define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_WINRT_PRIVACY_POLICY_LABEL"
    11.6  
    11.7 -/** \brief If set to "1", back button press events on Windows Phone 8+ will be marked as handled.
    11.8 +/** \brief Allows back-button-press events on Windows Phone to be marked as handled
    11.9   *
   11.10 - *  TODO, WinRT: document SDL_HINT_WINRT_HANDLE_BACK_BUTTON need and use
   11.11 - *  For now, more details on why this is needed can be found at the
   11.12 - *  beginning of the following web page:
   11.13 + *  Windows Phone devices typically feature a Back button.  When pressed,
   11.14 + *  the OS will emit back-button-press events, which apps are expected to
   11.15 + *  handle in an appropriate manner.  If apps do not explicitly mark these
   11.16 + *  events as 'Handled', then the OS will invoke its default behavior for
   11.17 + *  unhandled back-button-press events, which on Windows Phone 8 and 8.1 is to
   11.18 + *  terminate the app (and attempt to switch to the previous app, or to the
   11.19 + *  device's home screen).
   11.20 + *
   11.21 + *  Setting the SDL_HINT_WINRT_HANDLE_BACK_BUTTON hint to "1" will cause SDL
   11.22 + *  to mark back-button-press events as Handled, if and when one is sent to
   11.23 + *  the app.
   11.24 + *
   11.25 + *  Internally, Windows Phone sends back button events as parameters to
   11.26 + *  special back-button-press callback functions.  Apps that need to respond
   11.27 + *  to back-button-press events are expected to register one or more
   11.28 + *  callback functions for such, shortly after being launched (during the
   11.29 + *  app's initialization phase).  After the back button is pressed, the OS
   11.30 + *  will invoke these callbacks.  If the app's callback(s) do not explicitly
   11.31 + *  mark the event as handled by the time they return, or if the app never
   11.32 + *  registers one of these callback, the OS will consider the event
   11.33 + *  un-handled, and it will apply its default back button behavior (terminate
   11.34 + *  the app).
   11.35 + *
   11.36 + *  SDL registers its own back-button-press callback with the Windows Phone
   11.37 + *  OS.  This callback will emit a pair of SDL key-press events (SDL_KEYDOWN
   11.38 + *  and SDL_KEYUP), each with a scancode of SDL_SCANCODE_AC_BACK, after which
   11.39 + *  it will check the contents of the hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON.
   11.40 + *  If the hint's value is set to "1", the back button event's Handled
   11.41 + *  property will get set to 'true'.  If the hint's value is set to something
   11.42 + *  else, or if it is unset, SDL will leave the event's Handled property
   11.43 + *  alone.  (By default, the OS sets this property to 'false', to note.)
   11.44 + *
   11.45 + *  SDL apps can either set SDL_HINT_WINRT_HANDLE_BACK_BUTTON well before a
   11.46 + *  back button is pressed, or can set it in direct-response to a back button
   11.47 + *  being pressed.
   11.48 + *
   11.49 + *  In order to get notified when a back button is pressed, SDL apps should
   11.50 + *  register a callback function with SDL_AddEventWatch(), and have it listen
   11.51 + *  for SDL_KEYDOWN events that have a scancode of SDL_SCANCODE_AC_BACK.
   11.52 + *  (Alternatively, SDL_KEYUP events can be listened-for.  Listening for
   11.53 + *  either event type is suitable.)  Any value of SDL_HINT_WINRT_HANDLE_BACK_BUTTON
   11.54 + *  set by such a callback, will be applied to the OS' current
   11.55 + *  back-button-press event.
   11.56 + *
   11.57 + *  More details on back button behavior in Windows Phone apps can be found
   11.58 + *  at the following page, on Microsoft's developer site:
   11.59   *  http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx
   11.60   */
   11.61  #define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON"
    12.1 --- a/include/SDL_render.h	Tue Oct 28 01:34:40 2014 -0300
    12.2 +++ b/include/SDL_render.h	Tue Oct 28 18:36:29 2014 -0300
    12.3 @@ -552,7 +552,7 @@
    12.4                                                     SDL_Rect * rect);
    12.5  
    12.6  /**
    12.7 - *  \brief Get wether clipping is enabled on the given renderer
    12.8 + *  \brief Get whether clipping is enabled on the given renderer.
    12.9   *
   12.10   *  \param renderer The renderer from which clip state should be queried.
   12.11   *
    13.1 --- a/include/SDL_syswm.h	Tue Oct 28 01:34:40 2014 -0300
    13.2 +++ b/include/SDL_syswm.h	Tue Oct 28 18:36:29 2014 -0300
    13.3 @@ -152,6 +152,10 @@
    13.4  #if defined(SDL_VIDEO_DRIVER_COCOA)
    13.5          struct
    13.6          {
    13.7 +            /* Latest version of Xcode clang complains about empty structs in C v. C++:
    13.8 +                 error: empty struct has size 0 in C, size 1 in C++
    13.9 +             */
   13.10 +            int dummy;
   13.11              /* No Cocoa window events yet */
   13.12          } cocoa;
   13.13  #endif
    14.1 --- a/src/audio/android/SDL_androidaudio.c	Tue Oct 28 01:34:40 2014 -0300
    14.2 +++ b/src/audio/android/SDL_androidaudio.c	Tue Oct 28 18:36:29 2014 -0300
    14.3 @@ -32,7 +32,7 @@
    14.4  
    14.5  #include <android/log.h>
    14.6  
    14.7 -static void * audioDevice;
    14.8 +static SDL_AudioDevice* audioDevice = NULL;
    14.9  
   14.10  static int
   14.11  AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
   14.12 @@ -49,6 +49,11 @@
   14.13      }
   14.14  
   14.15      audioDevice = this;
   14.16 +    
   14.17 +    this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden));
   14.18 +    if (this->hidden == NULL) {
   14.19 +        return SDL_OutOfMemory();
   14.20 +    }
   14.21  
   14.22      test_format = SDL_FirstAudioFormat(this->spec.format);
   14.23      while (test_format != 0) { /* no "UNKNOWN" constant */
   14.24 @@ -110,6 +115,10 @@
   14.25      Android_JNI_CloseAudioDevice();
   14.26  
   14.27      if (audioDevice == this) {
   14.28 +        if (audioDevice->hidden != NULL) {
   14.29 +            SDL_free(this->hidden);
   14.30 +            this->hidden = NULL;
   14.31 +        }
   14.32          audioDevice = NULL;
   14.33      }
   14.34  }
   14.35 @@ -135,6 +144,41 @@
   14.36      "android", "SDL Android audio driver", AndroidAUD_Init, 0
   14.37  };
   14.38  
   14.39 +/* Pause (block) all non already paused audio devices by taking their mixer lock */
   14.40 +void AndroidAUD_PauseDevices(void)
   14.41 +{
   14.42 +    /* TODO: Handle multiple devices? */
   14.43 +    struct SDL_PrivateAudioData *private;
   14.44 +    if(audioDevice != NULL && audioDevice->hidden != NULL) {
   14.45 +        private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
   14.46 +        if (audioDevice->paused) {
   14.47 +            /* The device is already paused, leave it alone */
   14.48 +            private->resume = SDL_FALSE;
   14.49 +        }
   14.50 +        else {
   14.51 +            SDL_LockMutex(audioDevice->mixer_lock);
   14.52 +            audioDevice->paused = SDL_TRUE;
   14.53 +            private->resume = SDL_TRUE;
   14.54 +        }
   14.55 +    }
   14.56 +}
   14.57 +
   14.58 +/* Resume (unblock) all non already paused audio devices by releasing their mixer lock */
   14.59 +void AndroidAUD_ResumeDevices(void)
   14.60 +{
   14.61 +    /* TODO: Handle multiple devices? */
   14.62 +    struct SDL_PrivateAudioData *private;
   14.63 +    if(audioDevice != NULL && audioDevice->hidden != NULL) {
   14.64 +        private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
   14.65 +        if (private->resume) {
   14.66 +            audioDevice->paused = SDL_FALSE;
   14.67 +            private->resume = SDL_FALSE;
   14.68 +            SDL_UnlockMutex(audioDevice->mixer_lock);
   14.69 +        }
   14.70 +    }
   14.71 +}
   14.72 +
   14.73 +
   14.74  #endif /* SDL_AUDIO_DRIVER_ANDROID */
   14.75  
   14.76  /* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/audio/android/SDL_androidaudio.h	Tue Oct 28 01:34:40 2014 -0300
    15.2 +++ b/src/audio/android/SDL_androidaudio.h	Tue Oct 28 18:36:29 2014 -0300
    15.3 @@ -30,6 +30,8 @@
    15.4  
    15.5  struct SDL_PrivateAudioData
    15.6  {
    15.7 +    /* Resume device if it was paused automatically */
    15.8 +    int resume;
    15.9  };
   15.10  
   15.11  static void AndroidAUD_CloseDevice(_THIS);
    16.1 --- a/src/core/android/SDL_android.c	Tue Oct 28 01:34:40 2014 -0300
    16.2 +++ b/src/core/android/SDL_android.c	Tue Oct 28 18:36:29 2014 -0300
    16.3 @@ -444,7 +444,7 @@
    16.4  
    16.5  static SDL_bool LocalReferenceHolder_IsActive()
    16.6  {
    16.7 -    return s_active > 0;    
    16.8 +    return s_active > 0;
    16.9  }
   16.10  
   16.11  ANativeWindow* Android_JNI_GetNativeWindow(void)
   16.12 @@ -1302,6 +1302,9 @@
   16.13      (*env)->CallStaticVoidMethod(env, mActivityClass, midPollInputDevices);    
   16.14  }
   16.15  
   16.16 +/* See SDLActivity.java for constants. */
   16.17 +#define COMMAND_SET_KEEP_SCREEN_ON    5
   16.18 +
   16.19  /* sends message to be handled on the UI event dispatch thread */
   16.20  int Android_JNI_SendMessage(int command, int param)
   16.21  {
   16.22 @@ -1317,6 +1320,11 @@
   16.23      return success ? 0 : -1;
   16.24  }
   16.25  
   16.26 +void Android_JNI_SuspendScreenSaver(SDL_bool suspend)
   16.27 +{
   16.28 +    Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
   16.29 +}
   16.30 +
   16.31  void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
   16.32  {
   16.33      JNIEnv *env = Android_JNI_GetEnv();
   16.34 @@ -1342,6 +1350,85 @@
   16.35      Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
   16.36  }
   16.37  
   16.38 +int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   16.39 +{
   16.40 +    JNIEnv *env;
   16.41 +    jmethodID mid;
   16.42 +    jobject context;
   16.43 +    jstring title;
   16.44 +    jstring message;
   16.45 +    jintArray button_flags;
   16.46 +    jintArray button_ids;
   16.47 +    jobjectArray button_texts;
   16.48 +    jintArray colors;
   16.49 +    jint temp;
   16.50 +    int i;
   16.51 +
   16.52 +    env = Android_JNI_GetEnv();
   16.53 +
   16.54 +    /* convert parameters */
   16.55 +
   16.56 +    title = (*env)->NewStringUTF(env, messageboxdata->title);
   16.57 +    message = (*env)->NewStringUTF(env, messageboxdata->message);
   16.58 +
   16.59 +    button_flags = (*env)->NewIntArray(env, messageboxdata->numbuttons);
   16.60 +    button_ids = (*env)->NewIntArray(env, messageboxdata->numbuttons);
   16.61 +    button_texts = (*env)->NewObjectArray(env, messageboxdata->numbuttons,
   16.62 +        (*env)->FindClass(env, "java/lang/String"), NULL);
   16.63 +    for (i = 0; i < messageboxdata->numbuttons; ++i) {
   16.64 +        temp = messageboxdata->buttons[i].flags;
   16.65 +        (*env)->SetIntArrayRegion(env, button_flags, i, 1, &temp);
   16.66 +        temp = messageboxdata->buttons[i].buttonid;
   16.67 +        (*env)->SetIntArrayRegion(env, button_ids, i, 1, &temp);
   16.68 +        (*env)->SetObjectArrayElement(env, button_texts, i, (*env)->NewStringUTF(env, messageboxdata->buttons[i].text));
   16.69 +    }
   16.70 +
   16.71 +    if (messageboxdata->colorScheme) {
   16.72 +        colors = (*env)->NewIntArray(env, SDL_MESSAGEBOX_COLOR_MAX);
   16.73 +        for (i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; ++i) {
   16.74 +            temp = (0xFF << 24) |
   16.75 +                   (messageboxdata->colorScheme->colors[i].r << 16) |
   16.76 +                   (messageboxdata->colorScheme->colors[i].g << 8) |
   16.77 +                   (messageboxdata->colorScheme->colors[i].b << 0);
   16.78 +            (*env)->SetIntArrayRegion(env, colors, i, 1, &temp);
   16.79 +        }
   16.80 +    } else {
   16.81 +        colors = NULL;
   16.82 +    }
   16.83 +
   16.84 +    /* call function */
   16.85 +
   16.86 +    mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;");
   16.87 +
   16.88 +    context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid);
   16.89 +
   16.90 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
   16.91 +        "messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I");
   16.92 +    *buttonid = (*env)->CallIntMethod(env, context, mid,
   16.93 +        messageboxdata->flags,
   16.94 +        title,
   16.95 +        message,
   16.96 +        button_flags,
   16.97 +        button_ids,
   16.98 +        button_texts,
   16.99 +        colors);
  16.100 +
  16.101 +    /* delete parameters */
  16.102 +
  16.103 +    (*env)->DeleteLocalRef(env, title);
  16.104 +    (*env)->DeleteLocalRef(env, message);
  16.105 +    (*env)->DeleteLocalRef(env, button_flags);
  16.106 +    (*env)->DeleteLocalRef(env, button_ids);
  16.107 +    for (i = 0; i < messageboxdata->numbuttons; ++i) {
  16.108 +        (*env)->DeleteLocalRef(env, (*env)->GetObjectArrayElement(env, button_texts, i));
  16.109 +        (*env)->SetObjectArrayElement(env, button_texts, i, NULL);
  16.110 +    }
  16.111 +    (*env)->DeleteLocalRef(env, button_texts);
  16.112 +    (*env)->DeleteLocalRef(env, colors);
  16.113 +
  16.114 +    return 0;
  16.115 +}
  16.116 +
  16.117  /*
  16.118  //////////////////////////////////////////////////////////////////////////////
  16.119  //
    17.1 --- a/src/core/android/SDL_android.h	Tue Oct 28 01:34:40 2014 -0300
    17.2 +++ b/src/core/android/SDL_android.h	Tue Oct 28 18:36:29 2014 -0300
    17.3 @@ -68,6 +68,8 @@
    17.4  /* Joystick support */
    17.5  void Android_JNI_PollInputDevices();
    17.6  
    17.7 +/* Video */
    17.8 +void Android_JNI_SuspendScreenSaver(SDL_bool suspend);
    17.9  
   17.10  /* Touch support */
   17.11  int Android_JNI_GetTouchDeviceIds(int **ids);
    18.1 --- a/src/core/linux/SDL_evdev.c	Tue Oct 28 01:34:40 2014 -0300
    18.2 +++ b/src/core/linux/SDL_evdev.c	Tue Oct 28 18:36:29 2014 -0300
    18.3 @@ -584,6 +584,10 @@
    18.4      Uint32 kval;
    18.5  #endif
    18.6  
    18.7 +    if (!_this) {
    18.8 +        return;
    18.9 +    }
   18.10 +
   18.11  #if SDL_USE_LIBUDEV
   18.12      SDL_UDEV_Poll();
   18.13  #endif
    19.1 --- a/src/core/linux/SDL_udev.c	Tue Oct 28 01:34:40 2014 -0300
    19.2 +++ b/src/core/linux/SDL_udev.c	Tue Oct 28 18:36:29 2014 -0300
    19.3 @@ -25,18 +25,19 @@
    19.4   * udevadm info --query=all -n input/event3 (for a keyboard, mouse, etc)
    19.5   * udevadm info --query=property -n input/event2
    19.6   */
    19.7 -
    19.8  #include "SDL_udev.h"
    19.9  
   19.10  #ifdef SDL_USE_LIBUDEV
   19.11  
   19.12 +#include <linux/input.h>
   19.13 +
   19.14 +#include "SDL.h"
   19.15 +
   19.16  static char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
   19.17  
   19.18  #define _THIS SDL_UDEV_PrivateData *_this
   19.19  static _THIS = NULL;
   19.20  
   19.21 -#include "SDL.h"
   19.22 -
   19.23  static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr);
   19.24  static int SDL_UDEV_load_syms(void);
   19.25  static SDL_bool SDL_UDEV_hotplug_update_available(void);
   19.26 @@ -64,7 +65,9 @@
   19.27      SDL_UDEV_SYM(udev_device_get_action);
   19.28      SDL_UDEV_SYM(udev_device_get_devnode);
   19.29      SDL_UDEV_SYM(udev_device_get_subsystem);
   19.30 +    SDL_UDEV_SYM(udev_device_get_parent_with_subsystem_devtype);
   19.31      SDL_UDEV_SYM(udev_device_get_property_value);
   19.32 +    SDL_UDEV_SYM(udev_device_get_sysattr_value);
   19.33      SDL_UDEV_SYM(udev_device_new_from_syspath);
   19.34      SDL_UDEV_SYM(udev_device_unref);
   19.35      SDL_UDEV_SYM(udev_enumerate_add_match_property);
   19.36 @@ -274,6 +277,109 @@
   19.37      return retval;
   19.38  }
   19.39  
   19.40 +#define BITS_PER_LONG           (sizeof(unsigned long) * 8)
   19.41 +#define NBITS(x)                ((((x)-1)/BITS_PER_LONG)+1)
   19.42 +#define OFF(x)                  ((x)%BITS_PER_LONG)
   19.43 +#define BIT(x)                  (1UL<<OFF(x))
   19.44 +#define LONG(x)                 ((x)/BITS_PER_LONG)
   19.45 +#define test_bit(bit, array)    ((array[LONG(bit)] >> OFF(bit)) & 1)
   19.46 +
   19.47 +static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len)
   19.48 +{
   19.49 +    const char *value;
   19.50 +    char text[4096];
   19.51 +    char *word;
   19.52 +    int i;
   19.53 +    unsigned long v;
   19.54 +
   19.55 +    SDL_memset(bitmask, 0, bitmask_len*sizeof(*bitmask));
   19.56 +    value = _this->udev_device_get_sysattr_value(pdev, attr);
   19.57 +    if (!value) {
   19.58 +        return;
   19.59 +    }
   19.60 +
   19.61 +    SDL_strlcpy(text, value, sizeof(text));
   19.62 +    i = 0;
   19.63 +    while ((word = SDL_strrchr(text, ' ')) != NULL) {
   19.64 +        v = SDL_strtoul(word+1, NULL, 16);
   19.65 +        if (i < bitmask_len) {
   19.66 +            bitmask[i] = v;
   19.67 +        }
   19.68 +        ++i;
   19.69 +        *word = '\0';
   19.70 +    }
   19.71 +    v = SDL_strtoul(text, NULL, 16);
   19.72 +    if (i < bitmask_len) {
   19.73 +        bitmask[i] = v;
   19.74 +    }
   19.75 +}
   19.76 +
   19.77 +static int
   19.78 +guess_device_class(struct udev_device *dev)
   19.79 +{
   19.80 +    int devclass = 0;
   19.81 +    struct udev_device *pdev;
   19.82 +    unsigned long bitmask_ev[NBITS(EV_MAX)];
   19.83 +    unsigned long bitmask_abs[NBITS(ABS_MAX)];
   19.84 +    unsigned long bitmask_key[NBITS(KEY_MAX)];
   19.85 +    unsigned long bitmask_rel[NBITS(REL_MAX)];
   19.86 +    unsigned long keyboard_mask;
   19.87 +
   19.88 +    /* walk up the parental chain until we find the real input device; the
   19.89 +     * argument is very likely a subdevice of this, like eventN */
   19.90 +    pdev = dev;
   19.91 +    while (pdev && !_this->udev_device_get_sysattr_value(pdev, "capabilities/ev")) {
   19.92 +        pdev = _this->udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);
   19.93 +    }
   19.94 +    if (!pdev) {
   19.95 +        return 0;
   19.96 +    }
   19.97 +
   19.98 +    get_caps(dev, pdev, "capabilities/ev", bitmask_ev, SDL_arraysize(bitmask_ev));
   19.99 +    get_caps(dev, pdev, "capabilities/abs", bitmask_abs, SDL_arraysize(bitmask_abs));
  19.100 +    get_caps(dev, pdev, "capabilities/rel", bitmask_rel, SDL_arraysize(bitmask_rel));
  19.101 +    get_caps(dev, pdev, "capabilities/key", bitmask_key, SDL_arraysize(bitmask_key));
  19.102 +
  19.103 +    if (test_bit(EV_ABS, bitmask_ev) &&
  19.104 +        test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
  19.105 +        if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
  19.106 +            ; /* ID_INPUT_TABLET */
  19.107 +        } else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
  19.108 +            ; /* ID_INPUT_TOUCHPAD */
  19.109 +        } else if (test_bit(BTN_MOUSE, bitmask_key)) {
  19.110 +            devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
  19.111 +        } else if (test_bit(BTN_TOUCH, bitmask_key)) {
  19.112 +            ; /* ID_INPUT_TOUCHSCREEN */
  19.113 +        } else if (test_bit(BTN_TRIGGER, bitmask_key) ||
  19.114 +                 test_bit(BTN_A, bitmask_key) ||
  19.115 +                 test_bit(BTN_1, bitmask_key) ||
  19.116 +                 test_bit(ABS_RX, bitmask_abs) ||
  19.117 +                 test_bit(ABS_RY, bitmask_abs) ||
  19.118 +                 test_bit(ABS_RZ, bitmask_abs) ||
  19.119 +                 test_bit(ABS_THROTTLE, bitmask_abs) ||
  19.120 +                 test_bit(ABS_RUDDER, bitmask_abs) ||
  19.121 +                 test_bit(ABS_WHEEL, bitmask_abs) ||
  19.122 +                 test_bit(ABS_GAS, bitmask_abs) ||
  19.123 +                 test_bit(ABS_BRAKE, bitmask_abs)) {
  19.124 +            devclass |= SDL_UDEV_DEVICE_JOYSTICK; /* ID_INPUT_JOYSTICK */
  19.125 +        }
  19.126 +    }
  19.127 +
  19.128 +    if (test_bit(EV_REL, bitmask_ev) &&
  19.129 +        test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) &&
  19.130 +        test_bit(BTN_MOUSE, bitmask_key)) {
  19.131 +        devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
  19.132 +    }
  19.133 +
  19.134 +    /* the first 32 bits are ESC, numbers, and Q to D; if we have all of
  19.135 +     * those, consider it a full keyboard; do not test KEY_RESERVED, though */
  19.136 +    keyboard_mask = 0xFFFFFFFE;
  19.137 +    if ((bitmask_key[0] & keyboard_mask) == keyboard_mask)
  19.138 +        devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */
  19.139 +
  19.140 +    return devclass;
  19.141 +}
  19.142 +
  19.143  static void 
  19.144  device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) 
  19.145  {
  19.146 @@ -292,6 +398,8 @@
  19.147      if (SDL_strcmp(subsystem, "sound") == 0) {
  19.148          devclass = SDL_UDEV_DEVICE_SOUND;
  19.149      } else if (SDL_strcmp(subsystem, "input") == 0) {
  19.150 +        /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
  19.151 +        
  19.152          val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
  19.153          if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
  19.154              devclass |= SDL_UDEV_DEVICE_JOYSTICK;
  19.155 @@ -302,13 +410,19 @@
  19.156              devclass |= SDL_UDEV_DEVICE_MOUSE;
  19.157          }
  19.158  
  19.159 -        val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
  19.160 +        /* The undocumented rule is:
  19.161 +           - All devices with keys get ID_INPUT_KEY
  19.162 +           - From this subset, if they have ESC, numbers, and Q to D, it also gets ID_INPUT_KEYBOARD
  19.163 +           
  19.164 +           Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
  19.165 +        */
  19.166 +        val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEY");
  19.167          if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
  19.168              devclass |= SDL_UDEV_DEVICE_KEYBOARD;
  19.169          }
  19.170  
  19.171          if (devclass == 0) {
  19.172 -            // Fall back to old style input classes
  19.173 +            /* Fall back to old style input classes */
  19.174              val = _this->udev_device_get_property_value(dev, "ID_CLASS");
  19.175              if (val != NULL) {
  19.176                  if (SDL_strcmp(val, "joystick") == 0) {
  19.177 @@ -321,7 +435,8 @@
  19.178                      return;
  19.179                  }
  19.180              } else {
  19.181 -                return;
  19.182 +                /* We could be linked with libudev on a system that doesn't have udev running */
  19.183 +                devclass = guess_device_class(dev);
  19.184              }
  19.185          }
  19.186      } else {
    20.1 --- a/src/core/linux/SDL_udev.h	Tue Oct 28 01:34:40 2014 -0300
    20.2 +++ b/src/core/linux/SDL_udev.h	Tue Oct 28 18:36:29 2014 -0300
    20.3 @@ -75,7 +75,9 @@
    20.4      const char *(*udev_device_get_action)(struct udev_device *);
    20.5      const char *(*udev_device_get_devnode)(struct udev_device *);
    20.6      const char *(*udev_device_get_subsystem)(struct udev_device *);
    20.7 +	struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);
    20.8      const char *(*udev_device_get_property_value)(struct udev_device *, const char *);
    20.9 +	const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);
   20.10      struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);
   20.11      void (*udev_device_unref)(struct udev_device *);
   20.12      int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);
    21.1 --- a/src/events/SDL_mouse.c	Tue Oct 28 01:34:40 2014 -0300
    21.2 +++ b/src/events/SDL_mouse.c	Tue Oct 28 18:36:29 2014 -0300
    21.3 @@ -430,7 +430,9 @@
    21.4      SDL_Cursor *cursor, *next;
    21.5      SDL_Mouse *mouse = SDL_GetMouse();
    21.6  
    21.7 -    SDL_CaptureMouse(SDL_FALSE);
    21.8 +    if (mouse->CaptureMouse) {
    21.9 +        SDL_CaptureMouse(SDL_FALSE);
   21.10 +    }
   21.11      SDL_SetRelativeMouseMode(SDL_FALSE);
   21.12      SDL_ShowCursor(1);
   21.13  
    22.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Tue Oct 28 01:34:40 2014 -0300
    22.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Tue Oct 28 18:36:29 2014 -0300
    22.3 @@ -23,6 +23,7 @@
    22.4  #ifdef SDL_HAPTIC_IOKIT
    22.5  
    22.6  #include "SDL_assert.h"
    22.7 +#include "SDL_stdinc.h"
    22.8  #include "SDL_haptic.h"
    22.9  #include "../SDL_syshaptic.h"
   22.10  #include "SDL_joystick.h"
   22.11 @@ -872,9 +873,10 @@
   22.12          SDL_memset(periodic, 0, sizeof(FFPERIODIC));
   22.13  
   22.14          /* Specifics */
   22.15 -        periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
   22.16 +        periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
   22.17          periodic->lOffset = CONVERT(hap_periodic->offset);
   22.18 -        periodic->dwPhase = hap_periodic->phase;
   22.19 +        periodic->dwPhase = 
   22.20 +                (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000;
   22.21          periodic->dwPeriod = hap_periodic->period * 1000;
   22.22          dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
   22.23          dest->lpvTypeSpecificParams = periodic;
    23.1 --- a/src/haptic/windows/SDL_dinputhaptic.c	Tue Oct 28 01:34:40 2014 -0300
    23.2 +++ b/src/haptic/windows/SDL_dinputhaptic.c	Tue Oct 28 18:36:29 2014 -0300
    23.3 @@ -21,6 +21,7 @@
    23.4  #include "../../SDL_internal.h"
    23.5  
    23.6  #include "SDL_error.h"
    23.7 +#include "SDL_stdinc.h"
    23.8  #include "SDL_haptic.h"
    23.9  #include "SDL_timer.h"
   23.10  #include "SDL_windowshaptic_c.h"
   23.11 @@ -714,9 +715,10 @@
   23.12          SDL_memset(periodic, 0, sizeof(DIPERIODIC));
   23.13  
   23.14          /* Specifics */
   23.15 -        periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
   23.16 +        periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
   23.17          periodic->lOffset = CONVERT(hap_periodic->offset);
   23.18 -        periodic->dwPhase = hap_periodic->phase;
   23.19 +        periodic->dwPhase = 
   23.20 +                (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000;
   23.21          periodic->dwPeriod = hap_periodic->period * 1000;
   23.22          dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
   23.23          dest->lpvTypeSpecificParams = periodic;
    24.1 --- a/src/joystick/SDL_gamecontroller.c	Tue Oct 28 01:34:40 2014 -0300
    24.2 +++ b/src/joystick/SDL_gamecontroller.c	Tue Oct 28 18:36:29 2014 -0300
    24.3 @@ -606,7 +606,7 @@
    24.4          if (freerw) {
    24.5              SDL_RWclose(rw);
    24.6          }
    24.7 -        return SDL_SetError("Could allocate space to not read DB into memory");
    24.8 +        return SDL_SetError("Could not allocate space to read DB into memory");
    24.9      }
   24.10      
   24.11      if (SDL_RWread(rw, buf, db_size, 1) != 1) {
   24.12 @@ -669,6 +669,10 @@
   24.13      ControllerMapping_t *pControllerMapping;
   24.14      SDL_bool is_xinput_mapping = SDL_FALSE;
   24.15  
   24.16 +    if (!mappingString) {
   24.17 +        return SDL_InvalidParamError("mappingString");
   24.18 +    }
   24.19 +
   24.20      pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString);
   24.21      if (!pchGUID) {
   24.22          return SDL_SetError("Couldn't parse GUID from %s", mappingString);
   24.23 @@ -735,6 +739,10 @@
   24.24          /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
   24.25          needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
   24.26          pMappingString = SDL_malloc(needed);
   24.27 +        if (!pMappingString) {
   24.28 +            SDL_OutOfMemory();
   24.29 +            return NULL;
   24.30 +        }
   24.31          SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
   24.32      }
   24.33      return pMappingString;
   24.34 @@ -746,6 +754,10 @@
   24.35  char *
   24.36  SDL_GameControllerMapping(SDL_GameController * gamecontroller)
   24.37  {
   24.38 +    if (!gamecontroller) {
   24.39 +        return NULL;
   24.40 +    }
   24.41 +
   24.42      return SDL_GameControllerMappingForGUID(gamecontroller->mapping.guid);
   24.43  }
   24.44  
   24.45 @@ -992,9 +1004,6 @@
   24.46  }
   24.47  
   24.48  
   24.49 -/*
   24.50 - * Get the number of multi-dimensional axis controls on a joystick
   24.51 - */
   24.52  const char *
   24.53  SDL_GameControllerName(SDL_GameController * gamecontroller)
   24.54  {
   24.55 @@ -1066,9 +1075,6 @@
   24.56  }
   24.57  
   24.58  
   24.59 -/*
   24.60 - * Close a joystick previously opened with SDL_JoystickOpen()
   24.61 - */
   24.62  void
   24.63  SDL_GameControllerClose(SDL_GameController * gamecontroller)
   24.64  {
    25.1 --- a/src/joystick/windows/SDL_windowsjoystick.c	Tue Oct 28 01:34:40 2014 -0300
    25.2 +++ b/src/joystick/windows/SDL_windowsjoystick.c	Tue Oct 28 18:36:29 2014 -0300
    25.3 @@ -46,7 +46,9 @@
    25.4  #include "../../events/SDL_events_c.h"
    25.5  #endif
    25.6  #include "../../core/windows/SDL_windows.h"
    25.7 +#if !defined(__WINRT__)
    25.8  #include <dbt.h>
    25.9 +#endif
   25.10  
   25.11  #define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
   25.12  #include "SDL_windowsjoystick_c.h"
    26.1 --- a/src/main/android/SDL_android_main.c	Tue Oct 28 01:34:40 2014 -0300
    26.2 +++ b/src/main/android/SDL_android_main.c	Tue Oct 28 18:36:29 2014 -0300
    26.3 @@ -17,22 +17,54 @@
    26.4  extern void SDL_Android_Init(JNIEnv* env, jclass cls);
    26.5  
    26.6  /* Start up the SDL app */
    26.7 -int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
    26.8 +int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
    26.9  {
   26.10 -    /* This interface could expand with ABI negotiation, calbacks, etc. */
   26.11 +    int i;
   26.12 +    int argc;
   26.13 +    int status;
   26.14 +
   26.15 +    /* This interface could expand with ABI negotiation, callbacks, etc. */
   26.16      SDL_Android_Init(env, cls);
   26.17  
   26.18      SDL_SetMainReady();
   26.19  
   26.20 -    /* Run the application code! */
   26.21 +    /* Prepare the arguments. */
   26.22 +
   26.23 +    int len = (*env)->GetArrayLength(env, array);
   26.24 +    char* argv[1 + len + 1];
   26.25 +    argc = 0;
   26.26      /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
   26.27         https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
   26.28       */
   26.29 -    int status;
   26.30 -    char *argv[2];
   26.31 -    argv[0] = SDL_strdup("app_process");
   26.32 -    argv[1] = NULL;
   26.33 -    status = SDL_main(1, argv);
   26.34 +    argv[argc++] = SDL_strdup("app_process");
   26.35 +    for (i = 0; i < len; ++i) {
   26.36 +        const char* utf;
   26.37 +        char* arg = NULL;
   26.38 +        jstring string = (*env)->GetObjectArrayElement(env, array, i);
   26.39 +        if (string) {
   26.40 +            utf = (*env)->GetStringUTFChars(env, string, 0);
   26.41 +            if (utf) {
   26.42 +                arg = SDL_strdup(utf);
   26.43 +                (*env)->ReleaseStringUTFChars(env, string, utf);
   26.44 +            }
   26.45 +        }
   26.46 +        if (!arg) {
   26.47 +            arg = SDL_strdup("");
   26.48 +        }
   26.49 +        argv[argc++] = arg;
   26.50 +    }
   26.51 +    argv[argc] = NULL;
   26.52 +
   26.53 +
   26.54 +    /* Run the application. */
   26.55 +
   26.56 +    status = SDL_main(argc, argv);
   26.57 +
   26.58 +    /* Release the arguments. */
   26.59 +
   26.60 +    for (i = 0; i < argc; ++i) {
   26.61 +        SDL_free(argv[i]);
   26.62 +    }
   26.63  
   26.64      /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
   26.65      /* exit(status); */
    27.1 --- a/src/render/direct3d11/SDL_render_d3d11.c	Tue Oct 28 01:34:40 2014 -0300
    27.2 +++ b/src/render/direct3d11/SDL_render_d3d11.c	Tue Oct 28 18:36:29 2014 -0300
    27.3 @@ -1330,10 +1330,22 @@
    27.4  }
    27.5  
    27.6  static int
    27.7 +D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
    27.8 +{
    27.9 +    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
   27.10 +    if (data->currentOffscreenRenderTargetView) {
   27.11 +        return DXGI_MODE_ROTATION_IDENTITY;
   27.12 +    } else {
   27.13 +        return data->rotation;
   27.14 +    }
   27.15 +}
   27.16 +
   27.17 +static int
   27.18  D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect)
   27.19  {
   27.20      D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
   27.21 -    switch (data->rotation) {
   27.22 +    const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
   27.23 +    switch (rotation) {
   27.24          case DXGI_MODE_ROTATION_IDENTITY:
   27.25              outRect->left = sdlRect->x;
   27.26              outRect->right = sdlRect->x + sdlRect->w;
   27.27 @@ -2151,6 +2163,7 @@
   27.28      SDL_FRect orientationAlignedViewport;
   27.29      BOOL swapDimensions;
   27.30      D3D11_VIEWPORT viewport;
   27.31 +    const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
   27.32  
   27.33      if (renderer->viewport.w == 0 || renderer->viewport.h == 0) {
   27.34          /* If the viewport is empty, assume that it is because
   27.35 @@ -2166,7 +2179,7 @@
   27.36       * default coordinate system) so rotations will be done in the opposite
   27.37       * direction of the DXGI_MODE_ROTATION enumeration.
   27.38       */
   27.39 -    switch (data->rotation) {
   27.40 +    switch (rotation) {
   27.41          case DXGI_MODE_ROTATION_IDENTITY:
   27.42              projection = MatrixIdentity();
   27.43              break;
   27.44 @@ -2217,7 +2230,7 @@
   27.45       * a landscape mode, for all Windows 8/RT devices, or a portrait mode,
   27.46       * for Windows Phone devices.
   27.47       */
   27.48 -    swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation);
   27.49 +    swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation);
   27.50      if (swapDimensions) {
   27.51          orientationAlignedViewport.x = (float) renderer->viewport.y;
   27.52          orientationAlignedViewport.y = (float) renderer->viewport.x;
    28.1 --- a/src/video/SDL_egl.c	Tue Oct 28 01:34:40 2014 -0300
    28.2 +++ b/src/video/SDL_egl.c	Tue Oct 28 18:36:29 2014 -0300
    28.3 @@ -38,7 +38,7 @@
    28.4  #define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so"
    28.5  #define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so"
    28.6  
    28.7 -#elif SDL_VIDEO_DRIVER_ANDROID
    28.8 +#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
    28.9  /* Android */
   28.10  #define DEFAULT_EGL "libEGL.so"
   28.11  #define DEFAULT_OGL_ES2 "libGLESv2.so"
   28.12 @@ -62,7 +62,7 @@
   28.13  #endif /* SDL_VIDEO_DRIVER_RPI */
   28.14  
   28.15  #define LOAD_FUNC(NAME) \
   28.16 -*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
   28.17 +_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
   28.18  if (!_this->egl_data->NAME) \
   28.19  { \
   28.20      return SDL_SetError("Could not retrieve EGL function " #NAME); \
    29.1 --- a/src/video/SDL_sysvideo.h	Tue Oct 28 01:34:40 2014 -0300
    29.2 +++ b/src/video/SDL_sysvideo.h	Tue Oct 28 18:36:29 2014 -0300
    29.3 @@ -391,8 +391,8 @@
    29.4  #if SDL_VIDEO_DRIVER_NACL
    29.5  extern VideoBootStrap NACL_bootstrap;
    29.6  #endif
    29.7 -#if SDL_VIDEO_DRIVER_MX6
    29.8 -extern VideoBootStrap MX6_bootstrap;
    29.9 +#if SDL_VIDEO_DRIVER_VIVANTE
   29.10 +extern VideoBootStrap VIVANTE_bootstrap;
   29.11  #endif
   29.12  
   29.13  extern SDL_VideoDevice *SDL_GetVideoDevice(void);
    30.1 --- a/src/video/SDL_video.c	Tue Oct 28 01:34:40 2014 -0300
    30.2 +++ b/src/video/SDL_video.c	Tue Oct 28 18:36:29 2014 -0300
    30.3 @@ -62,6 +62,12 @@
    30.4  #if SDL_VIDEO_DRIVER_MIR
    30.5      &MIR_bootstrap,
    30.6  #endif
    30.7 +#if SDL_VIDEO_DRIVER_WAYLAND
    30.8 +    &Wayland_bootstrap,
    30.9 +#endif
   30.10 +#if SDL_VIDEO_DRIVER_VIVANTE
   30.11 +    &VIVANTE_bootstrap,
   30.12 +#endif
   30.13  #if SDL_VIDEO_DRIVER_DIRECTFB
   30.14      &DirectFB_bootstrap,
   30.15  #endif
   30.16 @@ -89,15 +95,9 @@
   30.17  #if SDL_VIDEO_DRIVER_RPI
   30.18      &RPI_bootstrap,
   30.19  #endif 
   30.20 -#if SDL_VIDEO_DRIVER_WAYLAND
   30.21 -    &Wayland_bootstrap,
   30.22 -#endif
   30.23  #if SDL_VIDEO_DRIVER_NACL
   30.24      &NACL_bootstrap,
   30.25  #endif
   30.26 -#if SDL_VIDEO_DRIVER_MX6
   30.27 -    &MX6_bootstrap,
   30.28 -#endif
   30.29  #if SDL_VIDEO_DRIVER_DUMMY
   30.30      &DUMMY_bootstrap,
   30.31  #endif
   30.32 @@ -1339,6 +1339,10 @@
   30.33          SDL_UninitializedVideo();
   30.34          return NULL;
   30.35      }
   30.36 +    if (!_this->CreateWindowFrom) {
   30.37 +        SDL_Unsupported();
   30.38 +        return NULL;
   30.39 +    }
   30.40      window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
   30.41      if (!window) {
   30.42          SDL_OutOfMemory();
   30.43 @@ -1356,8 +1360,7 @@
   30.44      }
   30.45      _this->windows = window;
   30.46  
   30.47 -    if (!_this->CreateWindowFrom ||
   30.48 -        _this->CreateWindowFrom(_this, window, data) < 0) {
   30.49 +    if (_this->CreateWindowFrom(_this, window, data) < 0) {
   30.50          SDL_DestroyWindow(window);
   30.51          return NULL;
   30.52      }
   30.53 @@ -3181,11 +3184,13 @@
   30.54      CHECK_WINDOW_MAGIC(window, SDL_FALSE);
   30.55  
   30.56      if (!info) {
   30.57 +        SDL_InvalidParamError("info");
   30.58          return SDL_FALSE;
   30.59      }
   30.60      info->subsystem = SDL_SYSWM_UNKNOWN;
   30.61  
   30.62      if (!_this->GetWindowWMInfo) {
   30.63 +        SDL_Unsupported();
   30.64          return SDL_FALSE;
   30.65      }
   30.66      return (_this->GetWindowWMInfo(_this, window, info));
   30.67 @@ -3265,6 +3270,9 @@
   30.68      return SDL_FALSE;
   30.69  }
   30.70  
   30.71 +#if SDL_VIDEO_DRIVER_ANDROID
   30.72 +#include "android/SDL_androidmessagebox.h"
   30.73 +#endif
   30.74  #if SDL_VIDEO_DRIVER_WINDOWS
   30.75  #include "windows/SDL_windowsmessagebox.h"
   30.76  #endif
   30.77 @@ -3329,6 +3337,12 @@
   30.78      }
   30.79  
   30.80      /* It's completely fine to call this function before video is initialized */
   30.81 +#if SDL_VIDEO_DRIVER_ANDROID
   30.82 +    if (retval == -1 &&
   30.83 +        Android_ShowMessageBox(messageboxdata, buttonid) == 0) {
   30.84 +        retval = 0;
   30.85 +    }
   30.86 +#endif
   30.87  #if SDL_VIDEO_DRIVER_WINDOWS
   30.88      if (retval == -1 &&
   30.89          SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) &&
    31.1 --- a/src/video/android/SDL_androidevents.c	Tue Oct 28 01:34:40 2014 -0300
    31.2 +++ b/src/video/android/SDL_androidevents.c	Tue Oct 28 18:36:29 2014 -0300
    31.3 @@ -29,8 +29,11 @@
    31.4  #include "SDL_events.h"
    31.5  #include "SDL_androidwindow.h"
    31.6  
    31.7 +
    31.8  void android_egl_context_backup();
    31.9  void android_egl_context_restore();
   31.10 +void AndroidAUD_ResumeDevices(void);
   31.11 +void AndroidAUD_PauseDevices(void);
   31.12  
   31.13  void 
   31.14  android_egl_context_restore() 
   31.15 @@ -74,13 +77,14 @@
   31.16      if (isPaused && !isPausing) {
   31.17          /* Make sure this is the last thing we do before pausing */
   31.18          android_egl_context_backup();
   31.19 +        AndroidAUD_PauseDevices();
   31.20          if(SDL_SemWait(Android_ResumeSem) == 0) {
   31.21  #else
   31.22      if (isPaused) {
   31.23          if(SDL_SemTryWait(Android_ResumeSem) == 0) {
   31.24  #endif
   31.25              isPaused = 0;
   31.26 -            
   31.27 +            AndroidAUD_ResumeDevices();
   31.28              /* Restore the GL Context from here, as this operation is thread dependent */
   31.29              if (!SDL_HasEvent(SDL_QUIT)) {
   31.30                  android_egl_context_restore();
   31.31 @@ -103,6 +107,7 @@
   31.32  #else
   31.33          if(SDL_SemTryWait(Android_PauseSem) == 0) {
   31.34              android_egl_context_backup();
   31.35 +            AndroidAUD_PauseDevices();
   31.36              isPaused = 1;
   31.37          }
   31.38  #endif
    32.1 --- a/src/video/android/SDL_androidkeyboard.c	Tue Oct 28 01:34:40 2014 -0300
    32.2 +++ b/src/video/android/SDL_androidkeyboard.c	Tue Oct 28 18:36:29 2014 -0300
    32.3 @@ -263,6 +263,43 @@
    32.4      SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */
    32.5      SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */
    32.6      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_AUDIO_TRACK */
    32.7 +    SDL_SCANCODE_SLEEP, /* AKEYCODE_SLEEP */
    32.8 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WAKEUP */
    32.9 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PAIRING */
   32.10 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_TOP_MENU */
   32.11 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_11 */
   32.12 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_12 */
   32.13 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LAST_CHANNEL */
   32.14 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_DATA_SERVICE */
   32.15 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOICE_ASSIST */
   32.16 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_RADIO_SERVICE */
   32.17 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TELETEXT */
   32.18 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NUMBER_ENTRY */
   32.19 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_ANALOG */
   32.20 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_DIGITAL */
   32.21 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE */
   32.22 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_BS */
   32.23 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_CS */
   32.24 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_SERVICE */
   32.25 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NETWORK */
   32.26 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ANTENNA_CABLE */
   32.27 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_1 */
   32.28 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_2 */
   32.29 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_3 */
   32.30 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_4 */
   32.31 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_1 */
   32.32 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_2 */
   32.33 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_1 */
   32.34 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_2 */
   32.35 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_VGA_1 */
   32.36 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION */
   32.37 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP */
   32.38 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN */
   32.39 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ZOOM_MODE */
   32.40 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_CONTENTS_MENU */
   32.41 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */
   32.42 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */
   32.43 +    SDL_SCANCODE_HELP, /* AKEYCODE_HELP */
   32.44  };
   32.45  
   32.46  static SDL_Scancode
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/src/video/android/SDL_androidmessagebox.c	Tue Oct 28 18:36:29 2014 -0300
    33.3 @@ -0,0 +1,37 @@
    33.4 +/*
    33.5 +  Simple DirectMedia Layer
    33.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    33.7 +
    33.8 +  This software is provided 'as-is', without any express or implied
    33.9 +  warranty.  In no event will the authors be held liable for any damages
   33.10 +  arising from the use of this software.
   33.11 +
   33.12 +  Permission is granted to anyone to use this software for any purpose,
   33.13 +  including commercial applications, and to alter it and redistribute it
   33.14 +  freely, subject to the following restrictions:
   33.15 +
   33.16 +  1. The origin of this software must not be misrepresented; you must not
   33.17 +     claim that you wrote the original software. If you use this software
   33.18 +     in a product, an acknowledgment in the product documentation would be
   33.19 +     appreciated but is not required.
   33.20 +  2. Altered source versions must be plainly marked as such, and must not be
   33.21 +     misrepresented as being the original software.
   33.22 +  3. This notice may not be removed or altered from any source distribution.
   33.23 +*/
   33.24 +#include "SDL_config.h"
   33.25 +
   33.26 +#if SDL_VIDEO_DRIVER_ANDROID
   33.27 +
   33.28 +#include "SDL_messagebox.h"
   33.29 +
   33.30 +int
   33.31 +Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   33.32 +{
   33.33 +    int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
   33.34 +
   33.35 +    return Android_JNI_ShowMessageBox(messageboxdata, buttonid);
   33.36 +}
   33.37 +
   33.38 +#endif /* SDL_VIDEO_DRIVER_ANDROID */
   33.39 +
   33.40 +/* vi: set ts=4 sw=4 expandtab: */
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/src/video/android/SDL_androidmessagebox.h	Tue Oct 28 18:36:29 2014 -0300
    34.3 @@ -0,0 +1,29 @@
    34.4 +/*
    34.5 +  Simple DirectMedia Layer
    34.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    34.7 +
    34.8 +  This software is provided 'as-is', without any express or implied
    34.9 +  warranty.  In no event will the authors be held liable for any damages
   34.10 +  arising from the use of this software.
   34.11 +
   34.12 +  Permission is granted to anyone to use this software for any purpose,
   34.13 +  including commercial applications, and to alter it and redistribute it
   34.14 +  freely, subject to the following restrictions:
   34.15 +
   34.16 +  1. The origin of this software must not be misrepresented; you must not
   34.17 +     claim that you wrote the original software. If you use this software
   34.18 +     in a product, an acknowledgment in the product documentation would be
   34.19 +     appreciated but is not required.
   34.20 +  2. Altered source versions must be plainly marked as such, and must not be
   34.21 +     misrepresented as being the original software.
   34.22 +  3. This notice may not be removed or altered from any source distribution.
   34.23 +*/
   34.24 +#include "../../SDL_internal.h"
   34.25 +
   34.26 +#if SDL_VIDEO_DRIVER_ANDROID
   34.27 +
   34.28 +extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
   34.29 +
   34.30 +#endif /* SDL_VIDEO_DRIVER_ANDROID */
   34.31 +
   34.32 +/* vi: set ts=4 sw=4 expandtab: */
    35.1 --- a/src/video/android/SDL_androidvideo.c	Tue Oct 28 01:34:40 2014 -0300
    35.2 +++ b/src/video/android/SDL_androidvideo.c	Tue Oct 28 18:36:29 2014 -0300
    35.3 @@ -76,6 +76,12 @@
    35.4  }
    35.5  
    35.6  static void
    35.7 +Android_SuspendScreenSaver(_THIS)
    35.8 +{
    35.9 +    Android_JNI_SuspendScreenSaver(_this->suspend_screensaver);
   35.10 +}
   35.11 +
   35.12 +static void
   35.13  Android_DeleteDevice(SDL_VideoDevice * device)
   35.14  {
   35.15      SDL_free(device);
   35.16 @@ -126,6 +132,9 @@
   35.17      device->GL_SwapWindow = Android_GLES_SwapWindow;
   35.18      device->GL_DeleteContext = Android_GLES_DeleteContext;
   35.19  
   35.20 +    /* Screensaver */
   35.21 +    device->SuspendScreenSaver = Android_SuspendScreenSaver;
   35.22 +
   35.23      /* Text input */
   35.24      device->StartTextInput = Android_StartTextInput;
   35.25      device->StopTextInput = Android_StopTextInput;
    36.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Tue Oct 28 01:34:40 2014 -0300
    36.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Tue Oct 28 18:36:29 2014 -0300
    36.3 @@ -52,7 +52,7 @@
    36.4  #define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
    36.5  
    36.6  
    36.7 -/* GDI renderer implementation */
    36.8 +/* DirectFB renderer implementation */
    36.9  
   36.10  static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
   36.11                                               Uint32 flags);
    37.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Tue Oct 28 01:34:40 2014 -0300
    37.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Tue Oct 28 18:36:29 2014 -0300
    37.3 @@ -238,7 +238,7 @@
    37.4  
    37.5      if (!devdata->use_linux_input)
    37.6      {
    37.7 -        SDL_DFB_LOG("Disabling linxu input\n");
    37.8 +        SDL_DFB_LOG("Disabling linux input\n");
    37.9          DirectFBSetOption("disable-module", "linux_input");
   37.10      }
   37.11  
    38.1 --- a/src/video/mir/SDL_mirsym.h	Tue Oct 28 01:34:40 2014 -0300
    38.2 +++ b/src/video/mir/SDL_mirsym.h	Tue Oct 28 18:36:29 2014 -0300
    38.3 @@ -26,7 +26,7 @@
    38.4  SDL_MIR_SYM(MirSurface *,mir_connection_create_surface_sync,(MirConnection *connection, MirSurfaceParameters const *params))
    38.5  SDL_MIR_SYM(void,mir_connection_get_available_surface_formats,(MirConnection* connection, MirPixelFormat* formats, unsigned const int format_size, unsigned int *num_valid_formats))
    38.6  SDL_MIR_SYM(MirEGLNativeDisplayType,mir_connection_get_egl_native_display,(MirConnection *connection))
    38.7 -SDL_MIR_SYM(int,mir_connection_is_valid,(MirConnection *connection))
    38.8 +SDL_MIR_SYM(MirBool,mir_connection_is_valid,(MirConnection *connection))
    38.9  SDL_MIR_SYM(void,mir_connection_release,(MirConnection *connection))
   38.10  SDL_MIR_SYM(MirConnection *,mir_connect_sync,(char const *server, char const *app_name))
   38.11  SDL_MIR_SYM(void,mir_display_config_destroy,(MirDisplayConfiguration* display_configuration))
   38.12 @@ -34,10 +34,11 @@
   38.13  SDL_MIR_SYM(char const *,mir_surface_get_error_message,(MirSurface *surface))
   38.14  SDL_MIR_SYM(void,mir_surface_get_graphics_region,(MirSurface *surface, MirGraphicsRegion *graphics_region))
   38.15  SDL_MIR_SYM(void,mir_surface_get_parameters,(MirSurface *surface, MirSurfaceParameters *parameters))
   38.16 -SDL_MIR_SYM(int,mir_surface_is_valid,(MirSurface *surface))
   38.17 +SDL_MIR_SYM(MirBool,mir_surface_is_valid,(MirSurface *surface))
   38.18  SDL_MIR_SYM(void,mir_surface_release_sync,(MirSurface *surface))
   38.19  SDL_MIR_SYM(void,mir_surface_set_event_handler,(MirSurface *surface, MirEventDelegate const *event_handler))
   38.20  SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_type,(MirSurface *surface, MirSurfaceType type))
   38.21 +SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_state,(MirSurface *surface, MirSurfaceState state))
   38.22  SDL_MIR_SYM(void,mir_surface_swap_buffers_sync,(MirSurface *surface))
   38.23  
   38.24  SDL_MIR_MODULE(XKBCOMMON)
    39.1 --- a/src/video/mir/SDL_mirwindow.c	Tue Oct 28 01:34:40 2014 -0300
    39.2 +++ b/src/video/mir/SDL_mirwindow.c	Tue Oct 28 18:36:29 2014 -0300
    39.3 @@ -186,9 +186,9 @@
    39.4          return;
    39.5  
    39.6      if (fullscreen) {
    39.7 -        MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_fullscreen);
    39.8 +        MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_fullscreen);
    39.9      } else {
   39.10 -        MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_restored);
   39.11 +        MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_restored);
   39.12      }
   39.13  }
   39.14  
   39.15 @@ -200,7 +200,7 @@
   39.16      if (IsSurfaceValid(mir_window) < 0)
   39.17          return;
   39.18  
   39.19 -    MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_maximized);
   39.20 +    MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_maximized);
   39.21  }
   39.22  
   39.23  void
   39.24 @@ -211,7 +211,7 @@
   39.25      if (IsSurfaceValid(mir_window) < 0)
   39.26          return;
   39.27  
   39.28 -    MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_minimized);
   39.29 +    MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_minimized);
   39.30  }
   39.31  
   39.32  void
   39.33 @@ -222,7 +222,7 @@
   39.34      if (IsSurfaceValid(mir_window) < 0)
   39.35          return;
   39.36  
   39.37 -    MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_restored);
   39.38 +    MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_restored);
   39.39  }
   39.40  
   39.41  #endif /* SDL_VIDEO_DRIVER_MIR */
    40.1 --- a/src/video/mx6/SDL_mx6events.c	Tue Oct 28 01:34:40 2014 -0300
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,45 +0,0 @@
    40.4 -/*
    40.5 -  Simple DirectMedia Layer
    40.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    40.7 -
    40.8 -  This software is provided 'as-is', without any express or implied
    40.9 -  warranty.  In no event will the authors be held liable for any damages
   40.10 -  arising from the use of this software.
   40.11 -
   40.12 -  Permission is granted to anyone to use this software for any purpose,
   40.13 -  including commercial applications, and to alter it and redistribute it
   40.14 -  freely, subject to the following restrictions:
   40.15 -
   40.16 -  1. The origin of this software must not be misrepresented; you must not
   40.17 -     claim that you wrote the original software. If you use this software
   40.18 -     in a product, an acknowledgment in the product documentation would be
   40.19 -     appreciated but is not required.
   40.20 -  2. Altered source versions must be plainly marked as such, and must not be
   40.21 -     misrepresented as being the original software.
   40.22 -  3. This notice may not be removed or altered from any source distribution.
   40.23 -*/
   40.24 -
   40.25 -#include "../../SDL_internal.h"
   40.26 -
   40.27 -#if SDL_VIDEO_DRIVER_MX6
   40.28 -
   40.29 -#include "../../events/SDL_sysevents.h"
   40.30 -#include "../../events/SDL_events_c.h"
   40.31 -#include "../../events/SDL_keyboard_c.h"
   40.32 -#include "SDL_mx6video.h"
   40.33 -#include "SDL_mx6events_c.h"
   40.34 -
   40.35 -#ifdef SDL_INPUT_LINUXEV
   40.36 -#include "../../core/linux/SDL_evdev.h"
   40.37 -#endif
   40.38 -
   40.39 -void MX6_PumpEvents(_THIS)
   40.40 -{
   40.41 -#ifdef SDL_INPUT_LINUXEV
   40.42 -    SDL_EVDEV_Poll();
   40.43 -#endif
   40.44 -    
   40.45 -}
   40.46 -
   40.47 -#endif /* SDL_VIDEO_DRIVER_MX6 */
   40.48 -
    41.1 --- a/src/video/mx6/SDL_mx6events_c.h	Tue Oct 28 01:34:40 2014 -0300
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,31 +0,0 @@
    41.4 -/*
    41.5 -  Simple DirectMedia Layer
    41.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    41.7 -
    41.8 -  This software is provided 'as-is', without any express or implied
    41.9 -  warranty.  In no event will the authors be held liable for any damages
   41.10 -  arising from the use of this software.
   41.11 -
   41.12 -  Permission is granted to anyone to use this software for any purpose,
   41.13 -  including commercial applications, and to alter it and redistribute it
   41.14 -  freely, subject to the following restrictions:
   41.15 -
   41.16 -  1. The origin of this software must not be misrepresented; you must not
   41.17 -     claim that you wrote the original software. If you use this software
   41.18 -     in a product, an acknowledgment in the product documentation would be
   41.19 -     appreciated but is not required.
   41.20 -  2. Altered source versions must be plainly marked as such, and must not be
   41.21 -     misrepresented as being the original software.
   41.22 -  3. This notice may not be removed or altered from any source distribution.
   41.23 -*/
   41.24 -
   41.25 -#ifndef _SDL_mx6events_c_h
   41.26 -#define _SDL_mx6events_c_h
   41.27 -
   41.28 -#include "SDL_mx6video.h"
   41.29 -
   41.30 -void MX6_PumpEvents(_THIS);
   41.31 -void MX6_EventInit(_THIS);
   41.32 -void MX6_EventQuit(_THIS);
   41.33 -
   41.34 -#endif /* _SDL_mx6events_c_h */
    42.1 --- a/src/video/mx6/SDL_mx6opengles.c	Tue Oct 28 01:34:40 2014 -0300
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,209 +0,0 @@
    42.4 -/*
    42.5 -  Simple DirectMedia Layer
    42.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    42.7 -
    42.8 -  This software is provided 'as-is', without any express or implied
    42.9 -  warranty.  In no event will the authors be held liable for any damages
   42.10 -  arising from the use of this software.
   42.11 -
   42.12 -  Permission is granted to anyone to use this software for any purpose,
   42.13 -  including commercial applications, and to alter it and redistribute it
   42.14 -  freely, subject to the following restrictions:
   42.15 -
   42.16 -  1. The origin of this software must not be misrepresented; you must not
   42.17 -     claim that you wrote the original software. If you use this software
   42.18 -     in a product, an acknowledgment in the product documentation would be
   42.19 -     appreciated but is not required.
   42.20 -  2. Altered source versions must be plainly marked as such, and must not be
   42.21 -     misrepresented as being the original software.
   42.22 -  3. This notice may not be removed or altered from any source distribution.
   42.23 -*/
   42.24 -#include "../../SDL_internal.h"
   42.25 -
   42.26 -#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
   42.27 -
   42.28 -#include "SDL_mx6opengles.h"
   42.29 -#include "SDL_loadso.h"
   42.30 -#include "SDL_mx6video.h"
   42.31 -
   42.32 -#define DEFAULT_OGL "libGL.so.1"
   42.33 -#define DEFAULT_EGL "libEGL.so.1"
   42.34 -#define DEFAULT_OGL_ES2 "libGLESv2.so.2"
   42.35 -#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
   42.36 -
   42.37 -#define LOAD_FUNC(NAME) \
   42.38 -*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
   42.39 -if (!_this->egl_data->NAME) \
   42.40 -{ \
   42.41 -    return SDL_SetError("Could not retrieve EGL function " #NAME); \
   42.42 -}
   42.43 -
   42.44 -#define LOAD_VIV_FUNC(NAME) \
   42.45 -*((void**)&egl_viv_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
   42.46 -if (!egl_viv_data->NAME) \
   42.47 -{ \
   42.48 -    return SDL_SetError("Could not retrieve EGL function " #NAME); \
   42.49 -}
   42.50 -
   42.51 -/* EGL implementation of SDL OpenGL support */
   42.52 -
   42.53 -int
   42.54 -MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
   42.55 -    /* The definitions of egl_dll_handle and dll_handle were interchanged for some reason.
   42.56 -       Just left them as is for compatibility */
   42.57 -    void *dll_handle = NULL, *egl_dll_handle = NULL;
   42.58 -    char *path = NULL;
   42.59 -    SDL_DisplayData *displaydata;
   42.60 -
   42.61 -    if (_this->egl_data) {
   42.62 -        return SDL_SetError("OpenGL ES context already created");
   42.63 -    }
   42.64 -
   42.65 -    _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
   42.66 -    if (!_this->egl_data) {
   42.67 -        return SDL_OutOfMemory();
   42.68 -    }
   42.69 -
   42.70 -    egl_viv_data = (struct MX6_EGL_VivanteData *) SDL_calloc(1, sizeof(MX6_EGL_VivanteData));
   42.71 -    if (!egl_viv_data) {
   42.72 -        return SDL_OutOfMemory();
   42.73 -    }
   42.74 -
   42.75 -    path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
   42.76 -    if (path != NULL) {
   42.77 -        egl_dll_handle = SDL_LoadObject(path);
   42.78 -    }
   42.79 -
   42.80 -    if (egl_dll_handle == NULL) {
   42.81 -        if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
   42.82 -            if (_this->gl_config.major_version > 1) {
   42.83 -                path = DEFAULT_OGL_ES2;
   42.84 -                egl_dll_handle = SDL_LoadObject(path);
   42.85 -            }
   42.86 -            else {
   42.87 -                path = DEFAULT_OGL_ES;
   42.88 -                egl_dll_handle = SDL_LoadObject(path);
   42.89 -            }
   42.90 -        }      
   42.91 -        else {
   42.92 -            path = DEFAULT_OGL;
   42.93 -            egl_dll_handle = SDL_LoadObject(path);
   42.94 -        }     
   42.95 -    }
   42.96 -    _this->egl_data->egl_dll_handle = egl_dll_handle;
   42.97 -
   42.98 -    if (egl_dll_handle == NULL) {
   42.99 -        return SDL_SetError("Could not initialize OpenGL / GLES library");
  42.100 -    }
  42.101 -
  42.102 -    if (egl_path != NULL) {
  42.103 -        dll_handle = SDL_LoadObject(egl_path);
  42.104 -    }   
  42.105 -    
  42.106 -    if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
  42.107 -        if (dll_handle != NULL) {
  42.108 -            SDL_UnloadObject(dll_handle);
  42.109 -        }
  42.110 -        path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
  42.111 -        if (path == NULL) {
  42.112 -            path = DEFAULT_EGL;
  42.113 -        }
  42.114 -        dll_handle = SDL_LoadObject(path);
  42.115 -        if (dll_handle == NULL) {
  42.116 -            return SDL_SetError("Could not load EGL library");
  42.117 -        }
  42.118 -    }
  42.119 -
  42.120 -    _this->egl_data->dll_handle = dll_handle;
  42.121 -
  42.122 -    /* Load new function pointers */
  42.123 -    LOAD_FUNC(eglGetDisplay);
  42.124 -    LOAD_FUNC(eglInitialize);
  42.125 -    LOAD_FUNC(eglTerminate);
  42.126 -    LOAD_FUNC(eglGetProcAddress);
  42.127 -    LOAD_FUNC(eglChooseConfig);
  42.128 -    LOAD_FUNC(eglGetConfigAttrib);
  42.129 -    LOAD_FUNC(eglCreateContext);
  42.130 -    LOAD_FUNC(eglDestroyContext);
  42.131 -    LOAD_FUNC(eglCreateWindowSurface);
  42.132 -    LOAD_FUNC(eglDestroySurface);
  42.133 -    LOAD_FUNC(eglMakeCurrent);
  42.134 -    LOAD_FUNC(eglSwapBuffers);
  42.135 -    LOAD_FUNC(eglSwapInterval);
  42.136 -    LOAD_FUNC(eglWaitNative);
  42.137 -    LOAD_FUNC(eglWaitGL);
  42.138 -    LOAD_FUNC(eglBindAPI);
  42.139 -    /* Functions from Vivante GPU SDK */
  42.140 -    LOAD_VIV_FUNC(fbGetDisplay);
  42.141 -    LOAD_VIV_FUNC(fbGetDisplayByIndex);
  42.142 -    LOAD_VIV_FUNC(fbGetDisplayGeometry);
  42.143 -    LOAD_VIV_FUNC(fbGetDisplayInfo);
  42.144 -    LOAD_VIV_FUNC(fbDestroyDisplay);
  42.145 -    LOAD_VIV_FUNC(fbCreateWindow);
  42.146 -    LOAD_VIV_FUNC(fbGetWindowGeometry);
  42.147 -    LOAD_VIV_FUNC(fbGetWindowInfo);
  42.148 -    LOAD_VIV_FUNC(fbDestroyWindow);
  42.149 -    LOAD_VIV_FUNC(fbCreatePixmap);
  42.150 -    LOAD_VIV_FUNC(fbCreatePixmapWithBpp);
  42.151 -    LOAD_VIV_FUNC(fbGetPixmapGeometry);
  42.152 -    LOAD_VIV_FUNC(fbGetPixmapInfo);
  42.153 -    LOAD_VIV_FUNC(fbDestroyPixmap);
  42.154 -   
  42.155 -    displaydata = SDL_GetDisplayDriverData(0);
  42.156 -
  42.157 -    _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(displaydata->native_display);
  42.158 -    if (!_this->egl_data->egl_display) {
  42.159 -        return SDL_SetError("Could not get EGL display");
  42.160 -    }
  42.161 -    
  42.162 -    if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
  42.163 -        return SDL_SetError("Could not initialize EGL");
  42.164 -    }
  42.165 -
  42.166 -    displaydata->egl_display = _this->egl_data->egl_display;
  42.167 -
  42.168 -    _this->gl_config.driver_loaded = 1;
  42.169 -
  42.170 -    if (path) {
  42.171 -        SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
  42.172 -    } else {
  42.173 -        *_this->gl_config.driver_path = '\0';
  42.174 -    }
  42.175 -    
  42.176 -    return 0;
  42.177 -}
  42.178 -
  42.179 -void
  42.180 -MX6_GLES_UnloadLibrary(_THIS)
  42.181 -{
  42.182 -    if (_this->egl_data) {
  42.183 -        if (_this->egl_data->egl_display) {
  42.184 -            _this->egl_data->eglTerminate(_this->egl_data->egl_display);
  42.185 -            _this->egl_data->egl_display = NULL;
  42.186 -        }
  42.187 -
  42.188 -        if (_this->egl_data->dll_handle) {
  42.189 -            SDL_UnloadObject(_this->egl_data->dll_handle);
  42.190 -            _this->egl_data->dll_handle = NULL;
  42.191 -        }
  42.192 -        if (_this->egl_data->egl_dll_handle) {
  42.193 -            SDL_UnloadObject(_this->egl_data->egl_dll_handle);
  42.194 -            _this->egl_data->egl_dll_handle = NULL;
  42.195 -        }
  42.196 -        
  42.197 -        SDL_free(_this->egl_data);
  42.198 -        _this->egl_data = NULL;
  42.199 -
  42.200 -        SDL_free(egl_viv_data);
  42.201 -        egl_viv_data = NULL;
  42.202 -    }
  42.203 -}
  42.204 -
  42.205 -SDL_EGL_CreateContext_impl(MX6)
  42.206 -SDL_EGL_SwapWindow_impl(MX6)
  42.207 -SDL_EGL_MakeCurrent_impl(MX6)
  42.208 -
  42.209 -#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
  42.210 -
  42.211 -/* vi: set ts=4 sw=4 expandtab: */
  42.212 -
    43.1 --- a/src/video/mx6/SDL_mx6opengles.h	Tue Oct 28 01:34:40 2014 -0300
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,68 +0,0 @@
    43.4 -/*
    43.5 -  Simple DirectMedia Layer
    43.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    43.7 -
    43.8 -  This software is provided 'as-is', without any express or implied
    43.9 -  warranty.  In no event will the authors be held liable for any damages
   43.10 -  arising from the use of this software.
   43.11 -
   43.12 -  Permission is granted to anyone to use this software for any purpose,
   43.13 -  including commercial applications, and to alter it and redistribute it
   43.14 -  freely, subject to the following restrictions:
   43.15 -
   43.16 -  1. The origin of this software must not be misrepresented; you must not
   43.17 -     claim that you wrote the original software. If you use this software
   43.18 -     in a product, an acknowledgment in the product documentation would be
   43.19 -     appreciated but is not required.
   43.20 -  2. Altered source versions must be plainly marked as such, and must not be
   43.21 -     misrepresented as being the original software.
   43.22 -  3. This notice may not be removed or altered from any source distribution.
   43.23 -*/
   43.24 -#include "../../SDL_internal.h"
   43.25 -
   43.26 -#ifndef _SDL_mx6opengles_h
   43.27 -#define _SDL_mx6opengles_h
   43.28 -
   43.29 -#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
   43.30 -
   43.31 -#include "../SDL_sysvideo.h"
   43.32 -#include "../SDL_egl_c.h"
   43.33 -
   43.34 -typedef struct MX6_EGL_VivanteData
   43.35 -{
   43.36 -    EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay) (void *context);
   43.37 -    EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex) (int DisplayIndex);
   43.38 -    void(EGLAPIENTRY *fbGetDisplayGeometry) (EGLNativeDisplayType Display, int *Width, int *Height);
   43.39 -    void(EGLAPIENTRY *fbGetDisplayInfo) (EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
   43.40 -    void(EGLAPIENTRY *fbDestroyDisplay) (EGLNativeDisplayType Display);
   43.41 -    EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow) (EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
   43.42 -    void(EGLAPIENTRY *fbGetWindowGeometry) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
   43.43 -    void(EGLAPIENTRY *fbGetWindowInfo) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
   43.44 -    void(EGLAPIENTRY *fbDestroyWindow) (EGLNativeWindowType Window);
   43.45 -    EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmap) (EGLNativeDisplayType Display, int Width, int Height);
   43.46 -    EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmapWithBpp) (EGLNativeDisplayType Display, int Width, int Height, int BitsPerPixel);
   43.47 -    void(EGLAPIENTRY *fbGetPixmapGeometry) (EGLNativePixmapType Pixmap, int *Width, int *Height);
   43.48 -    void(EGLAPIENTRY *fbGetPixmapInfo) (EGLNativePixmapType Pixmap, int *Width, int *Height, int *BitsPerPixel, int *Stride, void **Bits);
   43.49 -    void(EGLAPIENTRY *fbDestroyPixmap) (EGLNativePixmapType Pixmap);
   43.50 -} MX6_EGL_VivanteData;
   43.51 -
   43.52 -struct MX6_EGL_VivanteData *egl_viv_data;
   43.53 -
   43.54 -/* OpenGLES functions */
   43.55 -#define MX6_GLES_GetAttribute SDL_EGL_GetAttribute
   43.56 -#define MX6_GLES_GetProcAddress SDL_EGL_GetProcAddress
   43.57 -#define MX6_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
   43.58 -#define MX6_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
   43.59 -#define MX6_GLES_DeleteContext SDL_EGL_DeleteContext
   43.60 -
   43.61 -extern int MX6_GLES_LoadLibrary(_THIS, const char *path);
   43.62 -extern void MX6_GLES_UnloadLibrary(_THIS);
   43.63 -extern SDL_GLContext MX6_GLES_CreateContext(_THIS, SDL_Window * window);
   43.64 -extern void MX6_GLES_SwapWindow(_THIS, SDL_Window * window);
   43.65 -extern int MX6_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
   43.66 -
   43.67 -#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
   43.68 -
   43.69 -#endif /* _SDL_mx6opengles_h */
   43.70 -
   43.71 -/* vi: set ts=4 sw=4 expandtab: */
    44.1 --- a/src/video/mx6/SDL_mx6video.c	Tue Oct 28 01:34:40 2014 -0300
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,325 +0,0 @@
    44.4 -/*
    44.5 -  Simple DirectMedia Layer
    44.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    44.7 -
    44.8 -  This software is provided 'as-is', without any express or implied
    44.9 -  warranty.  In no event will the authors be held liable for any damages
   44.10 -  arising from the use of this software.
   44.11 -
   44.12 -  Permission is granted to anyone to use this software for any purpose,
   44.13 -  including commercial applications, and to alter it and redistribute it
   44.14 -  freely, subject to the following restrictions:
   44.15 -
   44.16 -  1. The origin of this software must not be misrepresented; you must not
   44.17 -     claim that you wrote the original software. If you use this software
   44.18 -     in a product, an acknowledgment in the product documentation would be
   44.19 -     appreciated but is not required.
   44.20 -  2. Altered source versions must be plainly marked as such, and must not be
   44.21 -     misrepresented as being the original software.
   44.22 -  3. This notice may not be removed or altered from any source distribution.
   44.23 -*/
   44.24 -
   44.25 -#include "../../SDL_internal.h"
   44.26 -
   44.27 -#if SDL_VIDEO_DRIVER_MX6
   44.28 -
   44.29 -/* SDL internals */
   44.30 -#include "../SDL_sysvideo.h"
   44.31 -#include "SDL_version.h"
   44.32 -#include "SDL_syswm.h"
   44.33 -#include "SDL_loadso.h"
   44.34 -#include "SDL_events.h"
   44.35 -
   44.36 -#ifdef SDL_INPUT_LINUXEV
   44.37 -#include "../../core/linux/SDL_evdev.h"
   44.38 -#endif
   44.39 -
   44.40 -#include "SDL_mx6video.h"
   44.41 -#include "SDL_mx6events_c.h"
   44.42 -#include "SDL_mx6opengles.h"
   44.43 -
   44.44 -static int
   44.45 -MX6_Available(void)
   44.46 -{
   44.47 -    return 1;
   44.48 -}
   44.49 -
   44.50 -static void
   44.51 -MX6_Destroy(SDL_VideoDevice * device)
   44.52 -{
   44.53 -    if (device->driverdata != NULL) {
   44.54 -        device->driverdata = NULL;
   44.55 -    }
   44.56 -}
   44.57 -
   44.58 -static SDL_VideoDevice *
   44.59 -MX6_Create()
   44.60 -{
   44.61 -    SDL_VideoDevice *device;
   44.62 -    SDL_VideoData *phdata;
   44.63 -
   44.64 -    /* Initialize SDL_VideoDevice structure */
   44.65 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   44.66 -    if (device == NULL) {
   44.67 -        SDL_OutOfMemory();
   44.68 -        return NULL;
   44.69 -    }
   44.70 -
   44.71 -    /* Initialize internal data */
   44.72 -    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   44.73 -    if (phdata == NULL) {
   44.74 -        SDL_OutOfMemory();
   44.75 -        SDL_free(device);
   44.76 -        return NULL;
   44.77 -    }
   44.78 -
   44.79 -    device->driverdata = phdata;
   44.80 -
   44.81 -    /* Setup amount of available displays and current display */
   44.82 -    device->num_displays = 0;
   44.83 -
   44.84 -    /* Set device free function */
   44.85 -    device->free = MX6_Destroy;
   44.86 -
   44.87 -    /* Setup all functions which we can handle */
   44.88 -    device->VideoInit = MX6_VideoInit;
   44.89 -    device->VideoQuit = MX6_VideoQuit;
   44.90 -    device->GetDisplayModes = MX6_GetDisplayModes;
   44.91 -    device->SetDisplayMode = MX6_SetDisplayMode;
   44.92 -    device->CreateWindow = MX6_CreateWindow;
   44.93 -    device->CreateWindowFrom = MX6_CreateWindowFrom;
   44.94 -    device->SetWindowTitle = MX6_SetWindowTitle;
   44.95 -    device->SetWindowIcon = MX6_SetWindowIcon;
   44.96 -    device->SetWindowPosition = MX6_SetWindowPosition;
   44.97 -    device->SetWindowSize = MX6_SetWindowSize;
   44.98 -    device->ShowWindow = MX6_ShowWindow;
   44.99 -    device->HideWindow = MX6_HideWindow;
  44.100 -    device->RaiseWindow = MX6_RaiseWindow;
  44.101 -    device->MaximizeWindow = MX6_MaximizeWindow;
  44.102 -    device->MinimizeWindow = MX6_MinimizeWindow;
  44.103 -    device->RestoreWindow = MX6_RestoreWindow;
  44.104 -    device->SetWindowGrab = MX6_SetWindowGrab;
  44.105 -    device->DestroyWindow = MX6_DestroyWindow;
  44.106 -    device->GetWindowWMInfo = MX6_GetWindowWMInfo;
  44.107 -
  44.108 -    device->GL_LoadLibrary = MX6_GLES_LoadLibrary;
  44.109 -    device->GL_GetProcAddress = MX6_GLES_GetProcAddress;
  44.110 -    device->GL_UnloadLibrary = MX6_GLES_UnloadLibrary;
  44.111 -    device->GL_CreateContext = MX6_GLES_CreateContext;
  44.112 -    device->GL_MakeCurrent = MX6_GLES_MakeCurrent;
  44.113 -    device->GL_SetSwapInterval = MX6_GLES_SetSwapInterval;
  44.114 -    device->GL_GetSwapInterval = MX6_GLES_GetSwapInterval;
  44.115 -    device->GL_SwapWindow = MX6_GLES_SwapWindow;
  44.116 -    device->GL_DeleteContext = MX6_GLES_DeleteContext;
  44.117 -
  44.118 -    device->PumpEvents = MX6_PumpEvents;
  44.119 -
  44.120 -    return device;
  44.121 -}
  44.122 -
  44.123 -VideoBootStrap MX6_bootstrap = {
  44.124 -    "MX6",
  44.125 -    "Freescale i.MX6 Video Driver",
  44.126 -    MX6_Available,
  44.127 -    MX6_Create
  44.128 -};
  44.129 -
  44.130 -static void
  44.131 -MX6_UpdateDisplay(_THIS)
  44.132 -{
  44.133 -    SDL_VideoDisplay *display = &_this->displays[0];
  44.134 -    SDL_DisplayData *data = (SDL_DisplayData*)display->driverdata;
  44.135 -    EGLNativeDisplayType native_display = egl_viv_data->fbGetDisplayByIndex(0);
  44.136 -    SDL_DisplayMode current_mode;
  44.137 -    int pitch, bpp;
  44.138 -    unsigned long pixels;
  44.139 -
  44.140 -    /* Store the native EGL display */
  44.141 -    data->native_display = native_display;
  44.142 -
  44.143 -    SDL_zero(current_mode);
  44.144 -    egl_viv_data->fbGetDisplayInfo(native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
  44.145 -    /* FIXME: How do we query refresh rate? */
  44.146 -    current_mode.refresh_rate = 60;
  44.147 -
  44.148 -    switch (bpp)
  44.149 -    {
  44.150 -    default: /* Is another format used? */
  44.151 -    case 16:
  44.152 -        current_mode.format = SDL_PIXELFORMAT_RGB565;
  44.153 -        break;
  44.154 -    }
  44.155 -
  44.156 -    display->desktop_mode = current_mode;
  44.157 -    display->current_mode = current_mode;
  44.158 -}
  44.159 -
  44.160 -/*****************************************************************************/
  44.161 -/* SDL Video and Display initialization/handling functions                   */
  44.162 -/*****************************************************************************/
  44.163 -int
  44.164 -MX6_VideoInit(_THIS)
  44.165 -{
  44.166 -    SDL_VideoDisplay display;
  44.167 -    SDL_DisplayMode current_mode;
  44.168 -    SDL_DisplayData *data;
  44.169 -    
  44.170 -    data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
  44.171 -    if (data == NULL) {
  44.172 -        return SDL_OutOfMemory();
  44.173 -    }
  44.174 -
  44.175 -    SDL_zero(display);
  44.176 -    SDL_zero(current_mode);
  44.177 -    display.desktop_mode = current_mode;
  44.178 -    display.current_mode = current_mode;
  44.179 -    display.driverdata = data;
  44.180 -    SDL_AddVideoDisplay(&display);
  44.181 -
  44.182 -    if (SDL_GL_LoadLibrary(NULL) < 0) {
  44.183 -        return -1;
  44.184 -    }
  44.185 -    MX6_UpdateDisplay(_this);
  44.186 -
  44.187 -#ifdef SDL_INPUT_LINUXEV    
  44.188 -    SDL_EVDEV_Init();
  44.189 -#endif    
  44.190 -
  44.191 -    return 1;
  44.192 -}
  44.193 -
  44.194 -void
  44.195 -MX6_VideoQuit(_THIS)
  44.196 -{
  44.197 -#ifdef SDL_INPUT_LINUXEV    
  44.198 -    SDL_EVDEV_Quit();
  44.199 -#endif    
  44.200 -}
  44.201 -
  44.202 -void
  44.203 -MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
  44.204 -{
  44.205 -    /* Only one display mode available, the current one */
  44.206 -    SDL_AddDisplayMode(display, &display->current_mode);
  44.207 -}
  44.208 -
  44.209 -int
  44.210 -MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  44.211 -{
  44.212 -    return 0;
  44.213 -}
  44.214 -
  44.215 -int
  44.216 -MX6_CreateWindow(_THIS, SDL_Window * window)
  44.217 -{
  44.218 -    SDL_DisplayData *displaydata;
  44.219 -    SDL_WindowData *wdata;
  44.220 -    
  44.221 -    displaydata = SDL_GetDisplayDriverData(0);
  44.222 -    
  44.223 -    /* Allocate window internal data */
  44.224 -    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
  44.225 -    if (wdata == NULL) {
  44.226 -        return SDL_OutOfMemory();
  44.227 -    }
  44.228 -
  44.229 -    /* Setup driver data for this window */
  44.230 -    window->driverdata = wdata;
  44.231 -    window->flags |= SDL_WINDOW_OPENGL;
  44.232 -    
  44.233 -    if (!_this->egl_data) {
  44.234 -        return -1;
  44.235 -    }
  44.236 -
  44.237 -    wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);    
  44.238 -    if (!wdata->native_window) {
  44.239 -        return SDL_SetError("MX6: Can't create native window");
  44.240 -    }
  44.241 -
  44.242 -    wdata->egl_surface = SDL_EGL_CreateSurface(_this, wdata->native_window);
  44.243 -    if (wdata->egl_surface == EGL_NO_SURFACE) {
  44.244 -        return SDL_SetError("MX6: Can't create EGL surface");
  44.245 -    }
  44.246 -
  44.247 -    /* Window has been successfully created */
  44.248 -    return 0;
  44.249 -}
  44.250 -
  44.251 -void
  44.252 -MX6_DestroyWindow(_THIS, SDL_Window * window)
  44.253 -{
  44.254 -    SDL_WindowData *wdata;
  44.255 -    
  44.256 -    wdata = window->driverdata;
  44.257 -    if (wdata) {
  44.258 -        SDL_EGL_DestroySurface(_this, wdata->egl_surface);
  44.259 -    }
  44.260 -
  44.261 -    if (egl_viv_data) {
  44.262 -        egl_viv_data->fbDestroyWindow(wdata->native_window);
  44.263 -    }
  44.264 -}
  44.265 -
  44.266 -int
  44.267 -MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
  44.268 -{
  44.269 -    return -1;
  44.270 -}
  44.271 -
  44.272 -void
  44.273 -MX6_SetWindowTitle(_THIS, SDL_Window * window)
  44.274 -{
  44.275 -}
  44.276 -void
  44.277 -MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
  44.278 -{
  44.279 -}
  44.280 -void
  44.281 -MX6_SetWindowPosition(_THIS, SDL_Window * window)
  44.282 -{
  44.283 -}
  44.284 -void
  44.285 -MX6_SetWindowSize(_THIS, SDL_Window * window)
  44.286 -{
  44.287 -}
  44.288 -void
  44.289 -MX6_ShowWindow(_THIS, SDL_Window * window)
  44.290 -{
  44.291 -}
  44.292 -void
  44.293 -MX6_HideWindow(_THIS, SDL_Window * window)
  44.294 -{
  44.295 -}
  44.296 -void
  44.297 -MX6_RaiseWindow(_THIS, SDL_Window * window)
  44.298 -{
  44.299 -}
  44.300 -void
  44.301 -MX6_MaximizeWindow(_THIS, SDL_Window * window)
  44.302 -{
  44.303 -}
  44.304 -void
  44.305 -MX6_MinimizeWindow(_THIS, SDL_Window * window)
  44.306 -{
  44.307 -}
  44.308 -void
  44.309 -MX6_RestoreWindow(_THIS, SDL_Window * window)
  44.310 -{
  44.311 -}
  44.312 -void
  44.313 -MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
  44.314 -{
  44.315 -}
  44.316 -
  44.317 -/*****************************************************************************/
  44.318 -/* SDL Window Manager function                                               */
  44.319 -/*****************************************************************************/
  44.320 -SDL_bool
  44.321 -MX6_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
  44.322 -{
  44.323 -    return SDL_TRUE;
  44.324 -}
  44.325 -
  44.326 -#endif /* SDL_VIDEO_DRIVER_MX6 */
  44.327 -
  44.328 -/* vi: set ts=4 sw=4 expandtab: */
    45.1 --- a/src/video/mx6/SDL_mx6video.h	Tue Oct 28 01:34:40 2014 -0300
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,76 +0,0 @@
    45.4 -/*
    45.5 -  Simple DirectMedia Layer
    45.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    45.7 -
    45.8 -  This software is provided 'as-is', without any express or implied
    45.9 -  warranty.  In no event will the authors be held liable for any damages
   45.10 -  arising from the use of this software.
   45.11 -
   45.12 -  Permission is granted to anyone to use this software for any purpose,
   45.13 -  including commercial applications, and to alter it and redistribute it
   45.14 -  freely, subject to the following restrictions:
   45.15 -
   45.16 -  1. The origin of this software must not be misrepresented; you must not
   45.17 -     claim that you wrote the original software. If you use this software
   45.18 -     in a product, an acknowledgment in the product documentation would be
   45.19 -     appreciated but is not required.
   45.20 -  2. Altered source versions must be plainly marked as such, and must not be
   45.21 -     misrepresented as being the original software.
   45.22 -  3. This notice may not be removed or altered from any source distribution.
   45.23 -*/
   45.24 -
   45.25 -#ifndef __SDL_MX6VIDEO_H__
   45.26 -#define __SDL_MX6VIDEO_H__
   45.27 -
   45.28 -#include "../../SDL_internal.h"
   45.29 -#include "../SDL_sysvideo.h"
   45.30 -
   45.31 -#include "SDL_egl.h"
   45.32 -
   45.33 -typedef struct SDL_VideoData
   45.34 -{
   45.35 -} SDL_VideoData;
   45.36 -
   45.37 -typedef struct SDL_DisplayData
   45.38 -{
   45.39 -    EGLNativeDisplayType native_display;
   45.40 -    EGLDisplay egl_display;
   45.41 -} SDL_DisplayData;
   45.42 -
   45.43 -typedef struct SDL_WindowData
   45.44 -{
   45.45 -    EGLNativeWindowType native_window;
   45.46 -    EGLSurface egl_surface;
   45.47 -} SDL_WindowData;
   45.48 -
   45.49 -/****************************************************************************/
   45.50 -/* SDL_VideoDevice functions declaration                                    */
   45.51 -/****************************************************************************/
   45.52 -
   45.53 -/* Display and window functions */
   45.54 -int MX6_VideoInit(_THIS);
   45.55 -void MX6_VideoQuit(_THIS);
   45.56 -void MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   45.57 -int MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   45.58 -int MX6_CreateWindow(_THIS, SDL_Window * window);
   45.59 -int MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
   45.60 -void MX6_SetWindowTitle(_THIS, SDL_Window * window);
   45.61 -void MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
   45.62 -void MX6_SetWindowPosition(_THIS, SDL_Window * window);
   45.63 -void MX6_SetWindowSize(_THIS, SDL_Window * window);
   45.64 -void MX6_ShowWindow(_THIS, SDL_Window * window);
   45.65 -void MX6_HideWindow(_THIS, SDL_Window * window);
   45.66 -void MX6_RaiseWindow(_THIS, SDL_Window * window);
   45.67 -void MX6_MaximizeWindow(_THIS, SDL_Window * window);
   45.68 -void MX6_MinimizeWindow(_THIS, SDL_Window * window);
   45.69 -void MX6_RestoreWindow(_THIS, SDL_Window * window);
   45.70 -void MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
   45.71 -void MX6_DestroyWindow(_THIS, SDL_Window * window);
   45.72 -
   45.73 -/* Window manager function */
   45.74 -SDL_bool MX6_GetWindowWMInfo(_THIS, SDL_Window * window,
   45.75 -                             struct SDL_SysWMinfo *info);
   45.76 -
   45.77 -#endif /* __SDL_MX6VIDEO_H__ */
   45.78 -
   45.79 -/* vi: set ts=4 sw=4 expandtab: */
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/src/video/vivante/SDL_vivanteopengles.c	Tue Oct 28 18:36:29 2014 -0300
    46.3 @@ -0,0 +1,47 @@
    46.4 +/*
    46.5 +  Simple DirectMedia Layer
    46.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    46.7 +
    46.8 +  This software is provided 'as-is', without any express or implied
    46.9 +  warranty.  In no event will the authors be held liable for any damages
   46.10 +  arising from the use of this software.
   46.11 +
   46.12 +  Permission is granted to anyone to use this software for any purpose,
   46.13 +  including commercial applications, and to alter it and redistribute it
   46.14 +  freely, subject to the following restrictions:
   46.15 +
   46.16 +  1. The origin of this software must not be misrepresented; you must not
   46.17 +     claim that you wrote the original software. If you use this software
   46.18 +     in a product, an acknowledgment in the product documentation would be
   46.19 +     appreciated but is not required.
   46.20 +  2. Altered source versions must be plainly marked as such, and must not be
   46.21 +     misrepresented as being the original software.
   46.22 +  3. This notice may not be removed or altered from any source distribution.
   46.23 +*/
   46.24 +#include "../../SDL_internal.h"
   46.25 +
   46.26 +#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
   46.27 +
   46.28 +#include "SDL_vivanteopengles.h"
   46.29 +#include "SDL_vivantevideo.h"
   46.30 +
   46.31 +/* EGL implementation of SDL OpenGL support */
   46.32 +
   46.33 +int
   46.34 +VIVANTE_GLES_LoadLibrary(_THIS, const char *path)
   46.35 +{
   46.36 +    SDL_DisplayData *displaydata;
   46.37 +
   46.38 +    displaydata = SDL_GetDisplayDriverData(0);
   46.39 +
   46.40 +    return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display);
   46.41 +}
   46.42 +
   46.43 +SDL_EGL_CreateContext_impl(VIVANTE)
   46.44 +SDL_EGL_SwapWindow_impl(VIVANTE)
   46.45 +SDL_EGL_MakeCurrent_impl(VIVANTE)
   46.46 +
   46.47 +#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
   46.48 +
   46.49 +/* vi: set ts=4 sw=4 expandtab: */
   46.50 +
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/src/video/vivante/SDL_vivanteopengles.h	Tue Oct 28 18:36:29 2014 -0300
    47.3 @@ -0,0 +1,48 @@
    47.4 +/*
    47.5 +  Simple DirectMedia Layer
    47.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    47.7 +
    47.8 +  This software is provided 'as-is', without any express or implied
    47.9 +  warranty.  In no event will the authors be held liable for any damages
   47.10 +  arising from the use of this software.
   47.11 +
   47.12 +  Permission is granted to anyone to use this software for any purpose,
   47.13 +  including commercial applications, and to alter it and redistribute it
   47.14 +  freely, subject to the following restrictions:
   47.15 +
   47.16 +  1. The origin of this software must not be misrepresented; you must not
   47.17 +     claim that you wrote the original software. If you use this software
   47.18 +     in a product, an acknowledgment in the product documentation would be
   47.19 +     appreciated but is not required.
   47.20 +  2. Altered source versions must be plainly marked as such, and must not be
   47.21 +     misrepresented as being the original software.
   47.22 +  3. This notice may not be removed or altered from any source distribution.
   47.23 +*/
   47.24 +#include "../../SDL_internal.h"
   47.25 +
   47.26 +#ifndef _SDL_vivanteopengles_h
   47.27 +#define _SDL_vivanteopengles_h
   47.28 +
   47.29 +#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
   47.30 +
   47.31 +#include "../SDL_sysvideo.h"
   47.32 +#include "../SDL_egl_c.h"
   47.33 +
   47.34 +/* OpenGLES functions */
   47.35 +#define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute
   47.36 +#define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddress
   47.37 +#define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
   47.38 +#define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
   47.39 +#define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
   47.40 +#define VIVANTE_GLES_DeleteContext SDL_EGL_DeleteContext
   47.41 +
   47.42 +extern int VIVANTE_GLES_LoadLibrary(_THIS, const char *path);
   47.43 +extern SDL_GLContext VIVANTE_GLES_CreateContext(_THIS, SDL_Window * window);
   47.44 +extern void VIVANTE_GLES_SwapWindow(_THIS, SDL_Window * window);
   47.45 +extern int VIVANTE_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
   47.46 +
   47.47 +#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
   47.48 +
   47.49 +#endif /* _SDL_vivanteopengles_h */
   47.50 +
   47.51 +/* vi: set ts=4 sw=4 expandtab: */
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/src/video/vivante/SDL_vivanteplatform.c	Tue Oct 28 18:36:29 2014 -0300
    48.3 @@ -0,0 +1,44 @@
    48.4 +/*
    48.5 +  Simple DirectMedia Layer
    48.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    48.7 +
    48.8 +  This software is provided 'as-is', without any express or implied
    48.9 +  warranty.  In no event will the authors be held liable for any damages
   48.10 +  arising from the use of this software.
   48.11 +
   48.12 +  Permission is granted to anyone to use this software for any purpose,
   48.13 +  including commercial applications, and to alter it and redistribute it
   48.14 +  freely, subject to the following restrictions:
   48.15 +
   48.16 +  1. The origin of this software must not be misrepresented; you must not
   48.17 +     claim that you wrote the original software. If you use this software
   48.18 +     in a product, an acknowledgment in the product documentation would be
   48.19 +     appreciated but is not required.
   48.20 +  2. Altered source versions must be plainly marked as such, and must not be
   48.21 +     misrepresented as being the original software.
   48.22 +  3. This notice may not be removed or altered from any source distribution.
   48.23 +*/
   48.24 +#include "../../SDL_internal.h"
   48.25 +
   48.26 +#if SDL_VIDEO_DRIVER_VIVANTE
   48.27 +
   48.28 +#include "SDL_vivanteplatform.h"
   48.29 +
   48.30 +#ifdef VIVANTE_PLATFORM_GENERIC
   48.31 +
   48.32 +int
   48.33 +VIVANTE_SetupPlatform(_THIS)
   48.34 +{
   48.35 +    return 0;
   48.36 +}
   48.37 +
   48.38 +void
   48.39 +VIVANTE_CleanupPlatform(_THIS)
   48.40 +{
   48.41 +}
   48.42 +
   48.43 +#endif /* VIVANTE_PLATFORM_GENERIC */
   48.44 +
   48.45 +#endif /* SDL_VIDEO_DRIVER_VIVANTE */
   48.46 +
   48.47 +/* vi: set ts=4 sw=4 expandtab: */
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/src/video/vivante/SDL_vivanteplatform.h	Tue Oct 28 18:36:29 2014 -0300
    49.3 @@ -0,0 +1,45 @@
    49.4 +/*
    49.5 +  Simple DirectMedia Layer
    49.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    49.7 +
    49.8 +  This software is provided 'as-is', without any express or implied
    49.9 +  warranty.  In no event will the authors be held liable for any damages
   49.10 +  arising from the use of this software.
   49.11 +
   49.12 +  Permission is granted to anyone to use this software for any purpose,
   49.13 +  including commercial applications, and to alter it and redistribute it
   49.14 +  freely, subject to the following restrictions:
   49.15 +
   49.16 +  1. The origin of this software must not be misrepresented; you must not
   49.17 +     claim that you wrote the original software. If you use this software
   49.18 +     in a product, an acknowledgment in the product documentation would be
   49.19 +     appreciated but is not required.
   49.20 +  2. Altered source versions must be plainly marked as such, and must not be
   49.21 +     misrepresented as being the original software.
   49.22 +  3. This notice may not be removed or altered from any source distribution.
   49.23 +*/
   49.24 +#include "../../SDL_internal.h"
   49.25 +
   49.26 +#ifndef _SDL_vivanteplatform_h
   49.27 +#define _SDL_vivanteplatform_h
   49.28 +
   49.29 +#if SDL_VIDEO_DRIVER_VIVANTE
   49.30 +
   49.31 +#include "SDL_vivantevideo.h"
   49.32 +
   49.33 +#if defined(CAVIUM)
   49.34 +#define VIVANTE_PLATFORM_CAVIUM
   49.35 +#elif defined(MARVELL)
   49.36 +#define VIVANTE_PLATFORM_MARVELL
   49.37 +#else
   49.38 +#define VIVANTE_PLATFORM_GENERIC
   49.39 +#endif
   49.40 +
   49.41 +extern int VIVANTE_SetupPlatform(_THIS);
   49.42 +extern void VIVANTE_CleanupPlatform(_THIS);
   49.43 +
   49.44 +#endif /* SDL_VIDEO_DRIVER_VIVANTE */
   49.45 +
   49.46 +#endif /* _SDL_vivanteplatform_h */
   49.47 +
   49.48 +/* vi: set ts=4 sw=4 expandtab: */
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/src/video/vivante/SDL_vivantevideo.c	Tue Oct 28 18:36:29 2014 -0300
    50.3 @@ -0,0 +1,399 @@
    50.4 +/*
    50.5 +  Simple DirectMedia Layer
    50.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    50.7 +
    50.8 +  This software is provided 'as-is', without any express or implied
    50.9 +  warranty.  In no event will the authors be held liable for any damages
   50.10 +  arising from the use of this software.
   50.11 +
   50.12 +  Permission is granted to anyone to use this software for any purpose,
   50.13 +  including commercial applications, and to alter it and redistribute it
   50.14 +  freely, subject to the following restrictions:
   50.15 +
   50.16 +  1. The origin of this software must not be misrepresented; you must not
   50.17 +     claim that you wrote the original software. If you use this software
   50.18 +     in a product, an acknowledgment in the product documentation would be
   50.19 +     appreciated but is not required.
   50.20 +  2. Altered source versions must be plainly marked as such, and must not be
   50.21 +     misrepresented as being the original software.
   50.22 +  3. This notice may not be removed or altered from any source distribution.
   50.23 +*/
   50.24 +#include "../../SDL_internal.h"
   50.25 +
   50.26 +#if SDL_VIDEO_DRIVER_VIVANTE
   50.27 +
   50.28 +/* SDL internals */
   50.29 +#include "../SDL_sysvideo.h"
   50.30 +#include "SDL_version.h"
   50.31 +#include "SDL_syswm.h"
   50.32 +#include "SDL_loadso.h"
   50.33 +#include "SDL_events.h"
   50.34 +#include "../../events/SDL_events_c.h"
   50.35 +
   50.36 +#ifdef SDL_INPUT_LINUXEV
   50.37 +#include "../../core/linux/SDL_evdev.h"
   50.38 +#endif
   50.39 +
   50.40 +#include "SDL_vivantevideo.h"
   50.41 +#include "SDL_vivanteplatform.h"
   50.42 +#include "SDL_vivanteopengles.h"
   50.43 +
   50.44 +
   50.45 +static int
   50.46 +VIVANTE_Available(void)
   50.47 +{
   50.48 +    return 1;
   50.49 +}
   50.50 +
   50.51 +static void
   50.52 +VIVANTE_Destroy(SDL_VideoDevice * device)
   50.53 +{
   50.54 +    if (device->driverdata != NULL) {
   50.55 +        SDL_free(device->driverdata);
   50.56 +        device->driverdata = NULL;
   50.57 +    }
   50.58 +}
   50.59 +
   50.60 +static SDL_VideoDevice *
   50.61 +VIVANTE_Create()
   50.62 +{
   50.63 +    SDL_VideoDevice *device;
   50.64 +    SDL_VideoData *data;
   50.65 +
   50.66 +    /* Initialize SDL_VideoDevice structure */
   50.67 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   50.68 +    if (device == NULL) {
   50.69 +        SDL_OutOfMemory();
   50.70 +        return NULL;
   50.71 +    }
   50.72 +
   50.73 +    /* Initialize internal data */
   50.74 +    data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   50.75 +    if (data == NULL) {
   50.76 +        SDL_OutOfMemory();
   50.77 +        SDL_free(device);
   50.78 +        return NULL;
   50.79 +    }
   50.80 +
   50.81 +    device->driverdata = data;
   50.82 +
   50.83 +    /* Setup amount of available displays and current display */
   50.84 +    device->num_displays = 0;
   50.85 +
   50.86 +    /* Set device free function */
   50.87 +    device->free = VIVANTE_Destroy;
   50.88 +
   50.89 +    /* Setup all functions which we can handle */
   50.90 +    device->VideoInit = VIVANTE_VideoInit;
   50.91 +    device->VideoQuit = VIVANTE_VideoQuit;
   50.92 +    device->GetDisplayModes = VIVANTE_GetDisplayModes;
   50.93 +    device->SetDisplayMode = VIVANTE_SetDisplayMode;
   50.94 +    device->CreateWindow = VIVANTE_CreateWindow;
   50.95 +    device->SetWindowTitle = VIVANTE_SetWindowTitle;
   50.96 +    device->SetWindowPosition = VIVANTE_SetWindowPosition;
   50.97 +    device->SetWindowSize = VIVANTE_SetWindowSize;
   50.98 +    device->ShowWindow = VIVANTE_ShowWindow;
   50.99 +    device->HideWindow = VIVANTE_HideWindow;
  50.100 +    device->DestroyWindow = VIVANTE_DestroyWindow;
  50.101 +    device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo;
  50.102 +
  50.103 +    device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary;
  50.104 +    device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress;
  50.105 +    device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary;
  50.106 +    device->GL_CreateContext = VIVANTE_GLES_CreateContext;
  50.107 +    device->GL_MakeCurrent = VIVANTE_GLES_MakeCurrent;
  50.108 +    device->GL_SetSwapInterval = VIVANTE_GLES_SetSwapInterval;
  50.109 +    device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval;
  50.110 +    device->GL_SwapWindow = VIVANTE_GLES_SwapWindow;
  50.111 +    device->GL_DeleteContext = VIVANTE_GLES_DeleteContext;
  50.112 +
  50.113 +    device->PumpEvents = VIVANTE_PumpEvents;
  50.114 +
  50.115 +    return device;
  50.116 +}
  50.117 +
  50.118 +VideoBootStrap VIVANTE_bootstrap = {
  50.119 +    "vivante",
  50.120 +    "Vivante EGL Video Driver",
  50.121 +    VIVANTE_Available,
  50.122 +    VIVANTE_Create
  50.123 +};
  50.124 +
  50.125 +/*****************************************************************************/
  50.126 +/* SDL Video and Display initialization/handling functions                   */
  50.127 +/*****************************************************************************/
  50.128 +
  50.129 +static int
  50.130 +VIVANTE_AddVideoDisplays(_THIS)
  50.131 +{
  50.132 +    SDL_VideoData *videodata = _this->driverdata;
  50.133 +    SDL_VideoDisplay display;
  50.134 +    SDL_DisplayMode current_mode;
  50.135 +    SDL_DisplayData *data;
  50.136 +    int pitch = 0, bpp = 0;
  50.137 +    unsigned long pixels = 0;
  50.138 +
  50.139 +    data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
  50.140 +    if (data == NULL) {
  50.141 +        return SDL_OutOfMemory();
  50.142 +    }
  50.143 +
  50.144 +    SDL_zero(current_mode);
  50.145 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.146 +    data->native_display = vdkGetDisplay(videodata->vdk_private);
  50.147 +
  50.148 +    vdkGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
  50.149 +#else
  50.150 +    data->native_display = videodata->fbGetDisplayByIndex(0);
  50.151 +
  50.152 +    videodata->fbGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
  50.153 +#endif /* SDL_VIDEO_DRIVER_VIVANTE_VDK */
  50.154 +
  50.155 +    switch (bpp)
  50.156 +    {
  50.157 +    default: /* Is another format used? */
  50.158 +    case 16:
  50.159 +        current_mode.format = SDL_PIXELFORMAT_RGB565;
  50.160 +        break;
  50.161 +    }
  50.162 +    /* FIXME: How do we query refresh rate? */
  50.163 +    current_mode.refresh_rate = 60;
  50.164 +
  50.165 +    SDL_zero(display);
  50.166 +    display.desktop_mode = current_mode;
  50.167 +    display.current_mode = current_mode;
  50.168 +    display.driverdata = data;
  50.169 +    SDL_AddVideoDisplay(&display);
  50.170 +    return 0;
  50.171 +}
  50.172 +
  50.173 +int
  50.174 +VIVANTE_VideoInit(_THIS)
  50.175 +{
  50.176 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  50.177 +
  50.178 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.179 +    videodata->vdk_private = vdkInitialize();
  50.180 +    if (!videodata->vdk_private) {
  50.181 +        return SDL_SetError("vdkInitialize() failed");
  50.182 +    }
  50.183 +#else
  50.184 +    videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
  50.185 +    if (!videodata->egl_handle) {
  50.186 +        videodata->egl_handle = SDL_LoadObject("libEGL.so");
  50.187 +        if (!videodata->egl_handle) {
  50.188 +            return -1;
  50.189 +        }
  50.190 +    }
  50.191 +#define LOAD_FUNC(NAME) \
  50.192 +    videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \
  50.193 +    if (!videodata->NAME) return -1;
  50.194 +
  50.195 +    LOAD_FUNC(fbGetDisplay);
  50.196 +    LOAD_FUNC(fbGetDisplayByIndex);
  50.197 +    LOAD_FUNC(fbGetDisplayGeometry);
  50.198 +    LOAD_FUNC(fbGetDisplayInfo);
  50.199 +    LOAD_FUNC(fbDestroyDisplay);
  50.200 +    LOAD_FUNC(fbCreateWindow);
  50.201 +    LOAD_FUNC(fbGetWindowGeometry);
  50.202 +    LOAD_FUNC(fbGetWindowInfo);
  50.203 +    LOAD_FUNC(fbDestroyWindow);
  50.204 +#endif
  50.205 +
  50.206 +    if (VIVANTE_SetupPlatform(_this) < 0) {
  50.207 +        return -1;
  50.208 +    }
  50.209 +
  50.210 +    if (VIVANTE_AddVideoDisplays(_this) < 0) {
  50.211 +        return -1;
  50.212 +    }
  50.213 +
  50.214 +#ifdef SDL_INPUT_LINUXEV
  50.215 +    if (SDL_EVDEV_Init() < 0) {
  50.216 +        return -1;
  50.217 +    }
  50.218 +#endif
  50.219 +
  50.220 +    return 0;
  50.221 +}
  50.222 +
  50.223 +void
  50.224 +VIVANTE_VideoQuit(_THIS)
  50.225 +{
  50.226 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  50.227 +
  50.228 +#ifdef SDL_INPUT_LINUXEV
  50.229 +    SDL_EVDEV_Quit();
  50.230 +#endif
  50.231 +
  50.232 +    VIVANTE_CleanupPlatform(_this);
  50.233 +
  50.234 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.235 +    if (videodata->vdk_private) {
  50.236 +        vdkExit(videodata->vdk_private);
  50.237 +        videodata->vdk_private = NULL;
  50.238 +    }
  50.239 +#else
  50.240 +    if (videodata->egl_handle) {
  50.241 +        SDL_UnloadObject(videodata->egl_handle);
  50.242 +        videodata->egl_handle = NULL;
  50.243 +    }
  50.244 +#endif
  50.245 +}
  50.246 +
  50.247 +void
  50.248 +VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
  50.249 +{
  50.250 +    /* Only one display mode available, the current one */
  50.251 +    SDL_AddDisplayMode(display, &display->current_mode);
  50.252 +}
  50.253 +
  50.254 +int
  50.255 +VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  50.256 +{
  50.257 +    return 0;
  50.258 +}
  50.259 +
  50.260 +int
  50.261 +VIVANTE_CreateWindow(_THIS, SDL_Window * window)
  50.262 +{
  50.263 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  50.264 +    SDL_DisplayData *displaydata;
  50.265 +    SDL_WindowData *data;
  50.266 +
  50.267 +    displaydata = SDL_GetDisplayDriverData(0);
  50.268 +
  50.269 +    /* Allocate window internal data */
  50.270 +    data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
  50.271 +    if (data == NULL) {
  50.272 +        return SDL_OutOfMemory();
  50.273 +    }
  50.274 +
  50.275 +    /* Setup driver data for this window */
  50.276 +    window->driverdata = data;
  50.277 +
  50.278 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.279 +    data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
  50.280 +#else
  50.281 +    data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
  50.282 +#endif
  50.283 +    if (!data->native_window) {
  50.284 +        return SDL_SetError("VIVANTE: Can't create native window");
  50.285 +    }
  50.286 +
  50.287 +    if (window->flags & SDL_WINDOW_OPENGL) {
  50.288 +        data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
  50.289 +        if (data->egl_surface == EGL_NO_SURFACE) {
  50.290 +            return SDL_SetError("VIVANTE: Can't create EGL surface");
  50.291 +        }
  50.292 +    } else {
  50.293 +        data->egl_surface = EGL_NO_SURFACE;
  50.294 +    }
  50.295 +
  50.296 +    /* Window has been successfully created */
  50.297 +    return 0;
  50.298 +}
  50.299 +
  50.300 +void
  50.301 +VIVANTE_DestroyWindow(_THIS, SDL_Window * window)
  50.302 +{
  50.303 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  50.304 +    SDL_WindowData *data;
  50.305 +
  50.306 +    data = window->driverdata;
  50.307 +    if (data) {
  50.308 +        if (data->egl_surface != EGL_NO_SURFACE) {
  50.309 +            SDL_EGL_DestroySurface(_this, data->egl_surface);
  50.310 +        }
  50.311 +
  50.312 +        if (data->native_window) {
  50.313 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.314 +            vdkDestroyWindow(data->native_window);
  50.315 +#else
  50.316 +            videodata->fbDestroyWindow(data->native_window);
  50.317 +#endif
  50.318 +        }
  50.319 +
  50.320 +        SDL_free(data);
  50.321 +    }
  50.322 +    window->driverdata = NULL;
  50.323 +}
  50.324 +
  50.325 +void
  50.326 +VIVANTE_SetWindowTitle(_THIS, SDL_Window * window)
  50.327 +{
  50.328 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.329 +    SDL_WindowData *data = window->driverdata;
  50.330 +    vdkSetWindowTitle(data->native_window, window->title);
  50.331 +#endif
  50.332 +}
  50.333 +
  50.334 +void
  50.335 +VIVANTE_SetWindowPosition(_THIS, SDL_Window * window)
  50.336 +{
  50.337 +    /* FIXME */
  50.338 +}
  50.339 +
  50.340 +void
  50.341 +VIVANTE_SetWindowSize(_THIS, SDL_Window * window)
  50.342 +{
  50.343 +    /* FIXME */
  50.344 +}
  50.345 +
  50.346 +void
  50.347 +VIVANTE_ShowWindow(_THIS, SDL_Window * window)
  50.348 +{
  50.349 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.350 +    SDL_WindowData *data = window->driverdata;
  50.351 +    vdkShowWindow(data->native_window);
  50.352 +#endif
  50.353 +    SDL_SetMouseFocus(window);
  50.354 +    SDL_SetKeyboardFocus(window);
  50.355 +}
  50.356 +
  50.357 +void
  50.358 +VIVANTE_HideWindow(_THIS, SDL_Window * window)
  50.359 +{
  50.360 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  50.361 +    SDL_WindowData *data = window->driverdata;
  50.362 +    vdkHideWindow(data->native_window);
  50.363 +#endif
  50.364 +}
  50.365 +
  50.366 +/*****************************************************************************/
  50.367 +/* SDL Window Manager function                                               */
  50.368 +/*****************************************************************************/
  50.369 +SDL_bool
  50.370 +VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
  50.371 +{
  50.372 +/*
  50.373 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  50.374 +
  50.375 +    if (info->version.major == SDL_MAJOR_VERSION &&
  50.376 +        info->version.minor == SDL_MINOR_VERSION) {
  50.377 +        info->subsystem = SDL_SYSWM_VIVANTE;
  50.378 +        info->info.vivante.window = data->native_window;
  50.379 +        return SDL_TRUE;
  50.380 +    } else {
  50.381 +        SDL_SetError("Application not compiled with SDL %d.%d\n",
  50.382 +                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
  50.383 +        return SDL_FALSE;
  50.384 +    }
  50.385 +*/
  50.386 +    SDL_Unsupported();
  50.387 +    return SDL_FALSE;
  50.388 +}
  50.389 +
  50.390 +/*****************************************************************************/
  50.391 +/* SDL event functions                                                       */
  50.392 +/*****************************************************************************/
  50.393 +void VIVANTE_PumpEvents(_THIS)
  50.394 +{
  50.395 +#ifdef SDL_INPUT_LINUXEV
  50.396 +    SDL_EVDEV_Poll();
  50.397 +#endif
  50.398 +}
  50.399 +
  50.400 +#endif /* SDL_VIDEO_DRIVER_VIVANTE */
  50.401 +
  50.402 +/* vi: set ts=4 sw=4 expandtab: */
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/src/video/vivante/SDL_vivantevideo.h	Tue Oct 28 18:36:29 2014 -0300
    51.3 @@ -0,0 +1,91 @@
    51.4 +/*
    51.5 +  Simple DirectMedia Layer
    51.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    51.7 +
    51.8 +  This software is provided 'as-is', without any express or implied
    51.9 +  warranty.  In no event will the authors be held liable for any damages
   51.10 +  arising from the use of this software.
   51.11 +
   51.12 +  Permission is granted to anyone to use this software for any purpose,
   51.13 +  including commercial applications, and to alter it and redistribute it
   51.14 +  freely, subject to the following restrictions:
   51.15 +
   51.16 +  1. The origin of this software must not be misrepresented; you must not
   51.17 +     claim that you wrote the original software. If you use this software
   51.18 +     in a product, an acknowledgment in the product documentation would be
   51.19 +     appreciated but is not required.
   51.20 +  2. Altered source versions must be plainly marked as such, and must not be
   51.21 +     misrepresented as being the original software.
   51.22 +  3. This notice may not be removed or altered from any source distribution.
   51.23 +*/
   51.24 +
   51.25 +#ifndef _SDL_vivantevideo_h
   51.26 +#define _SDL_vivantevideo_h
   51.27 +
   51.28 +#include "../../SDL_internal.h"
   51.29 +#include "../SDL_sysvideo.h"
   51.30 +
   51.31 +#include "SDL_egl.h"
   51.32 +
   51.33 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
   51.34 +#include <gc_vdk.h>
   51.35 +#else
   51.36 +#include <EGL/egl.h>
   51.37 +#endif
   51.38 +
   51.39 +typedef struct SDL_VideoData
   51.40 +{
   51.41 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
   51.42 +    vdkPrivate vdk_private;
   51.43 +#else
   51.44 +    void *egl_handle; /* EGL shared library handle */
   51.45 +    EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplay)(void *context);
   51.46 +    EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex);
   51.47 +    void (EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height);
   51.48 +    void (EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
   51.49 +    void (EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display);
   51.50 +    EGLNativeWindowType (EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
   51.51 +    void (EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
   51.52 +    void (EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
   51.53 +    void (EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window);
   51.54 +#endif
   51.55 +} SDL_VideoData;
   51.56 +
   51.57 +typedef struct SDL_DisplayData
   51.58 +{
   51.59 +    EGLNativeDisplayType native_display;
   51.60 +} SDL_DisplayData;
   51.61 +
   51.62 +typedef struct SDL_WindowData
   51.63 +{
   51.64 +    EGLNativeWindowType native_window;
   51.65 +    EGLSurface egl_surface;
   51.66 +} SDL_WindowData;
   51.67 +
   51.68 +/****************************************************************************/
   51.69 +/* SDL_VideoDevice functions declaration                                    */
   51.70 +/****************************************************************************/
   51.71 +
   51.72 +/* Display and window functions */
   51.73 +int VIVANTE_VideoInit(_THIS);
   51.74 +void VIVANTE_VideoQuit(_THIS);
   51.75 +void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   51.76 +int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   51.77 +int VIVANTE_CreateWindow(_THIS, SDL_Window * window);
   51.78 +void VIVANTE_SetWindowTitle(_THIS, SDL_Window * window);
   51.79 +void VIVANTE_SetWindowPosition(_THIS, SDL_Window * window);
   51.80 +void VIVANTE_SetWindowSize(_THIS, SDL_Window * window);
   51.81 +void VIVANTE_ShowWindow(_THIS, SDL_Window * window);
   51.82 +void VIVANTE_HideWindow(_THIS, SDL_Window * window);
   51.83 +void VIVANTE_DestroyWindow(_THIS, SDL_Window * window);
   51.84 +
   51.85 +/* Window manager function */
   51.86 +SDL_bool VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window,
   51.87 +                             struct SDL_SysWMinfo *info);
   51.88 +
   51.89 +/* Event functions */
   51.90 +void VIVANTE_PumpEvents(_THIS);
   51.91 +
   51.92 +#endif /* _SDL_vivantevideo_h */
   51.93 +
   51.94 +/* vi: set ts=4 sw=4 expandtab: */
    52.1 --- a/src/video/wayland/SDL_waylandmouse.c	Tue Oct 28 01:34:40 2014 -0300
    52.2 +++ b/src/video/wayland/SDL_waylandmouse.c	Tue Oct 28 18:36:29 2014 -0300
    52.3 @@ -126,7 +126,7 @@
    52.4                         MAP_SHARED,
    52.5                         shm_fd,
    52.6                         0);
    52.7 -    if (data == MAP_FAILED) {
    52.8 +    if (d->shm_data == MAP_FAILED) {
    52.9          d->shm_data = NULL;
   52.10          fprintf (stderr, "mmap () failed\n");
   52.11          close (shm_fd);
    53.1 --- a/src/video/winrt/SDL_winrtkeyboard.cpp	Tue Oct 28 01:34:40 2014 -0300
    53.2 +++ b/src/video/winrt/SDL_winrtkeyboard.cpp	Tue Oct 28 18:36:29 2014 -0300
    53.3 @@ -22,10 +22,6 @@
    53.4  
    53.5  #if SDL_VIDEO_DRIVER_WINRT
    53.6  
    53.7 -/* Standard C++11 includes */
    53.8 -#include <unordered_map>
    53.9 -
   53.10 -
   53.11  /* Windows-specific includes */
   53.12  #include <Windows.h>
   53.13  #include <agile.h>
   53.14 @@ -42,248 +38,290 @@
   53.15  
   53.16  
   53.17  static SDL_Scancode WinRT_Official_Keycodes[] = {
   53.18 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
   53.19 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
   53.20 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
   53.21 -    SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
   53.22 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
   53.23 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
   53.24 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
   53.25 -    SDL_SCANCODE_UNKNOWN, // -- 7
   53.26 -    SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
   53.27 -    SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
   53.28 -    SDL_SCANCODE_UNKNOWN, // -- 10
   53.29 -    SDL_SCANCODE_UNKNOWN, // -- 11
   53.30 -    SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
   53.31 -    SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
   53.32 -    SDL_SCANCODE_UNKNOWN, // -- 14
   53.33 -    SDL_SCANCODE_UNKNOWN, // -- 15
   53.34 -    SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
   53.35 -    SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
   53.36 -    SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
   53.37 -    SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
   53.38 -    SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
   53.39 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
   53.40 -    SDL_SCANCODE_UNKNOWN, // -- 22
   53.41 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
   53.42 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
   53.43 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
   53.44 -    SDL_SCANCODE_UNKNOWN, // -- 26
   53.45 -    SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
   53.46 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
   53.47 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
   53.48 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
   53.49 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31  (maybe SDL_SCANCODE_MODE ?)
   53.50 -    SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
   53.51 -    SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
   53.52 -    SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
   53.53 -    SDL_SCANCODE_END, // VirtualKey.End -- 35
   53.54 -    SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
   53.55 -    SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
   53.56 -    SDL_SCANCODE_UP, // VirtualKey.Up -- 38
   53.57 -    SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
   53.58 -    SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
   53.59 -    SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
   53.60 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42  (maybe SDL_SCANCODE_PRINTSCREEN ?)
   53.61 -    SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
   53.62 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
   53.63 -    SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
   53.64 -    SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
   53.65 -    SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
   53.66 -    SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
   53.67 -    SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
   53.68 -    SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
   53.69 -    SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
   53.70 -    SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
   53.71 -    SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
   53.72 -    SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
   53.73 -    SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
   53.74 -    SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
   53.75 -    SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
   53.76 -    SDL_SCANCODE_UNKNOWN, // -- 58
   53.77 -    SDL_SCANCODE_UNKNOWN, // -- 59
   53.78 -    SDL_SCANCODE_UNKNOWN, // -- 60
   53.79 -    SDL_SCANCODE_UNKNOWN, // -- 61
   53.80 -    SDL_SCANCODE_UNKNOWN, // -- 62
   53.81 -    SDL_SCANCODE_UNKNOWN, // -- 63
   53.82 -    SDL_SCANCODE_UNKNOWN, // -- 64
   53.83 -    SDL_SCANCODE_A, // VirtualKey.A -- 65
   53.84 -    SDL_SCANCODE_B, // VirtualKey.B -- 66
   53.85 -    SDL_SCANCODE_C, // VirtualKey.C -- 67
   53.86 -    SDL_SCANCODE_D, // VirtualKey.D -- 68
   53.87 -    SDL_SCANCODE_E, // VirtualKey.E -- 69
   53.88 -    SDL_SCANCODE_F, // VirtualKey.F -- 70
   53.89 -    SDL_SCANCODE_G, // VirtualKey.G -- 71
   53.90 -    SDL_SCANCODE_H, // VirtualKey.H -- 72
   53.91 -    SDL_SCANCODE_I, // VirtualKey.I -- 73
   53.92 -    SDL_SCANCODE_J, // VirtualKey.J -- 74
   53.93 -    SDL_SCANCODE_K, // VirtualKey.K -- 75
   53.94 -    SDL_SCANCODE_L, // VirtualKey.L -- 76
   53.95 -    SDL_SCANCODE_M, // VirtualKey.M -- 77
   53.96 -    SDL_SCANCODE_N, // VirtualKey.N -- 78
   53.97 -    SDL_SCANCODE_O, // VirtualKey.O -- 79
   53.98 -    SDL_SCANCODE_P, // VirtualKey.P -- 80
   53.99 -    SDL_SCANCODE_Q, // VirtualKey.Q -- 81
  53.100 -    SDL_SCANCODE_R, // VirtualKey.R -- 82
  53.101 -    SDL_SCANCODE_S, // VirtualKey.S -- 83
  53.102 -    SDL_SCANCODE_T, // VirtualKey.T -- 84
  53.103 -    SDL_SCANCODE_U, // VirtualKey.U -- 85
  53.104 -    SDL_SCANCODE_V, // VirtualKey.V -- 86
  53.105 -    SDL_SCANCODE_W, // VirtualKey.W -- 87
  53.106 -    SDL_SCANCODE_X, // VirtualKey.X -- 88
  53.107 -    SDL_SCANCODE_Y, // VirtualKey.Y -- 89
  53.108 -    SDL_SCANCODE_Z, // VirtualKey.Z -- 90
  53.109 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
  53.110 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
  53.111 -    SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
  53.112 -    SDL_SCANCODE_UNKNOWN, // -- 94
  53.113 -    SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
  53.114 -    SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
  53.115 -    SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
  53.116 -    SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
  53.117 -    SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
  53.118 -    SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
  53.119 -    SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
  53.120 -    SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
  53.121 -    SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
  53.122 -    SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
  53.123 -    SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
  53.124 -    SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
  53.125 -    SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
  53.126 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
  53.127 -    SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
  53.128 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110  (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
  53.129 -    SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
  53.130 -    SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
  53.131 -    SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
  53.132 -    SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
  53.133 -    SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
  53.134 -    SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
  53.135 -    SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
  53.136 -    SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
  53.137 -    SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
  53.138 -    SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
  53.139 -    SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
  53.140 -    SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
  53.141 -    SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
  53.142 -    SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
  53.143 -    SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
  53.144 -    SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
  53.145 -    SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
  53.146 -    SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
  53.147 -    SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
  53.148 -    SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
  53.149 -    SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
  53.150 -    SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
  53.151 -    SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
  53.152 -    SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
  53.153 -    SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
  53.154 -    SDL_SCANCODE_UNKNOWN, // -- 136
  53.155 -    SDL_SCANCODE_UNKNOWN, // -- 137
  53.156 -    SDL_SCANCODE_UNKNOWN, // -- 138
  53.157 -    SDL_SCANCODE_UNKNOWN, // -- 139
  53.158 -    SDL_SCANCODE_UNKNOWN, // -- 140
  53.159 -    SDL_SCANCODE_UNKNOWN, // -- 141
  53.160 -    SDL_SCANCODE_UNKNOWN, // -- 142
  53.161 -    SDL_SCANCODE_UNKNOWN, // -- 143
  53.162 -    SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
  53.163 -    SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
  53.164 -    SDL_SCANCODE_UNKNOWN, // -- 146
  53.165 -    SDL_SCANCODE_UNKNOWN, // -- 147
  53.166 -    SDL_SCANCODE_UNKNOWN, // -- 148
  53.167 -    SDL_SCANCODE_UNKNOWN, // -- 149
  53.168 -    SDL_SCANCODE_UNKNOWN, // -- 150
  53.169 -    SDL_SCANCODE_UNKNOWN, // -- 151
  53.170 -    SDL_SCANCODE_UNKNOWN, // -- 152
  53.171 -    SDL_SCANCODE_UNKNOWN, // -- 153
  53.172 -    SDL_SCANCODE_UNKNOWN, // -- 154
  53.173 -    SDL_SCANCODE_UNKNOWN, // -- 155
  53.174 -    SDL_SCANCODE_UNKNOWN, // -- 156
  53.175 -    SDL_SCANCODE_UNKNOWN, // -- 157
  53.176 -    SDL_SCANCODE_UNKNOWN, // -- 158
  53.177 -    SDL_SCANCODE_UNKNOWN, // -- 159
  53.178 -    SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
  53.179 -    SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
  53.180 -    SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
  53.181 -    SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
  53.182 -    SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
  53.183 -    SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
  53.184 -    SDL_SCANCODE_AC_BACK, // VirtualKey.GoBack -- 166 : The go back key.
  53.185 -    SDL_SCANCODE_AC_FORWARD, // VirtualKey.GoForward -- 167 : The go forward key.
  53.186 -    SDL_SCANCODE_AC_REFRESH, // VirtualKey.Refresh -- 168 : The refresh key.
  53.187 -    SDL_SCANCODE_AC_STOP, // VirtualKey.Stop -- 169 : The stop key.
  53.188 -    SDL_SCANCODE_AC_SEARCH, // VirtualKey.Search -- 170 : The search key.
  53.189 -    SDL_SCANCODE_AC_BOOKMARKS, // VirtualKey.Favorites -- 171 : The favorites key.
  53.190 -    SDL_SCANCODE_AC_HOME // VirtualKey.GoHome -- 172 : The go home key.
  53.191 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.None -- 0 */
  53.192 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.LeftButton -- 1 */
  53.193 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.RightButton -- 2 */
  53.194 +    SDL_SCANCODE_CANCEL,        /* VirtualKey.Cancel -- 3 */
  53.195 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.MiddleButton -- 4 */
  53.196 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.XButton1 -- 5 */
  53.197 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.XButton2 -- 6 */
  53.198 +    SDL_SCANCODE_UNKNOWN,       /* -- 7 */
  53.199 +    SDL_SCANCODE_BACKSPACE,     /* VirtualKey.Back -- 8 */
  53.200 +    SDL_SCANCODE_TAB,           /* VirtualKey.Tab -- 9 */
  53.201 +    SDL_SCANCODE_UNKNOWN,       /* -- 10 */
  53.202 +    SDL_SCANCODE_UNKNOWN,       /* -- 11 */
  53.203 +    SDL_SCANCODE_CLEAR,         /* VirtualKey.Clear -- 12 */
  53.204 +    SDL_SCANCODE_RETURN,        /* VirtualKey.Enter -- 13 */
  53.205 +    SDL_SCANCODE_UNKNOWN,       /* -- 14 */
  53.206 +    SDL_SCANCODE_UNKNOWN,       /* -- 15 */
  53.207 +    SDL_SCANCODE_LSHIFT,        /* VirtualKey.Shift -- 16 */
  53.208 +    SDL_SCANCODE_LCTRL,         /* VirtualKey.Control -- 17 */
  53.209 +    SDL_SCANCODE_MENU,          /* VirtualKey.Menu -- 18 */
  53.210 +    SDL_SCANCODE_PAUSE,         /* VirtualKey.Pause -- 19 */
  53.211 +    SDL_SCANCODE_CAPSLOCK,      /* VirtualKey.CapitalLock -- 20 */
  53.212 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Kana or VirtualKey.Hangul -- 21 */
  53.213 +    SDL_SCANCODE_UNKNOWN,       /* -- 22 */
  53.214 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Junja -- 23 */
  53.215 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Final -- 24 */
  53.216 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Hanja or VirtualKey.Kanji -- 25 */
  53.217 +    SDL_SCANCODE_UNKNOWN,       /* -- 26 */
  53.218 +    SDL_SCANCODE_ESCAPE,        /* VirtualKey.Escape -- 27 */
  53.219 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Convert -- 28 */
  53.220 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.NonConvert -- 29 */
  53.221 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Accept -- 30 */
  53.222 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.ModeChange -- 31  (maybe SDL_SCANCODE_MODE ?) */
  53.223 +    SDL_SCANCODE_SPACE,         /* VirtualKey.Space -- 32 */
  53.224 +    SDL_SCANCODE_PAGEUP,        /* VirtualKey.PageUp -- 33 */
  53.225 +    SDL_SCANCODE_PAGEDOWN,      /* VirtualKey.PageDown -- 34 */
  53.226 +    SDL_SCANCODE_END,           /* VirtualKey.End -- 35 */
  53.227 +    SDL_SCANCODE_HOME,          /* VirtualKey.Home -- 36 */
  53.228 +    SDL_SCANCODE_LEFT,          /* VirtualKey.Left -- 37 */
  53.229 +    SDL_SCANCODE_UP,            /* VirtualKey.Up -- 38 */
  53.230 +    SDL_SCANCODE_RIGHT,         /* VirtualKey.Right -- 39 */
  53.231 +    SDL_SCANCODE_DOWN,          /* VirtualKey.Down -- 40 */
  53.232 +    SDL_SCANCODE_SELECT,        /* VirtualKey.Select -- 41 */
  53.233 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Print -- 42  (maybe SDL_SCANCODE_PRINTSCREEN ?) */
  53.234 +    SDL_SCANCODE_EXECUTE,       /* VirtualKey.Execute -- 43 */
  53.235 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Snapshot -- 44 */
  53.236 +    SDL_SCANCODE_INSERT,        /* VirtualKey.Insert -- 45 */
  53.237 +    SDL_SCANCODE_DELETE,        /* VirtualKey.Delete -- 46 */
  53.238 +    SDL_SCANCODE_HELP,          /* VirtualKey.Help -- 47 */
  53.239 +    SDL_SCANCODE_0,             /* VirtualKey.Number0 -- 48 */
  53.240 +    SDL_SCANCODE_1,             /* VirtualKey.Number1 -- 49 */
  53.241 +    SDL_SCANCODE_2,             /* VirtualKey.Number2 -- 50 */
  53.242 +    SDL_SCANCODE_3,             /* VirtualKey.Number3 -- 51 */
  53.243 +    SDL_SCANCODE_4,             /* VirtualKey.Number4 -- 52 */
  53.244 +    SDL_SCANCODE_5,             /* VirtualKey.Number5 -- 53 */
  53.245 +    SDL_SCANCODE_6,             /* VirtualKey.Number6 -- 54 */
  53.246 +    SDL_SCANCODE_7,             /* VirtualKey.Number7 -- 55 */
  53.247 +    SDL_SCANCODE_8,             /* VirtualKey.Number8 -- 56 */
  53.248 +    SDL_SCANCODE_9,             /* VirtualKey.Number9 -- 57 */
  53.249 +    SDL_SCANCODE_UNKNOWN,       /* -- 58 */
  53.250 +    SDL_SCANCODE_UNKNOWN,       /* -- 59 */
  53.251 +    SDL_SCANCODE_UNKNOWN,       /* -- 60 */
  53.252 +    SDL_SCANCODE_UNKNOWN,       /* -- 61 */
  53.253 +    SDL_SCANCODE_UNKNOWN,       /* -- 62 */
  53.254 +    SDL_SCANCODE_UNKNOWN,       /* -- 63 */
  53.255 +    SDL_SCANCODE_UNKNOWN,       /* -- 64 */
  53.256 +    SDL_SCANCODE_A,             /* VirtualKey.A -- 65 */
  53.257 +    SDL_SCANCODE_B,             /* VirtualKey.B -- 66 */
  53.258 +    SDL_SCANCODE_C,             /* VirtualKey.C -- 67 */
  53.259 +    SDL_SCANCODE_D,             /* VirtualKey.D -- 68 */
  53.260 +    SDL_SCANCODE_E,             /* VirtualKey.E -- 69 */
  53.261 +    SDL_SCANCODE_F,             /* VirtualKey.F -- 70 */
  53.262 +    SDL_SCANCODE_G,             /* VirtualKey.G -- 71 */
  53.263 +    SDL_SCANCODE_H,             /* VirtualKey.H -- 72 */
  53.264 +    SDL_SCANCODE_I,             /* VirtualKey.I -- 73 */
  53.265 +    SDL_SCANCODE_J,             /* VirtualKey.J -- 74 */
  53.266 +    SDL_SCANCODE_K,             /* VirtualKey.K -- 75 */
  53.267 +    SDL_SCANCODE_L,             /* VirtualKey.L -- 76 */
  53.268 +    SDL_SCANCODE_M,             /* VirtualKey.M -- 77 */
  53.269 +    SDL_SCANCODE_N,             /* VirtualKey.N -- 78 */
  53.270 +    SDL_SCANCODE_O,             /* VirtualKey.O -- 79 */
  53.271 +    SDL_SCANCODE_P,             /* VirtualKey.P -- 80 */
  53.272 +    SDL_SCANCODE_Q,             /* VirtualKey.Q -- 81 */
  53.273 +    SDL_SCANCODE_R,             /* VirtualKey.R -- 82 */
  53.274 +    SDL_SCANCODE_S,             /* VirtualKey.S -- 83 */
  53.275 +    SDL_SCANCODE_T,             /* VirtualKey.T -- 84 */
  53.276 +    SDL_SCANCODE_U,             /* VirtualKey.U -- 85 */
  53.277 +    SDL_SCANCODE_V,             /* VirtualKey.V -- 86 */
  53.278 +    SDL_SCANCODE_W,             /* VirtualKey.W -- 87 */
  53.279 +    SDL_SCANCODE_X,             /* VirtualKey.X -- 88 */
  53.280 +    SDL_SCANCODE_Y,             /* VirtualKey.Y -- 89 */
  53.281 +    SDL_SCANCODE_Z,             /* VirtualKey.Z -- 90 */
  53.282 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.LeftWindows -- 91  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) */
  53.283 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.RightWindows -- 92  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) */
  53.284 +    SDL_SCANCODE_APPLICATION,   /* VirtualKey.Application -- 93 */
  53.285 +    SDL_SCANCODE_UNKNOWN,       /* -- 94 */
  53.286 +    SDL_SCANCODE_SLEEP,         /* VirtualKey.Sleep -- 95 */
  53.287 +    SDL_SCANCODE_KP_0,          /* VirtualKey.NumberPad0 -- 96 */
  53.288 +    SDL_SCANCODE_KP_1,          /* VirtualKey.NumberPad1 -- 97 */
  53.289 +    SDL_SCANCODE_KP_2,          /* VirtualKey.NumberPad2 -- 98 */
  53.290 +    SDL_SCANCODE_KP_3,          /* VirtualKey.NumberPad3 -- 99 */
  53.291 +    SDL_SCANCODE_KP_4,          /* VirtualKey.NumberPad4 -- 100 */
  53.292 +    SDL_SCANCODE_KP_5,          /* VirtualKey.NumberPad5 -- 101 */
  53.293 +    SDL_SCANCODE_KP_6,          /* VirtualKey.NumberPad6 -- 102 */
  53.294 +    SDL_SCANCODE_KP_7,          /* VirtualKey.NumberPad7 -- 103 */
  53.295 +    SDL_SCANCODE_KP_8,          /* VirtualKey.NumberPad8 -- 104 */
  53.296 +    SDL_SCANCODE_KP_9,          /* VirtualKey.NumberPad9 -- 105 */
  53.297 +    SDL_SCANCODE_KP_MULTIPLY,   /* VirtualKey.Multiply -- 106 */
  53.298 +    SDL_SCANCODE_KP_PLUS,       /* VirtualKey.Add -- 107 */
  53.299 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Separator -- 108 */
  53.300 +    SDL_SCANCODE_KP_MINUS,      /* VirtualKey.Subtract -- 109 */
  53.301 +    SDL_SCANCODE_UNKNOWN,       /* VirtualKey.Decimal -- 110  (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) */
  53.302 +    SDL_SCANCODE_KP_DIVIDE,     /* VirtualKey.Divide -- 111 */
  53.303 +    SDL_SCANCODE_F1,            /* VirtualKey.F1 -- 112 */
  53.304 +    SDL_SCANCODE_F2,            /* VirtualKey.F2 -- 113 */
  53.305 +    SDL_SCANCODE_F3,            /* VirtualKey.F3 -- 114 */
  53.306 +    SDL_SCANCODE_F4,            /* VirtualKey.F4 -- 115 */
  53.307 +    SDL_SCANCODE_F5,            /* VirtualKey.F5 -- 116 */
  53.308 +    SDL_SCANCODE_F6,            /* VirtualKey.F6 -- 117 */
  53.309 +    SDL_SCANCODE_F7,            /* VirtualKey.F7 -- 118 */
  53.310 +    SDL_SCANCODE_F8,            /* VirtualKey.F8 -- 119 */
  53.311 +    SDL_SCANCODE_F9,            /* VirtualKey.F9 -- 120 */
  53.312 +    SDL_SCANCODE_F10,           /* VirtualKey.F10 -- 121 */
  53.313 +    SDL_SCANCODE_F11,           /* VirtualKey.F11 -- 122 */
  53.314 +    SDL_SCANCODE_F12,           /* VirtualKey.F12 -- 123 */
  53.315 +    SDL_SCANCODE_F13,           /* VirtualKey.F13 -- 124 */
  53.316 +    SDL_SCANCODE_F14,           /* VirtualKey.F14 -- 125 */
  53.317 +    SDL_SCANCODE_F15,           /* VirtualKey.F15 -- 126 */
  53.318 +    SDL_SCANCODE_F16,           /* VirtualKey.F16 -- 127 */
  53.319 +    SDL_SCANCODE_F17,           /* VirtualKey.F17 -- 128 */
  53.320 +    SDL_SCANCODE_F18,           /* VirtualKey.F18 -- 129 */
  53.321 +    SDL_SCANCODE_F19,           /* VirtualKey.F19 -- 130 */
  53.322 +    SDL_SCANCODE_F20,           /* VirtualKey.F20 -- 131 */
  53.323 +    SDL_SCANCODE_F21,           /* VirtualKey.F21 -- 132 */
  53.324 +    SDL_SCANCODE_F22,           /* VirtualKey.F22 -- 133 */
  53.325 +    SDL_SCANCODE_F23,           /* VirtualKey.F23 -- 134 */
  53.326 +    SDL_SCANCODE_F24,           /* VirtualKey.F24 -- 135 */
  53.327 +    SDL_SCANCODE_UNKNOWN,       /* -- 136 */
  53.328 +    SDL_SCANCODE_UNKNOWN,       /* -- 137 */
  53.329 +    SDL_SCANCODE_UNKNOWN,       /* -- 138 */
  53.330 +    SDL_SCANCODE_UNKNOWN,       /* -- 139 */
  53.331 +    SDL_SCANCODE_UNKNOWN,       /* -- 140 */
  53.332 +    SDL_SCANCODE_UNKNOWN,       /* -- 141 */
  53.333 +    SDL_SCANCODE_UNKNOWN,       /* -- 142 */
  53.334 +    SDL_SCANCODE_UNKNOWN,       /* -- 143 */
  53.335 +    SDL_SCANCODE_NUMLOCKCLEAR,  /* VirtualKey.NumberKeyLock -- 144 */
  53.336 +    SDL_SCANCODE_SCROLLLOCK,    /* VirtualKey.Scroll -- 145 */
  53.337 +    SDL_SCANCODE_UNKNOWN,       /* -- 146 */
  53.338 +    SDL_SCANCODE_UNKNOWN,       /* -- 147 */
  53.339 +    SDL_SCANCODE_UNKNOWN,       /* -- 148 */
  53.340 +    SDL_SCANCODE_UNKNOWN,       /* -- 149 */
  53.341 +    SDL_SCANCODE_UNKNOWN,       /* -- 150 */
  53.342 +    SDL_SCANCODE_UNKNOWN,       /* -- 151 */
  53.343 +    SDL_SCANCODE_UNKNOWN,       /* -- 152 */
  53.344 +    SDL_SCANCODE_UNKNOWN,       /* -- 153 */
  53.345 +    SDL_SCANCODE_UNKNOWN,       /* -- 154 */
  53.346 +    SDL_SCANCODE_UNKNOWN,       /* -- 155 */
  53.347 +    SDL_SCANCODE_UNKNOWN,       /* -- 156 */
  53.348 +    SDL_SCANCODE_UNKNOWN,       /* -- 157 */
  53.349 +    SDL_SCANCODE_UNKNOWN,       /* -- 158 */
  53.350 +    SDL_SCANCODE_UNKNOWN,       /* -- 159 */
  53.351 +    SDL_SCANCODE_LSHIFT,        /* VirtualKey.LeftShift -- 160 */
  53.352 +    SDL_SCANCODE_RSHIFT,        /* VirtualKey.RightShift -- 161 */
  53.353 +    SDL_SCANCODE_LCTRL,         /* VirtualKey.LeftControl -- 162 */
  53.354 +    SDL_SCANCODE_RCTRL,         /* VirtualKey.RightControl -- 163 */
  53.355 +    SDL_SCANCODE_MENU,          /* VirtualKey.LeftMenu -- 164 */
  53.356 +    SDL_SCANCODE_MENU,          /* VirtualKey.RightMenu -- 165 */
  53.357 +    SDL_SCANCODE_AC_BACK,       /* VirtualKey.GoBack -- 166 : The go back key. */
  53.358 +    SDL_SCANCODE_AC_FORWARD,    /* VirtualKey.GoForward -- 167 : The go forward key. */
  53.359 +    SDL_SCANCODE_AC_REFRESH,    /* VirtualKey.Refresh -- 168 : The refresh key. */
  53.360 +    SDL_SCANCODE_AC_STOP,       /* VirtualKey.Stop -- 169 : The stop key. */
  53.361 +    SDL_SCANCODE_AC_SEARCH,     /* VirtualKey.Search -- 170 : The search key. */
  53.362 +    SDL_SCANCODE_AC_BOOKMARKS,  /* VirtualKey.Favorites -- 171 : The favorites key. */
  53.363 +    SDL_SCANCODE_AC_HOME        /* VirtualKey.GoHome -- 172 : The go home key. */
  53.364  };
  53.365  
  53.366 -static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
  53.367 +/* Attempt to translate a keycode that isn't listed in WinRT's VirtualKey enum.
  53.368 + */
  53.369 +static SDL_Scancode
  53.370 +WINRT_TranslateUnofficialKeycode(int keycode)
  53.371 +{
  53.372 +    switch (keycode) {
  53.373 +        case 173: return SDL_SCANCODE_MUTE;         /* VK_VOLUME_MUTE */
  53.374 +        case 174: return SDL_SCANCODE_VOLUMEDOWN;   /* VK_VOLUME_DOWN */
  53.375 +        case 175: return SDL_SCANCODE_VOLUMEUP;     /* VK_VOLUME_UP */
  53.376 +        case 176: return SDL_SCANCODE_AUDIONEXT;    /* VK_MEDIA_NEXT_TRACK */
  53.377 +        case 177: return SDL_SCANCODE_AUDIOPREV;    /* VK_MEDIA_PREV_TRACK */
  53.378 +        // case 178: return ;                       /* VK_MEDIA_STOP */
  53.379 +        case 179: return SDL_SCANCODE_AUDIOPLAY;    /* VK_MEDIA_PLAY_PAUSE */
  53.380 +        case 180: return SDL_SCANCODE_MAIL;         /* VK_LAUNCH_MAIL */
  53.381 +        case 181: return SDL_SCANCODE_MEDIASELECT;  /* VK_LAUNCH_MEDIA_SELECT */
  53.382 +        // case 182: return ;                       /* VK_LAUNCH_APP1 */
  53.383 +        case 183: return SDL_SCANCODE_CALCULATOR;   /* VK_LAUNCH_APP2 */
  53.384 +        // case 184: return ;                       /* ... reserved ... */
  53.385 +        // case 185: return ;                       /* ... reserved ... */
  53.386 +        case 186: return SDL_SCANCODE_SEMICOLON;    /* VK_OEM_1, ';:' key on US standard keyboards */
  53.387 +        case 187: return SDL_SCANCODE_EQUALS;       /* VK_OEM_PLUS */
  53.388 +        case 188: return SDL_SCANCODE_COMMA;        /* VK_OEM_COMMA */
  53.389 +        case 189: return SDL_SCANCODE_MINUS;        /* VK_OEM_MINUS */
  53.390 +        case 190: return SDL_SCANCODE_PERIOD;       /* VK_OEM_PERIOD */
  53.391 +        case 191: return SDL_SCANCODE_SLASH;        /* VK_OEM_2, '/?' key on US standard keyboards */
  53.392 +        case 192: return SDL_SCANCODE_GRAVE;        /* VK_OEM_3, '`~' key on US standard keyboards */
  53.393 +        // ?
  53.394 +        // ... reserved or unassigned ...
  53.395 +        // ?
  53.396 +        case 219: return SDL_SCANCODE_LEFTBRACKET;  /* VK_OEM_4, '[{' key on US standard keyboards */
  53.397 +        case 220: return SDL_SCANCODE_BACKSLASH;    /* VK_OEM_5, '\|' key on US standard keyboards */
  53.398 +        case 221: return SDL_SCANCODE_RIGHTBRACKET; /* VK_OEM_6, ']}' key on US standard keyboards */
  53.399 +        case 222: return SDL_SCANCODE_APOSTROPHE;   /* VK_OEM_7, 'single/double quote' on US standard keyboards */
  53.400 +        default: break;
  53.401 +    }
  53.402 +    return SDL_SCANCODE_UNKNOWN;
  53.403 +}
  53.404  
  53.405  static SDL_Scancode
  53.406 -TranslateKeycode(int keycode)
  53.407 +WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode)
  53.408  {
  53.409 -    if (WinRT_Unofficial_Keycodes.empty()) {
  53.410 -        /* Set up a table of keycodes that aren't listed in WinRT's
  53.411 -         * VirtualKey enum.
  53.412 -         */
  53.413 +    // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
  53.414  
  53.415 -        WinRT_Unofficial_Keycodes[173] = SDL_SCANCODE_MUTE;
  53.416 -        WinRT_Unofficial_Keycodes[174] = SDL_SCANCODE_VOLUMEDOWN;
  53.417 -        WinRT_Unofficial_Keycodes[175] = SDL_SCANCODE_VOLUMEUP;
  53.418 -        WinRT_Unofficial_Keycodes[176] = SDL_SCANCODE_AUDIONEXT;
  53.419 -        WinRT_Unofficial_Keycodes[177] = SDL_SCANCODE_AUDIOPREV;
  53.420 -        // WinRT_Unofficial_Keycodes[178] = ;
  53.421 -        WinRT_Unofficial_Keycodes[179] = SDL_SCANCODE_AUDIOPLAY;
  53.422 -        WinRT_Unofficial_Keycodes[180] = SDL_SCANCODE_MAIL;
  53.423 -        WinRT_Unofficial_Keycodes[181] = SDL_SCANCODE_MEDIASELECT;
  53.424 -        // WinRT_Unofficial_Keycodes[182] = ;
  53.425 -        WinRT_Unofficial_Keycodes[183] = SDL_SCANCODE_CALCULATOR;
  53.426 -        // WinRT_Unofficial_Keycodes[184] = ;
  53.427 -        // WinRT_Unofficial_Keycodes[185] = ;
  53.428 -        WinRT_Unofficial_Keycodes[186] = SDL_SCANCODE_SEMICOLON;
  53.429 -        WinRT_Unofficial_Keycodes[187] = SDL_SCANCODE_EQUALS;
  53.430 -        WinRT_Unofficial_Keycodes[188] = SDL_SCANCODE_COMMA;
  53.431 -        WinRT_Unofficial_Keycodes[189] = SDL_SCANCODE_MINUS;
  53.432 -        WinRT_Unofficial_Keycodes[190] = SDL_SCANCODE_PERIOD;
  53.433 -        WinRT_Unofficial_Keycodes[191] = SDL_SCANCODE_SLASH;
  53.434 -        WinRT_Unofficial_Keycodes[192] = SDL_SCANCODE_GRAVE;
  53.435 -        // ?
  53.436 -        // ...
  53.437 -        // ?
  53.438 -        WinRT_Unofficial_Keycodes[219] = SDL_SCANCODE_LEFTBRACKET;
  53.439 -        WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_BACKSLASH;
  53.440 -        WinRT_Unofficial_Keycodes[221] = SDL_SCANCODE_RIGHTBRACKET;
  53.441 -        WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_APOSTROPHE;
  53.442 +    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
  53.443 +
  53.444 +    /* HACK ALERT: At least one VirtualKey constant (Shift) with a left/right
  53.445 +     * designation might not get reported with its correct handedness, however
  53.446 +     * its hardware scan code can fill in the gaps.  If this is detected,
  53.447 +     * use the hardware scan code to try telling if the left, or the right
  53.448 +     * side's key was used.
  53.449 +     *
  53.450 +     * If Microsoft ever allows MapVirtualKey or MapVirtualKeyEx to be used
  53.451 +     * in WinRT apps, or something similar to these (it doesn't appear to be,
  53.452 +     * at least not for Windows [Phone] 8/8.1, as of Oct 24, 2014), then this
  53.453 +     * hack might become deprecated, or obsolete.
  53.454 +     */
  53.455 +    if (nativeScancode < SDL_arraysize(windows_scancode_table)) {
  53.456 +        switch (keycode) {
  53.457 +            case 16:    // VirtualKey.Shift
  53.458 +                switch (windows_scancode_table[nativeScancode]) {
  53.459 +                    case SDL_SCANCODE_LSHIFT:
  53.460 +                    case SDL_SCANCODE_RSHIFT:
  53.461 +                        return windows_scancode_table[nativeScancode];
  53.462 +                }
  53.463 +                break;
  53.464 +            
  53.465 +            // Add others, as necessary.
  53.466 +            //
  53.467 +            // Unfortunately, this hack doesn't seem to work in determining
  53.468 +            // handedness with Control keys.
  53.469 +
  53.470 +            default:
  53.471 +                break;
  53.472 +        }
  53.473      }
  53.474  
  53.475 -    /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
  53.476 +    /* Try to get a documented, WinRT, 'VirtualKey' next (as documented at
  53.477         http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
  53.478         If that fails, fall back to a Win32 virtual key.
  53.479 +       If that fails, attempt to fall back to a scancode-derived key.
  53.480      */
  53.481 -    // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
  53.482 -    //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
  53.483 -    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
  53.484      if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
  53.485          scancode = WinRT_Official_Keycodes[keycode];
  53.486      }
  53.487      if (scancode == SDL_SCANCODE_UNKNOWN) {
  53.488 -        if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
  53.489 -            scancode = WinRT_Unofficial_Keycodes[keycode];
  53.490 +        scancode = WINRT_TranslateUnofficialKeycode(keycode);
  53.491 +    }
  53.492 +    if (scancode == SDL_SCANCODE_UNKNOWN) {
  53.493 +        if (nativeScancode < SDL_arraysize(windows_scancode_table)) {
  53.494 +            scancode = windows_scancode_table[nativeScancode];
  53.495          }
  53.496      }
  53.497 +    /*
  53.498      if (scancode == SDL_SCANCODE_UNKNOWN) {
  53.499          SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
  53.500      }
  53.501 +    */
  53.502      return scancode;
  53.503  }
  53.504  
  53.505  void
  53.506  WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
  53.507  {
  53.508 -    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
  53.509 +    SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
  53.510  #if 0
  53.511      SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
  53.512 -    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
  53.513 +    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, "
  53.514 +            "repeat count=%d, native scan code=0x%x, was down?=%s, vkey=%d, "
  53.515 +            "sdl scan code=%d (%s), sdl key code=%d (%s)\n",
  53.516          (args->Handled ? "1" : "0"),
  53.517          (args->KeyStatus.IsExtendedKey ? "1" : "0"),
  53.518          (args->KeyStatus.IsKeyReleased ? "1" : "0"),
  53.519 @@ -297,7 +335,6 @@
  53.520          keycode,
  53.521          SDL_GetKeyName(keycode));
  53.522      //args->Handled = true;
  53.523 -    //VirtualKey vkey = args->VirtualKey;
  53.524  #endif
  53.525      SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
  53.526  }
  53.527 @@ -305,10 +342,12 @@
  53.528  void
  53.529  WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args)
  53.530  {
  53.531 -    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
  53.532 +    SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
  53.533  #if 0
  53.534      SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
  53.535 -    SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
  53.536 +    SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, "
  53.537 +            "repeat count=%d, native scan code=0x%x, was down?=%s, vkey=%d, "
  53.538 +            "sdl scan code=%d (%s), sdl key code=%d (%s)\n",
  53.539          (args->Handled ? "1" : "0"),
  53.540          (args->KeyStatus.IsExtendedKey ? "1" : "0"),
  53.541          (args->KeyStatus.IsKeyReleased ? "1" : "0"),
    54.1 --- a/src/video/x11/SDL_x11events.c	Tue Oct 28 01:34:40 2014 -0300
    54.2 +++ b/src/video/x11/SDL_x11events.c	Tue Oct 28 18:36:29 2014 -0300
    54.3 @@ -508,6 +508,26 @@
    54.4  }
    54.5  
    54.6  static void
    54.7 +ReconcileKeyboardState(_THIS, const SDL_WindowData *data)
    54.8 +{
    54.9 +    SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
   54.10 +    Display *display = viddata->display;
   54.11 +    char keys[32];
   54.12 +    int keycode = 0;
   54.13 +
   54.14 +    X11_XQueryKeymap( display, keys );
   54.15 +
   54.16 +    while ( keycode < 256 ) {
   54.17 +        if ( keys[keycode / 8] & (1 << (keycode % 8)) ) {
   54.18 +            SDL_SendKeyboardKey(SDL_PRESSED, viddata->key_layout[keycode]);
   54.19 +        } else {
   54.20 +            SDL_SendKeyboardKey(SDL_RELEASED, viddata->key_layout[keycode]);
   54.21 +        }
   54.22 +        keycode++;
   54.23 +    }
   54.24 +}
   54.25 +
   54.26 +static void
   54.27  X11_DispatchEvent(_THIS)
   54.28  {
   54.29      SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   54.30 @@ -655,16 +675,7 @@
   54.31  #endif
   54.32              if (data->pending_focus == PENDING_FOCUS_OUT &&
   54.33                  data->window == SDL_GetKeyboardFocus()) {
   54.34 -                /* We want to reset the keyboard here, because we may have
   54.35 -                   missed keyboard messages after our previous FocusOut.
   54.36 -                 */
   54.37 -                /* Actually, if we do this we clear the ALT key on Unity
   54.38 -                   because it briefly takes focus for their dashboard.
   54.39 -
   54.40 -                   I think it's better to think the ALT key is held down
   54.41 -                   when it's not, then always lose the ALT modifier on Unity.
   54.42 -                 */
   54.43 -                /* SDL_ResetKeyboard(); */
   54.44 +                ReconcileKeyboardState(_this, data);
   54.45              }
   54.46              data->pending_focus = PENDING_FOCUS_IN;
   54.47              data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_IN_TIME;
    55.1 --- a/src/video/x11/SDL_x11modes.c	Tue Oct 28 01:34:40 2014 -0300
    55.2 +++ b/src/video/x11/SDL_x11modes.c	Tue Oct 28 18:36:29 2014 -0300
    55.3 @@ -375,7 +375,7 @@
    55.4  X11_InitModes(_THIS)
    55.5  {
    55.6      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    55.7 -    int screen, screencount;
    55.8 +    int snum, screen, screencount;
    55.9  #if SDL_VIDEO_DRIVER_X11_XINERAMA
   55.10      int xinerama_major, xinerama_minor;
   55.11      int use_xinerama = 0;
   55.12 @@ -423,7 +423,7 @@
   55.13      }
   55.14  #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
   55.15  
   55.16 -    for (screen = 0; screen < screencount; ++screen) {
   55.17 +    for (snum = 0; snum < screencount; ++snum) {
   55.18          XVisualInfo vinfo;
   55.19          SDL_VideoDisplay display;
   55.20          SDL_DisplayData *displaydata;
   55.21 @@ -433,6 +433,15 @@
   55.22          char display_name[128];
   55.23          int i, n;
   55.24  
   55.25 +        /* Re-order screens to always put default screen first */
   55.26 +        if (snum == 0) {
   55.27 +            screen = DefaultScreen(data->display);
   55.28 +        } else if (snum == DefaultScreen(data->display)) {
   55.29 +            screen = 0;
   55.30 +        } else {
   55.31 +            screen = snum;
   55.32 +        }
   55.33 +
   55.34  #if SDL_VIDEO_DRIVER_X11_XINERAMA
   55.35          if (xinerama) {
   55.36              if (get_visualinfo(data->display, 0, &vinfo) < 0) {
    56.1 --- a/src/video/x11/SDL_x11opengles.c	Tue Oct 28 01:34:40 2014 -0300
    56.2 +++ b/src/video/x11/SDL_x11opengles.c	Tue Oct 28 18:36:29 2014 -0300
    56.3 @@ -29,8 +29,8 @@
    56.4  /* EGL implementation of SDL OpenGL support */
    56.5  
    56.6  int
    56.7 -X11_GLES_LoadLibrary(_THIS, const char *path) {
    56.8 -        
    56.9 +X11_GLES_LoadLibrary(_THIS, const char *path)
   56.10 +{
   56.11      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   56.12  
   56.13      /* If the profile requested is not GL ES, switch over to X11_GL functions  */
    57.1 --- a/test/testhaptic.c	Tue Oct 28 01:34:40 2014 -0300
    57.2 +++ b/test/testhaptic.c	Tue Oct 28 18:36:29 2014 -0300
    57.3 @@ -122,7 +122,8 @@
    57.4          SDL_Log("   effect %d: Sine Wave\n", nefx);
    57.5          efx[nefx].type = SDL_HAPTIC_SINE;
    57.6          efx[nefx].periodic.period = 1000;
    57.7 -        efx[nefx].periodic.magnitude = 0x4000;
    57.8 +        efx[nefx].periodic.magnitude = -0x2000;    /* Negative magnitude and ...                      */
    57.9 +        efx[nefx].periodic.phase = 18000;          /* ... 180 degrees phase shift => cancel eachother */
   57.10          efx[nefx].periodic.length = 5000;
   57.11          efx[nefx].periodic.attack_length = 1000;
   57.12          efx[nefx].periodic.fade_length = 1000;
    58.1 --- a/test/testmultiaudio.c	Tue Oct 28 01:34:40 2014 -0300
    58.2 +++ b/test/testmultiaudio.c	Tue Oct 28 18:36:29 2014 -0300
    58.3 @@ -50,6 +50,12 @@
    58.4      callback_data cbd[64];
    58.5      int keep_going = 1;
    58.6      int i;
    58.7 +    
    58.8 +#ifdef __ANDROID__  
    58.9 +    SDL_Event event;
   58.10 +  
   58.11 +    SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
   58.12 +#endif
   58.13  
   58.14      if (devcount > 64) {
   58.15          SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
   58.16 @@ -71,8 +77,12 @@
   58.17              SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
   58.18          } else {
   58.19              SDL_PauseAudioDevice(cbd[0].dev, 0);
   58.20 -            while (!cbd[0].done)
   58.21 +            while (!cbd[0].done) {
   58.22 +#ifdef __ANDROID__                
   58.23 +                while (SDL_PollEvent(&event)){}
   58.24 +#endif                
   58.25                  SDL_Delay(100);
   58.26 +            }
   58.27              SDL_PauseAudioDevice(cbd[0].dev, 1);
   58.28              SDL_Log("done.\n");
   58.29              SDL_CloseAudioDevice(cbd[0].dev);
   58.30 @@ -104,6 +114,9 @@
   58.31                  keep_going = 1;
   58.32              }
   58.33          }
   58.34 +#ifdef __ANDROID__        
   58.35 +        while (SDL_PollEvent(&event)){}
   58.36 +#endif        
   58.37          SDL_Delay(100);
   58.38      }
   58.39