Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Errors. #2

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/pandroid/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage"/>

<uses-feature
android:required="true"
android:glEsVersion="0x0030000"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -13,14 +19,16 @@
android:theme="@style/Theme.Pandroid"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".app.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".app.GameActivity"
android:configChanges="screenSize|screenLayout|orientation|density|uiMode">
</activity>
</application>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage"/>
</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.panda3ds.pandroid.app;

import androidx.appcompat.app.AppCompatActivity;

public class BaseActivity extends AppCompatActivity {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.panda3ds.pandroid.app;

import android.content.Intent;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.panda3ds.pandroid.utils.Constants;
import com.panda3ds.pandroid.view.PandaGlSurfaceView;

public class GameActivity extends BaseActivity {
private PandaGlSurfaceView pandaSurface;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = getIntent();
if(!intent.hasExtra(Constants.EXTRA_PATH)){

setContentView(new FrameLayout(this));
Toast.makeText(this, "INVALID ROM PATH", Toast.LENGTH_LONG).show();
GabrielBRDeveloper marked this conversation as resolved.
Show resolved Hide resolved
finish();
return;
}

pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH));;
setContentView(pandaSurface);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package com.panda3ds.pandroid;
package com.panda3ds.pandroid.app;

import androidx.appcompat.app.AppCompatActivity;
import static android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.WindowInsets;
import android.view.View;
import android.os.Environment;
import android.widget.Toast;
import android.widget.FrameLayout;
import com.panda3ds.pandroid.PathUtils;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

public class MainActivity extends AppCompatActivity {
import androidx.appcompat.app.AppCompatActivity;

PandaGlSurfaceView glView;
import com.panda3ds.pandroid.utils.Constants;
import com.panda3ds.pandroid.R;
import com.panda3ds.pandroid.utils.PathUtils;

public class MainActivity extends AppCompatActivity {
private static final int PICK_3DS_ROM = 2;

private void openFile() {
Expand All @@ -31,22 +27,18 @@ private void openFile() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!Environment.isExternalStorageManager()) {
Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
startActivity(intent);
}

glView = new PandaGlSurfaceView(this);
setContentView(glView);
FloatingActionButton fab = new FloatingActionButton(this);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openFile();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
startActivity(intent);
}
}

setContentView(R.layout.activity_main);

findViewById(R.id.load_rom).setOnClickListener(v->{
openFile();
});
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(200, 200);
addContentView(fab, params);
}

@Override
Expand All @@ -55,13 +47,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
String path = PathUtils.getPath(getApplicationContext(), data.getData());
Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show();
glView.queueEvent(new Runnable() {
@Override
public void run() {
AlberDriver.LoadRom(path);
}
});
startActivity(new Intent(this, GameActivity.class)
.putExtra(Constants.EXTRA_PATH, path));
}
super.onActivityResult(requestCode, resultCode, data);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.panda3ds.pandroid.utils;

public class Constants {
public static final String EXTRA_PATH = "path";
public static final String LOG_TAG = "Alber";
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.panda3ds.pandroid;
package com.panda3ds.pandroid.utils;

import android.content.ContentUris;
import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.panda3ds.pandroid;
package com.panda3ds.pandroid.view;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
Expand All @@ -7,22 +7,25 @@

import android.content.res.Resources;
import android.opengl.GLSurfaceView;
import android.util.DisplayMetrics;
import android.util.Log;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import com.panda3ds.pandroid.AlberDriver;

import java.util.ArrayList;

public class PandaGlRenderer implements GLSurfaceView.Renderer {

private final String romPath;
int screenWidth, screenHeight;
int screenTexture;
public int screenFbo;

PandaGlRenderer() {
PandaGlRenderer(String romPath) {
super();
this.romPath = romPath;
}


@Override
protected void finalize() throws Throwable {
if (screenTexture != 0) {
Expand All @@ -33,7 +36,7 @@ protected void finalize() throws Throwable {
}
super.finalize();
}

public void onSurfaceCreated(GL10 unused, EGLConfig config) {
Log.i("pandroid", glGetString(GL_EXTENSIONS));
Log.w("pandroid", glGetString(GL_VERSION));
Expand All @@ -59,6 +62,7 @@ public void onSurfaceCreated(GL10 unused, EGLConfig config) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);

AlberDriver.Initialize();
AlberDriver.LoadRom(romPath);
}

public void onDrawFrame(GL10 unused) {
Expand All @@ -76,4 +80,4 @@ public void onSurfaceChanged(GL10 unused, int width, int height) {
screenHeight = height;
glDisable(GL_SCISSOR_TEST);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.panda3ds.pandroid.view;

import android.content.Context;
import android.opengl.GLSurfaceView;

public class PandaGlSurfaceView extends GLSurfaceView {
final PandaGlRenderer renderer;

public PandaGlSurfaceView(Context context, String romPath) {
super(context);
setEGLContextClientVersion(3);
setDebugFlags(DEBUG_LOG_GL_CALLS);
renderer = new PandaGlRenderer(romPath);
setRenderer(renderer);
}

public PandaGlRenderer getRenderer() {
return renderer;
}
}
26 changes: 15 additions & 11 deletions src/pandroid/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context=".app.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom|end"
android:padding="17dp">
<Button
android:id="@+id/load_rom"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="@string/load_rom"/>
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
1 change: 1 addition & 0 deletions src/pandroid/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">pandroid</string>
<string name="load_rom">Load ROM</string>
</resources>