Skip to content

Commit

Permalink
untested simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 1, 2024
1 parent 74e753a commit 57e8ddc
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Simulator"
android:exported="true"
android:configChanges="keyboard|keyboardHidden|orientation"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ add_subdirectory(droidboot_gui)
# System.loadLibrary() and pass the name of the library defined here;
# for GameActivity/NativeActivity derived applications, the same library name must be
# used in the AndroidManifest.xml file.
add_library(${CMAKE_PROJECT_NAME} SHARED
# List C/C++ source files with relative paths to this CMakeLists.txt.
app.cpp)
add_library(${CMAKE_PROJECT_NAME} SHARED app.cpp)

# Specifies libraries CMake should link to your target library. You
# can link libraries from various origins, such as libraries defined in this
# build script, prebuilt third-party libraries, or Android system libraries.
target_link_libraries(${CMAKE_PROJECT_NAME}
# List libraries link to the target library
android
log
droidboot_gui)
target_link_libraries(${CMAKE_PROJECT_NAME} droidboot_gui)
34 changes: 19 additions & 15 deletions app/src/main/cpp/app.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// Write C++ code here.
//
// Do not forget to dynamically load the C++ library into your application.
// Created by nick on 01.08.24.
//
// For instance,
//
// In MainActivity.java:
// static {
// System.loadLibrary("app");
// }
//
// Or, in MainActivity.kt:
// companion object {
// init {
// System.loadLibrary("app")
// }
// }

#include <jni.h>

extern void simulator_start(JNIEnv* env, jobject bitmap, jint w, jint h);
extern void simulator_stop();
extern void simulator_key(jint key);

extern "C" JNIEXPORT void JNICALL Java_org_andbootmgr_app_Simulator_key(JNIEnv* env, jobject thiz, jint key) {
simulator_key(key);
}

extern "C" JNIEXPORT void JNICALL Java_org_andbootmgr_app_Simulator_stop(JNIEnv* env, jobject thiz) {
simulator_stop();
}

extern "C" JNIEXPORT void JNICALL Java_org_andbootmgr_app_Simulator_start(JNIEnv* env, jobject thiz, jobject bitmap, jint w, jint h) {
simulator_start(env, bitmap, w, h);
}
30 changes: 30 additions & 0 deletions app/src/main/java/org/andbootmgr/app/Simulator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.andbootmgr.app

import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity

class Simulator : AppCompatActivity() {
external fun start(bitmap: Bitmap, w: Int, h: Int)
external fun stop()
external fun key(key: Int)
private lateinit var bitmap: Bitmap
private var w: Int = 0
private var h: Int = 0

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
w = 1080
h = 1920
bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
setContentView(object : View(this) {
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
canvas.drawBitmap(this@Simulator.bitmap, 0f, 0f, null)
}
})
start(bitmap, w, h)
}
}

0 comments on commit 57e8ddc

Please sign in to comment.