mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 03:14:34 +01:00
Some cleanup
This commit is contained in:
1 parent
31f7ad574a
commit
3b45ca1d2f
5 files changed
+59
-47
No files matched your search
@@ -44,8 +44,6 @@ std::queue<FrameCommand> frameCommands;
|
||||
std::string systemName;
|
||||
std::string langRegion;
|
||||
|
||||
const bool extraLog = true;
|
||||
|
||||
static float left_joystick_x_async;
|
||||
static float left_joystick_y_async;
|
||||
static float right_joystick_x_async;
|
||||
@@ -134,13 +132,9 @@ extern "C" jboolean Java_com_henrikrydgard_libnative_NativeApp_isLandscape(JNIEn
|
||||
return landscape;
|
||||
}
|
||||
|
||||
// For the Back button to work right.
|
||||
// Allow the app to intercept the back button.
|
||||
extern "C" jboolean Java_com_henrikrydgard_libnative_NativeApp_isAtTopLevel(JNIEnv *env, jclass) {
|
||||
bool isAtTop = NativeIsAtTopLevel();
|
||||
if (extraLog) {
|
||||
ILOG("isAtTopLevel %i", (int)isAtTop);
|
||||
}
|
||||
return isAtTop;
|
||||
return NativeIsAtTopLevel();
|
||||
}
|
||||
|
||||
extern "C" void Java_com_henrikrydgard_libnative_NativeApp_audioConfig
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Minimal audio streaming using OpenSL.
|
||||
//
|
||||
// Loosely based on the Android NDK sample code.
|
||||
// Hardcoded to 44.1kHz stereo 16-bit audio, because as far as I'm concerned,
|
||||
// that's the only format that makes any sense.
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.henrikrydgard.libnative;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.UUID;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
public class Installation {
|
||||
private static String sID = null;
|
||||
private static final String INSTALLATION = "INSTALLATION";
|
||||
|
||||
public synchronized static String id(Context context) {
|
||||
if (sID == null) {
|
||||
File installation = new File(context.getFilesDir(), INSTALLATION);
|
||||
try {
|
||||
if (!installation.exists())
|
||||
writeInstallationFile(installation);
|
||||
sID = readInstallationFile(installation);
|
||||
} catch (Exception e) {
|
||||
// We can't even open a file for writing? Then we can't get a unique-ish installation id.
|
||||
return "BROKENAPPUSERFILESYSTEM";
|
||||
}
|
||||
}
|
||||
return sID;
|
||||
}
|
||||
|
||||
private static String readInstallationFile(File installation) throws IOException {
|
||||
RandomAccessFile f = new RandomAccessFile(installation, "r");
|
||||
byte[] bytes = new byte[(int) f.length()];
|
||||
f.readFully(bytes);
|
||||
f.close();
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
private static void writeInstallationFile(File installation) throws IOException {
|
||||
FileOutputStream out = new FileOutputStream(installation);
|
||||
String id = UUID.randomUUID().toString();
|
||||
out.write(id.getBytes());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,41 +51,6 @@ import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
class Installation {
|
||||
private static String sID = null;
|
||||
private static final String INSTALLATION = "INSTALLATION";
|
||||
|
||||
public synchronized static String id(Context context) {
|
||||
if (sID == null) {
|
||||
File installation = new File(context.getFilesDir(), INSTALLATION);
|
||||
try {
|
||||
if (!installation.exists())
|
||||
writeInstallationFile(installation);
|
||||
sID = readInstallationFile(installation);
|
||||
} catch (Exception e) {
|
||||
// We can't even open a file for writing? Then we can't get a unique-ish installation id.
|
||||
return "BROKENAPPUSERFILESYSTEM";
|
||||
}
|
||||
}
|
||||
return sID;
|
||||
}
|
||||
|
||||
private static String readInstallationFile(File installation) throws IOException {
|
||||
RandomAccessFile f = new RandomAccessFile(installation, "r");
|
||||
byte[] bytes = new byte[(int) f.length()];
|
||||
f.readFully(bytes);
|
||||
f.close();
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
private static void writeInstallationFile(File installation) throws IOException {
|
||||
FileOutputStream out = new FileOutputStream(installation);
|
||||
String id = UUID.randomUUID().toString();
|
||||
out.write(id.getBytes());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
public class NativeActivity extends Activity {
|
||||
// Remember to loadLibrary your JNI .so in a static {} block
|
||||
|
||||
@@ -135,6 +100,10 @@ public class NativeActivity extends Activity {
|
||||
private void detectOptimalAudioSettings() {
|
||||
try {
|
||||
optimalFramesPerBuffer = Integer.parseInt(this.audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignore, if we can't parse it it's bogus and zero is a fine value (means we couldn't detect it).
|
||||
}
|
||||
try {
|
||||
optimalSampleRate = Integer.parseInt(this.audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignore, if we can't parse it it's bogus and zero is a fine value (means we couldn't detect it).
|
||||
@@ -159,7 +128,7 @@ public class NativeActivity extends Activity {
|
||||
return libdir;
|
||||
}
|
||||
|
||||
@TargetApi(13)
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
void GetScreenSizeHC(Point size) {
|
||||
WindowManager w = getWindowManager();
|
||||
w.getDefaultDisplay().getSize(size);
|
||||
|
||||
@@ -21,8 +21,10 @@ public class NativeRenderer implements GLSurfaceView.Renderer {
|
||||
isDark = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawFrame(GL10 unused /*use GLES20*/) {
|
||||
if (isDark) {
|
||||
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
|
||||
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_STENCIL_BUFFER_BIT);
|
||||
} else {
|
||||
@@ -30,17 +32,20 @@ public class NativeRenderer implements GLSurfaceView.Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
|
||||
// Log.i(TAG, "onSurfaceCreated - EGL context is new or was lost");
|
||||
// Actually, it seems that it is here we should recreate lost GL objects.
|
||||
displayInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceChanged(GL10 unused, int width, int height) {
|
||||
Log.i(TAG, "onSurfaceChanged");
|
||||
displayResize(width, height);
|
||||
}
|
||||
|
||||
|
||||
// Not override, it's custom.
|
||||
public void onDestroyed() {
|
||||
displayShutdown();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user