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