-
Notifications
You must be signed in to change notification settings - Fork 111
Feature/android port #893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
psjuan97
wants to merge
2
commits into
Try:master
Choose a base branch
from
psjuan97:feature/android_port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+124
−11
Draft
Feature/android port #893
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,18 @@ | |
| #include <Tempest/MetalApi> | ||
| #endif | ||
|
|
||
| #if defined(__IOS__) | ||
| #if defined(__IOS__) || defined(__ANDROID__) | ||
| #include "utils/installdetect.h" | ||
| #endif | ||
|
|
||
| #if defined(__ANDROID__) | ||
| #include <android_native_app_glue.h> | ||
| #include <android/log.h> | ||
| extern "C" void tempest_android_main(struct android_app* app); | ||
| static struct android_app* g_android_app = nullptr; | ||
| int main(int argc, const char** argv); | ||
| #endif | ||
|
|
||
| #include "utils/crashlog.h" | ||
| #include "mainwindow.h" | ||
| #include "gothic.h" | ||
|
|
@@ -53,7 +61,7 @@ std::unique_ptr<Tempest::AbstractGraphicsApi> mkApi(const CommandLine& g) { | |
| break; | ||
| #endif | ||
| case CommandLine::Vulkan: | ||
| #if !defined(__APPLE__) | ||
| #if !defined(__APPLE__) || defined(__ANDROID__) | ||
| return std::make_unique<Tempest::VulkanApi>(flg); | ||
| #else | ||
| break; | ||
|
|
@@ -67,12 +75,35 @@ std::unique_ptr<Tempest::AbstractGraphicsApi> mkApi(const CommandLine& g) { | |
| #endif | ||
| } | ||
|
|
||
| #if defined(__ANDROID__) | ||
| extern "C" void android_main(struct android_app* app) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to move into Tempest, as it's an implementation detail. |
||
| g_android_app = app; | ||
| tempest_android_main(app); | ||
|
|
||
| // Set up working directory | ||
| auto appdir = InstallDetect::applicationSupportDirectory(); | ||
| if(!appdir.empty()) { | ||
| std::filesystem::current_path(appdir); | ||
| } | ||
|
|
||
| const char* argv[] = {"opengothic", nullptr}; | ||
| main(1, argv); | ||
| } | ||
| #endif | ||
|
|
||
| int main(int argc,const char** argv) { | ||
| #if defined(__IOS__) | ||
| { | ||
| auto appdir = InstallDetect::applicationSupportDirectory(); | ||
| std::filesystem::current_path(appdir); | ||
| } | ||
| #elif defined(__ANDROID__) | ||
| { | ||
| auto appdir = InstallDetect::applicationSupportDirectory(); | ||
| if(!appdir.empty()) { | ||
| std::filesystem::current_path(appdir); | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| try { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,11 @@ | |
| #include "shlwapi.h" | ||
| #endif | ||
|
|
||
| #ifdef __ANDROID__ | ||
| #include <android_native_app_glue.h> | ||
| extern "C" struct android_app* tempest_android_get_app(); | ||
| #endif | ||
|
|
||
| #include <cstring> | ||
| #include "utils/fileutil.h" | ||
|
|
||
|
|
@@ -16,7 +21,7 @@ InstallDetect::InstallDetect() { | |
| pfiles = programFiles(false); | ||
| pfilesX86 = programFiles(true); | ||
| #endif | ||
| #if defined(__OSX__) || defined(__IOS__) | ||
| #if defined(__OSX__) || defined(__IOS__) || defined(__ANDROID__) | ||
| appDir = applicationSupportDirectory(); | ||
| #endif | ||
| } | ||
|
|
@@ -27,7 +32,7 @@ std::u16string InstallDetect::detectG2() { | |
| if(ret.empty()) | ||
| ret = detectG2(pfilesX86); | ||
| return ret; | ||
| #elif defined(__OSX__) || defined(__IOS__) | ||
| #elif defined(__OSX__) || defined(__IOS__) || defined(__ANDROID__) | ||
| if(FileUtil::exists(appDir)) | ||
| return appDir; | ||
| return u""; | ||
|
|
@@ -62,3 +67,27 @@ std::u16string InstallDetect::programFiles(bool x86) { | |
| return ret; | ||
| } | ||
| #endif | ||
|
|
||
| #ifdef __ANDROID__ | ||
| std::u16string InstallDetect::applicationSupportDirectory() { | ||
| struct android_app* app = tempest_android_get_app(); | ||
| if(app == nullptr || app->activity == nullptr) | ||
| return u""; | ||
|
|
||
| // Prefer external data path (accessible without root) | ||
| const char* path = app->activity->externalDataPath; | ||
| if(path == nullptr) | ||
| path = app->activity->internalDataPath; | ||
| if(path == nullptr) | ||
| return u""; | ||
|
|
||
| // Convert UTF-8 to UTF-16 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| std::u16string ret; | ||
| size_t len = std::strlen(path); | ||
| ret.reserve(len); | ||
| for(size_t i = 0; i < len; ++i) { | ||
| ret.push_back(static_cast<char16_t>(static_cast<unsigned char>(path[i]))); | ||
| } | ||
| return ret; | ||
| } | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Tempest
updated
6 files
| +49 −10 | Engine/CMakeLists.txt | |
| +98 −6 | Engine/gapi/vulkan/vswapchain.cpp | |
| +5 −2 | Engine/gapi/vulkanapi.cpp | |
| +772 −0 | Engine/system/api/androidapi.cpp | |
| +35 −0 | Engine/system/api/androidapi.h | |
| +3 −0 | Engine/system/systemapi.cpp |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but hacks in camera code for specific OS is not acceptable - just use auto-rotation.