2015-05-25 11:11:41 +00:00
|
|
|
// Copyright 2003 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2014-02-19 01:56:29 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
#include <android/native_window_jni.h>
|
2014-02-11 06:16:21 +00:00
|
|
|
#include <EGL/egl.h>
|
2015-05-17 22:12:11 +00:00
|
|
|
#include "../DiscIO/Volume.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Android/ButtonManager.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Common/CPUDetect.h"
|
2014-04-13 23:15:23 +00:00
|
|
|
#include "Common/Event.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2014-06-05 23:29:54 +00:00
|
|
|
#include "Common/Logging/LogManager.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Core/BootManager.h"
|
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/State.h"
|
|
|
|
#include "Core/HW/Wiimote.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2013-04-15 01:39:56 +00:00
|
|
|
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "DiscIO/VolumeCreator.h"
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2014-10-04 19:12:15 +00:00
|
|
|
#include "UICommon/UICommon.h"
|
|
|
|
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2013-03-20 02:53:09 +00:00
|
|
|
ANativeWindow* surf;
|
2013-07-27 20:09:18 +00:00
|
|
|
std::string g_filename;
|
2015-02-25 09:23:42 +00:00
|
|
|
std::string g_set_userpath = "";
|
2013-07-27 20:09:18 +00:00
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
#define DOLPHIN_TAG "DolphinEmuNative"
|
2013-02-26 19:49:00 +00:00
|
|
|
|
|
|
|
void Host_NotifyMapLoaded() {}
|
|
|
|
void Host_RefreshDSPDebuggerWindow() {}
|
|
|
|
|
|
|
|
Common::Event updateMainFrameEvent;
|
|
|
|
void Host_Message(int Id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void* Host_GetRenderHandle()
|
|
|
|
{
|
2013-03-20 02:53:09 +00:00
|
|
|
return surf;
|
2013-02-26 19:49:00 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
void Host_UpdateTitle(const std::string& title)
|
2013-07-27 20:09:18 +00:00
|
|
|
{
|
2014-03-17 23:17:12 +00:00
|
|
|
__android_log_write(ANDROID_LOG_INFO, DOLPHIN_TAG, title.c_str());
|
|
|
|
}
|
2013-02-26 19:49:00 +00:00
|
|
|
|
|
|
|
void Host_UpdateDisasmDialog(){}
|
|
|
|
|
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Host_RequestRenderWindowSize(int width, int height) {}
|
2014-07-16 13:53:33 +00:00
|
|
|
|
2014-07-26 10:43:49 +00:00
|
|
|
void Host_RequestFullscreen(bool enable_fullscreen) {}
|
2014-07-16 13:53:33 +00:00
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
void Host_SetStartupDebuggingParameters()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:24:40 +00:00
|
|
|
bool Host_UIHasFocus()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
bool Host_RendererHasFocus()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-04 16:09:56 +00:00
|
|
|
bool Host_RendererIsFullscreen()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
void Host_ConnectWiimote(int wm_idx, bool connect) {}
|
|
|
|
|
|
|
|
void Host_SetWiiMoteConnectionState(int _State) {}
|
|
|
|
|
2014-08-02 06:21:03 +00:00
|
|
|
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {}
|
|
|
|
|
2015-02-13 00:41:52 +00:00
|
|
|
static bool MsgAlert(const char* caption, const char* text, bool /*yes_no*/, int /*Style*/)
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "%s:%s", caption, text);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-23 19:21:48 +00:00
|
|
|
#define DVD_BANNER_WIDTH 96
|
|
|
|
#define DVD_BANNER_HEIGHT 32
|
|
|
|
|
2013-09-25 07:05:36 +00:00
|
|
|
static inline u32 Average32(u32 a, u32 b) {
|
|
|
|
return ((a >> 1) & 0x7f7f7f7f) + ((b >> 1) & 0x7f7f7f7f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 GetPixel(u32 *buffer, unsigned int x, unsigned int y) {
|
|
|
|
// thanks to unsignedness, these also check for <0 automatically.
|
|
|
|
if (x > 191) return 0;
|
|
|
|
if (y > 63) return 0;
|
|
|
|
return buffer[y * 192 + x];
|
|
|
|
}
|
|
|
|
|
2014-09-21 23:51:27 +00:00
|
|
|
static bool LoadBanner(std::string filename, u32 *Banner)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2015-04-10 20:10:49 +00:00
|
|
|
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2014-03-09 20:14:26 +00:00
|
|
|
if (pVolume != nullptr)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2015-04-10 20:10:49 +00:00
|
|
|
int Width, Height;
|
|
|
|
std::vector<u32> BannerVec = pVolume->GetBanner(&Width, &Height);
|
|
|
|
// This code (along with above inlines) is moved from
|
|
|
|
// elsewhere. Someone who knows anything about Android
|
|
|
|
// please get rid of it and use proper high-resolution
|
|
|
|
// images.
|
|
|
|
if (Height == 64 && Width == 192)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2015-04-10 20:10:49 +00:00
|
|
|
u32* Buffer = &BannerVec[0];
|
|
|
|
for (int y = 0; y < 32; y++)
|
|
|
|
{
|
|
|
|
for (int x = 0; x < 96; x++)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2015-04-10 20:10:49 +00:00
|
|
|
// simplified plus-shaped "gaussian"
|
|
|
|
u32 surround = Average32(
|
|
|
|
Average32(GetPixel(Buffer, x*2 - 1, y*2), GetPixel(Buffer, x*2 + 1, y*2)),
|
|
|
|
Average32(GetPixel(Buffer, x*2, y*2 - 1), GetPixel(Buffer, x*2, y*2 + 1)));
|
|
|
|
Banner[y * 96 + x] = Average32(GetPixel(Buffer, x*2, y*2), surround);
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
2015-04-10 20:10:49 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (Height == 32 && Width == 96)
|
|
|
|
{
|
|
|
|
memcpy(Banner, &BannerVec[0], 96 * 32 * 4);
|
|
|
|
return true;
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-21 23:51:27 +00:00
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
static int GetCountry(std::string filename)
|
2015-05-07 00:12:58 +00:00
|
|
|
{
|
|
|
|
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
|
|
|
|
|
|
|
|
if (pVolume != nullptr)
|
|
|
|
{
|
2015-05-17 00:52:55 +00:00
|
|
|
DiscIO::IVolume::ECountry country = pVolume->GetCountry();
|
2015-05-07 00:12:58 +00:00
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Country Code: %i", country);
|
2015-05-07 00:12:58 +00:00
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
return country;
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
// Return UNKNOWN
|
|
|
|
return 13;
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
static int GetPlatform(std::string filename)
|
2015-05-16 23:02:46 +00:00
|
|
|
{
|
|
|
|
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
|
|
|
|
|
|
|
|
if (pVolume != nullptr)
|
|
|
|
{
|
2015-05-17 00:52:55 +00:00
|
|
|
bool is_wii_disc = pVolume->IsWiiDisc();
|
|
|
|
bool is_wii_wad = pVolume->IsWadFile();
|
2015-05-16 23:02:46 +00:00
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
if (is_wii_disc)
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Volume is a Wii disc.");
|
2015-05-16 23:02:46 +00:00
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
// See Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/Game.java
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (is_wii_wad)
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Volume is a Wii WAD.");
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Volume is a Gamecube disc.");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-16 23:02:46 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
return -1;
|
2015-05-16 23:02:46 +00:00
|
|
|
}
|
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
static std::string GetTitle(std::string filename)
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Title for file: %s", filename.c_str());
|
|
|
|
|
|
|
|
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
|
|
|
|
|
|
|
|
if (pVolume != nullptr) {
|
|
|
|
std::map <DiscIO::IVolume::ELanguage, std::string> titles = pVolume->GetNames();
|
|
|
|
|
|
|
|
|
|
|
|
/*bool is_wii_title = IsWiiTitle(filename);
|
|
|
|
|
|
|
|
DiscIO::IVolume::ELanguage language = SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(
|
|
|
|
is_wii_title);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto it = titles.find(language);
|
|
|
|
if (it != end)
|
|
|
|
return it->second;*/
|
|
|
|
|
|
|
|
auto end = titles.end();
|
|
|
|
|
|
|
|
// English tends to be a good fallback when the requested language isn't available
|
2015-05-08 21:28:03 +00:00
|
|
|
//if (language != DiscIO::IVolume::ELanguage::LANGUAGE_ENGLISH) {
|
|
|
|
auto it = titles.find(DiscIO::IVolume::ELanguage::LANGUAGE_ENGLISH);
|
2015-05-07 00:12:58 +00:00
|
|
|
if (it != end)
|
|
|
|
return it->second;
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// If English isn't available either, just pick something
|
|
|
|
if (!titles.empty())
|
|
|
|
return titles.cbegin()->second;
|
|
|
|
|
|
|
|
// No usable name, return filename (better than nothing)
|
|
|
|
std::string name;
|
|
|
|
SplitPath(filename, nullptr, &name, nullptr);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
return std::string ("");
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string GetDescription(std::string filename)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2015-05-07 00:12:58 +00:00
|
|
|
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Description for file: %s", filename.c_str());
|
2015-04-10 20:10:49 +00:00
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
2015-04-10 20:10:49 +00:00
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
if (pVolume != nullptr)
|
2015-04-10 20:10:49 +00:00
|
|
|
{
|
2015-05-07 00:12:58 +00:00
|
|
|
std::map <DiscIO::IVolume::ELanguage, std::string> descriptions = pVolume->GetDescriptions();
|
|
|
|
|
|
|
|
/*
|
|
|
|
bool is_wii_title = IsWiiTitle(filename);
|
|
|
|
|
|
|
|
DiscIO::IVolume::ELanguage language = SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(
|
|
|
|
is_wii_title);
|
|
|
|
|
|
|
|
auto it = descriptions.find(language);
|
2015-04-10 20:10:49 +00:00
|
|
|
if (it != end)
|
2015-05-07 00:12:58 +00:00
|
|
|
return it->second;*/
|
|
|
|
|
|
|
|
auto end = descriptions.end();
|
|
|
|
|
|
|
|
// English tends to be a good fallback when the requested language isn't available
|
2015-05-08 21:28:03 +00:00
|
|
|
//if (language != DiscIO::IVolume::ELanguage::LANGUAGE_ENGLISH) {
|
|
|
|
auto it = descriptions.find(DiscIO::IVolume::ELanguage::LANGUAGE_ENGLISH);
|
2015-05-07 00:12:58 +00:00
|
|
|
if (it != end)
|
|
|
|
return it->second;
|
|
|
|
//}
|
|
|
|
|
|
|
|
// If English isn't available either, just pick something
|
|
|
|
if (!descriptions.empty())
|
|
|
|
return descriptions.cbegin()->second;
|
2015-04-10 20:10:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
return std::string ("");
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
static std::string GetGameId(std::string filename)
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting ID for file: %s", filename.c_str());
|
|
|
|
|
|
|
|
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
|
|
|
if (pVolume != nullptr)
|
|
|
|
{
|
|
|
|
std::string id = pVolume->GetUniqueID();
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Game ID: %s", id.c_str());
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
2015-05-10 14:46:46 +00:00
|
|
|
return std::string ("");
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
static std::string GetCompany(std::string filename)
|
2015-05-07 00:12:58 +00:00
|
|
|
{
|
2015-05-17 00:52:55 +00:00
|
|
|
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Company for file: %s", filename.c_str());
|
2015-05-07 00:12:58 +00:00
|
|
|
|
|
|
|
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
|
|
|
if (pVolume != nullptr)
|
|
|
|
{
|
2015-05-17 00:52:55 +00:00
|
|
|
std::string date = pVolume->GetCompany();
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Company: %s", date.c_str());
|
2015-05-07 00:12:58 +00:00
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
2015-05-10 14:46:46 +00:00
|
|
|
return std::string ("");
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u64 GetFileSize(std::string filename)
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting size of file: %s", filename.c_str());
|
|
|
|
|
|
|
|
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
|
|
|
if (pVolume != nullptr)
|
|
|
|
{
|
|
|
|
u64 size = pVolume->GetSize();
|
2015-05-17 22:12:11 +00:00
|
|
|
// Causes a warning because size is u64, not 'long unsigned'
|
|
|
|
//__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Size: %lu", size);
|
2015-05-07 00:12:58 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 23:51:27 +00:00
|
|
|
static std::string GetJString(JNIEnv *env, jstring jstr)
|
2014-03-14 21:20:44 +00:00
|
|
|
{
|
|
|
|
std::string result = "";
|
|
|
|
if (!jstr)
|
|
|
|
return result;
|
2014-03-29 10:05:44 +00:00
|
|
|
|
2014-03-14 21:20:44 +00:00
|
|
|
const char *s = env->GetStringUTFChars(jstr, nullptr);
|
|
|
|
result = s;
|
|
|
|
env->ReleaseStringUTFChars(jstr, s);
|
|
|
|
return result;
|
|
|
|
}
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
2014-03-14 21:20:44 +00:00
|
|
|
|
2015-02-24 11:32:55 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv *env, jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv *env, jobject obj);
|
2015-02-23 02:36:30 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Button, jint Action);
|
2015-02-24 11:32:55 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Axis, jfloat Value);
|
2015-05-07 00:12:58 +00:00
|
|
|
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile);JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv *env, jobject obj, jstring jFilename);
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDescription(JNIEnv *env, jobject obj, jstring jFilename);
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameId(JNIEnv *env, jobject obj, jstring jFilename);
|
2015-05-16 23:02:46 +00:00
|
|
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCountry(JNIEnv *env, jobject obj, jstring jFilename);
|
2015-05-17 00:52:55 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCompany(JNIEnv *env, jobject obj, jstring jFilename);
|
2015-05-07 00:12:58 +00:00
|
|
|
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetFilesize(JNIEnv *env, jobject obj, jstring jFilename);
|
2015-05-17 00:52:55 +00:00
|
|
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetPlatform(JNIEnv *env, jobject obj, jstring jFilename);
|
2015-02-24 11:32:55 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv *env, jobject obj);
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SupportsNEON(JNIEnv *env, jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv *env, jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv *env, jobject obj, jint api);
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv *env, jobject obj, jstring jFile);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv *env, jobject obj, jint slot);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv *env, jobject obj, jint slot);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFolders(JNIEnv *env, jobject obj);
|
2015-02-25 09:23:42 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(JNIEnv *env, jobject obj, jstring jDirectory);
|
2015-02-28 05:20:33 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv *env, jobject obj);
|
2015-02-24 11:32:55 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf);
|
|
|
|
|
2013-06-18 12:09:20 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj)
|
2013-03-20 02:53:09 +00:00
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
PowerPC::Start();
|
2013-03-20 02:53:09 +00:00
|
|
|
}
|
2013-10-29 05:23:17 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv *env, jobject obj)
|
2013-03-20 02:53:09 +00:00
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
PowerPC::Pause();
|
2013-03-20 02:53:09 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 05:23:17 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv *env, jobject obj)
|
2013-03-20 02:53:09 +00:00
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
Core::Stop();
|
|
|
|
updateMainFrameEvent.Set(); // Kick the waiting event
|
2013-03-20 02:53:09 +00:00
|
|
|
}
|
2015-02-23 02:36:30 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Button, jint Action)
|
2013-06-18 12:09:20 +00:00
|
|
|
{
|
2015-02-23 02:36:30 +00:00
|
|
|
return ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
|
2013-06-18 12:09:20 +00:00
|
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
|
2013-06-18 12:09:20 +00:00
|
|
|
}
|
2013-03-20 02:53:09 +00:00
|
|
|
|
2013-06-18 12:09:20 +00:00
|
|
|
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2014-03-14 21:20:44 +00:00
|
|
|
std::string file = GetJString(env, jFile);
|
2013-04-23 19:21:48 +00:00
|
|
|
u32 uBanner[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
|
2014-03-14 21:20:44 +00:00
|
|
|
jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
|
|
|
|
|
|
|
|
if (LoadBanner(file, uBanner))
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
|
|
|
env->SetIntArrayRegion(Banner, 0, DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT, (jint*)uBanner);
|
|
|
|
}
|
|
|
|
return Banner;
|
|
|
|
}
|
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv *env, jobject obj, jstring jFilename)
|
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
|
|
|
std::string name = GetTitle(filename);
|
2014-03-14 21:20:44 +00:00
|
|
|
return env->NewStringUTF(name.c_str());
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
2013-11-15 23:32:50 +00:00
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDescription(JNIEnv *env, jobject obj, jstring jFilename)
|
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
|
|
|
std::string description = GetDescription(filename);
|
|
|
|
return env->NewStringUTF(description.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameId(JNIEnv *env, jobject obj, jstring jFilename)
|
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
|
|
|
std::string id = GetGameId(filename);
|
|
|
|
return env->NewStringUTF(id.c_str());
|
|
|
|
}
|
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCompany(JNIEnv *env, jobject obj, jstring jFilename)
|
2015-05-07 00:12:58 +00:00
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
2015-05-17 00:52:55 +00:00
|
|
|
std::string company = GetCompany(filename);
|
|
|
|
return env->NewStringUTF(company.c_str());
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 23:02:46 +00:00
|
|
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCountry(JNIEnv *env, jobject obj, jstring jFilename)
|
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
|
|
|
int country = GetCountry(filename);
|
|
|
|
return country;
|
|
|
|
}
|
|
|
|
|
2015-05-07 00:12:58 +00:00
|
|
|
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetFilesize(JNIEnv *env, jobject obj, jstring jFilename)
|
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
|
|
|
u64 size = GetFileSize(filename);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2015-05-17 00:52:55 +00:00
|
|
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetPlatform(JNIEnv *env, jobject obj, jstring jFilename)
|
2015-05-07 00:12:58 +00:00
|
|
|
{
|
|
|
|
std::string filename = GetJString(env, jFilename);
|
2015-05-17 00:52:55 +00:00
|
|
|
int platform = GetPlatform(filename);
|
|
|
|
return platform;
|
2015-05-07 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
2013-06-23 03:54:28 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv *env, jobject obj)
|
|
|
|
{
|
|
|
|
return env->NewStringUTF(scm_rev_str);
|
|
|
|
}
|
2013-11-15 20:17:47 +00:00
|
|
|
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SupportsNEON(JNIEnv *env, jobject obj)
|
|
|
|
{
|
2014-11-30 07:29:41 +00:00
|
|
|
return cpu_info.bNEON || cpu_info.bASIMD;
|
2013-11-15 20:17:47 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 23:32:50 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv *env, jobject obj)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
Core::SaveScreenShot();
|
2013-11-15 23:32:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-11 06:16:21 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv *env, jobject obj, jint api)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
eglBindAPI(api);
|
2014-02-11 06:16:21 +00:00
|
|
|
}
|
|
|
|
|
2014-03-14 21:20:44 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
|
|
|
IniFile ini;
|
2014-03-14 21:20:44 +00:00
|
|
|
std::string file = GetJString(env, jFile);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
std::string defaultValue = GetJString(env, jDefault);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-14 21:20:44 +00:00
|
|
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
2013-04-23 19:21:48 +00:00
|
|
|
std::string value;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
ini.GetOrCreateSection(section)->Get(key, &value, defaultValue);
|
2013-04-23 19:21:48 +00:00
|
|
|
|
|
|
|
return env->NewStringUTF(value.c_str());
|
|
|
|
}
|
2015-05-10 14:46:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
std::string file = GetJString(env, jFile);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
std::string value = GetJString(env, jValue);
|
2013-06-18 12:09:20 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
ini.GetOrCreateSection(section)->Set(key, value);
|
|
|
|
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 20:09:18 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv *env, jobject obj, jstring jFile)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
g_filename = GetJString(env, jFile);
|
2013-07-27 20:09:18 +00:00
|
|
|
}
|
2013-04-15 01:39:56 +00:00
|
|
|
|
2013-08-29 22:47:50 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv *env, jobject obj, jint slot)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
State::Save(slot);
|
2013-08-29 22:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv *env, jobject obj, jint slot)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
State::Load(slot);
|
2013-08-29 22:47:50 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 23:07:32 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFolders(JNIEnv *env, jobject obj)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_WIIUSER_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP);
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP);
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP);
|
2013-08-29 23:07:32 +00:00
|
|
|
}
|
|
|
|
|
2015-02-25 09:23:42 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(JNIEnv *env, jobject obj, jstring jDirectory)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
std::string directory = GetJString(env, jDirectory);
|
|
|
|
g_set_userpath = directory;
|
|
|
|
UICommon::SetUserDirectory(directory);
|
2015-02-25 09:23:42 +00:00
|
|
|
}
|
|
|
|
|
2015-02-28 05:20:33 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv *env, jobject obj)
|
|
|
|
{
|
|
|
|
return env->NewStringUTF(File::GetUserPath(D_USER_IDX).c_str());
|
|
|
|
}
|
|
|
|
|
2013-07-27 20:09:18 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf)
|
|
|
|
{
|
2015-05-10 14:46:46 +00:00
|
|
|
surf = ANativeWindow_fromSurface(env, _surf);
|
2014-11-15 05:11:09 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
// Install our callbacks
|
|
|
|
OSD::AddCallback(OSD::OSD_INIT, ButtonManager::Init);
|
|
|
|
OSD::AddCallback(OSD::OSD_SHUTDOWN, ButtonManager::Shutdown);
|
2013-04-15 01:39:56 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
RegisterMsgAlertHandler(&MsgAlert);
|
2015-02-13 00:41:52 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
UICommon::SetUserDirectory(g_set_userpath);
|
|
|
|
UICommon::Init();
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
// No use running the loop when booting fails
|
|
|
|
if ( BootManager::BootCore( g_filename.c_str() ) )
|
|
|
|
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
|
|
|
|
updateMainFrameEvent.Wait();
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2015-05-10 14:46:46 +00:00
|
|
|
UICommon::Shutdown();
|
|
|
|
ANativeWindow_release(surf);
|
2013-02-26 19:49:00 +00:00
|
|
|
}
|
2013-07-27 20:09:18 +00:00
|
|
|
|
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|