diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c73c382e..f18fe19a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,6 +29,17 @@ + + + + + + + diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 80c8acb3..a6ccd05b 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -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) diff --git a/app/src/main/cpp/app.cpp b/app/src/main/cpp/app.cpp index 9a2285f8..cce8e871 100644 --- a/app/src/main/cpp/app.cpp +++ b/app/src/main/cpp/app.cpp @@ -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") -// } -// } \ No newline at end of file + +#include + +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); +} \ No newline at end of file diff --git a/app/src/main/cpp/droidboot_gui b/app/src/main/cpp/droidboot_gui index 534419e6..bb8d487e 160000 --- a/app/src/main/cpp/droidboot_gui +++ b/app/src/main/cpp/droidboot_gui @@ -1 +1 @@ -Subproject commit 534419e68c3defc8d46cd2058800cb895ef453f9 +Subproject commit bb8d487ed3aad73cb115e1217c4d03cdc2152977 diff --git a/app/src/main/java/org/andbootmgr/app/Simulator.kt b/app/src/main/java/org/andbootmgr/app/Simulator.kt new file mode 100644 index 00000000..f5a62ed0 --- /dev/null +++ b/app/src/main/java/org/andbootmgr/app/Simulator.kt @@ -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) + } +} \ No newline at end of file