Merged default into iOS-improvements

--HG--
branch : iOS-improvements
This commit is contained in:
Alex Szpakowski 2014-10-28 18:36:29 -03:00
commit 0cac1b6415
56 changed files with 2419 additions and 1164 deletions

View file

@ -247,7 +247,7 @@ endforeach()
set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE})
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
set_option(VIDEO_MX6 "Use Freescale i.MX6 video driver" OFF)
set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
# The options below are for compatibility to configure's default behaviour.
@ -679,7 +679,7 @@ if(UNIX AND NOT APPLE)
CheckOpenGLX11()
CheckOpenGLESX11()
CheckWayland()
CheckMX6()
CheckVivante()
endif()
if(LINUX)

View file

@ -17,9 +17,14 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsoluteLayout;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.os.*;
import android.util.Log;
import android.util.SparseArray;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.media.*;
import android.hardware.*;
@ -33,6 +38,9 @@ public class SDLActivity extends Activity {
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus;
public static boolean mExitCalledFromJava;
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
public static boolean mBrokenLibraries;
// Main components
protected static SDLActivity mSingleton;
protected static SDLSurface mSurface;
@ -46,16 +54,42 @@ public class SDLActivity extends Activity {
// Audio
protected static AudioTrack mAudioTrack;
// Load the .so
static {
System.loadLibrary("SDL2");
//System.loadLibrary("SDL2_image");
//System.loadLibrary("SDL2_mixer");
//System.loadLibrary("SDL2_net");
//System.loadLibrary("SDL2_ttf");
System.loadLibrary("main");
/**
* This method is called by SDL before loading the native shared libraries.
* It can be overridden to provide names of shared libraries to be loaded.
* The default implementation returns the defaults. It never returns null.
* An array returned by a new implementation must at least contain "SDL2".
* Also keep in mind that the order the libraries are loaded may matter.
* @return names of shared libraries to be loaded (e.g. "SDL2", "main").
*/
protected String[] getLibraries() {
return new String[] {
"SDL2",
// "SDL2_image",
// "SDL2_mixer",
// "SDL2_net",
// "SDL2_ttf",
"main"
};
}
// Load the .so
public void loadLibraries() {
for (String lib : getLibraries()) {
System.loadLibrary(lib);
}
}
/**
* This method is called by SDL using JNI.
* This method is called by SDL before starting the native application thread.
* It can be overridden to provide the arguments after the application name.
* The default implementation returns an empty array. It never returns null.
* @return arguments for the native application.
*/
protected String[] getArguments() {
return new String[0];
}
public static void initialize() {
// The static nature of the singleton and Android quirkyness force us to initialize everything here
@ -68,6 +102,7 @@ public class SDLActivity extends Activity {
mSDLThread = null;
mAudioTrack = null;
mExitCalledFromJava = false;
mBrokenLibraries = false;
mIsPaused = false;
mIsSurfaceReady = false;
mHasFocus = true;
@ -83,6 +118,42 @@ public class SDLActivity extends Activity {
// So we can call stuff from static callbacks
mSingleton = this;
// Load shared libraries
String errorMsgBrokenLib = "";
try {
loadLibraries();
} catch(UnsatisfiedLinkError e) {
System.err.println(e.getMessage());
mBrokenLibraries = true;
errorMsgBrokenLib = e.getMessage();
} catch(Exception e) {
System.err.println(e.getMessage());
mBrokenLibraries = true;
errorMsgBrokenLib = e.getMessage();
}
if (mBrokenLibraries)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage("An error occurred while trying to start the application. Please try again and/or reinstall."
+ System.getProperty("line.separator")
+ System.getProperty("line.separator")
+ "Error: " + errorMsgBrokenLib);
dlgAlert.setTitle("SDL Error");
dlgAlert.setPositiveButton("Exit",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close current activity
SDLActivity.mSingleton.finish();
}
});
dlgAlert.setCancelable(false);
dlgAlert.create().show();
return;
}
// Set up the surface
mSurface = new SDLSurface(getApplication());
@ -104,6 +175,11 @@ public class SDLActivity extends Activity {
protected void onPause() {
Log.v("SDL", "onPause()");
super.onPause();
if (SDLActivity.mBrokenLibraries) {
return;
}
SDLActivity.handlePause();
}
@ -111,6 +187,11 @@ public class SDLActivity extends Activity {
protected void onResume() {
Log.v("SDL", "onResume()");
super.onResume();
if (SDLActivity.mBrokenLibraries) {
return;
}
SDLActivity.handleResume();
}
@ -120,6 +201,10 @@ public class SDLActivity extends Activity {
super.onWindowFocusChanged(hasFocus);
Log.v("SDL", "onWindowFocusChanged(): " + hasFocus);
if (SDLActivity.mBrokenLibraries) {
return;
}
SDLActivity.mHasFocus = hasFocus;
if (hasFocus) {
SDLActivity.handleResume();
@ -130,12 +215,25 @@ public class SDLActivity extends Activity {
public void onLowMemory() {
Log.v("SDL", "onLowMemory()");
super.onLowMemory();
if (SDLActivity.mBrokenLibraries) {
return;
}
SDLActivity.nativeLowMemory();
}
@Override
protected void onDestroy() {
Log.v("SDL", "onDestroy()");
if (SDLActivity.mBrokenLibraries) {
super.onDestroy();
// Reset everything in case the user re opens the app
SDLActivity.initialize();
return;
}
// Send a quit message to the application
SDLActivity.mExitCalledFromJava = true;
SDLActivity.nativeQuit();
@ -159,6 +257,11 @@ public class SDLActivity extends Activity {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (SDLActivity.mBrokenLibraries) {
return false;
}
int keyCode = event.getKeyCode();
// Ignore certain special keys so they're handled by Android
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
@ -207,6 +310,7 @@ public class SDLActivity extends Activity {
static final int COMMAND_CHANGE_TITLE = 1;
static final int COMMAND_UNUSED = 2;
static final int COMMAND_TEXTEDIT_HIDE = 3;
static final int COMMAND_SET_KEEP_SCREEN_ON = 5;
protected static final int COMMAND_USER = 0x8000;
@ -251,7 +355,18 @@ public class SDLActivity extends Activity {
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
}
break;
case COMMAND_SET_KEEP_SCREEN_ON:
{
Window window = ((Activity) context).getWindow();
if (window != null) {
if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
break;
}
default:
if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
Log.e(TAG, "error handling message, command is " + msg.arg1);
@ -272,7 +387,7 @@ public class SDLActivity extends Activity {
}
// C functions we call
public static native int nativeInit();
public static native int nativeInit(Object arguments);
public static native void nativeLowMemory();
public static native void nativeQuit();
public static native void nativePause();
@ -583,6 +698,211 @@ public class SDLActivity extends Activity {
return fileStream;
}
// Messagebox
/** Result of current messagebox. Also used for blocking the calling thread. */
protected final int[] messageboxSelection = new int[1];
/** Id of current dialog. */
protected int dialogs = 0;
/**
* This method is called by SDL using JNI.
* Shows the messagebox from UI thread and block calling thread.
* buttonFlags, buttonIds and buttonTexts must have same length.
* @param buttonFlags array containing flags for every button.
* @param buttonIds array containing id for every button.
* @param buttonTexts array containing text for every button.
* @param colors null for default or array of length 5 containing colors.
* @return button id or -1.
*/
public int messageboxShowMessageBox(
final int flags,
final String title,
final String message,
final int[] buttonFlags,
final int[] buttonIds,
final String[] buttonTexts,
final int[] colors) {
messageboxSelection[0] = -1;
// sanity checks
if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) {
return -1; // implementation broken
}
// collect arguments for Dialog
final Bundle args = new Bundle();
args.putInt("flags", flags);
args.putString("title", title);
args.putString("message", message);
args.putIntArray("buttonFlags", buttonFlags);
args.putIntArray("buttonIds", buttonIds);
args.putStringArray("buttonTexts", buttonTexts);
args.putIntArray("colors", colors);
// trigger Dialog creation on UI thread
runOnUiThread(new Runnable() {
@Override
public void run() {
showDialog(dialogs++, args);
}
});
// block the calling thread
synchronized (messageboxSelection) {
try {
messageboxSelection.wait();
} catch (InterruptedException ex) {
ex.printStackTrace();
return -1;
}
}
// return selected value
return messageboxSelection[0];
}
@Override
protected Dialog onCreateDialog(int ignore, Bundle args) {
// TODO set values from "flags" to messagebox dialog
// get colors
int[] colors = args.getIntArray("colors");
int backgroundColor;
int textColor;
int buttonBorderColor;
int buttonBackgroundColor;
int buttonSelectedColor;
if (colors != null) {
int i = -1;
backgroundColor = colors[++i];
textColor = colors[++i];
buttonBorderColor = colors[++i];
buttonBackgroundColor = colors[++i];
buttonSelectedColor = colors[++i];
} else {
backgroundColor = Color.TRANSPARENT;
textColor = Color.TRANSPARENT;
buttonBorderColor = Color.TRANSPARENT;
buttonBackgroundColor = Color.TRANSPARENT;
buttonSelectedColor = Color.TRANSPARENT;
}
// create dialog with title and a listener to wake up calling thread
final Dialog dialog = new Dialog(this);
dialog.setTitle(args.getString("title"));
dialog.setCancelable(false);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface unused) {
synchronized (messageboxSelection) {
messageboxSelection.notify();
}
}
});
// create text
TextView message = new TextView(this);
message.setGravity(Gravity.CENTER);
message.setText(args.getString("message"));
if (textColor != Color.TRANSPARENT) {
message.setTextColor(textColor);
}
// create buttons
int[] buttonFlags = args.getIntArray("buttonFlags");
int[] buttonIds = args.getIntArray("buttonIds");
String[] buttonTexts = args.getStringArray("buttonTexts");
final SparseArray<Button> mapping = new SparseArray<Button>();
LinearLayout buttons = new LinearLayout(this);
buttons.setOrientation(LinearLayout.HORIZONTAL);
buttons.setGravity(Gravity.CENTER);
for (int i = 0; i < buttonTexts.length; ++i) {
Button button = new Button(this);
final int id = buttonIds[i];
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
messageboxSelection[0] = id;
dialog.dismiss();
}
});
if (buttonFlags[i] != 0) {
// see SDL_messagebox.h
if ((buttonFlags[i] & 0x00000001) != 0) {
mapping.put(KeyEvent.KEYCODE_ENTER, button);
}
if ((buttonFlags[i] & 0x00000002) != 0) {
mapping.put(111, button); /* API 11: KeyEvent.KEYCODE_ESCAPE */
}
}
button.setText(buttonTexts[i]);
if (textColor != Color.TRANSPARENT) {
button.setTextColor(textColor);
}
if (buttonBorderColor != Color.TRANSPARENT) {
// TODO set color for border of messagebox button
}
if (buttonBackgroundColor != Color.TRANSPARENT) {
Drawable drawable = button.getBackground();
if (drawable == null) {
// setting the color this way removes the style
button.setBackgroundColor(buttonBackgroundColor);
} else {
// setting the color this way keeps the style (gradient, padding, etc.)
drawable.setColorFilter(buttonBackgroundColor, PorterDuff.Mode.MULTIPLY);
}
}
if (buttonSelectedColor != Color.TRANSPARENT) {
// TODO set color for selected messagebox button
}
buttons.addView(button);
}
// create content
LinearLayout content = new LinearLayout(this);
content.setOrientation(LinearLayout.VERTICAL);
content.addView(message);
content.addView(buttons);
if (backgroundColor != Color.TRANSPARENT) {
content.setBackgroundColor(backgroundColor);
}
// add content to dialog and return
dialog.setContentView(content);
dialog.setOnKeyListener(new Dialog.OnKeyListener() {
@Override
public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) {
Button button = mapping.get(keyCode);
if (button != null) {
if (event.getAction() == KeyEvent.ACTION_UP) {
button.performClick();
}
return true; // also for ignored actions
}
return false;
}
});
return dialog;
}
}
/**
@ -592,7 +912,7 @@ class SDLMain implements Runnable {
@Override
public void run() {
// Runs SDL_main()
SDLActivity.nativeInit();
SDLActivity.nativeInit(SDLActivity.mSingleton.getArguments());
//Log.v("SDL", "SDL thread terminated");
}
@ -733,16 +1053,16 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
// This is the entry point to the C app.
// Start up the C app thread and enable sensor input for the first time
SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread");
final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
enableSensor(Sensor.TYPE_ACCELEROMETER, true);
SDLActivity.mSDLThread.start();
sdlThread.start();
// Set up a listener thread to catch when the native thread ends
new Thread(new Runnable(){
SDLActivity.mSDLThread = new Thread(new Runnable(){
@Override
public void run(){
try {
SDLActivity.mSDLThread.join();
sdlThread.join();
}
catch(Exception e){}
finally{
@ -752,7 +1072,8 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
}
}
}
}).start();
});
SDLActivity.mSDLThread.start();
}
}

View file

@ -602,22 +602,33 @@ endmacro(CheckDirectFB)
# Requires:
# - n/a
macro(CheckMX6)
if(VIDEO_MX6)
macro(CheckVivante)
if(VIDEO_VIVANTE)
check_c_source_compiles("
#include <gc_vdk.h>
int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_VDK)
check_c_source_compiles("
#define LINUX
#define EGL_API_FB
#include <EGL/eglvivante.h>
int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL_VIVANTE)
if(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
set(HAVE_VIDEO_MX6 TRUE)
int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_EGL_FB)
if(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
set(HAVE_VIDEO_VIVANTE TRUE)
set(HAVE_SDL_VIDEO TRUE)
file(GLOB MX6_SOURCES ${SDL2_SOURCE_DIR}/src/video/mx6/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${MX6_SOURCES})
set(SDL_VIDEO_DRIVER_MX6 1)
endif(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
endif(VIDEO_MX6)
endmacro(CheckMX6)
file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
set(SDL_VIDEO_DRIVER_VIVANTE 1)
if(HAVE_VIDEO_VIVANTE_VDK)
set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
list(APPEND EXTRA_LIBS VDK VIVANTE)
else()
set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
list(APPEND EXTRA_LIBS EGL)
endif(HAVE_VIDEO_VIVANTE_VDK)
endif(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
endif(VIDEO_VIVANTE)
endmacro(CheckVivante)
# Requires:
# - nada

146
configure vendored
View file

@ -832,7 +832,7 @@ enable_video_x11_xrandr
enable_video_x11_scrnsaver
enable_video_x11_xshape
enable_video_x11_vm
enable_video_mx6
enable_video_vivante
enable_video_cocoa
enable_video_directfb
enable_directfb_shared
@ -841,6 +841,8 @@ enable_fusionsound_shared
enable_video_dummy
enable_video_opengl
enable_video_opengles
enable_video_opengles1
enable_video_opengles2
enable_libudev
enable_dbus
enable_ibus
@ -1562,7 +1564,7 @@ Optional Features:
--enable-video-x11-xshape
enable X11 XShape support [[default=yes]]
--enable-video-x11-vm use X11 VM extension for fullscreen [[default=yes]]
--enable-video-mx6 use Freescale i.MX6 video driver [[default=no]]
--enable-video-vivante use Vivante EGL video driver [[default=yes]]
--enable-video-cocoa use Cocoa video driver [[default=yes]]
--enable-video-directfb use DirectFB video driver [[default=no]]
--enable-directfb-shared
@ -1574,6 +1576,10 @@ Optional Features:
--enable-video-dummy use dummy video driver [[default=yes]]
--enable-video-opengl include OpenGL support [[default=yes]]
--enable-video-opengles include OpenGL ES support [[default=yes]]
--enable-video-opengles1
include OpenGL ES 1.1 support [[default=yes]]
--enable-video-opengles2
include OpenGL ES 2.0 support [[default=yes]]
--enable-libudev enable libudev support [[default=yes]]
--enable-dbus enable D-Bus support [[default=yes]]
--enable-ibus enable IBus support [[default=yes]]
@ -20593,22 +20599,51 @@ $as_echo "#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1" >>confdefs.h
fi
}
CheckMX6Video()
CheckVivanteVideo()
{
# Check whether --enable-video-mx6 was given.
if test "${enable_video_mx6+set}" = set; then :
enableval=$enable_video_mx6;
# Check whether --enable-video-vivante was given.
if test "${enable_video_vivante+set}" = set; then :
enableval=$enable_video_vivante;
else
enable_video_mx6=no
enable_video_vivante=yes
fi
if test x$enable_video = xyes -a x$enable_video_mx6 = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante GPU SDK" >&5
$as_echo_n "checking for Vivante GPU SDK... " >&6; }
have_viv_sdk=no
if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante VDK API" >&5
$as_echo_n "checking for Vivante VDK API... " >&6; }
have_vivante_vdk=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define LINUX
#define EGL_API_FB
#include <gc_vdk.h>
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_vivante_vdk=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_vdk" >&5
$as_echo "$have_vivante_vdk" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante FB API" >&5
$as_echo_n "checking for Vivante FB API... " >&6; }
have_vivante_egl=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define LINUX
#define EGL_API_FB
#include <EGL/eglvivante.h>
@ -20623,18 +20658,26 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_viv_sdk=yes
have_vivante_egl=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_viv_sdk" >&5
$as_echo "$have_viv_sdk" >&6; }
if test x$have_viv_sdk = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_egl" >&5
$as_echo "$have_vivante_egl" >&6; }
$as_echo "#define SDL_VIDEO_DRIVER_MX6 1" >>confdefs.h
if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
SOURCES="$SOURCES $srcdir/src/video/mx6/*.c"
SUMMARY_video="${SUMMARY_video} mx6"
$as_echo "#define SDL_VIDEO_DRIVER_VIVANTE 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
if test x$have_vivante_vdk = xyes; then
$as_echo "#define SDL_VIDEO_DRIVER_VIVANTE_VDK 1" >>confdefs.h
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
fi
SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
SUMMARY_video="${SUMMARY_video} vivante"
have_video=yes
fi
fi
@ -21083,6 +21126,20 @@ else
enable_video_opengles=yes
fi
# Check whether --enable-video-opengles1 was given.
if test "${enable_video_opengles1+set}" = set; then :
enableval=$enable_video_opengles1;
else
enable_video_opengles1=yes
fi
# Check whether --enable-video-opengles2 was given.
if test "${enable_video_opengles2+set}" = set; then :
enableval=$enable_video_opengles2;
else
enable_video_opengles2=yes
fi
CheckOpenGLESX11()
{
@ -21093,9 +21150,10 @@ $as_echo_n "checking for EGL support... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define EGL_API_FB
#include <EGL/egl.h>
#include <EGL/eglext.h>
#define LINUX
#define EGL_API_FB
#include <EGL/egl.h>
#include <EGL/eglext.h>
int
main ()
@ -21120,14 +21178,15 @@ $as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5
if test x$enable_video_opengles1 = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5
$as_echo_n "checking for OpenGL ES v1 headers... " >&6; }
video_opengles_v1=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
video_opengles_v1=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
int
main ()
@ -21140,30 +21199,32 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
video_opengles_v1=yes
video_opengles_v1=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5
$as_echo "$video_opengles_v1" >&6; }
if test x$video_opengles_v1 = xyes; then
if test x$video_opengles_v1 = xyes; then
$as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h
$as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h
SUMMARY_video="${SUMMARY_video} opengl_es1"
SUMMARY_video="${SUMMARY_video} opengl_es1"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5
if test x$enable_video_opengles2 = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5
$as_echo_n "checking for OpenGL ES v2 headers... " >&6; }
video_opengles_v2=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
video_opengles_v2=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
int
main ()
@ -21176,20 +21237,21 @@ main ()
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
video_opengles_v2=yes
video_opengles_v2=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5
$as_echo "$video_opengles_v2" >&6; }
if test x$video_opengles_v2 = xyes; then
if test x$video_opengles_v2 = xyes; then
$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h
$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
SUMMARY_video="${SUMMARY_video} opengl_es2"
SUMMARY_video="${SUMMARY_video} opengl_es2"
fi
fi
fi
}
@ -21657,10 +21719,10 @@ else
fi
case "$host" in
*-*-androideabi*)
*-*-androideabi*)
pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
pthread_lib=""
;;
;;
*-*-linux*|*-*-uclinux*)
pthread_cflags="-D_REENTRANT"
pthread_lib="-lpthread"
@ -22868,7 +22930,7 @@ case "$host" in
CheckClockGettime
CheckLinuxVersion
CheckRPATH
CheckMX6Video
CheckVivanteVideo
# Set up files for the audio library
if test x$enable_audio = xyes; then
case $ARCH in

View file

@ -1729,27 +1729,46 @@ AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[d
fi
}
dnl Set up the MX6 video driver if enabled
CheckMX6Video()
dnl Set up the Vivante video driver if enabled
CheckVivanteVideo()
{
AC_ARG_ENABLE(video-mx6,
AC_HELP_STRING([--enable-video-mx6], [use Freescale i.MX6 video driver [[default=no]]]),
, enable_video_mx6=no)
if test x$enable_video = xyes -a x$enable_video_mx6 = xyes; then
AC_MSG_CHECKING(for Vivante GPU SDK)
have_viv_sdk=no
AC_ARG_ENABLE(video-vivante,
AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
, enable_video_vivante=yes)
if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
AC_MSG_CHECKING(for Vivante VDK API)
have_vivante_vdk=no
AC_TRY_COMPILE([
#define LINUX
#define EGL_API_FB
#include <gc_vdk.h>
],[
],[
have_vivante_vdk=yes
])
AC_MSG_RESULT($have_vivante_vdk)
AC_MSG_CHECKING(for Vivante FB API)
have_vivante_egl=no
AC_TRY_COMPILE([
#define LINUX
#define EGL_API_FB
#include <EGL/eglvivante.h>
],[
],[
have_viv_sdk=yes
have_vivante_egl=yes
])
AC_MSG_RESULT($have_viv_sdk)
if test x$have_viv_sdk = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_MX6, 1, [ ])
SOURCES="$SOURCES $srcdir/src/video/mx6/*.c"
SUMMARY_video="${SUMMARY_video} mx6"
AC_MSG_RESULT($have_vivante_egl)
if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
if test x$have_vivante_vdk = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
fi
SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
SUMMARY_video="${SUMMARY_video} vivante"
have_video=yes
fi
fi
@ -1973,6 +1992,12 @@ dnl Check to see if OpenGL ES support is desired
AC_ARG_ENABLE(video-opengles,
AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
, enable_video_opengles=yes)
AC_ARG_ENABLE(video-opengles1,
AC_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]),
, enable_video_opengles1=yes)
AC_ARG_ENABLE(video-opengles2,
AC_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
, enable_video_opengles2=yes)
dnl Find OpenGL ES
CheckOpenGLESX11()
@ -1981,9 +2006,10 @@ CheckOpenGLESX11()
AC_MSG_CHECKING(for EGL support)
video_opengl_egl=no
AC_TRY_COMPILE([
#define EGL_API_FB
#include <EGL/egl.h>
#include <EGL/eglext.h>
#define LINUX
#define EGL_API_FB
#include <EGL/egl.h>
#include <EGL/eglext.h>
],[
],[
video_opengl_egl=yes
@ -1993,36 +2019,40 @@ CheckOpenGLESX11()
AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
fi
AC_MSG_CHECKING(for OpenGL ES v1 headers)
video_opengles_v1=no
AC_TRY_COMPILE([
#include <GLES/gl.h>
#include <GLES/glext.h>
],[
],[
video_opengles_v1=yes
])
AC_MSG_RESULT($video_opengles_v1)
if test x$video_opengles_v1 = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
SUMMARY_video="${SUMMARY_video} opengl_es1"
if test x$enable_video_opengles1 = xyes; then
AC_MSG_CHECKING(for OpenGL ES v1 headers)
video_opengles_v1=no
AC_TRY_COMPILE([
#include <GLES/gl.h>
#include <GLES/glext.h>
],[
],[
video_opengles_v1=yes
])
AC_MSG_RESULT($video_opengles_v1)
if test x$video_opengles_v1 = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
SUMMARY_video="${SUMMARY_video} opengl_es1"
fi
fi
AC_MSG_CHECKING(for OpenGL ES v2 headers)
video_opengles_v2=no
AC_TRY_COMPILE([
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
],[
],[
video_opengles_v2=yes
])
AC_MSG_RESULT($video_opengles_v2)
if test x$video_opengles_v2 = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
SUMMARY_video="${SUMMARY_video} opengl_es2"
if test x$enable_video_opengles2 = xyes; then
AC_MSG_CHECKING(for OpenGL ES v2 headers)
video_opengles_v2=no
AC_TRY_COMPILE([
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
],[
],[
video_opengles_v2=yes
])
AC_MSG_RESULT($video_opengles_v2)
if test x$video_opengles_v2 = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
SUMMARY_video="${SUMMARY_video} opengl_es2"
fi
fi
fi
}
@ -2258,10 +2288,10 @@ AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[def
AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
, enable_pthread_sem=yes)
case "$host" in
*-*-androideabi*)
*-*-androideabi*)
pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
pthread_lib=""
;;
;;
*-*-linux*|*-*-uclinux*)
pthread_cflags="-D_REENTRANT"
pthread_lib="-lpthread"
@ -2836,7 +2866,7 @@ case "$host" in
CheckClockGettime
CheckLinuxVersion
CheckRPATH
CheckMX6Video
CheckVivanteVideo
# Set up files for the audio library
if test x$enable_audio = xyes; then
case $ARCH in

View file

@ -150,6 +150,23 @@ this determining the CAPS LOCK behavior:
sudo dpkg-reconfigure locales
================================================================================
OpenGL problems
================================================================================
If you have desktop OpenGL headers installed at build time in your RPi or cross
compilation environment, support for it will be built in. However, the chipset
does not actually have support for it, which causes issues in certain SDL apps
since the presence of OpenGL support supersedes the ES/ES2 variants.
The workaround is to disable OpenGL at configuration time:
./configure --disable-video-opengl
Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
environment variable:
export SDL_RENDER_DRIVER=opengles2
================================================================================
Notes
================================================================================

View file

@ -1,44 +1,369 @@
WinRT
================================================================================
=====
SDL/WinRT layer allows SDL2-based applications to run on many of Microsoft's
platforms that utilize the "Windows Runtime" (aka "WinRT") APIs. WinRT apps
are currently always full-screen apps, run in what Microsoft calls their
"Modern" environment (aka. "Metro"), and are distributed via Microsoft-run
online stores. Some of the operating systems that support such apps include:
This port allows SDL applications to run on Microsoft's platforms that require
use of "Windows Runtime", aka. "WinRT", APIs. WinRT apps are currently
full-screen only, and run in what Microsoft sometimes refers to as their
"Modern" (formerly, "Metro"), environment. For Windows 8.x, Microsoft may also
refer to them as "Windows Store" apps, due to them being distributed,
primarily, via a Microsoft-run online store (of the same name).
Some of the operating systems that include WinRT, are:
* Windows 8.x
* Windows RT 8.x (aka. Windows 8.x for ARM processors)
* Windows Phone 8.x
To note, WinRT applications that run on Windows 8.x and/or Windows RT are often
called "Windows Store" apps.
--------------------------------------------------------------------------------
Requirements
--------------------------------------------------------------------------------
- Microsoft Visual C++ 2012 -- Free, "Express" editions may be used, so long
as they include support for either "Windows Store" or "Windows Phone" apps.
(NOTE: MSVC 2013 support is pending. 2012 projects may be converted to 2013
projects by MSVC, in the meantime.)
- A valid Microsoft account -- This requirement is not imposed by SDL, but
rather by Microsoft's Visual C++ toolchain.
------------
* Microsoft Visual C++ (aka Visual Studio), either 2013 or 2012 versions
- Free, "Express" editions may be used, so long as they include support for
either "Windows Store" or "Windows Phone" apps. Versions marked as
supporting "Windows Desktop" development typically do not include support
for creating WinRT apps.
- Visual C++ 2012 can only build apps that target versions 8.0 of Windows, or
Windows Phone. 8.0-targetted apps will still run on devices running
8.1 editions of Windows, however they will not be able to take advantage of
8.1-specific features.
- Visual C++ 2013 can only create app projects that target 8.1 versions
of Windows, which do NOT run on 8.0 devices. An optional Visual Studio
add-in, "Tools for Maintaining Store apps for Windows 8", allows projects
that are created with Visual C++ 2012, which can create Windows 8.0 apps,
to be loaded and built with non-Express editions of Visual C++ 2013. More
details on targeting different versions of Windows can found at the
following web pages:
- [Develop apps by using Visual Studio 2013](http://msdn.microsoft.com/en-us/library/windows/apps/br211384.aspx)
- [To add the Tools for Maintaining Store apps for Windows 8](http://msdn.microsoft.com/en-us/library/windows/apps/dn263114.aspx#AddMaintenanceTools)
* A valid Microsoft account - This requirement is not imposed by SDL, but
rather by Microsoft's Visual C++ toolchain. This is required to launch or
debug apps.
Setup, High-Level Steps
-----------------------
The steps for setting up a project for an SDL/WinRT app looks like the
following, at a high-level:
1. create a new Visual C++ project using Microsoft's template for a,
"Direct3D App".
2. remove most of the files from the project.
3. make your app's project directly reference SDL/WinRT's own Visual C++
project file, via use of Visual C++'s "References" dialog. This will setup
the linker, and will copy SDL's .dll files to your app's final output.
4. adjust your app's build settings, at minimum, telling it where to find SDL's
header files.
5. add a file that contains a WinRT-appropriate main function.
6. add SDL-specific app code.
7. build and run your app.
Setup, Detailed Steps
---------------------
### 1. Create a new project ###
Create a new project using one of Visual C++'s templates for a plain, non-XAML,
"Direct3D App" (XAML support for SDL/WinRT is not yet ready for use). If you
don't see one of these templates, in Visual C++'s 'New Project' dialog, try
using the textbox titled, 'Search Installed Templates' to look for one.
### 2. Remove unneeded files from the project ###
In the new project, delete any file that has one of the following extensions:
- .cpp
- .h
- .hlsl
When you are done, you should be left with a few files, each of which will be a
necessary part of your app's project. These files will consist of:
- an .appxmanifest file, which contains metadata on your WinRT app. This is
similar to an Info.plist file on iOS, or an AndroidManifest.xml on Android.
- a few .png files, one of which is a splash screen (displayed when your app
launches), others are app icons.
- a .pfx file, used for code signing purposes.
### 3. Add references to SDL's project files ###
SDL/WinRT can be built in multiple variations, spanning across three different
CPU architectures (x86, x64, and ARM) and two different configurations
(Debug and Release). WinRT and Visual C++ do not currently provide a means
for combining multiple variations of one library into a single file.
Furthermore, it does not provide an easy means for copying pre-built .dll files
into your app's final output (via Post-Build steps, for example). It does,
however, provide a system whereby an app can reference the MSVC projects of
libraries such that, when the app is built:
1. each library gets built for the appropriate CPU architecture(s) and WinRT
platform(s).
2. each library's output, such as .dll files, get copied to the app's build
output.
To set this up for SDL/WinRT, you'll need to run through the following steps:
1. open up the Solution Explorer inside Visual C++ (under the "View" menu, then
"Solution Explorer")
2. right click on your app's solution.
3. navigate to "Add", then to "Existing Project..."
4. find SDL/WinRT's Visual C++ project file and open it. Different project
files exist for different WinRT platforms. All of them are in SDL's
source distribution, in the following directories:
* `VisualC-WinRT/WinPhone80_VS2012/` - for Windows Phone 8.0 apps
* `VisualC-WinRT/WinPhone81_VS2013/` - for Windows Phone 8.1 apps
* `VisualC-WinRT/WinRT80_VS2012/` - for Windows 8.0 apps
* `VisualC-WinRT/WinRT81_VS2013/` - for Windows 8.1 apps
5. once the project has been added, right-click on your app's project and
select, "References..."
6. click on the button titled, "Add New Reference..."
7. check the box next to SDL
8. click OK to close the dialog
9. SDL will now show up in the list of references. Click OK to close that
dialog.
Your project is now linked to SDL's project, insofar that when the app is
built, SDL will be built as well, with its build output getting included with
your app.
### 4. Adjust Your App's Build Settings ###
Some build settings need to be changed in your app's project. This guide will
outline the following:
- making sure that the compiler knows where to find SDL's header files
- **Optional for C++, but NECESSARY for compiling C code:** telling the
compiler not to use Microsoft's C++ extensions for WinRT development.
- **Optional:** telling the compiler not generate errors due to missing
precompiled header files.
To change these settings:
1. right-click on the project
2. choose "Properties"
3. in the drop-down box next to "Configuration", choose, "All Configurations"
4. in the drop-down box next to "Platform", choose, "All Platforms"
5. in the left-hand list, expand the "C/C++" section
6. select "General"
7. edit the "Additional Include Directories" setting, and add a path to SDL's
"include" directory
8. **Optional: to enable compilation of C code:** change the setting for
"Consume Windows Runtime Extension" from "Yes (/ZW)" to "No". If you're
working with a completely C++ based project, this step can usually be
omitted.
9. **Optional: to disable precompiled headers (which can produce
'stdafx.h'-related build errors, if setup incorrectly:** in the left-hand
list, select "Precompiled Headers", then change the setting for "Precompiled
Header" from "Use (/Yu)" to "Not Using Precompiled Headers".
10. close the dialog, saving settings, by clicking the "OK" button
### 5. Add a WinRT-appropriate main function to the app. ###
C/C++-based WinRT apps do contain a `main` function that the OS will invoke when
the app starts launching. The parameters of WinRT main functions are different
than those found on other platforms, Win32 included. SDL/WinRT provides a
platform-appropriate main function that will perform these actions, setup key
portions of the app, then invoke a classic, C/C++-style main function (that take
in "argc" and "argv" parameters). The code for this file is contained inside
SDL's source distribution, under `src/main/winrt/SDL_winrt_main_NonXAML.cpp`.
You'll need to add this file, or a copy of it, to your app's project, and make
sure it gets compiled using a Microsoft-specific set of C++ extensions called
C++/CX.
**NOTE: C++/CX compilation is currently required in at least one file of your
app's project. This is to make sure that Visual C++'s linker builds a 'Windows
Metadata' file (.winmd) for your app. Not doing so can lead to build errors.**
To include `SDL_winrt_main_NonXAML.cpp`:
1. right-click on your project (again, in Visual C++'s Solution Explorer),
navigate to "Add", then choose "Existing Item...".
2. open `SDL_winrt_main_NonXAML.cpp`, which is found inside SDL's source
distribution, under `src/main/winrt/`. Make sure that the open-file dialog
closes, either by double-clicking on the file, or single-clicking on it and
then clicking Add.
3. right-click on the file (as listed in your project), then click on
"Properties...".
4. in the drop-down box next to "Configuration", choose, "All Configurations"
5. in the drop-down box next to "Platform", choose, "All Platforms"
6. in the left-hand list, click on "C/C++"
7. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)".
8. click the OK button. This will close the dialog.
### 6. Add app code and assets ###
At this point, you can add in SDL-specific source code. Be sure to include a
C-style main function (ie: `int main(int argc, char *argv[])`). From there you
should be able to create a single `SDL_Window` (WinRT apps can only have one
window, at present), as well as an `SDL_Renderer`. Direct3D will be used to
draw content. Events are received via SDL's usual event functions
(`SDL_PollEvent`, etc.) If you have a set of existing source files and assets,
you can start adding them to the project now. If not, or if you would like to
make sure that you're setup correctly, some short and simple sample code is
provided below.
#### 6.A. ... when creating a new app ####
If you are creating a new app (rather than porting an existing SDL-based app),
or if you would just like a simple app to test SDL/WinRT with before trying to
get existing code working, some working SDL/WinRT code is provided below. To
set this up:
1. right click on your app's project
2. select Add, then New Item. An "Add New Item" dialog will show up.
3. from the left-hand list, choose "Visual C++"
4. from the middle/main list, choose "C++ File (.cpp)"
5. near the bottom of the dialog, next to "Name:", type in a name for your
source file, such as, "main.cpp".
6. click on the Add button. This will close the dialog, add the new file to
your project, and open the file in Visual C++'s text editor.
7. Copy and paste the following code into the new file, then save it.
#include <SDL.h>
int main(int argc, char **argv)
{
SDL_DisplayMode mode;
SDL_Window * window = NULL;
SDL_Renderer * renderer = NULL;
SDL_Event evt;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
return 1;
}
if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
return 1;
}
if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
return 1;
}
while (1) {
while (SDL_PollEvent(&evt)) {
}
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
}
#### 6.B. Adding code and assets ####
If you have existing code and assets that you'd like to add, you should be able
to add them now. The process for adding a set of files is as such.
1. right click on the app's project
2. select Add, then click on "New Item..."
3. open any source, header, or asset files as appropriate. Support for C and
C++ is available.
Do note that WinRT only supports a subset of the APIs that are available to
Win32-based apps. Many portions of the Win32 API and the C runtime are not
available.
A list of unsupported C APIs can be found at
<http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx>
General information on using the C runtime in WinRT can be found at
<http://msdn.microsoft.com/en-us/LIBRARY/hh972425(v=vs.110).aspx>
A list of supported Win32 APIs for Windows 8/RT apps can be found at
<http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx>. To note,
the list of supported Win32 APIs for Windows Phone 8 development is different.
That list can be found at
<http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662956(v=vs.105).aspx>
### 7. Build and run your app ###
Your app project should now be setup, and you should be ready to build your app.
To run it on the local machine, open the Debug menu and choose "Start
Debugging". This will build your app, then run your app full-screen. To switch
out of your app, press the Windows key. Alternatively, you can choose to run
your app in a window. To do this, before building and running your app, find
the drop-down menu in Visual C++'s toolbar that says, "Local Machine". Expand
this by clicking on the arrow on the right side of the list, then click on
Simulator. Once you do that, any time you build and run the app, the app will
launch in window, rather than full-screen.
#### 7.A. Running apps on ARM-based devices ####
To build and run the app on ARM-based, "Windows RT" devices, you'll need to:
- install Microsoft's "Remote Debugger" on the device. Visual C++ installs and
debugs ARM-based apps via IP networks.
- change a few options on the development machine, both to make sure it builds
for ARM (rather than x86 or x64), and to make sure it knows how to find the
Windows RT device (on the network).
Microsoft's Remote Debugger can be found at
<http://msdn.microsoft.com/en-us/library/vstudio/bt727f1t.aspx>. Please note
that separate versions of this debugger exist for different versions of Visual
C++, one for debugging with MSVC 2012, another for debugging with MSVC 2013.
To setup Visual C++ to launch your app on an ARM device:
1. make sure the Remote Debugger is running on your ARM device, and that it's on
the same IP network as your development machine.
2. from Visual C++'s toolbar, find a drop-down menu that says, "Win32". Click
it, then change the value to "ARM".
3. make sure Visual C++ knows the hostname or IP address of the ARM device. To
do this:
1. open the app project's properties
2. select "Debugging"
3. next to "Machine Name", enter the hostname or IP address of the ARM
device
4. if, and only if, you've turned off authentication in the Remote Debugger, then change the setting for "Require Authentication" to No
5. click "OK"
4. build and run the app (from Visual C++). The first time you do this, a
prompt will show up on the ARM device, asking for a Microsoft Account. You
do, unfortunately, need to log in here, and will need to follow the
subsequent registration steps in order to launch the app. After you do so,
if the app didn't already launch, try relaunching it again from within Visual
C++.
Troubleshooting
---------------
#### Build fails with message, "error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'"
Try adding the following to your linker flags. In MSVC, this can be done by
right-clicking on the app project, navigating to Configuration Properties ->
Linker -> Command Line, then adding them to the Additional Options
section.
* For Release builds / MSVC-Configurations, add:
/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib
* For Debug builds / MSVC-Configurations, add:
/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib
--------------------------------------------------------------------------------
TODO
--------------------------------------------------------------------------------
- Finish adding support for MSVC 2013, and "Universal" WinRT apps, which
support Windows 8.1, Windows Phone 8.1, and in the future, Xbox One and
Windows Desktop.
- Finish adding support for the SDL satellite libraries (SDL_image, SDL_mixer,
SDL_ttf, etc.)
----
- Document details of SDL satellite library support
- Make [NuGet](https://www.nuget.org) packages for SDL/WinRT
- Create templates for both MSVC 2012 and MSVC 2013, and have the corresponding
VSIX packages either include pre-built copies of SDL, or reference binaries
available via MSVC's NuGet servers
- Write setup instructions that use MSVC 201x templates
- Write setup instructions that don't use MSVC 201x templates, and use
MSVC project-to-project references, rather than pre-built binaries
- Write setup instructions that use MSVC 201x templates
- Write a list of caveats found in SDL/WinRT, such as APIs that don't work due
to platform restrictions, or things that need further work

View file

@ -264,7 +264,8 @@
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
#cmakedefine SDL_VIDEO_DRIVER_MX6 @SDL_VIDEO_DRIVER_MX6@
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
#if 0
/* !!! FIXME: in configure script version, missing here: */

View file

@ -308,7 +308,8 @@
#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
#undef SDL_VIDEO_DRIVER_NACL
#undef SDL_VIDEO_DRIVER_MX6
#undef SDL_VIDEO_DRIVER_VIVANTE
#undef SDL_VIDEO_DRIVER_VIVANTE_VDK
#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_D3D11

View file

@ -492,7 +492,7 @@ typedef struct SDL_HapticConstant
* over time. The type determines the shape of the wave and the parameters
* determine the dimensions of the wave.
*
* Phase is given by hundredth of a cycle meaning that giving the phase a value
* Phase is given by hundredth of a degree meaning that giving the phase a value
* of 9000 will displace it 25% of its period. Here are sample values:
* - 0: No phase displacement.
* - 9000: Displaced 25% of its period.
@ -553,9 +553,9 @@ typedef struct SDL_HapticPeriodic
/* Periodic */
Uint16 period; /**< Period of the wave. */
Sint16 magnitude; /**< Peak value. */
Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */
Sint16 offset; /**< Mean value of the wave. */
Uint16 phase; /**< Horizontal shift given by hundredth of a cycle. */
Uint16 phase; /**< Horizontal shift given by hundredth of a degree. */
/* Envelope */
Uint16 attack_length; /**< Duration of the attack. */

View file

@ -440,11 +440,54 @@ extern "C" {
*/
#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_WINRT_PRIVACY_POLICY_LABEL"
/** \brief If set to "1", back button press events on Windows Phone 8+ will be marked as handled.
/** \brief Allows back-button-press events on Windows Phone to be marked as handled
*
* TODO, WinRT: document SDL_HINT_WINRT_HANDLE_BACK_BUTTON need and use
* For now, more details on why this is needed can be found at the
* beginning of the following web page:
* Windows Phone devices typically feature a Back button. When pressed,
* the OS will emit back-button-press events, which apps are expected to
* handle in an appropriate manner. If apps do not explicitly mark these
* events as 'Handled', then the OS will invoke its default behavior for
* unhandled back-button-press events, which on Windows Phone 8 and 8.1 is to
* terminate the app (and attempt to switch to the previous app, or to the
* device's home screen).
*
* Setting the SDL_HINT_WINRT_HANDLE_BACK_BUTTON hint to "1" will cause SDL
* to mark back-button-press events as Handled, if and when one is sent to
* the app.
*
* Internally, Windows Phone sends back button events as parameters to
* special back-button-press callback functions. Apps that need to respond
* to back-button-press events are expected to register one or more
* callback functions for such, shortly after being launched (during the
* app's initialization phase). After the back button is pressed, the OS
* will invoke these callbacks. If the app's callback(s) do not explicitly
* mark the event as handled by the time they return, or if the app never
* registers one of these callback, the OS will consider the event
* un-handled, and it will apply its default back button behavior (terminate
* the app).
*
* SDL registers its own back-button-press callback with the Windows Phone
* OS. This callback will emit a pair of SDL key-press events (SDL_KEYDOWN
* and SDL_KEYUP), each with a scancode of SDL_SCANCODE_AC_BACK, after which
* it will check the contents of the hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON.
* If the hint's value is set to "1", the back button event's Handled
* property will get set to 'true'. If the hint's value is set to something
* else, or if it is unset, SDL will leave the event's Handled property
* alone. (By default, the OS sets this property to 'false', to note.)
*
* SDL apps can either set SDL_HINT_WINRT_HANDLE_BACK_BUTTON well before a
* back button is pressed, or can set it in direct-response to a back button
* being pressed.
*
* In order to get notified when a back button is pressed, SDL apps should
* register a callback function with SDL_AddEventWatch(), and have it listen
* for SDL_KEYDOWN events that have a scancode of SDL_SCANCODE_AC_BACK.
* (Alternatively, SDL_KEYUP events can be listened-for. Listening for
* either event type is suitable.) Any value of SDL_HINT_WINRT_HANDLE_BACK_BUTTON
* set by such a callback, will be applied to the OS' current
* back-button-press event.
*
* More details on back button behavior in Windows Phone apps can be found
* at the following page, on Microsoft's developer site:
* http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx
*/
#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON"

View file

@ -552,7 +552,7 @@ extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
SDL_Rect * rect);
/**
* \brief Get wether clipping is enabled on the given renderer
* \brief Get whether clipping is enabled on the given renderer.
*
* \param renderer The renderer from which clip state should be queried.
*

View file

@ -152,6 +152,10 @@ struct SDL_SysWMmsg
#if defined(SDL_VIDEO_DRIVER_COCOA)
struct
{
/* Latest version of Xcode clang complains about empty structs in C v. C++:
error: empty struct has size 0 in C, size 1 in C++
*/
int dummy;
/* No Cocoa window events yet */
} cocoa;
#endif

View file

@ -32,7 +32,7 @@
#include <android/log.h>
static void * audioDevice;
static SDL_AudioDevice* audioDevice = NULL;
static int
AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
@ -50,6 +50,11 @@ AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
audioDevice = this;
this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
test_format = SDL_FirstAudioFormat(this->spec.format);
while (test_format != 0) { /* no "UNKNOWN" constant */
if ((test_format == AUDIO_U8) || (test_format == AUDIO_S16LSB)) {
@ -110,6 +115,10 @@ AndroidAUD_CloseDevice(_THIS)
Android_JNI_CloseAudioDevice();
if (audioDevice == this) {
if (audioDevice->hidden != NULL) {
SDL_free(this->hidden);
this->hidden = NULL;
}
audioDevice = NULL;
}
}
@ -135,6 +144,41 @@ AudioBootStrap ANDROIDAUD_bootstrap = {
"android", "SDL Android audio driver", AndroidAUD_Init, 0
};
/* Pause (block) all non already paused audio devices by taking their mixer lock */
void AndroidAUD_PauseDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if(audioDevice != NULL && audioDevice->hidden != NULL) {
private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
if (audioDevice->paused) {
/* The device is already paused, leave it alone */
private->resume = SDL_FALSE;
}
else {
SDL_LockMutex(audioDevice->mixer_lock);
audioDevice->paused = SDL_TRUE;
private->resume = SDL_TRUE;
}
}
}
/* Resume (unblock) all non already paused audio devices by releasing their mixer lock */
void AndroidAUD_ResumeDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if(audioDevice != NULL && audioDevice->hidden != NULL) {
private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
if (private->resume) {
audioDevice->paused = SDL_FALSE;
private->resume = SDL_FALSE;
SDL_UnlockMutex(audioDevice->mixer_lock);
}
}
}
#endif /* SDL_AUDIO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -30,6 +30,8 @@
struct SDL_PrivateAudioData
{
/* Resume device if it was paused automatically */
int resume;
};
static void AndroidAUD_CloseDevice(_THIS);

View file

@ -1302,6 +1302,9 @@ void Android_JNI_PollInputDevices()
(*env)->CallStaticVoidMethod(env, mActivityClass, midPollInputDevices);
}
/* See SDLActivity.java for constants. */
#define COMMAND_SET_KEEP_SCREEN_ON 5
/* sends message to be handled on the UI event dispatch thread */
int Android_JNI_SendMessage(int command, int param)
{
@ -1317,6 +1320,11 @@ int Android_JNI_SendMessage(int command, int param)
return success ? 0 : -1;
}
void Android_JNI_SuspendScreenSaver(SDL_bool suspend)
{
Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
}
void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
{
JNIEnv *env = Android_JNI_GetEnv();
@ -1342,6 +1350,85 @@ void Android_JNI_HideTextInput()
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
}
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
JNIEnv *env;
jmethodID mid;
jobject context;
jstring title;
jstring message;
jintArray button_flags;
jintArray button_ids;
jobjectArray button_texts;
jintArray colors;
jint temp;
int i;
env = Android_JNI_GetEnv();
/* convert parameters */
title = (*env)->NewStringUTF(env, messageboxdata->title);
message = (*env)->NewStringUTF(env, messageboxdata->message);
button_flags = (*env)->NewIntArray(env, messageboxdata->numbuttons);
button_ids = (*env)->NewIntArray(env, messageboxdata->numbuttons);
button_texts = (*env)->NewObjectArray(env, messageboxdata->numbuttons,
(*env)->FindClass(env, "java/lang/String"), NULL);
for (i = 0; i < messageboxdata->numbuttons; ++i) {
temp = messageboxdata->buttons[i].flags;
(*env)->SetIntArrayRegion(env, button_flags, i, 1, &temp);
temp = messageboxdata->buttons[i].buttonid;
(*env)->SetIntArrayRegion(env, button_ids, i, 1, &temp);
(*env)->SetObjectArrayElement(env, button_texts, i, (*env)->NewStringUTF(env, messageboxdata->buttons[i].text));
}
if (messageboxdata->colorScheme) {
colors = (*env)->NewIntArray(env, SDL_MESSAGEBOX_COLOR_MAX);
for (i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; ++i) {
temp = (0xFF << 24) |
(messageboxdata->colorScheme->colors[i].r << 16) |
(messageboxdata->colorScheme->colors[i].g << 8) |
(messageboxdata->colorScheme->colors[i].b << 0);
(*env)->SetIntArrayRegion(env, colors, i, 1, &temp);
}
} else {
colors = NULL;
}
/* call function */
mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;");
context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid);
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
"messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I");
*buttonid = (*env)->CallIntMethod(env, context, mid,
messageboxdata->flags,
title,
message,
button_flags,
button_ids,
button_texts,
colors);
/* delete parameters */
(*env)->DeleteLocalRef(env, title);
(*env)->DeleteLocalRef(env, message);
(*env)->DeleteLocalRef(env, button_flags);
(*env)->DeleteLocalRef(env, button_ids);
for (i = 0; i < messageboxdata->numbuttons; ++i) {
(*env)->DeleteLocalRef(env, (*env)->GetObjectArrayElement(env, button_texts, i));
(*env)->SetObjectArrayElement(env, button_texts, i, NULL);
}
(*env)->DeleteLocalRef(env, button_texts);
(*env)->DeleteLocalRef(env, colors);
return 0;
}
/*
//////////////////////////////////////////////////////////////////////////////
//

View file

@ -68,6 +68,8 @@ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seco
/* Joystick support */
void Android_JNI_PollInputDevices();
/* Video */
void Android_JNI_SuspendScreenSaver(SDL_bool suspend);
/* Touch support */
int Android_JNI_GetTouchDeviceIds(int **ids);

View file

@ -584,6 +584,10 @@ SDL_EVDEV_Poll(void)
Uint32 kval;
#endif
if (!_this) {
return;
}
#if SDL_USE_LIBUDEV
SDL_UDEV_Poll();
#endif

View file

@ -25,18 +25,19 @@
* udevadm info --query=all -n input/event3 (for a keyboard, mouse, etc)
* udevadm info --query=property -n input/event2
*/
#include "SDL_udev.h"
#ifdef SDL_USE_LIBUDEV
#include <linux/input.h>
#include "SDL.h"
static char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
#define _THIS SDL_UDEV_PrivateData *_this
static _THIS = NULL;
#include "SDL.h"
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr);
static int SDL_UDEV_load_syms(void);
static SDL_bool SDL_UDEV_hotplug_update_available(void);
@ -64,7 +65,9 @@ SDL_UDEV_load_syms(void)
SDL_UDEV_SYM(udev_device_get_action);
SDL_UDEV_SYM(udev_device_get_devnode);
SDL_UDEV_SYM(udev_device_get_subsystem);
SDL_UDEV_SYM(udev_device_get_parent_with_subsystem_devtype);
SDL_UDEV_SYM(udev_device_get_property_value);
SDL_UDEV_SYM(udev_device_get_sysattr_value);
SDL_UDEV_SYM(udev_device_new_from_syspath);
SDL_UDEV_SYM(udev_device_unref);
SDL_UDEV_SYM(udev_enumerate_add_match_property);
@ -274,6 +277,109 @@ SDL_UDEV_LoadLibrary(void)
return retval;
}
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
#define BIT(x) (1UL<<OFF(x))
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len)
{
const char *value;
char text[4096];
char *word;
int i;
unsigned long v;
SDL_memset(bitmask, 0, bitmask_len*sizeof(*bitmask));
value = _this->udev_device_get_sysattr_value(pdev, attr);
if (!value) {
return;
}
SDL_strlcpy(text, value, sizeof(text));
i = 0;
while ((word = SDL_strrchr(text, ' ')) != NULL) {
v = SDL_strtoul(word+1, NULL, 16);
if (i < bitmask_len) {
bitmask[i] = v;
}
++i;
*word = '\0';
}
v = SDL_strtoul(text, NULL, 16);
if (i < bitmask_len) {
bitmask[i] = v;
}
}
static int
guess_device_class(struct udev_device *dev)
{
int devclass = 0;
struct udev_device *pdev;
unsigned long bitmask_ev[NBITS(EV_MAX)];
unsigned long bitmask_abs[NBITS(ABS_MAX)];
unsigned long bitmask_key[NBITS(KEY_MAX)];
unsigned long bitmask_rel[NBITS(REL_MAX)];
unsigned long keyboard_mask;
/* walk up the parental chain until we find the real input device; the
* argument is very likely a subdevice of this, like eventN */
pdev = dev;
while (pdev && !_this->udev_device_get_sysattr_value(pdev, "capabilities/ev")) {
pdev = _this->udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);
}
if (!pdev) {
return 0;
}
get_caps(dev, pdev, "capabilities/ev", bitmask_ev, SDL_arraysize(bitmask_ev));
get_caps(dev, pdev, "capabilities/abs", bitmask_abs, SDL_arraysize(bitmask_abs));
get_caps(dev, pdev, "capabilities/rel", bitmask_rel, SDL_arraysize(bitmask_rel));
get_caps(dev, pdev, "capabilities/key", bitmask_key, SDL_arraysize(bitmask_key));
if (test_bit(EV_ABS, bitmask_ev) &&
test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
; /* ID_INPUT_TABLET */
} else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
; /* ID_INPUT_TOUCHPAD */
} else if (test_bit(BTN_MOUSE, bitmask_key)) {
devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
} else if (test_bit(BTN_TOUCH, bitmask_key)) {
; /* ID_INPUT_TOUCHSCREEN */
} else if (test_bit(BTN_TRIGGER, bitmask_key) ||
test_bit(BTN_A, bitmask_key) ||
test_bit(BTN_1, bitmask_key) ||
test_bit(ABS_RX, bitmask_abs) ||
test_bit(ABS_RY, bitmask_abs) ||
test_bit(ABS_RZ, bitmask_abs) ||
test_bit(ABS_THROTTLE, bitmask_abs) ||
test_bit(ABS_RUDDER, bitmask_abs) ||
test_bit(ABS_WHEEL, bitmask_abs) ||
test_bit(ABS_GAS, bitmask_abs) ||
test_bit(ABS_BRAKE, bitmask_abs)) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK; /* ID_INPUT_JOYSTICK */
}
}
if (test_bit(EV_REL, bitmask_ev) &&
test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) &&
test_bit(BTN_MOUSE, bitmask_key)) {
devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
}
/* the first 32 bits are ESC, numbers, and Q to D; if we have all of
* those, consider it a full keyboard; do not test KEY_RESERVED, though */
keyboard_mask = 0xFFFFFFFE;
if ((bitmask_key[0] & keyboard_mask) == keyboard_mask)
devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */
return devclass;
}
static void
device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
{
@ -292,6 +398,8 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
if (SDL_strcmp(subsystem, "sound") == 0) {
devclass = SDL_UDEV_DEVICE_SOUND;
} else if (SDL_strcmp(subsystem, "input") == 0) {
/* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
@ -302,13 +410,19 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
devclass |= SDL_UDEV_DEVICE_MOUSE;
}
val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
/* The undocumented rule is:
- All devices with keys get ID_INPUT_KEY
- From this subset, if they have ESC, numbers, and Q to D, it also gets ID_INPUT_KEYBOARD
Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
*/
val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEY");
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
devclass |= SDL_UDEV_DEVICE_KEYBOARD;
}
if (devclass == 0) {
// Fall back to old style input classes
/* Fall back to old style input classes */
val = _this->udev_device_get_property_value(dev, "ID_CLASS");
if (val != NULL) {
if (SDL_strcmp(val, "joystick") == 0) {
@ -321,7 +435,8 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
return;
}
} else {
return;
/* We could be linked with libudev on a system that doesn't have udev running */
devclass = guess_device_class(dev);
}
}
} else {

View file

@ -75,7 +75,9 @@ typedef struct SDL_UDEV_PrivateData
const char *(*udev_device_get_action)(struct udev_device *);
const char *(*udev_device_get_devnode)(struct udev_device *);
const char *(*udev_device_get_subsystem)(struct udev_device *);
struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);
const char *(*udev_device_get_property_value)(struct udev_device *, const char *);
const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);
struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);
void (*udev_device_unref)(struct udev_device *);
int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);

View file

@ -430,7 +430,9 @@ SDL_MouseQuit(void)
SDL_Cursor *cursor, *next;
SDL_Mouse *mouse = SDL_GetMouse();
SDL_CaptureMouse(SDL_FALSE);
if (mouse->CaptureMouse) {
SDL_CaptureMouse(SDL_FALSE);
}
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_ShowCursor(1);

View file

@ -23,6 +23,7 @@
#ifdef SDL_HAPTIC_IOKIT
#include "SDL_assert.h"
#include "SDL_stdinc.h"
#include "SDL_haptic.h"
#include "../SDL_syshaptic.h"
#include "SDL_joystick.h"
@ -872,9 +873,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
SDL_memset(periodic, 0, sizeof(FFPERIODIC));
/* Specifics */
periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
periodic->lOffset = CONVERT(hap_periodic->offset);
periodic->dwPhase = hap_periodic->phase;
periodic->dwPhase =
(hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000;
periodic->dwPeriod = hap_periodic->period * 1000;
dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
dest->lpvTypeSpecificParams = periodic;

View file

@ -21,6 +21,7 @@
#include "../../SDL_internal.h"
#include "SDL_error.h"
#include "SDL_stdinc.h"
#include "SDL_haptic.h"
#include "SDL_timer.h"
#include "SDL_windowshaptic_c.h"
@ -714,9 +715,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
SDL_memset(periodic, 0, sizeof(DIPERIODIC));
/* Specifics */
periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
periodic->lOffset = CONVERT(hap_periodic->offset);
periodic->dwPhase = hap_periodic->phase;
periodic->dwPhase =
(hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000;
periodic->dwPeriod = hap_periodic->period * 1000;
dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
dest->lpvTypeSpecificParams = periodic;

View file

@ -606,7 +606,7 @@ SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw)
if (freerw) {
SDL_RWclose(rw);
}
return SDL_SetError("Could allocate space to not read DB into memory");
return SDL_SetError("Could not allocate space to read DB into memory");
}
if (SDL_RWread(rw, buf, db_size, 1) != 1) {
@ -669,6 +669,10 @@ SDL_GameControllerAddMapping(const char *mappingString)
ControllerMapping_t *pControllerMapping;
SDL_bool is_xinput_mapping = SDL_FALSE;
if (!mappingString) {
return SDL_InvalidParamError("mappingString");
}
pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString);
if (!pchGUID) {
return SDL_SetError("Couldn't parse GUID from %s", mappingString);
@ -735,6 +739,10 @@ SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
/* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
pMappingString = SDL_malloc(needed);
if (!pMappingString) {
SDL_OutOfMemory();
return NULL;
}
SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
}
return pMappingString;
@ -746,6 +754,10 @@ SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
char *
SDL_GameControllerMapping(SDL_GameController * gamecontroller)
{
if (!gamecontroller) {
return NULL;
}
return SDL_GameControllerMappingForGUID(gamecontroller->mapping.guid);
}
@ -992,9 +1004,6 @@ SDL_GameControllerGetAttached(SDL_GameController * gamecontroller)
}
/*
* Get the number of multi-dimensional axis controls on a joystick
*/
const char *
SDL_GameControllerName(SDL_GameController * gamecontroller)
{
@ -1066,9 +1075,6 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameControll
}
/*
* Close a joystick previously opened with SDL_JoystickOpen()
*/
void
SDL_GameControllerClose(SDL_GameController * gamecontroller)
{

View file

@ -46,7 +46,9 @@
#include "../../events/SDL_events_c.h"
#endif
#include "../../core/windows/SDL_windows.h"
#if !defined(__WINRT__)
#include <dbt.h>
#endif
#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
#include "SDL_windowsjoystick_c.h"

View file

@ -17,22 +17,54 @@
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
/* Start up the SDL app */
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
{
/* This interface could expand with ABI negotiation, calbacks, etc. */
int i;
int argc;
int status;
/* This interface could expand with ABI negotiation, callbacks, etc. */
SDL_Android_Init(env, cls);
SDL_SetMainReady();
/* Run the application code! */
/* Prepare the arguments. */
int len = (*env)->GetArrayLength(env, array);
char* argv[1 + len + 1];
argc = 0;
/* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
*/
int status;
char *argv[2];
argv[0] = SDL_strdup("app_process");
argv[1] = NULL;
status = SDL_main(1, argv);
argv[argc++] = SDL_strdup("app_process");
for (i = 0; i < len; ++i) {
const char* utf;
char* arg = NULL;
jstring string = (*env)->GetObjectArrayElement(env, array, i);
if (string) {
utf = (*env)->GetStringUTFChars(env, string, 0);
if (utf) {
arg = SDL_strdup(utf);
(*env)->ReleaseStringUTFChars(env, string, utf);
}
}
if (!arg) {
arg = SDL_strdup("");
}
argv[argc++] = arg;
}
argv[argc] = NULL;
/* Run the application. */
status = SDL_main(argc, argv);
/* Release the arguments. */
for (i = 0; i < argc; ++i) {
SDL_free(argv[i]);
}
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
/* exit(status); */

View file

@ -1329,11 +1329,23 @@ D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
}
}
static int
D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
if (data->currentOffscreenRenderTargetView) {
return DXGI_MODE_ROTATION_IDENTITY;
} else {
return data->rotation;
}
}
static int
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
switch (data->rotation) {
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
outRect->left = sdlRect->x;
outRect->right = sdlRect->x + sdlRect->w;
@ -2151,6 +2163,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
SDL_FRect orientationAlignedViewport;
BOOL swapDimensions;
D3D11_VIEWPORT viewport;
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
if (renderer->viewport.w == 0 || renderer->viewport.h == 0) {
/* If the viewport is empty, assume that it is because
@ -2166,7 +2179,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
* default coordinate system) so rotations will be done in the opposite
* direction of the DXGI_MODE_ROTATION enumeration.
*/
switch (data->rotation) {
switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
projection = MatrixIdentity();
break;
@ -2217,7 +2230,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
* a landscape mode, for all Windows 8/RT devices, or a portrait mode,
* for Windows Phone devices.
*/
swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation);
swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation);
if (swapDimensions) {
orientationAlignedViewport.x = (float) renderer->viewport.y;
orientationAlignedViewport.y = (float) renderer->viewport.x;

View file

@ -38,7 +38,7 @@
#define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so"
#define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so"
#elif SDL_VIDEO_DRIVER_ANDROID
#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
/* Android */
#define DEFAULT_EGL "libEGL.so"
#define DEFAULT_OGL_ES2 "libGLESv2.so"
@ -62,7 +62,7 @@
#endif /* SDL_VIDEO_DRIVER_RPI */
#define LOAD_FUNC(NAME) \
*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
if (!_this->egl_data->NAME) \
{ \
return SDL_SetError("Could not retrieve EGL function " #NAME); \

View file

@ -391,8 +391,8 @@ extern VideoBootStrap Wayland_bootstrap;
#if SDL_VIDEO_DRIVER_NACL
extern VideoBootStrap NACL_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_MX6
extern VideoBootStrap MX6_bootstrap;
#if SDL_VIDEO_DRIVER_VIVANTE
extern VideoBootStrap VIVANTE_bootstrap;
#endif
extern SDL_VideoDevice *SDL_GetVideoDevice(void);

View file

@ -62,6 +62,12 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_MIR
&MIR_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_WAYLAND
&Wayland_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_VIVANTE
&VIVANTE_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DIRECTFB
&DirectFB_bootstrap,
#endif
@ -89,15 +95,9 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_RPI
&RPI_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_WAYLAND
&Wayland_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_NACL
&NACL_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_MX6
&MX6_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap,
#endif
@ -1339,6 +1339,10 @@ SDL_CreateWindowFrom(const void *data)
SDL_UninitializedVideo();
return NULL;
}
if (!_this->CreateWindowFrom) {
SDL_Unsupported();
return NULL;
}
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
if (!window) {
SDL_OutOfMemory();
@ -1356,8 +1360,7 @@ SDL_CreateWindowFrom(const void *data)
}
_this->windows = window;
if (!_this->CreateWindowFrom ||
_this->CreateWindowFrom(_this, window, data) < 0) {
if (_this->CreateWindowFrom(_this, window, data) < 0) {
SDL_DestroyWindow(window);
return NULL;
}
@ -3181,11 +3184,13 @@ SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info)
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
if (!info) {
SDL_InvalidParamError("info");
return SDL_FALSE;
}
info->subsystem = SDL_SYSWM_UNKNOWN;
if (!_this->GetWindowWMInfo) {
SDL_Unsupported();
return SDL_FALSE;
}
return (_this->GetWindowWMInfo(_this, window, info));
@ -3265,6 +3270,9 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
return SDL_FALSE;
}
#if SDL_VIDEO_DRIVER_ANDROID
#include "android/SDL_androidmessagebox.h"
#endif
#if SDL_VIDEO_DRIVER_WINDOWS
#include "windows/SDL_windowsmessagebox.h"
#endif
@ -3329,6 +3337,12 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
}
/* It's completely fine to call this function before video is initialized */
#if SDL_VIDEO_DRIVER_ANDROID
if (retval == -1 &&
Android_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_WINDOWS
if (retval == -1 &&
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) &&

View file

@ -29,8 +29,11 @@
#include "SDL_events.h"
#include "SDL_androidwindow.h"
void android_egl_context_backup();
void android_egl_context_restore();
void AndroidAUD_ResumeDevices(void);
void AndroidAUD_PauseDevices(void);
void
android_egl_context_restore()
@ -74,13 +77,14 @@ Android_PumpEvents(_THIS)
if (isPaused && !isPausing) {
/* Make sure this is the last thing we do before pausing */
android_egl_context_backup();
AndroidAUD_PauseDevices();
if(SDL_SemWait(Android_ResumeSem) == 0) {
#else
if (isPaused) {
if(SDL_SemTryWait(Android_ResumeSem) == 0) {
#endif
isPaused = 0;
AndroidAUD_ResumeDevices();
/* Restore the GL Context from here, as this operation is thread dependent */
if (!SDL_HasEvent(SDL_QUIT)) {
android_egl_context_restore();
@ -103,6 +107,7 @@ Android_PumpEvents(_THIS)
#else
if(SDL_SemTryWait(Android_PauseSem) == 0) {
android_egl_context_backup();
AndroidAUD_PauseDevices();
isPaused = 1;
}
#endif

View file

@ -263,6 +263,43 @@ static SDL_Scancode Android_Keycodes[] = {
SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */
SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_AUDIO_TRACK */
SDL_SCANCODE_SLEEP, /* AKEYCODE_SLEEP */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WAKEUP */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PAIRING */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_TOP_MENU */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_11 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_12 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LAST_CHANNEL */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_DATA_SERVICE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOICE_ASSIST */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_RADIO_SERVICE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TELETEXT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NUMBER_ENTRY */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_ANALOG */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_DIGITAL */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_BS */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_CS */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_SERVICE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NETWORK */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ANTENNA_CABLE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_1 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_2 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_3 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_4 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_1 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_2 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_1 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_2 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_VGA_1 */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ZOOM_MODE */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_CONTENTS_MENU */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */
SDL_SCANCODE_HELP, /* AKEYCODE_HELP */
};
static SDL_Scancode

View file

@ -0,0 +1,37 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#if SDL_VIDEO_DRIVER_ANDROID
#include "SDL_messagebox.h"
int
Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
return Android_JNI_ShowMessageBox(messageboxdata, buttonid);
}
#endif /* SDL_VIDEO_DRIVER_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -18,14 +18,12 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef _SDL_mx6events_c_h
#define _SDL_mx6events_c_h
#if SDL_VIDEO_DRIVER_ANDROID
#include "SDL_mx6video.h"
extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
void MX6_PumpEvents(_THIS);
void MX6_EventInit(_THIS);
void MX6_EventQuit(_THIS);
#endif /* SDL_VIDEO_DRIVER_ANDROID */
#endif /* _SDL_mx6events_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -75,6 +75,12 @@ Android_Available(void)
return 1;
}
static void
Android_SuspendScreenSaver(_THIS)
{
Android_JNI_SuspendScreenSaver(_this->suspend_screensaver);
}
static void
Android_DeleteDevice(SDL_VideoDevice * device)
{
@ -126,6 +132,9 @@ Android_CreateDevice(int devindex)
device->GL_SwapWindow = Android_GLES_SwapWindow;
device->GL_DeleteContext = Android_GLES_DeleteContext;
/* Screensaver */
device->SuspendScreenSaver = Android_SuspendScreenSaver;
/* Text input */
device->StartTextInput = Android_StartTextInput;
device->StopTextInput = Android_StopTextInput;

View file

@ -52,7 +52,7 @@
#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL)
/* GDI renderer implementation */
/* DirectFB renderer implementation */
static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window,
Uint32 flags);

View file

@ -238,7 +238,7 @@ DirectFB_VideoInit(_THIS)
if (!devdata->use_linux_input)
{
SDL_DFB_LOG("Disabling linxu input\n");
SDL_DFB_LOG("Disabling linux input\n");
DirectFBSetOption("disable-module", "linux_input");
}

View file

@ -26,7 +26,7 @@ SDL_MIR_SYM(MirDisplayConfiguration*,mir_connection_create_display_config,(MirCo
SDL_MIR_SYM(MirSurface *,mir_connection_create_surface_sync,(MirConnection *connection, MirSurfaceParameters const *params))
SDL_MIR_SYM(void,mir_connection_get_available_surface_formats,(MirConnection* connection, MirPixelFormat* formats, unsigned const int format_size, unsigned int *num_valid_formats))
SDL_MIR_SYM(MirEGLNativeDisplayType,mir_connection_get_egl_native_display,(MirConnection *connection))
SDL_MIR_SYM(int,mir_connection_is_valid,(MirConnection *connection))
SDL_MIR_SYM(MirBool,mir_connection_is_valid,(MirConnection *connection))
SDL_MIR_SYM(void,mir_connection_release,(MirConnection *connection))
SDL_MIR_SYM(MirConnection *,mir_connect_sync,(char const *server, char const *app_name))
SDL_MIR_SYM(void,mir_display_config_destroy,(MirDisplayConfiguration* display_configuration))
@ -34,10 +34,11 @@ SDL_MIR_SYM(MirEGLNativeWindowType,mir_surface_get_egl_native_window,(MirSurface
SDL_MIR_SYM(char const *,mir_surface_get_error_message,(MirSurface *surface))
SDL_MIR_SYM(void,mir_surface_get_graphics_region,(MirSurface *surface, MirGraphicsRegion *graphics_region))
SDL_MIR_SYM(void,mir_surface_get_parameters,(MirSurface *surface, MirSurfaceParameters *parameters))
SDL_MIR_SYM(int,mir_surface_is_valid,(MirSurface *surface))
SDL_MIR_SYM(MirBool,mir_surface_is_valid,(MirSurface *surface))
SDL_MIR_SYM(void,mir_surface_release_sync,(MirSurface *surface))
SDL_MIR_SYM(void,mir_surface_set_event_handler,(MirSurface *surface, MirEventDelegate const *event_handler))
SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_type,(MirSurface *surface, MirSurfaceType type))
SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_state,(MirSurface *surface, MirSurfaceState state))
SDL_MIR_SYM(void,mir_surface_swap_buffers_sync,(MirSurface *surface))
SDL_MIR_MODULE(XKBCOMMON)

View file

@ -186,9 +186,9 @@ MIR_SetWindowFullscreen(_THIS, SDL_Window* window,
return;
if (fullscreen) {
MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_fullscreen);
MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_fullscreen);
} else {
MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_restored);
MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_restored);
}
}
@ -200,7 +200,7 @@ MIR_MaximizeWindow(_THIS, SDL_Window* window)
if (IsSurfaceValid(mir_window) < 0)
return;
MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_maximized);
MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_maximized);
}
void
@ -211,7 +211,7 @@ MIR_MinimizeWindow(_THIS, SDL_Window* window)
if (IsSurfaceValid(mir_window) < 0)
return;
MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_minimized);
MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_minimized);
}
void
@ -222,7 +222,7 @@ MIR_RestoreWindow(_THIS, SDL_Window * window)
if (IsSurfaceValid(mir_window) < 0)
return;
MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_restored);
MIR_mir_surface_set_state(mir_window->surface, mir_surface_state_restored);
}
#endif /* SDL_VIDEO_DRIVER_MIR */

View file

@ -1,209 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
#include "SDL_mx6opengles.h"
#include "SDL_loadso.h"
#include "SDL_mx6video.h"
#define DEFAULT_OGL "libGL.so.1"
#define DEFAULT_EGL "libEGL.so.1"
#define DEFAULT_OGL_ES2 "libGLESv2.so.2"
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
#define LOAD_FUNC(NAME) \
*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
if (!_this->egl_data->NAME) \
{ \
return SDL_SetError("Could not retrieve EGL function " #NAME); \
}
#define LOAD_VIV_FUNC(NAME) \
*((void**)&egl_viv_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
if (!egl_viv_data->NAME) \
{ \
return SDL_SetError("Could not retrieve EGL function " #NAME); \
}
/* EGL implementation of SDL OpenGL support */
int
MX6_GLES_LoadLibrary(_THIS, const char *egl_path) {
/* The definitions of egl_dll_handle and dll_handle were interchanged for some reason.
Just left them as is for compatibility */
void *dll_handle = NULL, *egl_dll_handle = NULL;
char *path = NULL;
SDL_DisplayData *displaydata;
if (_this->egl_data) {
return SDL_SetError("OpenGL ES context already created");
}
_this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
if (!_this->egl_data) {
return SDL_OutOfMemory();
}
egl_viv_data = (struct MX6_EGL_VivanteData *) SDL_calloc(1, sizeof(MX6_EGL_VivanteData));
if (!egl_viv_data) {
return SDL_OutOfMemory();
}
path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
if (path != NULL) {
egl_dll_handle = SDL_LoadObject(path);
}
if (egl_dll_handle == NULL) {
if(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if (_this->gl_config.major_version > 1) {
path = DEFAULT_OGL_ES2;
egl_dll_handle = SDL_LoadObject(path);
}
else {
path = DEFAULT_OGL_ES;
egl_dll_handle = SDL_LoadObject(path);
}
}
else {
path = DEFAULT_OGL;
egl_dll_handle = SDL_LoadObject(path);
}
}
_this->egl_data->egl_dll_handle = egl_dll_handle;
if (egl_dll_handle == NULL) {
return SDL_SetError("Could not initialize OpenGL / GLES library");
}
if (egl_path != NULL) {
dll_handle = SDL_LoadObject(egl_path);
}
if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
if (dll_handle != NULL) {
SDL_UnloadObject(dll_handle);
}
path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
if (path == NULL) {
path = DEFAULT_EGL;
}
dll_handle = SDL_LoadObject(path);
if (dll_handle == NULL) {
return SDL_SetError("Could not load EGL library");
}
}
_this->egl_data->dll_handle = dll_handle;
/* Load new function pointers */
LOAD_FUNC(eglGetDisplay);
LOAD_FUNC(eglInitialize);
LOAD_FUNC(eglTerminate);
LOAD_FUNC(eglGetProcAddress);
LOAD_FUNC(eglChooseConfig);
LOAD_FUNC(eglGetConfigAttrib);
LOAD_FUNC(eglCreateContext);
LOAD_FUNC(eglDestroyContext);
LOAD_FUNC(eglCreateWindowSurface);
LOAD_FUNC(eglDestroySurface);
LOAD_FUNC(eglMakeCurrent);
LOAD_FUNC(eglSwapBuffers);
LOAD_FUNC(eglSwapInterval);
LOAD_FUNC(eglWaitNative);
LOAD_FUNC(eglWaitGL);
LOAD_FUNC(eglBindAPI);
/* Functions from Vivante GPU SDK */
LOAD_VIV_FUNC(fbGetDisplay);
LOAD_VIV_FUNC(fbGetDisplayByIndex);
LOAD_VIV_FUNC(fbGetDisplayGeometry);
LOAD_VIV_FUNC(fbGetDisplayInfo);
LOAD_VIV_FUNC(fbDestroyDisplay);
LOAD_VIV_FUNC(fbCreateWindow);
LOAD_VIV_FUNC(fbGetWindowGeometry);
LOAD_VIV_FUNC(fbGetWindowInfo);
LOAD_VIV_FUNC(fbDestroyWindow);
LOAD_VIV_FUNC(fbCreatePixmap);
LOAD_VIV_FUNC(fbCreatePixmapWithBpp);
LOAD_VIV_FUNC(fbGetPixmapGeometry);
LOAD_VIV_FUNC(fbGetPixmapInfo);
LOAD_VIV_FUNC(fbDestroyPixmap);
displaydata = SDL_GetDisplayDriverData(0);
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(displaydata->native_display);
if (!_this->egl_data->egl_display) {
return SDL_SetError("Could not get EGL display");
}
if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
return SDL_SetError("Could not initialize EGL");
}
displaydata->egl_display = _this->egl_data->egl_display;
_this->gl_config.driver_loaded = 1;
if (path) {
SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
} else {
*_this->gl_config.driver_path = '\0';
}
return 0;
}
void
MX6_GLES_UnloadLibrary(_THIS)
{
if (_this->egl_data) {
if (_this->egl_data->egl_display) {
_this->egl_data->eglTerminate(_this->egl_data->egl_display);
_this->egl_data->egl_display = NULL;
}
if (_this->egl_data->dll_handle) {
SDL_UnloadObject(_this->egl_data->dll_handle);
_this->egl_data->dll_handle = NULL;
}
if (_this->egl_data->egl_dll_handle) {
SDL_UnloadObject(_this->egl_data->egl_dll_handle);
_this->egl_data->egl_dll_handle = NULL;
}
SDL_free(_this->egl_data);
_this->egl_data = NULL;
SDL_free(egl_viv_data);
egl_viv_data = NULL;
}
}
SDL_EGL_CreateContext_impl(MX6)
SDL_EGL_SwapWindow_impl(MX6)
SDL_EGL_MakeCurrent_impl(MX6)
#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,68 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef _SDL_mx6opengles_h
#define _SDL_mx6opengles_h
#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
typedef struct MX6_EGL_VivanteData
{
EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay) (void *context);
EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex) (int DisplayIndex);
void(EGLAPIENTRY *fbGetDisplayGeometry) (EGLNativeDisplayType Display, int *Width, int *Height);
void(EGLAPIENTRY *fbGetDisplayInfo) (EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
void(EGLAPIENTRY *fbDestroyDisplay) (EGLNativeDisplayType Display);
EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow) (EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
void(EGLAPIENTRY *fbGetWindowGeometry) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
void(EGLAPIENTRY *fbGetWindowInfo) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
void(EGLAPIENTRY *fbDestroyWindow) (EGLNativeWindowType Window);
EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmap) (EGLNativeDisplayType Display, int Width, int Height);
EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmapWithBpp) (EGLNativeDisplayType Display, int Width, int Height, int BitsPerPixel);
void(EGLAPIENTRY *fbGetPixmapGeometry) (EGLNativePixmapType Pixmap, int *Width, int *Height);
void(EGLAPIENTRY *fbGetPixmapInfo) (EGLNativePixmapType Pixmap, int *Width, int *Height, int *BitsPerPixel, int *Stride, void **Bits);
void(EGLAPIENTRY *fbDestroyPixmap) (EGLNativePixmapType Pixmap);
} MX6_EGL_VivanteData;
struct MX6_EGL_VivanteData *egl_viv_data;
/* OpenGLES functions */
#define MX6_GLES_GetAttribute SDL_EGL_GetAttribute
#define MX6_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define MX6_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define MX6_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define MX6_GLES_DeleteContext SDL_EGL_DeleteContext
extern int MX6_GLES_LoadLibrary(_THIS, const char *path);
extern void MX6_GLES_UnloadLibrary(_THIS);
extern SDL_GLContext MX6_GLES_CreateContext(_THIS, SDL_Window * window);
extern void MX6_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int MX6_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
#endif /* _SDL_mx6opengles_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,325 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_MX6
/* SDL internals */
#include "../SDL_sysvideo.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
#include "SDL_loadso.h"
#include "SDL_events.h"
#ifdef SDL_INPUT_LINUXEV
#include "../../core/linux/SDL_evdev.h"
#endif
#include "SDL_mx6video.h"
#include "SDL_mx6events_c.h"
#include "SDL_mx6opengles.h"
static int
MX6_Available(void)
{
return 1;
}
static void
MX6_Destroy(SDL_VideoDevice * device)
{
if (device->driverdata != NULL) {
device->driverdata = NULL;
}
}
static SDL_VideoDevice *
MX6_Create()
{
SDL_VideoDevice *device;
SDL_VideoData *phdata;
/* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Initialize internal data */
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (phdata == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata = phdata;
/* Setup amount of available displays and current display */
device->num_displays = 0;
/* Set device free function */
device->free = MX6_Destroy;
/* Setup all functions which we can handle */
device->VideoInit = MX6_VideoInit;
device->VideoQuit = MX6_VideoQuit;
device->GetDisplayModes = MX6_GetDisplayModes;
device->SetDisplayMode = MX6_SetDisplayMode;
device->CreateWindow = MX6_CreateWindow;
device->CreateWindowFrom = MX6_CreateWindowFrom;
device->SetWindowTitle = MX6_SetWindowTitle;
device->SetWindowIcon = MX6_SetWindowIcon;
device->SetWindowPosition = MX6_SetWindowPosition;
device->SetWindowSize = MX6_SetWindowSize;
device->ShowWindow = MX6_ShowWindow;
device->HideWindow = MX6_HideWindow;
device->RaiseWindow = MX6_RaiseWindow;
device->MaximizeWindow = MX6_MaximizeWindow;
device->MinimizeWindow = MX6_MinimizeWindow;
device->RestoreWindow = MX6_RestoreWindow;
device->SetWindowGrab = MX6_SetWindowGrab;
device->DestroyWindow = MX6_DestroyWindow;
device->GetWindowWMInfo = MX6_GetWindowWMInfo;
device->GL_LoadLibrary = MX6_GLES_LoadLibrary;
device->GL_GetProcAddress = MX6_GLES_GetProcAddress;
device->GL_UnloadLibrary = MX6_GLES_UnloadLibrary;
device->GL_CreateContext = MX6_GLES_CreateContext;
device->GL_MakeCurrent = MX6_GLES_MakeCurrent;
device->GL_SetSwapInterval = MX6_GLES_SetSwapInterval;
device->GL_GetSwapInterval = MX6_GLES_GetSwapInterval;
device->GL_SwapWindow = MX6_GLES_SwapWindow;
device->GL_DeleteContext = MX6_GLES_DeleteContext;
device->PumpEvents = MX6_PumpEvents;
return device;
}
VideoBootStrap MX6_bootstrap = {
"MX6",
"Freescale i.MX6 Video Driver",
MX6_Available,
MX6_Create
};
static void
MX6_UpdateDisplay(_THIS)
{
SDL_VideoDisplay *display = &_this->displays[0];
SDL_DisplayData *data = (SDL_DisplayData*)display->driverdata;
EGLNativeDisplayType native_display = egl_viv_data->fbGetDisplayByIndex(0);
SDL_DisplayMode current_mode;
int pitch, bpp;
unsigned long pixels;
/* Store the native EGL display */
data->native_display = native_display;
SDL_zero(current_mode);
egl_viv_data->fbGetDisplayInfo(native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
/* FIXME: How do we query refresh rate? */
current_mode.refresh_rate = 60;
switch (bpp)
{
default: /* Is another format used? */
case 16:
current_mode.format = SDL_PIXELFORMAT_RGB565;
break;
}
display->desktop_mode = current_mode;
display->current_mode = current_mode;
}
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
int
MX6_VideoInit(_THIS)
{
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData *data;
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
if (data == NULL) {
return SDL_OutOfMemory();
}
SDL_zero(display);
SDL_zero(current_mode);
display.desktop_mode = current_mode;
display.current_mode = current_mode;
display.driverdata = data;
SDL_AddVideoDisplay(&display);
if (SDL_GL_LoadLibrary(NULL) < 0) {
return -1;
}
MX6_UpdateDisplay(_this);
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Init();
#endif
return 1;
}
void
MX6_VideoQuit(_THIS)
{
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Quit();
#endif
}
void
MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
/* Only one display mode available, the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
int
MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
int
MX6_CreateWindow(_THIS, SDL_Window * window)
{
SDL_DisplayData *displaydata;
SDL_WindowData *wdata;
displaydata = SDL_GetDisplayDriverData(0);
/* Allocate window internal data */
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
if (wdata == NULL) {
return SDL_OutOfMemory();
}
/* Setup driver data for this window */
window->driverdata = wdata;
window->flags |= SDL_WINDOW_OPENGL;
if (!_this->egl_data) {
return -1;
}
wdata->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
if (!wdata->native_window) {
return SDL_SetError("MX6: Can't create native window");
}
wdata->egl_surface = SDL_EGL_CreateSurface(_this, wdata->native_window);
if (wdata->egl_surface == EGL_NO_SURFACE) {
return SDL_SetError("MX6: Can't create EGL surface");
}
/* Window has been successfully created */
return 0;
}
void
MX6_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *wdata;
wdata = window->driverdata;
if (wdata) {
SDL_EGL_DestroySurface(_this, wdata->egl_surface);
}
if (egl_viv_data) {
egl_viv_data->fbDestroyWindow(wdata->native_window);
}
}
int
MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
return -1;
}
void
MX6_SetWindowTitle(_THIS, SDL_Window * window)
{
}
void
MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
{
}
void
MX6_SetWindowPosition(_THIS, SDL_Window * window)
{
}
void
MX6_SetWindowSize(_THIS, SDL_Window * window)
{
}
void
MX6_ShowWindow(_THIS, SDL_Window * window)
{
}
void
MX6_HideWindow(_THIS, SDL_Window * window)
{
}
void
MX6_RaiseWindow(_THIS, SDL_Window * window)
{
}
void
MX6_MaximizeWindow(_THIS, SDL_Window * window)
{
}
void
MX6_MinimizeWindow(_THIS, SDL_Window * window)
{
}
void
MX6_RestoreWindow(_THIS, SDL_Window * window)
{
}
void
MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{
}
/*****************************************************************************/
/* SDL Window Manager function */
/*****************************************************************************/
SDL_bool
MX6_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
return SDL_TRUE;
}
#endif /* SDL_VIDEO_DRIVER_MX6 */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,76 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef __SDL_MX6VIDEO_H__
#define __SDL_MX6VIDEO_H__
#include "../../SDL_internal.h"
#include "../SDL_sysvideo.h"
#include "SDL_egl.h"
typedef struct SDL_VideoData
{
} SDL_VideoData;
typedef struct SDL_DisplayData
{
EGLNativeDisplayType native_display;
EGLDisplay egl_display;
} SDL_DisplayData;
typedef struct SDL_WindowData
{
EGLNativeWindowType native_window;
EGLSurface egl_surface;
} SDL_WindowData;
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int MX6_VideoInit(_THIS);
void MX6_VideoQuit(_THIS);
void MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
int MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
int MX6_CreateWindow(_THIS, SDL_Window * window);
int MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
void MX6_SetWindowTitle(_THIS, SDL_Window * window);
void MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
void MX6_SetWindowPosition(_THIS, SDL_Window * window);
void MX6_SetWindowSize(_THIS, SDL_Window * window);
void MX6_ShowWindow(_THIS, SDL_Window * window);
void MX6_HideWindow(_THIS, SDL_Window * window);
void MX6_RaiseWindow(_THIS, SDL_Window * window);
void MX6_MaximizeWindow(_THIS, SDL_Window * window);
void MX6_MinimizeWindow(_THIS, SDL_Window * window);
void MX6_RestoreWindow(_THIS, SDL_Window * window);
void MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
void MX6_DestroyWindow(_THIS, SDL_Window * window);
/* Window manager function */
SDL_bool MX6_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
#endif /* __SDL_MX6VIDEO_H__ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,47 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
#include "SDL_vivanteopengles.h"
#include "SDL_vivantevideo.h"
/* EGL implementation of SDL OpenGL support */
int
VIVANTE_GLES_LoadLibrary(_THIS, const char *path)
{
SDL_DisplayData *displaydata;
displaydata = SDL_GetDisplayDriverData(0);
return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display);
}
SDL_EGL_CreateContext_impl(VIVANTE)
SDL_EGL_SwapWindow_impl(VIVANTE)
SDL_EGL_MakeCurrent_impl(VIVANTE)
#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,48 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef _SDL_vivanteopengles_h
#define _SDL_vivanteopengles_h
#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
/* OpenGLES functions */
#define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute
#define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
#define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define VIVANTE_GLES_DeleteContext SDL_EGL_DeleteContext
extern int VIVANTE_GLES_LoadLibrary(_THIS, const char *path);
extern SDL_GLContext VIVANTE_GLES_CreateContext(_THIS, SDL_Window * window);
extern void VIVANTE_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int VIVANTE_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
#endif /* _SDL_vivanteopengles_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -18,28 +18,27 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_MX6
#if SDL_VIDEO_DRIVER_VIVANTE
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_mx6video.h"
#include "SDL_mx6events_c.h"
#include "SDL_vivanteplatform.h"
#ifdef SDL_INPUT_LINUXEV
#include "../../core/linux/SDL_evdev.h"
#endif
#ifdef VIVANTE_PLATFORM_GENERIC
void MX6_PumpEvents(_THIS)
int
VIVANTE_SetupPlatform(_THIS)
{
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Poll();
#endif
return 0;
}
#endif /* SDL_VIDEO_DRIVER_MX6 */
void
VIVANTE_CleanupPlatform(_THIS)
{
}
#endif /* VIVANTE_PLATFORM_GENERIC */
#endif /* SDL_VIDEO_DRIVER_VIVANTE */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,45 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef _SDL_vivanteplatform_h
#define _SDL_vivanteplatform_h
#if SDL_VIDEO_DRIVER_VIVANTE
#include "SDL_vivantevideo.h"
#if defined(CAVIUM)
#define VIVANTE_PLATFORM_CAVIUM
#elif defined(MARVELL)
#define VIVANTE_PLATFORM_MARVELL
#else
#define VIVANTE_PLATFORM_GENERIC
#endif
extern int VIVANTE_SetupPlatform(_THIS);
extern void VIVANTE_CleanupPlatform(_THIS);
#endif /* SDL_VIDEO_DRIVER_VIVANTE */
#endif /* _SDL_vivanteplatform_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,399 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_VIVANTE
/* SDL internals */
#include "../SDL_sysvideo.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
#include "SDL_loadso.h"
#include "SDL_events.h"
#include "../../events/SDL_events_c.h"
#ifdef SDL_INPUT_LINUXEV
#include "../../core/linux/SDL_evdev.h"
#endif
#include "SDL_vivantevideo.h"
#include "SDL_vivanteplatform.h"
#include "SDL_vivanteopengles.h"
static int
VIVANTE_Available(void)
{
return 1;
}
static void
VIVANTE_Destroy(SDL_VideoDevice * device)
{
if (device->driverdata != NULL) {
SDL_free(device->driverdata);
device->driverdata = NULL;
}
}
static SDL_VideoDevice *
VIVANTE_Create()
{
SDL_VideoDevice *device;
SDL_VideoData *data;
/* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Initialize internal data */
data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (data == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata = data;
/* Setup amount of available displays and current display */
device->num_displays = 0;
/* Set device free function */
device->free = VIVANTE_Destroy;
/* Setup all functions which we can handle */
device->VideoInit = VIVANTE_VideoInit;
device->VideoQuit = VIVANTE_VideoQuit;
device->GetDisplayModes = VIVANTE_GetDisplayModes;
device->SetDisplayMode = VIVANTE_SetDisplayMode;
device->CreateWindow = VIVANTE_CreateWindow;
device->SetWindowTitle = VIVANTE_SetWindowTitle;
device->SetWindowPosition = VIVANTE_SetWindowPosition;
device->SetWindowSize = VIVANTE_SetWindowSize;
device->ShowWindow = VIVANTE_ShowWindow;
device->HideWindow = VIVANTE_HideWindow;
device->DestroyWindow = VIVANTE_DestroyWindow;
device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo;
device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary;
device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress;
device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary;
device->GL_CreateContext = VIVANTE_GLES_CreateContext;
device->GL_MakeCurrent = VIVANTE_GLES_MakeCurrent;
device->GL_SetSwapInterval = VIVANTE_GLES_SetSwapInterval;
device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval;
device->GL_SwapWindow = VIVANTE_GLES_SwapWindow;
device->GL_DeleteContext = VIVANTE_GLES_DeleteContext;
device->PumpEvents = VIVANTE_PumpEvents;
return device;
}
VideoBootStrap VIVANTE_bootstrap = {
"vivante",
"Vivante EGL Video Driver",
VIVANTE_Available,
VIVANTE_Create
};
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
static int
VIVANTE_AddVideoDisplays(_THIS)
{
SDL_VideoData *videodata = _this->driverdata;
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData *data;
int pitch = 0, bpp = 0;
unsigned long pixels = 0;
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
if (data == NULL) {
return SDL_OutOfMemory();
}
SDL_zero(current_mode);
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
data->native_display = vdkGetDisplay(videodata->vdk_private);
vdkGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
#else
data->native_display = videodata->fbGetDisplayByIndex(0);
videodata->fbGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
#endif /* SDL_VIDEO_DRIVER_VIVANTE_VDK */
switch (bpp)
{
default: /* Is another format used? */
case 16:
current_mode.format = SDL_PIXELFORMAT_RGB565;
break;
}
/* FIXME: How do we query refresh rate? */
current_mode.refresh_rate = 60;
SDL_zero(display);
display.desktop_mode = current_mode;
display.current_mode = current_mode;
display.driverdata = data;
SDL_AddVideoDisplay(&display);
return 0;
}
int
VIVANTE_VideoInit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
videodata->vdk_private = vdkInitialize();
if (!videodata->vdk_private) {
return SDL_SetError("vdkInitialize() failed");
}
#else
videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
if (!videodata->egl_handle) {
videodata->egl_handle = SDL_LoadObject("libEGL.so");
if (!videodata->egl_handle) {
return -1;
}
}
#define LOAD_FUNC(NAME) \
videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \
if (!videodata->NAME) return -1;
LOAD_FUNC(fbGetDisplay);
LOAD_FUNC(fbGetDisplayByIndex);
LOAD_FUNC(fbGetDisplayGeometry);
LOAD_FUNC(fbGetDisplayInfo);
LOAD_FUNC(fbDestroyDisplay);
LOAD_FUNC(fbCreateWindow);
LOAD_FUNC(fbGetWindowGeometry);
LOAD_FUNC(fbGetWindowInfo);
LOAD_FUNC(fbDestroyWindow);
#endif
if (VIVANTE_SetupPlatform(_this) < 0) {
return -1;
}
if (VIVANTE_AddVideoDisplays(_this) < 0) {
return -1;
}
#ifdef SDL_INPUT_LINUXEV
if (SDL_EVDEV_Init() < 0) {
return -1;
}
#endif
return 0;
}
void
VIVANTE_VideoQuit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Quit();
#endif
VIVANTE_CleanupPlatform(_this);
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
if (videodata->vdk_private) {
vdkExit(videodata->vdk_private);
videodata->vdk_private = NULL;
}
#else
if (videodata->egl_handle) {
SDL_UnloadObject(videodata->egl_handle);
videodata->egl_handle = NULL;
}
#endif
}
void
VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
/* Only one display mode available, the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
int
VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
int
VIVANTE_CreateWindow(_THIS, SDL_Window * window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_DisplayData *displaydata;
SDL_WindowData *data;
displaydata = SDL_GetDisplayDriverData(0);
/* Allocate window internal data */
data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
if (data == NULL) {
return SDL_OutOfMemory();
}
/* Setup driver data for this window */
window->driverdata = data;
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
#else
data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
#endif
if (!data->native_window) {
return SDL_SetError("VIVANTE: Can't create native window");
}
if (window->flags & SDL_WINDOW_OPENGL) {
data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
if (data->egl_surface == EGL_NO_SURFACE) {
return SDL_SetError("VIVANTE: Can't create EGL surface");
}
} else {
data->egl_surface = EGL_NO_SURFACE;
}
/* Window has been successfully created */
return 0;
}
void
VIVANTE_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_WindowData *data;
data = window->driverdata;
if (data) {
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}
if (data->native_window) {
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
vdkDestroyWindow(data->native_window);
#else
videodata->fbDestroyWindow(data->native_window);
#endif
}
SDL_free(data);
}
window->driverdata = NULL;
}
void
VIVANTE_SetWindowTitle(_THIS, SDL_Window * window)
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
SDL_WindowData *data = window->driverdata;
vdkSetWindowTitle(data->native_window, window->title);
#endif
}
void
VIVANTE_SetWindowPosition(_THIS, SDL_Window * window)
{
/* FIXME */
}
void
VIVANTE_SetWindowSize(_THIS, SDL_Window * window)
{
/* FIXME */
}
void
VIVANTE_ShowWindow(_THIS, SDL_Window * window)
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
SDL_WindowData *data = window->driverdata;
vdkShowWindow(data->native_window);
#endif
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
}
void
VIVANTE_HideWindow(_THIS, SDL_Window * window)
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
SDL_WindowData *data = window->driverdata;
vdkHideWindow(data->native_window);
#endif
}
/*****************************************************************************/
/* SDL Window Manager function */
/*****************************************************************************/
SDL_bool
VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
/*
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (info->version.major == SDL_MAJOR_VERSION &&
info->version.minor == SDL_MINOR_VERSION) {
info->subsystem = SDL_SYSWM_VIVANTE;
info->info.vivante.window = data->native_window;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
*/
SDL_Unsupported();
return SDL_FALSE;
}
/*****************************************************************************/
/* SDL event functions */
/*****************************************************************************/
void VIVANTE_PumpEvents(_THIS)
{
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Poll();
#endif
}
#endif /* SDL_VIDEO_DRIVER_VIVANTE */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,91 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDL_vivantevideo_h
#define _SDL_vivantevideo_h
#include "../../SDL_internal.h"
#include "../SDL_sysvideo.h"
#include "SDL_egl.h"
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
#include <gc_vdk.h>
#else
#include <EGL/egl.h>
#endif
typedef struct SDL_VideoData
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
vdkPrivate vdk_private;
#else
void *egl_handle; /* EGL shared library handle */
EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplay)(void *context);
EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex);
void (EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height);
void (EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
void (EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display);
EGLNativeWindowType (EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
void (EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
void (EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
void (EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window);
#endif
} SDL_VideoData;
typedef struct SDL_DisplayData
{
EGLNativeDisplayType native_display;
} SDL_DisplayData;
typedef struct SDL_WindowData
{
EGLNativeWindowType native_window;
EGLSurface egl_surface;
} SDL_WindowData;
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int VIVANTE_VideoInit(_THIS);
void VIVANTE_VideoQuit(_THIS);
void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
int VIVANTE_CreateWindow(_THIS, SDL_Window * window);
void VIVANTE_SetWindowTitle(_THIS, SDL_Window * window);
void VIVANTE_SetWindowPosition(_THIS, SDL_Window * window);
void VIVANTE_SetWindowSize(_THIS, SDL_Window * window);
void VIVANTE_ShowWindow(_THIS, SDL_Window * window);
void VIVANTE_HideWindow(_THIS, SDL_Window * window);
void VIVANTE_DestroyWindow(_THIS, SDL_Window * window);
/* Window manager function */
SDL_bool VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
/* Event functions */
void VIVANTE_PumpEvents(_THIS);
#endif /* _SDL_vivantevideo_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -126,7 +126,7 @@ create_buffer_from_shm(Wayland_CursorData *d,
MAP_SHARED,
shm_fd,
0);
if (data == MAP_FAILED) {
if (d->shm_data == MAP_FAILED) {
d->shm_data = NULL;
fprintf (stderr, "mmap () failed\n");
close (shm_fd);

View file

@ -22,10 +22,6 @@
#if SDL_VIDEO_DRIVER_WINRT
/* Standard C++11 includes */
#include <unordered_map>
/* Windows-specific includes */
#include <Windows.h>
#include <agile.h>
@ -42,248 +38,290 @@ extern "C" {
static SDL_Scancode WinRT_Official_Keycodes[] = {
SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
SDL_SCANCODE_UNKNOWN, // -- 7
SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
SDL_SCANCODE_UNKNOWN, // -- 10
SDL_SCANCODE_UNKNOWN, // -- 11
SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
SDL_SCANCODE_UNKNOWN, // -- 14
SDL_SCANCODE_UNKNOWN, // -- 15
SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
SDL_SCANCODE_UNKNOWN, // -- 22
SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
SDL_SCANCODE_UNKNOWN, // -- 26
SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?)
SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
SDL_SCANCODE_END, // VirtualKey.End -- 35
SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
SDL_SCANCODE_UP, // VirtualKey.Up -- 38
SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?)
SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
SDL_SCANCODE_UNKNOWN, // -- 58
SDL_SCANCODE_UNKNOWN, // -- 59
SDL_SCANCODE_UNKNOWN, // -- 60
SDL_SCANCODE_UNKNOWN, // -- 61
SDL_SCANCODE_UNKNOWN, // -- 62
SDL_SCANCODE_UNKNOWN, // -- 63
SDL_SCANCODE_UNKNOWN, // -- 64
SDL_SCANCODE_A, // VirtualKey.A -- 65
SDL_SCANCODE_B, // VirtualKey.B -- 66
SDL_SCANCODE_C, // VirtualKey.C -- 67
SDL_SCANCODE_D, // VirtualKey.D -- 68
SDL_SCANCODE_E, // VirtualKey.E -- 69
SDL_SCANCODE_F, // VirtualKey.F -- 70
SDL_SCANCODE_G, // VirtualKey.G -- 71
SDL_SCANCODE_H, // VirtualKey.H -- 72
SDL_SCANCODE_I, // VirtualKey.I -- 73
SDL_SCANCODE_J, // VirtualKey.J -- 74
SDL_SCANCODE_K, // VirtualKey.K -- 75
SDL_SCANCODE_L, // VirtualKey.L -- 76
SDL_SCANCODE_M, // VirtualKey.M -- 77
SDL_SCANCODE_N, // VirtualKey.N -- 78
SDL_SCANCODE_O, // VirtualKey.O -- 79
SDL_SCANCODE_P, // VirtualKey.P -- 80
SDL_SCANCODE_Q, // VirtualKey.Q -- 81
SDL_SCANCODE_R, // VirtualKey.R -- 82
SDL_SCANCODE_S, // VirtualKey.S -- 83
SDL_SCANCODE_T, // VirtualKey.T -- 84
SDL_SCANCODE_U, // VirtualKey.U -- 85
SDL_SCANCODE_V, // VirtualKey.V -- 86
SDL_SCANCODE_W, // VirtualKey.W -- 87
SDL_SCANCODE_X, // VirtualKey.X -- 88
SDL_SCANCODE_Y, // VirtualKey.Y -- 89
SDL_SCANCODE_Z, // VirtualKey.Z -- 90
SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
SDL_SCANCODE_UNKNOWN, // -- 94
SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
SDL_SCANCODE_UNKNOWN, // -- 136
SDL_SCANCODE_UNKNOWN, // -- 137
SDL_SCANCODE_UNKNOWN, // -- 138
SDL_SCANCODE_UNKNOWN, // -- 139
SDL_SCANCODE_UNKNOWN, // -- 140
SDL_SCANCODE_UNKNOWN, // -- 141
SDL_SCANCODE_UNKNOWN, // -- 142
SDL_SCANCODE_UNKNOWN, // -- 143
SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
SDL_SCANCODE_UNKNOWN, // -- 146
SDL_SCANCODE_UNKNOWN, // -- 147
SDL_SCANCODE_UNKNOWN, // -- 148
SDL_SCANCODE_UNKNOWN, // -- 149
SDL_SCANCODE_UNKNOWN, // -- 150
SDL_SCANCODE_UNKNOWN, // -- 151
SDL_SCANCODE_UNKNOWN, // -- 152
SDL_SCANCODE_UNKNOWN, // -- 153
SDL_SCANCODE_UNKNOWN, // -- 154
SDL_SCANCODE_UNKNOWN, // -- 155
SDL_SCANCODE_UNKNOWN, // -- 156
SDL_SCANCODE_UNKNOWN, // -- 157
SDL_SCANCODE_UNKNOWN, // -- 158
SDL_SCANCODE_UNKNOWN, // -- 159
SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
SDL_SCANCODE_AC_BACK, // VirtualKey.GoBack -- 166 : The go back key.
SDL_SCANCODE_AC_FORWARD, // VirtualKey.GoForward -- 167 : The go forward key.
SDL_SCANCODE_AC_REFRESH, // VirtualKey.Refresh -- 168 : The refresh key.
SDL_SCANCODE_AC_STOP, // VirtualKey.Stop -- 169 : The stop key.
SDL_SCANCODE_AC_SEARCH, // VirtualKey.Search -- 170 : The search key.
SDL_SCANCODE_AC_BOOKMARKS, // VirtualKey.Favorites -- 171 : The favorites key.
SDL_SCANCODE_AC_HOME // VirtualKey.GoHome -- 172 : The go home key.
SDL_SCANCODE_UNKNOWN, /* VirtualKey.None -- 0 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftButton -- 1 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightButton -- 2 */
SDL_SCANCODE_CANCEL, /* VirtualKey.Cancel -- 3 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.MiddleButton -- 4 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton1 -- 5 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.XButton2 -- 6 */
SDL_SCANCODE_UNKNOWN, /* -- 7 */
SDL_SCANCODE_BACKSPACE, /* VirtualKey.Back -- 8 */
SDL_SCANCODE_TAB, /* VirtualKey.Tab -- 9 */
SDL_SCANCODE_UNKNOWN, /* -- 10 */
SDL_SCANCODE_UNKNOWN, /* -- 11 */
SDL_SCANCODE_CLEAR, /* VirtualKey.Clear -- 12 */
SDL_SCANCODE_RETURN, /* VirtualKey.Enter -- 13 */
SDL_SCANCODE_UNKNOWN, /* -- 14 */
SDL_SCANCODE_UNKNOWN, /* -- 15 */
SDL_SCANCODE_LSHIFT, /* VirtualKey.Shift -- 16 */
SDL_SCANCODE_LCTRL, /* VirtualKey.Control -- 17 */
SDL_SCANCODE_MENU, /* VirtualKey.Menu -- 18 */
SDL_SCANCODE_PAUSE, /* VirtualKey.Pause -- 19 */
SDL_SCANCODE_CAPSLOCK, /* VirtualKey.CapitalLock -- 20 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Kana or VirtualKey.Hangul -- 21 */
SDL_SCANCODE_UNKNOWN, /* -- 22 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Junja -- 23 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Final -- 24 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Hanja or VirtualKey.Kanji -- 25 */
SDL_SCANCODE_UNKNOWN, /* -- 26 */
SDL_SCANCODE_ESCAPE, /* VirtualKey.Escape -- 27 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Convert -- 28 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.NonConvert -- 29 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Accept -- 30 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?) */
SDL_SCANCODE_SPACE, /* VirtualKey.Space -- 32 */
SDL_SCANCODE_PAGEUP, /* VirtualKey.PageUp -- 33 */
SDL_SCANCODE_PAGEDOWN, /* VirtualKey.PageDown -- 34 */
SDL_SCANCODE_END, /* VirtualKey.End -- 35 */
SDL_SCANCODE_HOME, /* VirtualKey.Home -- 36 */
SDL_SCANCODE_LEFT, /* VirtualKey.Left -- 37 */
SDL_SCANCODE_UP, /* VirtualKey.Up -- 38 */
SDL_SCANCODE_RIGHT, /* VirtualKey.Right -- 39 */
SDL_SCANCODE_DOWN, /* VirtualKey.Down -- 40 */
SDL_SCANCODE_SELECT, /* VirtualKey.Select -- 41 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?) */
SDL_SCANCODE_EXECUTE, /* VirtualKey.Execute -- 43 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Snapshot -- 44 */
SDL_SCANCODE_INSERT, /* VirtualKey.Insert -- 45 */
SDL_SCANCODE_DELETE, /* VirtualKey.Delete -- 46 */
SDL_SCANCODE_HELP, /* VirtualKey.Help -- 47 */
SDL_SCANCODE_0, /* VirtualKey.Number0 -- 48 */
SDL_SCANCODE_1, /* VirtualKey.Number1 -- 49 */
SDL_SCANCODE_2, /* VirtualKey.Number2 -- 50 */
SDL_SCANCODE_3, /* VirtualKey.Number3 -- 51 */
SDL_SCANCODE_4, /* VirtualKey.Number4 -- 52 */
SDL_SCANCODE_5, /* VirtualKey.Number5 -- 53 */
SDL_SCANCODE_6, /* VirtualKey.Number6 -- 54 */
SDL_SCANCODE_7, /* VirtualKey.Number7 -- 55 */
SDL_SCANCODE_8, /* VirtualKey.Number8 -- 56 */
SDL_SCANCODE_9, /* VirtualKey.Number9 -- 57 */
SDL_SCANCODE_UNKNOWN, /* -- 58 */
SDL_SCANCODE_UNKNOWN, /* -- 59 */
SDL_SCANCODE_UNKNOWN, /* -- 60 */
SDL_SCANCODE_UNKNOWN, /* -- 61 */
SDL_SCANCODE_UNKNOWN, /* -- 62 */
SDL_SCANCODE_UNKNOWN, /* -- 63 */
SDL_SCANCODE_UNKNOWN, /* -- 64 */
SDL_SCANCODE_A, /* VirtualKey.A -- 65 */
SDL_SCANCODE_B, /* VirtualKey.B -- 66 */
SDL_SCANCODE_C, /* VirtualKey.C -- 67 */
SDL_SCANCODE_D, /* VirtualKey.D -- 68 */
SDL_SCANCODE_E, /* VirtualKey.E -- 69 */
SDL_SCANCODE_F, /* VirtualKey.F -- 70 */
SDL_SCANCODE_G, /* VirtualKey.G -- 71 */
SDL_SCANCODE_H, /* VirtualKey.H -- 72 */
SDL_SCANCODE_I, /* VirtualKey.I -- 73 */
SDL_SCANCODE_J, /* VirtualKey.J -- 74 */
SDL_SCANCODE_K, /* VirtualKey.K -- 75 */
SDL_SCANCODE_L, /* VirtualKey.L -- 76 */
SDL_SCANCODE_M, /* VirtualKey.M -- 77 */
SDL_SCANCODE_N, /* VirtualKey.N -- 78 */
SDL_SCANCODE_O, /* VirtualKey.O -- 79 */
SDL_SCANCODE_P, /* VirtualKey.P -- 80 */
SDL_SCANCODE_Q, /* VirtualKey.Q -- 81 */
SDL_SCANCODE_R, /* VirtualKey.R -- 82 */
SDL_SCANCODE_S, /* VirtualKey.S -- 83 */
SDL_SCANCODE_T, /* VirtualKey.T -- 84 */
SDL_SCANCODE_U, /* VirtualKey.U -- 85 */
SDL_SCANCODE_V, /* VirtualKey.V -- 86 */
SDL_SCANCODE_W, /* VirtualKey.W -- 87 */
SDL_SCANCODE_X, /* VirtualKey.X -- 88 */
SDL_SCANCODE_Y, /* VirtualKey.Y -- 89 */
SDL_SCANCODE_Z, /* VirtualKey.Z -- 90 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) */
SDL_SCANCODE_APPLICATION, /* VirtualKey.Application -- 93 */
SDL_SCANCODE_UNKNOWN, /* -- 94 */
SDL_SCANCODE_SLEEP, /* VirtualKey.Sleep -- 95 */
SDL_SCANCODE_KP_0, /* VirtualKey.NumberPad0 -- 96 */
SDL_SCANCODE_KP_1, /* VirtualKey.NumberPad1 -- 97 */
SDL_SCANCODE_KP_2, /* VirtualKey.NumberPad2 -- 98 */
SDL_SCANCODE_KP_3, /* VirtualKey.NumberPad3 -- 99 */
SDL_SCANCODE_KP_4, /* VirtualKey.NumberPad4 -- 100 */
SDL_SCANCODE_KP_5, /* VirtualKey.NumberPad5 -- 101 */
SDL_SCANCODE_KP_6, /* VirtualKey.NumberPad6 -- 102 */
SDL_SCANCODE_KP_7, /* VirtualKey.NumberPad7 -- 103 */
SDL_SCANCODE_KP_8, /* VirtualKey.NumberPad8 -- 104 */
SDL_SCANCODE_KP_9, /* VirtualKey.NumberPad9 -- 105 */
SDL_SCANCODE_KP_MULTIPLY, /* VirtualKey.Multiply -- 106 */
SDL_SCANCODE_KP_PLUS, /* VirtualKey.Add -- 107 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Separator -- 108 */
SDL_SCANCODE_KP_MINUS, /* VirtualKey.Subtract -- 109 */
SDL_SCANCODE_UNKNOWN, /* VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) */
SDL_SCANCODE_KP_DIVIDE, /* VirtualKey.Divide -- 111 */
SDL_SCANCODE_F1, /* VirtualKey.F1 -- 112 */
SDL_SCANCODE_F2, /* VirtualKey.F2 -- 113 */
SDL_SCANCODE_F3, /* VirtualKey.F3 -- 114 */
SDL_SCANCODE_F4, /* VirtualKey.F4 -- 115 */
SDL_SCANCODE_F5, /* VirtualKey.F5 -- 116 */
SDL_SCANCODE_F6, /* VirtualKey.F6 -- 117 */
SDL_SCANCODE_F7, /* VirtualKey.F7 -- 118 */
SDL_SCANCODE_F8, /* VirtualKey.F8 -- 119 */
SDL_SCANCODE_F9, /* VirtualKey.F9 -- 120 */
SDL_SCANCODE_F10, /* VirtualKey.F10 -- 121 */
SDL_SCANCODE_F11, /* VirtualKey.F11 -- 122 */
SDL_SCANCODE_F12, /* VirtualKey.F12 -- 123 */
SDL_SCANCODE_F13, /* VirtualKey.F13 -- 124 */
SDL_SCANCODE_F14, /* VirtualKey.F14 -- 125 */
SDL_SCANCODE_F15, /* VirtualKey.F15 -- 126 */
SDL_SCANCODE_F16, /* VirtualKey.F16 -- 127 */
SDL_SCANCODE_F17, /* VirtualKey.F17 -- 128 */
SDL_SCANCODE_F18, /* VirtualKey.F18 -- 129 */
SDL_SCANCODE_F19, /* VirtualKey.F19 -- 130 */
SDL_SCANCODE_F20, /* VirtualKey.F20 -- 131 */
SDL_SCANCODE_F21, /* VirtualKey.F21 -- 132 */
SDL_SCANCODE_F22, /* VirtualKey.F22 -- 133 */
SDL_SCANCODE_F23, /* VirtualKey.F23 -- 134 */
SDL_SCANCODE_F24, /* VirtualKey.F24 -- 135 */
SDL_SCANCODE_UNKNOWN, /* -- 136 */
SDL_SCANCODE_UNKNOWN, /* -- 137 */
SDL_SCANCODE_UNKNOWN, /* -- 138 */
SDL_SCANCODE_UNKNOWN, /* -- 139 */
SDL_SCANCODE_UNKNOWN, /* -- 140 */
SDL_SCANCODE_UNKNOWN, /* -- 141 */
SDL_SCANCODE_UNKNOWN, /* -- 142 */
SDL_SCANCODE_UNKNOWN, /* -- 143 */
SDL_SCANCODE_NUMLOCKCLEAR, /* VirtualKey.NumberKeyLock -- 144 */
SDL_SCANCODE_SCROLLLOCK, /* VirtualKey.Scroll -- 145 */
SDL_SCANCODE_UNKNOWN, /* -- 146 */
SDL_SCANCODE_UNKNOWN, /* -- 147 */
SDL_SCANCODE_UNKNOWN, /* -- 148 */
SDL_SCANCODE_UNKNOWN, /* -- 149 */
SDL_SCANCODE_UNKNOWN, /* -- 150 */
SDL_SCANCODE_UNKNOWN, /* -- 151 */
SDL_SCANCODE_UNKNOWN, /* -- 152 */
SDL_SCANCODE_UNKNOWN, /* -- 153 */
SDL_SCANCODE_UNKNOWN, /* -- 154 */
SDL_SCANCODE_UNKNOWN, /* -- 155 */
SDL_SCANCODE_UNKNOWN, /* -- 156 */
SDL_SCANCODE_UNKNOWN, /* -- 157 */
SDL_SCANCODE_UNKNOWN, /* -- 158 */
SDL_SCANCODE_UNKNOWN, /* -- 159 */
SDL_SCANCODE_LSHIFT, /* VirtualKey.LeftShift -- 160 */
SDL_SCANCODE_RSHIFT, /* VirtualKey.RightShift -- 161 */
SDL_SCANCODE_LCTRL, /* VirtualKey.LeftControl -- 162 */
SDL_SCANCODE_RCTRL, /* VirtualKey.RightControl -- 163 */
SDL_SCANCODE_MENU, /* VirtualKey.LeftMenu -- 164 */
SDL_SCANCODE_MENU, /* VirtualKey.RightMenu -- 165 */
SDL_SCANCODE_AC_BACK, /* VirtualKey.GoBack -- 166 : The go back key. */
SDL_SCANCODE_AC_FORWARD, /* VirtualKey.GoForward -- 167 : The go forward key. */
SDL_SCANCODE_AC_REFRESH, /* VirtualKey.Refresh -- 168 : The refresh key. */
SDL_SCANCODE_AC_STOP, /* VirtualKey.Stop -- 169 : The stop key. */
SDL_SCANCODE_AC_SEARCH, /* VirtualKey.Search -- 170 : The search key. */
SDL_SCANCODE_AC_BOOKMARKS, /* VirtualKey.Favorites -- 171 : The favorites key. */
SDL_SCANCODE_AC_HOME /* VirtualKey.GoHome -- 172 : The go home key. */
};
static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
/* Attempt to translate a keycode that isn't listed in WinRT's VirtualKey enum.
*/
static SDL_Scancode
WINRT_TranslateUnofficialKeycode(int keycode)
{
switch (keycode) {
case 173: return SDL_SCANCODE_MUTE; /* VK_VOLUME_MUTE */
case 174: return SDL_SCANCODE_VOLUMEDOWN; /* VK_VOLUME_DOWN */
case 175: return SDL_SCANCODE_VOLUMEUP; /* VK_VOLUME_UP */
case 176: return SDL_SCANCODE_AUDIONEXT; /* VK_MEDIA_NEXT_TRACK */
case 177: return SDL_SCANCODE_AUDIOPREV; /* VK_MEDIA_PREV_TRACK */
// case 178: return ; /* VK_MEDIA_STOP */
case 179: return SDL_SCANCODE_AUDIOPLAY; /* VK_MEDIA_PLAY_PAUSE */
case 180: return SDL_SCANCODE_MAIL; /* VK_LAUNCH_MAIL */
case 181: return SDL_SCANCODE_MEDIASELECT; /* VK_LAUNCH_MEDIA_SELECT */
// case 182: return ; /* VK_LAUNCH_APP1 */
case 183: return SDL_SCANCODE_CALCULATOR; /* VK_LAUNCH_APP2 */
// case 184: return ; /* ... reserved ... */
// case 185: return ; /* ... reserved ... */
case 186: return SDL_SCANCODE_SEMICOLON; /* VK_OEM_1, ';:' key on US standard keyboards */
case 187: return SDL_SCANCODE_EQUALS; /* VK_OEM_PLUS */
case 188: return SDL_SCANCODE_COMMA; /* VK_OEM_COMMA */
case 189: return SDL_SCANCODE_MINUS; /* VK_OEM_MINUS */
case 190: return SDL_SCANCODE_PERIOD; /* VK_OEM_PERIOD */
case 191: return SDL_SCANCODE_SLASH; /* VK_OEM_2, '/?' key on US standard keyboards */
case 192: return SDL_SCANCODE_GRAVE; /* VK_OEM_3, '`~' key on US standard keyboards */
// ?
// ... reserved or unassigned ...
// ?
case 219: return SDL_SCANCODE_LEFTBRACKET; /* VK_OEM_4, '[{' key on US standard keyboards */
case 220: return SDL_SCANCODE_BACKSLASH; /* VK_OEM_5, '\|' key on US standard keyboards */
case 221: return SDL_SCANCODE_RIGHTBRACKET; /* VK_OEM_6, ']}' key on US standard keyboards */
case 222: return SDL_SCANCODE_APOSTROPHE; /* VK_OEM_7, 'single/double quote' on US standard keyboards */
default: break;
}
return SDL_SCANCODE_UNKNOWN;
}
static SDL_Scancode
TranslateKeycode(int keycode)
WINRT_TranslateKeycode(int keycode, unsigned int nativeScancode)
{
if (WinRT_Unofficial_Keycodes.empty()) {
/* Set up a table of keycodes that aren't listed in WinRT's
* VirtualKey enum.
*/
// TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
WinRT_Unofficial_Keycodes[173] = SDL_SCANCODE_MUTE;
WinRT_Unofficial_Keycodes[174] = SDL_SCANCODE_VOLUMEDOWN;
WinRT_Unofficial_Keycodes[175] = SDL_SCANCODE_VOLUMEUP;
WinRT_Unofficial_Keycodes[176] = SDL_SCANCODE_AUDIONEXT;
WinRT_Unofficial_Keycodes[177] = SDL_SCANCODE_AUDIOPREV;
// WinRT_Unofficial_Keycodes[178] = ;
WinRT_Unofficial_Keycodes[179] = SDL_SCANCODE_AUDIOPLAY;
WinRT_Unofficial_Keycodes[180] = SDL_SCANCODE_MAIL;
WinRT_Unofficial_Keycodes[181] = SDL_SCANCODE_MEDIASELECT;
// WinRT_Unofficial_Keycodes[182] = ;
WinRT_Unofficial_Keycodes[183] = SDL_SCANCODE_CALCULATOR;
// WinRT_Unofficial_Keycodes[184] = ;
// WinRT_Unofficial_Keycodes[185] = ;
WinRT_Unofficial_Keycodes[186] = SDL_SCANCODE_SEMICOLON;
WinRT_Unofficial_Keycodes[187] = SDL_SCANCODE_EQUALS;
WinRT_Unofficial_Keycodes[188] = SDL_SCANCODE_COMMA;
WinRT_Unofficial_Keycodes[189] = SDL_SCANCODE_MINUS;
WinRT_Unofficial_Keycodes[190] = SDL_SCANCODE_PERIOD;
WinRT_Unofficial_Keycodes[191] = SDL_SCANCODE_SLASH;
WinRT_Unofficial_Keycodes[192] = SDL_SCANCODE_GRAVE;
// ?
// ...
// ?
WinRT_Unofficial_Keycodes[219] = SDL_SCANCODE_LEFTBRACKET;
WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_BACKSLASH;
WinRT_Unofficial_Keycodes[221] = SDL_SCANCODE_RIGHTBRACKET;
WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_APOSTROPHE;
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
/* HACK ALERT: At least one VirtualKey constant (Shift) with a left/right
* designation might not get reported with its correct handedness, however
* its hardware scan code can fill in the gaps. If this is detected,
* use the hardware scan code to try telling if the left, or the right
* side's key was used.
*
* If Microsoft ever allows MapVirtualKey or MapVirtualKeyEx to be used
* in WinRT apps, or something similar to these (it doesn't appear to be,
* at least not for Windows [Phone] 8/8.1, as of Oct 24, 2014), then this
* hack might become deprecated, or obsolete.
*/
if (nativeScancode < SDL_arraysize(windows_scancode_table)) {
switch (keycode) {
case 16: // VirtualKey.Shift
switch (windows_scancode_table[nativeScancode]) {
case SDL_SCANCODE_LSHIFT:
case SDL_SCANCODE_RSHIFT:
return windows_scancode_table[nativeScancode];
}
break;
// Add others, as necessary.
//
// Unfortunately, this hack doesn't seem to work in determining
// handedness with Control keys.
default:
break;
}
}
/* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
/* Try to get a documented, WinRT, 'VirtualKey' next (as documented at
http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
If that fails, fall back to a Win32 virtual key.
If that fails, attempt to fall back to a scancode-derived key.
*/
// TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
//SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
scancode = WinRT_Official_Keycodes[keycode];
}
if (scancode == SDL_SCANCODE_UNKNOWN) {
if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
scancode = WinRT_Unofficial_Keycodes[keycode];
scancode = WINRT_TranslateUnofficialKeycode(keycode);
}
if (scancode == SDL_SCANCODE_UNKNOWN) {
if (nativeScancode < SDL_arraysize(windows_scancode_table)) {
scancode = windows_scancode_table[nativeScancode];
}
}
/*
if (scancode == SDL_SCANCODE_UNKNOWN) {
SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
}
*/
return scancode;
}
void
WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
{
SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
#if 0
SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
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",
SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, "
"repeat count=%d, native scan code=0x%x, was down?=%s, vkey=%d, "
"sdl scan code=%d (%s), sdl key code=%d (%s)\n",
(args->Handled ? "1" : "0"),
(args->KeyStatus.IsExtendedKey ? "1" : "0"),
(args->KeyStatus.IsKeyReleased ? "1" : "0"),
@ -297,7 +335,6 @@ WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
keycode,
SDL_GetKeyName(keycode));
//args->Handled = true;
//VirtualKey vkey = args->VirtualKey;
#endif
SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
}
@ -305,10 +342,12 @@ WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
void
WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args)
{
SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
#if 0
SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
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",
SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, "
"repeat count=%d, native scan code=0x%x, was down?=%s, vkey=%d, "
"sdl scan code=%d (%s), sdl key code=%d (%s)\n",
(args->Handled ? "1" : "0"),
(args->KeyStatus.IsExtendedKey ? "1" : "0"),
(args->KeyStatus.IsKeyReleased ? "1" : "0"),

View file

@ -507,6 +507,26 @@ ProcessHitTest(_THIS, const SDL_WindowData *data, const XEvent *xev)
return ret;
}
static void
ReconcileKeyboardState(_THIS, const SDL_WindowData *data)
{
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
Display *display = viddata->display;
char keys[32];
int keycode = 0;
X11_XQueryKeymap( display, keys );
while ( keycode < 256 ) {
if ( keys[keycode / 8] & (1 << (keycode % 8)) ) {
SDL_SendKeyboardKey(SDL_PRESSED, viddata->key_layout[keycode]);
} else {
SDL_SendKeyboardKey(SDL_RELEASED, viddata->key_layout[keycode]);
}
keycode++;
}
}
static void
X11_DispatchEvent(_THIS)
{
@ -655,16 +675,7 @@ X11_DispatchEvent(_THIS)
#endif
if (data->pending_focus == PENDING_FOCUS_OUT &&
data->window == SDL_GetKeyboardFocus()) {
/* We want to reset the keyboard here, because we may have
missed keyboard messages after our previous FocusOut.
*/
/* Actually, if we do this we clear the ALT key on Unity
because it briefly takes focus for their dashboard.
I think it's better to think the ALT key is held down
when it's not, then always lose the ALT modifier on Unity.
*/
/* SDL_ResetKeyboard(); */
ReconcileKeyboardState(_this, data);
}
data->pending_focus = PENDING_FOCUS_IN;
data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_IN_TIME;

View file

@ -375,7 +375,7 @@ int
X11_InitModes(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
int screen, screencount;
int snum, screen, screencount;
#if SDL_VIDEO_DRIVER_X11_XINERAMA
int xinerama_major, xinerama_minor;
int use_xinerama = 0;
@ -423,7 +423,7 @@ X11_InitModes(_THIS)
}
#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
for (screen = 0; screen < screencount; ++screen) {
for (snum = 0; snum < screencount; ++snum) {
XVisualInfo vinfo;
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
@ -433,6 +433,15 @@ X11_InitModes(_THIS)
char display_name[128];
int i, n;
/* Re-order screens to always put default screen first */
if (snum == 0) {
screen = DefaultScreen(data->display);
} else if (snum == DefaultScreen(data->display)) {
screen = 0;
} else {
screen = snum;
}
#if SDL_VIDEO_DRIVER_X11_XINERAMA
if (xinerama) {
if (get_visualinfo(data->display, 0, &vinfo) < 0) {

View file

@ -29,8 +29,8 @@
/* EGL implementation of SDL OpenGL support */
int
X11_GLES_LoadLibrary(_THIS, const char *path) {
X11_GLES_LoadLibrary(_THIS, const char *path)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
/* If the profile requested is not GL ES, switch over to X11_GL functions */

View file

@ -122,7 +122,8 @@ main(int argc, char **argv)
SDL_Log(" effect %d: Sine Wave\n", nefx);
efx[nefx].type = SDL_HAPTIC_SINE;
efx[nefx].periodic.period = 1000;
efx[nefx].periodic.magnitude = 0x4000;
efx[nefx].periodic.magnitude = -0x2000; /* Negative magnitude and ... */
efx[nefx].periodic.phase = 18000; /* ... 180 degrees phase shift => cancel eachother */
efx[nefx].periodic.length = 5000;
efx[nefx].periodic.attack_length = 1000;
efx[nefx].periodic.fade_length = 1000;

View file

@ -51,6 +51,12 @@ test_multi_audio(int devcount)
int keep_going = 1;
int i;
#ifdef __ANDROID__
SDL_Event event;
SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
#endif
if (devcount > 64) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
devcount);
@ -71,8 +77,12 @@ test_multi_audio(int devcount)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
} else {
SDL_PauseAudioDevice(cbd[0].dev, 0);
while (!cbd[0].done)
while (!cbd[0].done) {
#ifdef __ANDROID__
while (SDL_PollEvent(&event)){}
#endif
SDL_Delay(100);
}
SDL_PauseAudioDevice(cbd[0].dev, 1);
SDL_Log("done.\n");
SDL_CloseAudioDevice(cbd[0].dev);
@ -104,6 +114,9 @@ test_multi_audio(int devcount)
keep_going = 1;
}
}
#ifdef __ANDROID__
while (SDL_PollEvent(&event)){}
#endif
SDL_Delay(100);
}