]> Chaos Git - vn/vndc.git/commitdiff
Finish up for today - Android is not succeeding in working properly. It may be best...
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 26 Aug 2014 05:58:06 +0000 (01:58 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 26 Aug 2014 05:58:06 +0000 (01:58 -0400)
external/Android/AndroidManifest.xml
external/Android/jni/Application.mk
external/Android/src/org/libsdl/app/SDLActivity.java
vndc/include/gitrev.hpp

index a3c10c17687a73ec3a8932e0742b69689622a0ed..1f9e5fee3e641605c83adcfa06f77b4f61b4cb69 100644 (file)
@@ -25,8 +25,8 @@
         <activity android:name="VNDCActivity"
                   android:label="@string/app_name"
                   android:configChanges="keyboardHidden|orientation"
-                  android:screenOrientation="landscape"
                   >
+
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
index 08ff3217e779b51759876b19664decdce0b2b738..12c3c4a4234597b951fb6ba68d723fd9613a7e03 100644 (file)
@@ -3,5 +3,5 @@
 # See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
 # APP_STL := stlport_static 
 
+APP_STL := gnustl_static
 APP_ABI := armeabi armeabi-v7a x86
-APP_STL := gnustl_shared
index 49a1d38f8a7bb9305c44611b45b61d98c153f74a..25b1b02e1911605d8e6c974fb6a039b0f7e213fc 100644 (file)
@@ -40,21 +40,21 @@ public class SDLActivity extends Activity {
 
     // This is what SDL runs in. It invokes SDL_main(), eventually
     protected static Thread mSDLThread;
-    
+
     // Audio
     protected static AudioTrack mAudioTrack;
 
     // Load the .so
     static {
         System.loadLibrary("SDL2");
-        //System.loadLibrary("SDL2_image");
-        //System.loadLibrary("SDL2_mixer");
+        System.loadLibrary("SDL2_image");
+        System.loadLibrary("SDL2_mixer");
         //System.loadLibrary("SDL2_net");
-        //System.loadLibrary("SDL2_ttf");
+        System.loadLibrary("SDL2_ttf");
         System.loadLibrary("main");
     }
-    
-    
+
+
     public static void initialize() {
         // The static nature of the singleton and Android quirkyness force us to initialize everything here
         // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values
@@ -76,14 +76,14 @@ public class SDLActivity extends Activity {
     protected void onCreate(Bundle savedInstanceState) {
         Log.v("SDL", "onCreate():" + mSingleton);
         super.onCreate(savedInstanceState);
-        
+
         SDLActivity.initialize();
         // So we can call stuff from static callbacks
         mSingleton = this;
 
         // Set up the surface
         mSurface = new SDLSurface(getApplication());
-        
+
         if(Build.VERSION.SDK_INT >= 12) {
             mJoystickHandler = new SDLJoystickHandler_API12();
         }
@@ -149,7 +149,7 @@ public class SDLActivity extends Activity {
 
             //Log.v("SDL", "Finished waiting for SDL thread");
         }
-            
+
         super.onDestroy();
         // Reset everything in case the user re opens the app
         SDLActivity.initialize();
@@ -193,7 +193,7 @@ public class SDLActivity extends Activity {
             mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
         }
     }
-        
+
     /* The native thread has finished */
     public static void handleNativeExit() {
         SDLActivity.mSDLThread = null;
@@ -286,14 +286,14 @@ public class SDLActivity extends Activity {
     public static native void onNativeKeyUp(int keycode);
     public static native void onNativeKeyboardFocusLost();
     public static native void onNativeTouch(int touchDevId, int pointerFingerId,
-                                            int action, float x, 
+                                            int action, float x,
                                             float y, float p);
     public static native void onNativeAccel(float x, float y, float z);
     public static native void onNativeSurfaceChanged();
     public static native void onNativeSurfaceDestroyed();
     public static native void nativeFlipBuffers();
-    public static native int nativeAddJoystick(int device_id, String name, 
-                                               int is_accelerometer, int nbuttons, 
+    public static native int nativeAddJoystick(int device_id, String name,
+                                               int is_accelerometer, int nbuttons,
                                                int naxes, int nhats, int nballs);
     public static native int nativeRemoveJoystick(int device_id);
 
@@ -384,7 +384,7 @@ public class SDLActivity extends Activity {
         // Transfer the task to the main thread as a Runnable
         return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
     }
-            
+
     public static Surface getNativeSurface() {
         return SDLActivity.mSurface.getNativeSurface();
     }
@@ -394,36 +394,36 @@ public class SDLActivity extends Activity {
         int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
         int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
         int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
-        
+
         Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
-        
+
         // Let the user pick a larger buffer if they really want -- but ye
         // gods they probably shouldn't, the minimums are horrifyingly high
         // latency already
         desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
-        
+
         if (mAudioTrack == null) {
             mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
                     channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
-            
+
             // Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
             // Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
             // Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
-            
+
             if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
                 Log.e("SDL", "Failed during initialization of Audio Track");
                 mAudioTrack = null;
                 return -1;
             }
-            
+
             mAudioTrack.play();
         }
-       
+
         Log.v("SDL", "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
-        
+
         return 0;
     }
-    
+
     public static void audioWriteShortBuffer(short[] buffer) {
         for (int i = 0; i < buffer.length; ) {
             int result = mAudioTrack.write(buffer, i, buffer.length - i);
@@ -441,7 +441,7 @@ public class SDLActivity extends Activity {
             }
         }
     }
-    
+
     public static void audioWriteByteBuffer(byte[] buffer) {
         for (int i = 0; i < buffer.length; ) {
             int result = mAudioTrack.write(buffer, i, buffer.length - i);
@@ -484,18 +484,18 @@ public class SDLActivity extends Activity {
         }
         return Arrays.copyOf(filtered, used);
     }
-            
+
     // Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
     public static boolean handleJoystickMotionEvent(MotionEvent event) {
         return mJoystickHandler.handleMotionEvent(event);
     }
-    
+
     public static void pollInputDevices() {
         if (SDLActivity.mSDLThread != null) {
             mJoystickHandler.pollInputDevices();
         }
     }
-    
+
 }
 
 /**
@@ -514,11 +514,11 @@ class SDLMain implements Runnable {
 
 /**
     SDLSurface. This is what we draw on, so we need to know when it's created
-    in order to do anything useful. 
+    in order to do anything useful.
 
     Because of this, that's where we set up the SDL thread
 */
-class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, 
+class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
     View.OnKeyListener, View.OnTouchListener, SensorEventListener  {
 
     // Sensors
@@ -528,20 +528,20 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
     // Keep track of the surface size to normalize touch events
     protected static float mWidth, mHeight;
 
-    // Startup    
+    // Startup
     public SDLSurface(Context context) {
         super(context);
-        getHolder().addCallback(this); 
-    
+        getHolder().addCallback(this);
+
         setFocusable(true);
         setFocusableInTouchMode(true);
         requestFocus();
-        setOnKeyListener(this); 
-        setOnTouchListener(this);   
+        setOnKeyListener(this);
+        setOnTouchListener(this);
 
         mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
         mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
-        
+
         if(Build.VERSION.SDK_INT >= 12) {
             setOnGenericMotionListener(new SDLGenericMotionListener_API12());
         }
@@ -550,7 +550,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
         mWidth = 1.0f;
         mHeight = 1.0f;
     }
-    
+
     public Surface getNativeSurface() {
         return getHolder().getSurface();
     }
@@ -640,7 +640,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
             SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread");
             enableSensor(Sensor.TYPE_ACCELEROMETER, true);
             SDLActivity.mSDLThread.start();
-            
+
             // Set up a listener thread to catch when the native thread ends
             new Thread(new Runnable(){
                 @Override
@@ -649,7 +649,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                         SDLActivity.mSDLThread.join();
                     }
                     catch(Exception e){}
-                    finally{ 
+                    finally{
                         // Native thread has finished
                         if (! SDLActivity.mExitCalledFromJava) {
                             SDLActivity.handleNativeExit();
@@ -671,7 +671,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
         // Dispatch the different events depending on where they come from
         // Some SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
         // So, we try to process them as DPAD or GAMEPAD events first, if that fails we try them as KEYBOARD
-        
+
         if ( (event.getSource() & 0x00000401) != 0 || /* API 12: SOURCE_GAMEPAD */
                    (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {
             if (event.getAction() == KeyEvent.ACTION_DOWN) {
@@ -684,7 +684,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                 }
             }
         }
-        
+
         if( (event.getSource() & InputDevice.SOURCE_KEYBOARD) != 0) {
             if (event.getAction() == KeyEvent.ACTION_DOWN) {
                 //Log.v("SDL", "key down: " + keyCode);
@@ -697,7 +697,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                 return true;
             }
         }
-        
+
         return false;
     }
 
@@ -711,7 +711,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
         int pointerFingerId;
         int i = -1;
         float x,y,p;
-        
+
         switch(action) {
             case MotionEvent.ACTION_MOVE:
                 for (i = 0; i < pointerCount; i++) {
@@ -722,7 +722,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                     SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
                 }
                 break;
-            
+
             case MotionEvent.ACTION_UP:
             case MotionEvent.ACTION_DOWN:
                 // Primary pointer up/down, the index is always zero
@@ -733,34 +733,34 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                 if (i == -1) {
                     i = event.getActionIndex();
                 }
-                
+
                 pointerFingerId = event.getPointerId(i);
                 x = event.getX(i) / mWidth;
                 y = event.getY(i) / mHeight;
                 p = event.getPressure(i);
                 SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
                 break;
-            
+
             default:
                 break;
         }
 
         return true;
-   } 
+   }
 
     // Sensor events
     public void enableSensor(int sensortype, boolean enabled) {
         // TODO: This uses getDefaultSensor - what if we have >1 accels?
         if (enabled) {
-            mSensorManager.registerListener(this, 
-                            mSensorManager.getDefaultSensor(sensortype), 
+            mSensorManager.registerListener(this,
+                            mSensorManager.getDefaultSensor(sensortype),
                             SensorManager.SENSOR_DELAY_GAME, null);
         } else {
-            mSensorManager.unregisterListener(this, 
+            mSensorManager.unregisterListener(this,
                             mSensorManager.getDefaultSensor(sensortype));
         }
     }
-    
+
     @Override
     public void onAccuracyChanged(Sensor sensor, int accuracy) {
         // TODO
@@ -792,7 +792,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                                       y / SensorManager.GRAVITY_EARTH,
                                       event.values[2] / SensorManager.GRAVITY_EARTH - 1);
         }
-    }    
+    }
 }
 
 /* This is a fake invisible editor view that receives the input and defines the
@@ -834,7 +834,7 @@ class DummyEdit extends View implements View.OnKeyListener {
 
         return false;
     }
-        
+
     //
     @Override
     public boolean onKeyPreIme (int keyCode, KeyEvent event) {
@@ -913,7 +913,7 @@ class SDLInputConnection extends BaseInputConnection {
     public native void nativeSetComposingText(String text, int newCursorPosition);
 
     @Override
-    public boolean deleteSurroundingText(int beforeLength, int afterLength) {       
+    public boolean deleteSurroundingText(int beforeLength, int afterLength) {
         // Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
         if (beforeLength == 1 && afterLength == 0) {
             // backspace
@@ -927,18 +927,18 @@ class SDLInputConnection extends BaseInputConnection {
 
 /* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */
 class SDLJoystickHandler {
-    
+
     public boolean handleMotionEvent(MotionEvent event) {
         return false;
     }
-    
+
     public void pollInputDevices() {
     }
 }
 
 /* Actual joystick functionality available for API >= 12 devices */
 class SDLJoystickHandler_API12 extends SDLJoystickHandler {
-  
+
     class SDLJoystick {
         public int device_id;
         public String name;
@@ -952,11 +952,11 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
             return arg0.getAxis() - arg1.getAxis();
         }
     }
-    
+
     private ArrayList<SDLJoystick> mJoysticks;
-    
+
     public SDLJoystickHandler_API12() {
-       
+
         mJoysticks = new ArrayList<SDLJoystick>();
     }
 
@@ -967,7 +967,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
         // For example, in the case of the XBox 360 wireless dongle,
         // so the first controller seen by SDL matches what the receiver
         // considers to be the first controller
-        
+
         for(int i=deviceIds.length-1; i>-1; i--) {
             SDLJoystick joystick = getJoystick(deviceIds[i]);
             if (joystick == null) {
@@ -978,7 +978,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
                     joystick.name = joystickDevice.getName();
                     joystick.axes = new ArrayList<InputDevice.MotionRange>();
                     joystick.hats = new ArrayList<InputDevice.MotionRange>();
-                    
+
                     List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
                     Collections.sort(ranges, new RangeComparator());
                     for (InputDevice.MotionRange range : ranges ) {
@@ -992,14 +992,14 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
                             }
                         }
                     }
-                    
+
                     mJoysticks.add(joystick);
-                    SDLActivity.nativeAddJoystick(joystick.device_id, joystick.name, 0, -1, 
+                    SDLActivity.nativeAddJoystick(joystick.device_id, joystick.name, 0, -1,
                                                   joystick.axes.size(), joystick.hats.size()/2, 0);
                 }
             }
         }
-        
+
         /* Check removed devices */
         ArrayList<Integer> removedDevices = new ArrayList<Integer>();
         for(int i=0; i < mJoysticks.size(); i++) {
@@ -1012,7 +1012,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
                 removedDevices.add(device_id);
             }
         }
-            
+
         for(int i=0; i < removedDevices.size(); i++) {
             int device_id = removedDevices.get(i);
             SDLActivity.nativeRemoveJoystick(device_id);
@@ -1022,9 +1022,9 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
                     break;
                 }
             }
-        }        
+        }
     }
-    
+
     protected SDLJoystick getJoystick(int device_id) {
         for(int i=0; i < mJoysticks.size(); i++) {
             if (mJoysticks.get(i).device_id == device_id) {
@@ -1032,9 +1032,9 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
             }
         }
         return null;
-    }   
-    
-    @Override        
+    }
+
+    @Override
     public boolean handleMotionEvent(MotionEvent event) {
         if ( (event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
             int actionPointerIndex = event.getActionIndex();
@@ -1048,7 +1048,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
                             /* Normalize the value to -1...1 */
                             float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
                             SDLActivity.onNativeJoy(joystick.device_id, i, value );
-                        }          
+                        }
                         for (int i = 0; i < joystick.hats.size(); i+=2) {
                             int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
                             int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
@@ -1061,7 +1061,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
             }
         }
         return true;
-    }            
+    }
 }
 
 class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
index bb44b26218c26d256dc645b42a0ae22a5a5603ef..37aada8dab6722cb7bede82ec177e1a1bd4acafe 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef GIT_REV_HDR
 #define GIT_REV_HDR
-#define GIT_REV "76f2254e2693ed8e1696445264e7aed57e60784e"
-
+#define GIT_REV "1982fb78b84fe7edfe01a2bd291ee4200536c563"
+#define WITH_ANDROID 1
 #endif