mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
Merge pull request #11133 from unknownbrackets/java-format
Android: Reformat Java files
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioManager.OnAudioFocusChangeListener;
|
||||
|
||||
public class AudioFocusChangeListener implements OnAudioFocusChangeListener{
|
||||
public class AudioFocusChangeListener implements OnAudioFocusChangeListener {
|
||||
// not used right now, but we may need to use it sometime. So just store it
|
||||
// for now.
|
||||
private boolean hasAudioFocus = false;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onAudioFocusChange(int focusChange) {
|
||||
switch (focusChange){
|
||||
switch (focusChange) {
|
||||
case AudioManager.AUDIOFOCUS_GAIN:
|
||||
hasAudioFocus = true;
|
||||
break;
|
||||
|
||||
|
||||
case AudioManager.AUDIOFOCUS_LOSS:
|
||||
hasAudioFocus = false;
|
||||
break;
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.graphics.SurfaceTexture;
|
||||
import android.graphics.YuvImage;
|
||||
import android.hardware.Camera;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -42,10 +41,10 @@ class CameraHelper {
|
||||
|
||||
// crop to expected size and convert to Jpeg
|
||||
Rect rect = new Rect(
|
||||
(previewWidth-targetW)/2,
|
||||
(previewHeight-targetH)/2,
|
||||
previewWidth-(previewWidth-targetW)/2,
|
||||
previewHeight-(previewHeight-targetH)/2
|
||||
(previewWidth - targetW) / 2,
|
||||
(previewHeight - targetH) / 2,
|
||||
previewWidth - (previewWidth - targetW) / 2,
|
||||
previewHeight - (previewHeight - targetH) / 2
|
||||
);
|
||||
yuvImage.compressToJpeg(rect, 80, baos);
|
||||
NativeApp.pushCameraImage(baos.toByteArray());
|
||||
|
||||
@@ -11,42 +11,44 @@ import android.view.MotionEvent;
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||
public class InputDeviceState {
|
||||
private static final String TAG = "InputDeviceState";
|
||||
|
||||
|
||||
private static final int deviceId = NativeApp.DEVICE_ID_PAD_0;
|
||||
|
||||
private InputDevice mDevice;
|
||||
private int[] mAxes;
|
||||
|
||||
InputDevice getDevice() { return mDevice; }
|
||||
InputDevice getDevice() {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
@TargetApi(19)
|
||||
void logAdvanced(InputDevice device) {
|
||||
Log.i(TAG, "Vendor ID:" + device.getVendorId() + " productId: " + device.getProductId());
|
||||
Log.i(TAG, "Vendor ID:" + device.getVendorId() + " productId: " + device.getProductId());
|
||||
}
|
||||
|
||||
|
||||
public InputDeviceState(InputDevice device) {
|
||||
mDevice = device;
|
||||
int numAxes = 0;
|
||||
for (MotionRange range : device.getMotionRanges()) {
|
||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
numAxes += 1;
|
||||
}
|
||||
}
|
||||
mDevice = device;
|
||||
int numAxes = 0;
|
||||
for (MotionRange range : device.getMotionRanges()) {
|
||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
numAxes += 1;
|
||||
}
|
||||
}
|
||||
|
||||
mAxes = new int[numAxes];
|
||||
mAxes = new int[numAxes];
|
||||
|
||||
int i = 0;
|
||||
for (MotionRange range : device.getMotionRanges()) {
|
||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
mAxes[i++] = range.getAxis();
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "Registering input device with " + numAxes + " axes: " + device.getName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
logAdvanced(device);
|
||||
}
|
||||
NativeApp.sendMessage("inputDeviceConnected", device.getName());
|
||||
int i = 0;
|
||||
for (MotionRange range : device.getMotionRanges()) {
|
||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
mAxes[i++] = range.getAxis();
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "Registering input device with " + numAxes + " axes: " + device.getName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
logAdvanced(device);
|
||||
}
|
||||
NativeApp.sendMessage("inputDeviceConnected", device.getName());
|
||||
}
|
||||
|
||||
public boolean onKeyDown(KeyEvent event) {
|
||||
@@ -54,12 +56,12 @@ public class InputDeviceState {
|
||||
boolean repeat = event.getRepeatCount() > 0;
|
||||
return NativeApp.keyDown(deviceId, keyCode, repeat);
|
||||
}
|
||||
|
||||
|
||||
public boolean onKeyUp(KeyEvent event) {
|
||||
int keyCode = event.getKeyCode();
|
||||
return NativeApp.keyUp(deviceId, keyCode);
|
||||
return NativeApp.keyUp(deviceId, keyCode);
|
||||
}
|
||||
|
||||
|
||||
public boolean onJoystickMotion(MotionEvent event) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) {
|
||||
return false;
|
||||
|
||||
@@ -48,12 +48,12 @@ class LocationHelper implements LocationListener {
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
float latitude = (float)location.getLatitude();
|
||||
float longitude = (float)location.getLongitude();
|
||||
float altitude = (float)location.getAltitude();
|
||||
float speed = location.getSpeed();
|
||||
float bearing = location.getBearing();
|
||||
long time = location.getTime() / 1000; // ms to s !!
|
||||
float latitude = (float) location.getLatitude();
|
||||
float longitude = (float) location.getLongitude();
|
||||
float altitude = (float) location.getAltitude();
|
||||
float speed = location.getSpeed();
|
||||
float bearing = location.getBearing();
|
||||
long time = location.getTime() / 1000; // ms to s !!
|
||||
|
||||
NativeApp.pushNewGpsData(latitude, longitude, altitude, speed, bearing, time);
|
||||
}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
/**
|
||||
* Mupen64PlusAE, an N64 emulator for the Android platform
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2013 Paul Lamb
|
||||
*
|
||||
*
|
||||
* This file is part of Mupen64PlusAE.
|
||||
*
|
||||
*
|
||||
* Mupen64PlusAE is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* Mupen64PlusAE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Mupen64PlusAE. If
|
||||
* not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Authors: Paul Lamb
|
||||
*/
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -29,90 +27,73 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.bda.controller.Controller;
|
||||
import com.bda.controller.IControllerService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Temporary hack for crash in MOGA library on Lollipop. This hack can be removed once MOGA fixes
|
||||
* their library. The actual issue is caused by the use of implicit service intents, which are
|
||||
* illegal in Lollipop, as seen in the logcat message below.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* {@code Service Intent must be explicit: Intent { act=com.bda.controller.IControllerService } }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @see <a href="http://www.mogaanywhere.com/developers/">MOGA developer site</a>
|
||||
* @see <a href="http://commonsware.com/blog/2014/06/29/dealing-deprecations-bindservice.html">
|
||||
* Discussion on explicit intents</a>
|
||||
*/
|
||||
public class MogaHack
|
||||
{
|
||||
public static void init(Controller controller, Context context )
|
||||
{
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
|
||||
{
|
||||
boolean mIsBound = false;
|
||||
java.lang.reflect.Field fIsBound = null;
|
||||
android.content.ServiceConnection mServiceConnection = null;
|
||||
java.lang.reflect.Field fServiceConnection = null;
|
||||
try
|
||||
{
|
||||
Class<?> cMogaController = controller.getClass();
|
||||
fIsBound = cMogaController.getDeclaredField( "mIsBound" );
|
||||
fIsBound.setAccessible( true );
|
||||
mIsBound = fIsBound.getBoolean( controller );
|
||||
fServiceConnection = cMogaController.getDeclaredField( "mServiceConnection" );
|
||||
fServiceConnection.setAccessible( true );
|
||||
mServiceConnection = ( android.content.ServiceConnection ) fServiceConnection.get( controller );
|
||||
}
|
||||
catch( NoSuchFieldException e )
|
||||
{
|
||||
Log.e( "MogaHack", "MOGA Lollipop Hack NoSuchFieldException (get)", e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
Log.e( "MogaHack", "MOGA Lollipop Hack IllegalAccessException (get)", e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
Log.e( "MogaHack", "MOGA Lollipop Hack IllegalArgumentException (get)", e );
|
||||
}
|
||||
if( ( !mIsBound ) && ( mServiceConnection != null ) )
|
||||
{
|
||||
// Convert implicit intent to explicit intent, see http://stackoverflow.com/a/26318757
|
||||
Intent intent = new Intent( IControllerService.class.getName() );
|
||||
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentServices( intent, 0 );
|
||||
if( resolveInfos == null || resolveInfos.size() != 1 )
|
||||
{
|
||||
// What? this doesn't do anything.
|
||||
// Log.e( "MogaHack", "Somebody is trying to intercept our intent. Disabling MOGA controller for security." );
|
||||
}
|
||||
ServiceInfo serviceInfo = resolveInfos.get( 0 ).serviceInfo;
|
||||
String packageName = serviceInfo.packageName;
|
||||
String className = serviceInfo.name;
|
||||
intent.setComponent( new ComponentName( packageName, className ) );
|
||||
|
||||
// Start the service explicitly
|
||||
context.startService( intent );
|
||||
context.bindService( intent, mServiceConnection, 1 );
|
||||
try
|
||||
{
|
||||
fIsBound.setBoolean( controller, true );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
Log.e( "MogaHack", "MOGA Lollipop Hack IllegalAccessException (set)", e );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
Log.e( "MogaHack", "MOGA Lollipop Hack IllegalArgumentException (set)", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
controller.init();
|
||||
}
|
||||
}
|
||||
public class MogaHack {
|
||||
public static void init(Controller controller, Context context) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||
boolean mIsBound = false;
|
||||
java.lang.reflect.Field fIsBound = null;
|
||||
android.content.ServiceConnection mServiceConnection = null;
|
||||
java.lang.reflect.Field fServiceConnection = null;
|
||||
|
||||
try {
|
||||
Class<?> cMogaController = controller.getClass();
|
||||
fIsBound = cMogaController.getDeclaredField("mIsBound");
|
||||
fIsBound.setAccessible(true);
|
||||
mIsBound = fIsBound.getBoolean(controller);
|
||||
fServiceConnection = cMogaController.getDeclaredField("mServiceConnection");
|
||||
fServiceConnection.setAccessible(true);
|
||||
mServiceConnection = (android.content.ServiceConnection) fServiceConnection.get(controller);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack NoSuchFieldException (get)", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalAccessException (get)", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalArgumentException (get)", e);
|
||||
}
|
||||
|
||||
if ((!mIsBound) && (mServiceConnection != null)) {
|
||||
// Convert implicit intent to explicit intent, see http://stackoverflow.com/a/26318757
|
||||
Intent intent = new Intent(IControllerService.class.getName());
|
||||
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentServices(intent, 0);
|
||||
if (resolveInfos == null || resolveInfos.size() != 1) {
|
||||
// What? this doesn't do anything.
|
||||
// Log.e("MogaHack", "Somebody is trying to intercept our intent. Disabling MOGA controller for security.");
|
||||
}
|
||||
ServiceInfo serviceInfo = resolveInfos.get(0).serviceInfo;
|
||||
String packageName = serviceInfo.packageName;
|
||||
String className = serviceInfo.name;
|
||||
intent.setComponent(new ComponentName(packageName, className));
|
||||
|
||||
// Start the service explicitly
|
||||
context.startService(intent);
|
||||
context.bindService(intent, mServiceConnection, 1);
|
||||
try {
|
||||
fIsBound.setBoolean(controller, true);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalAccessException (set)", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalArgumentException (set)", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
controller.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,16 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
|
||||
// Note that the display* methods are in NativeRenderer.java
|
||||
|
||||
public class NativeApp {
|
||||
public final static int DEVICE_ID_DEFAULT = 0;
|
||||
public final static int DEVICE_ID_KEYBOARD = 1;
|
||||
public final static int DEVICE_ID_MOUSE = 2;
|
||||
public final static int DEVICE_ID_PAD_0 = 10;
|
||||
public static final int DEVICE_ID_DEFAULT = 0;
|
||||
public static final int DEVICE_ID_KEYBOARD = 1;
|
||||
public static final int DEVICE_ID_MOUSE = 2;
|
||||
public static final int DEVICE_ID_PAD_0 = 10;
|
||||
|
||||
public final static int DEVICE_TYPE_MOBILE = 0;
|
||||
public final static int DEVICE_TYPE_TV = 1;
|
||||
public final static int DEVICE_TYPE_DESKTOP = 2;
|
||||
public static final int DEVICE_TYPE_MOBILE = 0;
|
||||
public static final int DEVICE_TYPE_TV = 1;
|
||||
public static final int DEVICE_TYPE_DESKTOP = 2;
|
||||
|
||||
public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String cacheDir, String shortcutParam, int androidVersion, String board);
|
||||
public static native void audioInit();
|
||||
@@ -56,4 +55,3 @@ public class NativeApp {
|
||||
|
||||
public static native void pushCameraImage(byte[] image);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
|
||||
import android.opengl.GLSurfaceView.EGLConfigChooser;
|
||||
import android.util.Log;
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
|
||||
public class NativeEGLConfigChooser implements EGLConfigChooser {
|
||||
private static final String TAG = "NativeEGLConfigChooser";
|
||||
@@ -24,6 +23,7 @@ public class NativeEGLConfigChooser implements EGLConfigChooser {
|
||||
public int stencil;
|
||||
public int depth;
|
||||
public int samples;
|
||||
|
||||
public void Log() {
|
||||
Log.i(TAG, "EGLConfig: red=" + red + " green=" + green + " blue=" + blue + " alpha=" + alpha + " depth=" + depth + " stencil=" + stencil + " samples=" + samples);
|
||||
}
|
||||
@@ -79,22 +79,22 @@ public class NativeEGLConfigChooser implements EGLConfigChooser {
|
||||
};
|
||||
|
||||
int[] num_config = new int[1];
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
|
||||
throw new IllegalArgumentException("eglChooseConfig failed when counting");
|
||||
}
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
|
||||
throw new IllegalArgumentException("eglChooseConfig failed when counting");
|
||||
}
|
||||
|
||||
int numConfigs = num_config[0];
|
||||
Log.i(TAG, "There are " + numConfigs + " egl configs");
|
||||
if (numConfigs <= 0) {
|
||||
throw new IllegalArgumentException("No configs match configSpec");
|
||||
}
|
||||
int numConfigs = num_config[0];
|
||||
Log.i(TAG, "There are " + numConfigs + " egl configs");
|
||||
if (numConfigs <= 0) {
|
||||
throw new IllegalArgumentException("No configs match configSpec");
|
||||
}
|
||||
|
||||
EGLConfig[] eglConfigs = new EGLConfig[numConfigs];
|
||||
if (!egl.eglChooseConfig(display, configSpec, eglConfigs, numConfigs, num_config)) {
|
||||
throw new IllegalArgumentException("eglChooseConfig failed when retrieving");
|
||||
}
|
||||
throw new IllegalArgumentException("eglChooseConfig failed when retrieving");
|
||||
}
|
||||
|
||||
ConfigAttribs [] configs = getConfigAttribs(egl, display, eglConfigs);
|
||||
ConfigAttribs[] configs = getConfigAttribs(egl, display, eglConfigs);
|
||||
|
||||
ConfigAttribs chosen = null;
|
||||
|
||||
@@ -103,7 +103,6 @@ public class NativeEGLConfigChooser implements EGLConfigChooser {
|
||||
configs[i].Log();
|
||||
}
|
||||
|
||||
|
||||
// We now ignore destination alpha as a workaround for the Mali issue
|
||||
// where we get badly composited if we use it.
|
||||
// Though, that may be possible to fix by using EGL10.EGL_TRANSPARENT_TYPE, EGL10.EGL_NONE.
|
||||
@@ -201,12 +200,11 @@ public class NativeEGLConfigChooser implements EGLConfigChooser {
|
||||
}
|
||||
|
||||
if (chosen == null) {
|
||||
throw new IllegalArgumentException("Failed to find a valid EGL config");
|
||||
throw new IllegalArgumentException("Failed to find a valid EGL config");
|
||||
}
|
||||
|
||||
Log.i(TAG, "Final chosen config: ");
|
||||
chosen.Log();
|
||||
return chosen.config;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.bda.controller.*;
|
||||
|
||||
public class NativeGLView extends GLSurfaceView implements SensorEventListener, ControllerListener {
|
||||
@@ -37,7 +35,7 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
|
||||
super(activity);
|
||||
mActivity = activity;
|
||||
|
||||
mSensorManager = (SensorManager)activity.getSystemService(Activity.SENSOR_SERVICE);
|
||||
mSensorManager = (SensorManager) activity.getSystemService(Activity.SENSOR_SERVICE);
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
|
||||
mController = Controller.getInstance(activity);
|
||||
@@ -89,7 +87,7 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
|
||||
if (code != 0) {
|
||||
if (canReadToolType) {
|
||||
int tool = getToolType(ev, i);
|
||||
code |= tool << 10; // We use the Android tool type codes
|
||||
code |= tool << 10; // We use the Android tool type codes
|
||||
}
|
||||
// Can't use || due to short circuit evaluation
|
||||
numTouchesHandled += NativeApp.touch(ev.getX(i), ev.getY(i), code, pid) ? 1 : 0;
|
||||
@@ -161,7 +159,7 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
|
||||
}
|
||||
}
|
||||
|
||||
boolean repeat = false; // Moga has no repeats?
|
||||
boolean repeat = false; // Moga has no repeats?
|
||||
switch (event.getAction()) {
|
||||
case KeyEvent.ACTION_DOWN:
|
||||
NativeApp.keyDown(NativeApp.DEVICE_ID_PAD_0, event.getKeyCode(), repeat);
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.util.Log;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
public class NativeRenderer implements GLSurfaceView.Renderer {
|
||||
private static String TAG = "NativeRenderer";
|
||||
private NativeActivity mActivity;
|
||||
@@ -35,12 +30,13 @@ public class NativeRenderer implements GLSurfaceView.Renderer {
|
||||
// Actually, it seems that it is here we should recreate lost GL objects.
|
||||
displayInit();
|
||||
}
|
||||
|
||||
|
||||
public void onSurfaceChanged(GL10 unused, int width, int height) {
|
||||
}
|
||||
|
||||
// Note: This also means "device lost" and you should reload
|
||||
// all buffered objects.
|
||||
public native void displayInit();
|
||||
// all buffered objects.
|
||||
public native void displayInit();
|
||||
|
||||
public native void displayRender();
|
||||
}
|
||||
|
||||
@@ -13,12 +13,9 @@ import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
// import android.os.Build;
|
||||
// import android.util.Log;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.bda.controller.*;
|
||||
|
||||
public class NativeSurfaceView extends SurfaceView implements SensorEventListener, ControllerListener {
|
||||
@@ -35,7 +32,7 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
|
||||
|
||||
Log.i(TAG, "NativeSurfaceView");
|
||||
|
||||
mSensorManager = (SensorManager)activity.getSystemService(Activity.SENSOR_SERVICE);
|
||||
mSensorManager = (SensorManager) activity.getSystemService(Activity.SENSOR_SERVICE);
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
|
||||
mController = Controller.getInstance(activity);
|
||||
@@ -62,8 +59,6 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
|
||||
boolean canReadToolType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||
|
||||
int numTouchesHandled = 0;
|
||||
//float scaleX = (float)mActivity.getRenderer().getDpiScaleX();
|
||||
//float scaleY = (float)mActivity.getRenderer().getDpiScaleY();
|
||||
for (int i = 0; i < ev.getPointerCount(); i++) {
|
||||
int pid = ev.getPointerId(i);
|
||||
int code = 0;
|
||||
@@ -92,7 +87,7 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
|
||||
if (code != 0) {
|
||||
if (canReadToolType) {
|
||||
int tool = getToolType(ev, i);
|
||||
code |= tool << 10; // We use the Android tool type codes
|
||||
code |= tool << 10; // We use the Android tool type codes
|
||||
}
|
||||
// Can't use || due to short circuit evaluation
|
||||
numTouchesHandled += NativeApp.touch(ev.getX(i), ev.getY(i), code, pid) ? 1 : 0;
|
||||
@@ -157,7 +152,7 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
|
||||
}
|
||||
}
|
||||
|
||||
boolean repeat = false; // Moga has no repeats?
|
||||
boolean repeat = false; // Moga has no repeats?
|
||||
switch (event.getAction()) {
|
||||
case KeyEvent.ACTION_DOWN:
|
||||
NativeApp.keyDown(NativeApp.DEVICE_ID_PAD_0, event.getKeyCode(), repeat);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PowerSaveModeReceiver extends BroadcastReceiver {
|
||||
|
||||
@TargetApi(21)
|
||||
private static boolean getNativePowerSaving(final Context context) {
|
||||
final PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||
final PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
return pm.isPowerSaveMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PpssppActivity extends NativeActivity {
|
||||
private static final String TAG = "PpssppActivity";
|
||||
@@ -58,7 +57,6 @@ public class PpssppActivity extends NativeActivity {
|
||||
}
|
||||
Looper.loop();
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
||||
try {
|
||||
@@ -95,7 +93,6 @@ public class PpssppActivity extends NativeActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
// called by the C++ code through JNI. Dispatch anything we can't directly handle
|
||||
// on the gfx thread to the UI thread.
|
||||
public void postCommand(String command, String parameter) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
@@ -11,10 +9,11 @@ import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This class will respond to android.intent.action.CREATE_SHORTCUT intent from
|
||||
* launcher homescreen. Register this class in AndroidManifest.xml.
|
||||
* This class will respond to android.intent.action.CREATE_SHORTCUT intent from launcher homescreen.
|
||||
* Register this class in AndroidManifest.xml.
|
||||
*/
|
||||
public class ShortcutActivity extends Activity {
|
||||
private static final String TAG = "PPSSPP";
|
||||
@@ -24,9 +23,7 @@ public class ShortcutActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Show file selector dialog here.
|
||||
SimpleFileChooser fileDialog = new SimpleFileChooser(this,
|
||||
Environment.getExternalStorageDirectory(),
|
||||
onFileSelectedListener);
|
||||
SimpleFileChooser fileDialog = new SimpleFileChooser(this, Environment.getExternalStorageDirectory(), onFileSelectedListener);
|
||||
fileDialog.showDialog();
|
||||
}
|
||||
|
||||
@@ -56,10 +53,8 @@ public class ShortcutActivity extends Activity {
|
||||
Intent responseIntent = new Intent();
|
||||
responseIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
responseIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
|
||||
ShortcutIconResource iconResource = Intent.ShortcutIconResource
|
||||
.fromContext(this, R.drawable.ic_launcher);
|
||||
responseIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
|
||||
iconResource);
|
||||
ShortcutIconResource iconResource = ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
|
||||
responseIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
|
||||
|
||||
setResult(RESULT_OK, responseIntent);
|
||||
|
||||
@@ -97,5 +92,4 @@ public class ShortcutActivity extends Activity {
|
||||
respondToShortcutRequest(file.getAbsolutePath());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
|
||||
/**
|
||||
* Simple dialog to pick file.
|
||||
*/
|
||||
/** Simple dialog to pick file. */
|
||||
public class SimpleFileChooser {
|
||||
|
||||
public interface FileSelectedListener {
|
||||
void onFileSelected(File file);
|
||||
}
|
||||
@@ -27,8 +23,7 @@ public class SimpleFileChooser {
|
||||
private String[] mFileList;
|
||||
private File mCurrentPath;
|
||||
|
||||
public SimpleFileChooser(Activity activity, File path,
|
||||
FileSelectedListener listener) {
|
||||
public SimpleFileChooser(Activity activity, File path, FileSelectedListener listener) {
|
||||
this.mActivity = activity;
|
||||
this.mFileListener = listener;
|
||||
if (!path.exists())
|
||||
@@ -83,8 +78,7 @@ public class SimpleFileChooser {
|
||||
return 1;
|
||||
else
|
||||
// when both are folders or both are files, sort by name
|
||||
return file1.getName().toUpperCase()
|
||||
.compareTo(file2.getName().toUpperCase());
|
||||
return file1.getName().toUpperCase().compareTo(file2.getName().toUpperCase());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -107,5 +101,4 @@ public class SimpleFileChooser {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.*;
|
||||
import android.util.Log;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class TextRenderer {
|
||||
private static Paint p;
|
||||
private static Paint bg;
|
||||
private static Typeface robotoCondensed;
|
||||
private static final String TAG = "TextRenderer";
|
||||
|
||||
static {
|
||||
p = new Paint(Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
|
||||
p.setColor(Color.WHITE);
|
||||
bg = new Paint();
|
||||
bg.setColor(Color.BLACK);
|
||||
}
|
||||
|
||||
public static void init(Context ctx) {
|
||||
robotoCondensed = Typeface.createFromAsset(ctx.getAssets(), "Roboto-Condensed.ttf");
|
||||
if (robotoCondensed != null) {
|
||||
@@ -25,23 +26,25 @@ public class TextRenderer {
|
||||
Log.e(TAG, "Failed to load Roboto Condensed");
|
||||
}
|
||||
}
|
||||
|
||||
private static Point measureLine(String string, double textSize) {
|
||||
int w;
|
||||
if (string.length() > 0) {
|
||||
p.setTextSize((float)textSize);
|
||||
w = (int)p.measureText(string);
|
||||
// Round width up to even already here to avoid annoyances from odd-width 16-bit textures which
|
||||
// OpenGL does not like - each line must be 4-byte aligned
|
||||
p.setTextSize((float) textSize);
|
||||
w = (int) p.measureText(string);
|
||||
// Round width up to even already here to avoid annoyances from odd-width 16-bit textures
|
||||
// which OpenGL does not like - each line must be 4-byte aligned
|
||||
w = (w + 5) & ~1;
|
||||
} else {
|
||||
w = 1;
|
||||
}
|
||||
int h = (int)(p.descent() - p.ascent() + 2.0f);
|
||||
int h = (int) (p.descent() - p.ascent() + 2.0f);
|
||||
Point p = new Point();
|
||||
p.x = w;
|
||||
p.y = h;
|
||||
return p;
|
||||
}
|
||||
|
||||
private static Point measure(String string, double textSize) {
|
||||
String lines[] = string.replaceAll("\\r", "").split("\n");
|
||||
Point total = new Point();
|
||||
@@ -50,13 +53,15 @@ public class TextRenderer {
|
||||
Point sz = measureLine(line, textSize);
|
||||
total.x = Math.max(sz.x, total.x);
|
||||
}
|
||||
total.y = (int)(p.descent() - p.ascent()) * lines.length + 2;
|
||||
total.y = (int) (p.descent() - p.ascent()) * lines.length + 2;
|
||||
return total;
|
||||
}
|
||||
|
||||
public static int measureText(String string, double textSize) {
|
||||
Point s = measure(string, textSize);
|
||||
return (s.x << 16) | s.y;
|
||||
}
|
||||
|
||||
public static int[] renderText(String string, double textSize) {
|
||||
Point s = measure(string, textSize);
|
||||
|
||||
@@ -79,7 +84,7 @@ public class TextRenderer {
|
||||
y += p.descent() - p.ascent();
|
||||
}
|
||||
|
||||
int [] pixels = new int[w * h];
|
||||
int[] pixels = new int[w * h];
|
||||
bmp.getPixels(pixels, 0, w, 0, 0, w, h);
|
||||
bmp.recycle();
|
||||
return pixels;
|
||||
|
||||
Reference in New Issue
Block a user