Browse Source

Added opt_arch and opt_target_platform config options.

woollybah 9 năm trước cách đây
mục cha
commit
8a76c2e7e4

+ 61 - 28
bmk_config.bmx

@@ -11,6 +11,7 @@ Const BMK_VERSION:String = "3.14"
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc"
 
 Global opt_arch$
+Global opt_arch_set=False
 Global opt_server$
 Global opt_outfile$
 Global opt_framework$
@@ -33,6 +34,7 @@ Global opt_traceheaders
 Global opt_appstub$="brl.appstub" ' BaH 28/9/2007
 Global opt_universal=False
 Global opt_target_platform:String
+Global opt_target_platform_set=False
 Global opt_gdbdebug=False
 Global opt_gdbdebug_set=False
 Global opt_standalone=False
@@ -155,21 +157,8 @@ Function ParseConfigArgs$[]( args$[] )
 			n:+1
 			If n=args.length CmdError "Missing arg for '-g'"
 			opt_arch=args[n].ToLower()
-			Select opt_arch
-				Case "ppc"
-				Case "x86"
-				Case "x64"
-				Case "arm"
-				Case "armeabi"
-				Case "armeabiv7a"
-				Case "arm64v8a"
-				Case "armv7"
-				Case "arm64"
-				Case "js"
-				Default
-					' oops
-					CmdError "Not a valid architecture : '" + opt_arch + "'"
-			End Select
+			ValidateArch(opt_arch)
+			opt_arch_set = True
 		Case "t"
 			n:+1
 			If n=args.length CmdError "Missing arg for '-t'"
@@ -207,19 +196,8 @@ Function ParseConfigArgs$[]( args$[] )
 			n:+1
 			If n=args.length CmdError "Missing arg for '-l'"
 			opt_target_platform=args[n].ToLower()
-			Select opt_target_platform
-				Case "win32"
-				Case "macos"
-				Case "osx"
-				Case "ios"
-				Case "linux"
-				Case "android"
-				Case "raspberrypi"
-				Case "emscripten"
-				Default
-					' oops
-					CmdError "Not valid platform : '" + opt_target_platform + "'"
-			End Select
+			ValidatePlatform(opt_target_platform)
+			opt_target_platform_set = True
 		Case "gdb"
 			opt_gdbdebug = True
 			opt_gdbdebug_set = True
@@ -499,6 +477,28 @@ Function AsConfigurable:Int(key:String, value:String)
 				End If
 			End If
 			config = True
+		Case "opt_arch"
+			If Not opt_arch_set Then
+				opt_arch = value.ToLower()
+				ValidateArch(opt_arch)
+				set = 1
+			Else
+				If opt_arch <> value.ToLower() Then
+					set = 2
+				End If
+			End If
+			config = True
+		Case "opt_target_platform"
+			If Not opt_target_platform_set Then
+				opt_target_platform = value.ToLower()
+				ValidatePlatform(opt_target_platform)
+				set = 1
+			Else
+				If opt_target_platform <> value.ToLower() Then
+					set = 2
+				End If
+			End If
+			config = True
 	End Select
 	If set And opt_verbose Then
 		If set = 1 Then
@@ -509,3 +509,36 @@ Function AsConfigurable:Int(key:String, value:String)
 	End If
 	Return config
 End Function
+
+Function ValidateArch(arch:String)
+	Select arch
+		Case "ppc"
+		Case "x86"
+		Case "x64"
+		Case "arm"
+		Case "armeabi"
+		Case "armeabiv7a"
+		Case "arm64v8a"
+		Case "armv7"
+		Case "arm64"
+		Case "js"
+		Default
+			CmdError "Not a valid architecture : '" + arch + "'"
+	End Select
+End Function
+
+Function ValidatePlatform(platform:String)
+	Select platform
+		Case "win32"
+		Case "macos"
+		Case "osx"
+		Case "ios"
+		Case "linux"
+		Case "android"
+		Case "raspberrypi"
+		Case "emscripten"
+		Default
+			' oops
+			CmdError "Not valid platform : '" + platform + "'"
+	End Select
+End Function

+ 16 - 3
resources/android/android-project/src/org/libsdl/app/SDLActivity.java

@@ -1196,6 +1196,20 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
             }
         }
 
+        if ((event.getSource() & InputDevice.SOURCE_MOUSE) != 0) {
+            // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
+            // they are ignored here because sending them as mouse input to SDL is messy
+            if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
+                switch (event.getAction()) {
+                case KeyEvent.ACTION_DOWN:
+                case KeyEvent.ACTION_UP:
+                    // mark the event as handled or it will be handled by system
+                    // handling KEYCODE_BACK by system will call onBackPressed()
+                    return true;
+                }
+            }
+        }
+
         return false;
     }
 
@@ -1214,7 +1228,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
         // !!! FIXME: dump this SDK check after 2.0.4 ships and require API14.
         if (event.getSource() == InputDevice.SOURCE_MOUSE && SDLActivity.mSeparateMouseAndTouch) {
             if (Build.VERSION.SDK_INT < 14) {
-                mouseButton = 1;    // For Android==12 all mouse buttons are the left button
+                mouseButton = 1; // all mouse buttons are the left button
             } else {
                 try {
                     mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
@@ -1627,8 +1641,7 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
             case InputDevice.SOURCE_JOYSTICK:
             case InputDevice.SOURCE_GAMEPAD:
             case InputDevice.SOURCE_DPAD:
-                SDLActivity.handleJoystickMotionEvent(event);
-                return true;
+                return SDLActivity.handleJoystickMotionEvent(event);
 
             case InputDevice.SOURCE_MOUSE:
                 action = event.getActionMasked();