Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
49b441c
- project building, working
polymonster Nov 20, 2025
d83d970
- pmbuild with latest android studio
polymonster Nov 20, 2025
d7542c3
- add stubbed functions, compiling and launching
polymonster Nov 20, 2025
688bc85
- add android logging macro
polymonster Nov 22, 2025
138ac93
- add android fmod libs
polymonster Nov 22, 2025
ef7329b
- reinstate filesystem
polymonster Nov 22, 2025
6af20a7
- add stub physics api
polymonster Nov 22, 2025
cf2c002
- build system and premake updates for android
polymonster Nov 22, 2025
983f33b
- compile fixes, missing externs and activity wip for android
polymonster Nov 22, 2025
de18c69
- add android only guard for android fmod setup
polymonster Nov 22, 2025
b4b3c67
- hooking in surface create and initial android hooks
polymonster Nov 22, 2025
cac653a
- solid wip hooking in surface create, starting user thread
polymonster Nov 22, 2025
0403532
- triangle rendering on android
polymonster Nov 23, 2025
2e5dfed
- all samples should build and link now, all libs copied and loaded c…
polymonster Nov 24, 2025
d80bda0
- windows dev env setup working and imgui now working
polymonster Nov 24, 2025
d9b634a
- use os.get for host detection
polymonster Nov 24, 2025
01c4d55
- fmod hook in, initialised and audio working... need to double check…
polymonster Nov 25, 2025
f30f367
Merge branch 'android-dev' of https://github.com/polymonster/pmtech i…
polymonster Nov 25, 2025
515dd30
- hook in touch events for input, fixup missing android symbol hooks,…
polymonster Nov 26, 2025
8834744
- add todo and comments
polymonster Nov 26, 2025
790bf31
- downgrade fmod android libs to match other platforms
polymonster Nov 26, 2025
bbed381
- add a few more filesystem functions specific for android
polymonster Nov 28, 2025
6f153a1
- merge latest
polymonster Nov 28, 2025
f69676e
- add stub functions to pass linker, android os.cpp. make paths for s…
polymonster Nov 28, 2025
8448d50
- more android backend impl
polymonster Dec 1, 2025
f52cf61
- activity setup for examples and flexible for extension
polymonster Dec 5, 2025
8366c23
- fix conflicts
polymonster Dec 5, 2025
fec32eb
- remove entry in favour of init
polymonster Dec 5, 2025
5260344
- android impl
polymonster Dec 5, 2025
fc8d0cf
- fix conflicts
polymonster Dec 5, 2025
f727db6
- fix example app activity because of java src dirs not files
polymonster Dec 6, 2025
24ebc47
- refactoring to support user specificied app activity, + fix examples
polymonster Dec 6, 2025
4114aa8
- examples running on android withmodified activity setup
polymonster Dec 6, 2025
fe1089f
- android add credential functions, os create dirs and delete dirs
polymonster Dec 7, 2025
e3e817d
- add missing comma to pmtech examples lua, move openURL calls to uiT…
polymonster Dec 7, 2025
040accd
- dirent functions for android
polymonster Dec 8, 2025
0089735
- kill app on background
polymonster Dec 9, 2025
3fb99db
- add setup guard in onSurfaceCreated
polymonster Dec 9, 2025
790c977
- vibrate support. + add general permissions to the example manifest
polymonster Dec 9, 2025
d61efe7
- update pmbuild
polymonster Dec 9, 2025
95e4644
- update pmbuild
polymonster Dec 10, 2025
44b4db1
- update todo comments / notes
polymonster Dec 12, 2025
045e137
- update pmbuild
polymonster Dec 12, 2025
9bcdb2f
- update pmbuild
polymonster Dec 13, 2025
4e0b686
- add keep screen on hint to android
polymonster Dec 13, 2025
b338fb6
- add WindoManager import
polymonster Dec 13, 2025
f57a086
- added new apis for streaming audio urls and fetching download progress
polymonster Dec 21, 2025
35e56d3
- add clipboard api
polymonster Jan 8, 2026
10956f6
- paste support for android
polymonster Jan 8, 2026
8c07293
- add os_tapped
polymonster Jan 16, 2026
1cb7cd4
Merge branch 'stream-audio' into android-dev
polymonster Jan 16, 2026
3156cef
- improve android handling of long press paste
polymonster Jan 18, 2026
d9d2cd1
- add background thread for loading PCM data / waveform
polymonster Jan 30, 2026
cbb547f
- improve fmod waveform and state cleanup on release
polymonster Feb 2, 2026
9f8233c
- add dr_mp3 for waveform
polymonster Feb 4, 2026
6968c66
- add file system direct functions for android
polymonster Feb 4, 2026
0ba316e
- add android ci
polymonster Feb 4, 2026
ffe25cd
- fix return on fs direct function windows
polymonster Feb 4, 2026
a5c2363
- fix android ci
polymonster Feb 4, 2026
fea3a0c
- vorbis support
polymonster Mar 21, 2026
0490d84
- physics support for android
polymonster Mar 22, 2026
52cd3b6
- add stubs for mobile apis
polymonster Mar 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .ci/android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
cd examples
../pmbuild android -libs
../pmbuild android
cd build/android
gradle wrapper
./gradlew assembleRelease
22 changes: 21 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
with:
submodules: "recursive"
lfs: true
- run: |
Expand All @@ -98,3 +98,23 @@ jobs:
../pmbuild linux-editor -libs
../pmbuild linux-editor
../pmbuild make linux-editor all
android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
lfs: true
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
- uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.14.3
- run: |
cd examples
../pmbuild android
cd build/android
gradle wrapper
./gradlew assembleRelease
5 changes: 5 additions & 0 deletions core/pen/include/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ inline void output_debug(const c8* format, ...)
#else
#define PEN_SYSTEM system
#endif
#ifdef PEN_PLATFORM_ANDROID
#include <android/log.h>
#define PEN_LOG(F, ...) __android_log_print(ANDROID_LOG_DEBUG, "PMTECH", F, ## __VA_ARGS__)
#else
#define PEN_LOG output_debug
#endif
#define PEN_LOG_VA(fmt, va) output_debug_va(fmt, va)
#define PEN_ASSERT assert
#define PEN_ASSERT_MSG(A, M) \
Expand Down
1 change: 1 addition & 0 deletions core/pen/include/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace pen

bool filesystem_file_exists(const c8* filename);
pen_error filesystem_read_file_to_buffer(const c8* filename, void** p_buffer, u32& buffer_size);
pen_error filesystem_read_file_to_buffer_direct(const c8* filename, void** p_buffer, u32& buffer_size);
pen_error filesystem_getmtime(const c8* filename, u32& mtime_out);
size_t filesystem_getsize(const c8* filename);
void filesystem_toggle_hidden_files();
Expand Down
4 changes: 4 additions & 0 deletions core/pen/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ namespace pen
bool os_is_backgrounded();
void os_register_background_callback(void (*callback)(bool));
bool os_require_audio_reinit(bool reset);
Str os_get_clipboard_string();
void os_clear_clipboard_string();
void os_enable_paste_popup(bool enable);
bool os_tapped();

// music
struct music_item
Expand Down
65 changes: 34 additions & 31 deletions core/pen/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local function setup_win32()
{
"$(VK_SDK_PATH)/Include"
}
elseif renderer_dir == "opengl" then
elseif renderer_dir == "opengl" then
includedirs
{
"../../third_party/glew/include",
Expand All @@ -16,31 +16,31 @@ local function setup_win32()
end

local function setup_ios()
files
{
files
{
"source/posix/**.cpp",
"source/mach/**.cpp"
}
end

local function setup_osx()
files
{
files
{
"source/posix/**.cpp",
"source/mach/**.cpp"
}
end

local function setup_linux()
files
{
files
{
"source/posix/**.cpp"
}
end

local function setup_web()
files
{
files
{
"source/posix/**.cpp",
"source/linux/timer.cpp",
"source/single_threaded/**.cpp"
Expand All @@ -52,9 +52,12 @@ local function setup_web()
end

local function setup_android()
files
{
"source/posix/**.cpp"
files
{
"source/posix/pen_string.cpp",
"source/posix/threads.cpp",

"source/linux/timer.cpp",
}
end

Expand All @@ -74,58 +77,58 @@ local function setup_platform()
end
end

-- Project
-- Project
project "pen"
setup_env()
setup_platform_defines()
setup_platform()
location ("build/" .. platform_dir)
setup_platform()
kind "StaticLib"
location ("build/" .. platform_dir)
language "C++"
files

files
{
"include/*.h",
"source/*.cpp",
"include/" .. platform_dir .. "/**.h",

"include/" .. platform_dir .. "/**.h",

"source/" .. platform_dir .. "/**.cpp",
"source/" .. platform_dir .. "/**.mm",
"../../third_party/str/*.cpp",

"../../third_party/str/*.cpp",
}
includedirs

includedirs
{
"include",
"include/" .. platform_dir,
"../../third_party",
"include/" .. platform_dir,

"../../third_party",
"../../third_party/libstem_gamepad/source"
}

-- rendere selection, and allow for no renderer
if string.len(renderer_dir) > 0 then
files
{
{
"include/" .. renderer_dir .. "/**.h",
"source/" .. renderer_dir .. "/**.cpp",
"source/" .. renderer_dir .. "/**.mm",
}
includedirs
includedirs
{
"include/" .. renderer_dir,
}
end

filter "configurations:Release"
defines { "NDEBUG" }
entrypoint "WinMainCRTStartup"
optimize "Speed"
targetdir ("lib/" .. platform_dir .. "/release")
targetname "pen"

filter "configurations:Debug"
defines { "DEBUG" }
entrypoint "WinMainCRTStartup"
Expand Down
151 changes: 151 additions & 0 deletions core/pen/source/android/file_system.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// file_system.cpp
// Copyright 2014 - 2025 Alex Dixon.
// License: https://github.com/polymonster/pmtech/blob/master/license.md

#include "file_system.h"
#include "memory.h"
#include "os.h"
#include "pen.h"
#include "pen_string.h"

#include <sys/stat.h>
#include <dirent.h>

namespace pen
{
pen_error filesystem_enum_volumes(fs_tree_node& results)
{
// stub
return PEN_ERR_OK;
}

void filesystem_toggle_hidden_files()
{
// stub
}

bool match_file(struct dirent* ent, s32 num_wildcards, va_list wildcards)
{
return false;
}

pen_error filesystem_enum_directory(const c8* directory, fs_tree_node& results, s32 num_wildcards, ...)
{
va_list wc;
va_start(wc, num_wildcards);

pen_error res = filesystem_enum_directory(directory, results, num_wildcards, wc);

va_end(wc);

return res;
}

pen_error filesystem_enum_directory(const c8* directory, fs_tree_node& results, s32 num_wildcards, va_list wildcards)
{
DIR* dir;
struct dirent* ent;

u32 num_items = 0;
if ((dir = opendir(directory)) != nullptr)
{
while ((ent = readdir(dir)) != nullptr)
{
if (match_file(ent, num_wildcards, wildcards))
{
num_items++;
}
}

closedir(dir);
}

if (num_items == 0)
{
return PEN_ERR_FILE_NOT_FOUND;
}

if (results.children == nullptr)
{
// alloc new mem
results.children = (fs_tree_node*)pen::memory_alloc(sizeof(fs_tree_node) * num_items);
pen::memory_zero(results.children, sizeof(fs_tree_node) * num_items);
}
else
{
// grow buffer
if (results.num_children < num_items)
{
results.children = (fs_tree_node*)pen::memory_realloc(results.children, sizeof(fs_tree_node) * num_items);
}
}

results.num_children = num_items;

u32 i = 0;
if ((dir = opendir(directory)) != nullptr)
{
while ((ent = readdir(dir)) != nullptr)
{
if (match_file(ent, num_wildcards, wildcards))
{
if (results.children[i].name == nullptr)
{
// allocate 1024 file buffer
results.children[i].name = (c8*)pen::memory_alloc(1024);
pen::memory_zero(results.children[i].name, 1024);
}

u32 len = pen::string_length(ent->d_name);
len = min<u32>(len, 1022);

memcpy(results.children[i].name, ent->d_name, len);
results.children[i].name[len] = '\0';

results.children[i].num_children = 0;

++i;
}
}

closedir(dir);
}

return PEN_ERR_OK;
}

pen_error filesystem_enum_free_mem(fs_tree_node& tree)
{
for (s32 i = 0; i < tree.num_children; ++i)
{
filesystem_enum_free_mem(tree.children[i]);
}

pen::memory_free(tree.children);
pen::memory_free(tree.name);

return PEN_ERR_OK;
}

pen_error filesystem_getmtime(const c8* filename, u32& mtime_out)
{
struct stat st;
if (stat(filename, &st) == 0) {
mtime_out = (u32)st.st_mtime; // modification time
return PEN_ERR_OK;
}

return PEN_ERR_FILE_NOT_FOUND;
}

const c8** filesystem_get_user_directory(s32& directory_depth)
{
return nullptr;
}

s32 filesystem_exclude_slash_depth()
{
// directory depth 0 can be a slash
return 0;
}
} // namespace pen
Loading
Loading