mirror of
https://github.com/dgis/emu48android
synced 2024-12-26 09:58:49 +01:00
This commit is contained in:
parent
000de917f0
commit
7ec3193649
4 changed files with 29 additions and 30 deletions
|
@ -80,6 +80,8 @@ find_library( # Sets the name of the path variable.
|
||||||
target_link_libraries( # Specifies the target library.
|
target_link_libraries( # Specifies the target library.
|
||||||
native-lib
|
native-lib
|
||||||
|
|
||||||
|
android
|
||||||
|
|
||||||
# Links the target library to the log library
|
# Links the target library to the log library
|
||||||
# included in the NDK.
|
# included in the NDK.
|
||||||
${log-lib})
|
${log-lib})
|
|
@ -33,7 +33,7 @@ dependencies {
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
implementation 'com.android.support:design:28.0.0'
|
implementation 'com.android.support:design:28.0.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
// testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
//
|
//
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <android/asset_manager.h>
|
||||||
|
#include <android/asset_manager_jni.h>
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_regis_cosnier_emu48_MainActivity_stringFromJNI(
|
Java_com_regis_cosnier_emu48_MainActivity_stringFromJNI(
|
||||||
|
@ -14,10 +16,9 @@ Java_com_regis_cosnier_emu48_MainActivity_stringFromJNI(
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void emu48Start();
|
extern void emu48Start();
|
||||||
#include <asset_manager.h>
|
extern AAssetManager * assetManager;
|
||||||
#include <asset_manager_jni.h>
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_com_regis_cosnier_emu48_MainActivity_emu48Start(JNIEnv *env, jobject thisz, jobject assetManager) {
|
JNIEXPORT void JNICALL Java_com_regis_cosnier_emu48_MainActivity_emu48Start(JNIEnv *env, jobject thisz, jobject assetMgr) {
|
||||||
AAssetManager * mgr = (AAssetManager *)assetManager;
|
assetManager = AAssetManager_fromJava(env, assetMgr);
|
||||||
emu48Start();
|
emu48Start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <android/asset_manager.h>
|
||||||
|
#include <android/asset_manager_jni.h>
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
HANDLE hWnd;
|
HANDLE hWnd;
|
||||||
LPTSTR szTitle;
|
LPTSTR szTitle;
|
||||||
|
|
||||||
//static HANDLE gEventId;
|
|
||||||
|
|
||||||
|
|
||||||
DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) {
|
DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) {
|
||||||
if(getcwd(lpBuffer, nBufferLength)) {
|
if(getcwd(lpBuffer, nBufferLength)) {
|
||||||
|
@ -26,28 +27,25 @@ BOOL SetCurrentDirectory(LPCTSTR path)
|
||||||
return chdir(path);
|
return chdir(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <jni.h>
|
AAssetManager * assetManager;
|
||||||
#include <asset_manager.h>
|
|
||||||
#include <asset_manager_jni.h>
|
|
||||||
HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile)
|
HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile)
|
||||||
{
|
{
|
||||||
if(strncmp(lpFileName, "assets/", 7) == 0) {
|
if(strncmp(lpFileName, "assets/", 7) == 0) {
|
||||||
AAssetDir* assetDir = AAssetManager_openDir(mgr, "");
|
|
||||||
const char* filename = (const char*)NULL;
|
AAsset* asset = AAssetManager_open(assetManager, "calculators/real48sx.kml", AASSET_MODE_STREAMING);
|
||||||
while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) {
|
char buf[BUFSIZ];
|
||||||
AAsset* asset = AAssetManager_open(mgr, filename, AASSET_MODE_STREAMING);
|
int nb_read = 0;
|
||||||
char buf[BUFSIZ];
|
nb_read = AAsset_read(asset, buf, BUFSIZ);
|
||||||
int nb_read = 0;
|
AAsset_close(asset);
|
||||||
FILE* out = fopen(filename, "w");
|
// }
|
||||||
while ((nb_read = AAsset_read(asset, buf, BUFSIZ)) > 0)
|
// AAssetDir* assetDir = AAssetManager_openDir(assetManager, "");
|
||||||
fwrite(buf, nb_read, 1, out);
|
// const char* filename = (const char*)NULL;
|
||||||
fclose(out);
|
// while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) {
|
||||||
AAsset_close(asset);
|
// AAssetDir_close(assetDir);
|
||||||
}
|
|
||||||
AAssetDir_close(assetDir);
|
|
||||||
HANDLE handle = malloc(sizeof(_HANDLE));
|
HANDLE handle = malloc(sizeof(_HANDLE));
|
||||||
handle->handleType = HANDLE_TYPE_FILE;
|
handle->handleType = HANDLE_TYPE_FILE;
|
||||||
handle->fileDescriptor = fd;
|
//handle->fileDescriptor = fd;
|
||||||
handle->fileIsAsset = TRUE;
|
handle->fileIsAsset = TRUE;
|
||||||
return handle;
|
return handle;
|
||||||
} else {
|
} else {
|
||||||
|
@ -779,7 +777,7 @@ INT_PTR DialogBoxParam(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndPare
|
||||||
}
|
}
|
||||||
HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) {
|
HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) {
|
||||||
//TODO
|
//TODO
|
||||||
return NULL;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData) {
|
BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData) {
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -801,13 +799,11 @@ PIDLIST_ABSOLUTE SHBrowseForFolderA(LPBROWSEINFOA lpbi) {
|
||||||
//TODO
|
//TODO
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
//extern INT_PTR CALLBACK ChooseKMLProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
#include "resource.h"
|
|
||||||
extern TCHAR szCurrentKml[MAX_PATH];
|
extern TCHAR szCurrentKml[MAX_PATH];
|
||||||
INT_PTR DialogBoxParamA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) {
|
INT_PTR DialogBoxParamA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) {
|
||||||
//TODO
|
//TODO
|
||||||
if(lpTemplateName == MAKEINTRESOURCE(IDD_CHOOSEKML)) {
|
if(lpTemplateName == MAKEINTRESOURCE(IDD_CHOOSEKML)) {
|
||||||
lstrcpy(szCurrentKml, "hello.kml");
|
lstrcpy(szCurrentKml, "assets/calculators/real48sx.kml");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue