mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-10-02 16:23:57 +08:00
harmonyos: Port SDL3 to HarmonyOS/OpenHarmony.
Build (All) / Create test plan (push) Canceled after 0s
Build (All) / level1 (push) Canceled after 0s
Build (All) / level2 (push) Canceled after 0s
Build (All) / Create test plan (push) Canceled after 0s
Build (All) / level1 (push) Canceled after 0s
Build (All) / level2 (push) Canceled after 0s
This is my port of SDL3 to HarmonyOS/OpenHarmony. It has been tested on real hardware from Huawei, and commercial games are being prepped to ship with it already. There is _heavy_ documentation in docs/README-harmonyos.md, including how to set up a development environment and project, build, and debug, for the completely uninitiated. This work was sponsored by Outfit7: https://outfit7.com/ Fixes #9837.
This commit is contained in:
+10
@@ -99,6 +99,16 @@ out/
|
||||
android-project/local.properties
|
||||
android-project/.gradle/
|
||||
|
||||
# for OpenHarmony/HarmonyOS
|
||||
openharmony-project/entry/src/main/cpp/CMakeLists.txt
|
||||
openharmony-project/entry/src/main/cpp/*.c
|
||||
openharmony-project/entry/src/main/cpp/*.h
|
||||
openharmony-project/entry/src/main/cpp/SDL
|
||||
openharmony-project/entry/src/main/resources/rawfile
|
||||
openharmony-project/AppScope/app.json5
|
||||
openharmony-project/AppScope/resources/base/element/string.json
|
||||
openharmony-project/build-profile.json5
|
||||
|
||||
test/checkkeys
|
||||
test/checkkeysthreads
|
||||
test/gamepadmap
|
||||
|
||||
+167
-2
@@ -78,6 +78,7 @@ include("${SDL3_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/3rdparty.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/PreseedMSVCCache.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/PreseedEmscriptenCache.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/PreseedOpenHarmonyCache.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/PreseedHaikuCache.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/PreseedNokiaNGageCache.cmake")
|
||||
include("${SDL3_SOURCE_DIR}/cmake/PreseedDOSCache.cmake")
|
||||
@@ -322,7 +323,7 @@ dep_option(SDL_SSE4_2 "Use SSE4.2 assembly routines" ON "SDL_ASSEMB
|
||||
dep_option(SDL_MMX "Use MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
||||
dep_option(SDL_ALTIVEC "Use Altivec assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_POWERPC32 OR SDL_CPU_POWERPC64" OFF)
|
||||
dep_option(SDL_ARMNEON "Use NEON assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_ARM32 OR SDL_CPU_ARM64" OFF)
|
||||
dep_option(SDL_ARMSVE2 "Use SVE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_ARM64" OFF)
|
||||
dep_option(SDL_ARMSVE2 "Use SVE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_ARM64 AND NOT OHOS" OFF)
|
||||
dep_option(SDL_LSX "Use LSX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_LOONGARCH64" OFF)
|
||||
dep_option(SDL_LASX "Use LASX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_LOONGARCH64" OFF)
|
||||
|
||||
@@ -385,7 +386,7 @@ dep_option(SDL_RENDER_D3D12 "Enable the Direct3D 12 render driver" ON "SD
|
||||
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;APPLE" OFF)
|
||||
dep_option(SDL_RENDER_GPU "Enable the SDL_GPU render driver" ON "SDL_RENDER;SDL_GPU" OFF)
|
||||
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
|
||||
dep_option(SDL_VULKAN "Enable Vulkan support" "${SDL_VULKAN_DEFAULT}" "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR OPENBSD OR WINDOWS OR CYGWIN" OFF)
|
||||
dep_option(SDL_VULKAN "Enable Vulkan support" "${SDL_VULKAN_DEFAULT}" "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR OPENBSD OR WINDOWS OR CYGWIN OR OHOS" OFF)
|
||||
dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN" OFF)
|
||||
dep_option(SDL_METAL "Enable Metal support" ON "APPLE" OFF)
|
||||
set_option(SDL_OPENVR "Use OpenVR video driver" OFF)
|
||||
@@ -1724,6 +1725,170 @@ if(ANDROID)
|
||||
target_link_options(SDL3-static INTERFACE "-Wl,-u,JNI_OnLoad")
|
||||
endif()
|
||||
|
||||
elseif(OHOS) # OpenHarmony/HarmonyOS
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/core/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/core/openharmony/*.h"
|
||||
)
|
||||
|
||||
sdl_link_dependency(openharmonycore LIBS libace_napi.z.so libace_ndk.z.so deviceinfo_ndk.z rawfile.z hilog_ndk.z ohcommonevent)
|
||||
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/main/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/main/openharmony/*.h"
|
||||
)
|
||||
set(HAVE_SDL_MAIN_CALLBACKS TRUE)
|
||||
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/misc/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/misc/openharmony/*.h"
|
||||
)
|
||||
set(HAVE_SDL_MISC TRUE)
|
||||
|
||||
if(SDL_AUDIO)
|
||||
set(SDL_AUDIO_DRIVER_OHAUDIO 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/audio/ohaudio/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/audio/ohaudio/*.h"
|
||||
)
|
||||
|
||||
set(HAVE_SDL_AUDIO TRUE)
|
||||
endif()
|
||||
|
||||
set(SDL_FILESYSTEM_OPENHARMONY 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/filesystem/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/filesystem/openharmony/*.h"
|
||||
)
|
||||
sdl_link_dependency(openharmonyfs LIBS ability_runtime)
|
||||
set(HAVE_SDL_FILESYSTEM TRUE)
|
||||
|
||||
set(SDL_FSOPS_POSIX 1)
|
||||
sdl_sources("${SDL3_SOURCE_DIR}/src/filesystem/posix/SDL_sysfsops.c")
|
||||
set(HAVE_SDL_FSOPS TRUE)
|
||||
|
||||
if (False) # !!! FIXME
|
||||
if(SDL_HAPTIC)
|
||||
set(SDL_HAPTIC_OPENHARMONY 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/haptic/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/haptic/openharmony/*.h"
|
||||
)
|
||||
set(HAVE_SDL_HAPTIC TRUE)
|
||||
endif()
|
||||
|
||||
# !!! FIXME: any chance HIDAPI would work here?
|
||||
CheckHIDAPI()
|
||||
|
||||
if(SDL_JOYSTICK)
|
||||
set(SDL_JOYSTICK_OPENHARMONY 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/joystick/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/joystick/openharmony/*.h"
|
||||
)
|
||||
set(HAVE_SDL_JOYSTICK TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(SDL_LOADSO_DLOPEN 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/loadso/dlopen/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/loadso/dlopen/*.h"
|
||||
)
|
||||
set(HAVE_SDL_LOADSO TRUE)
|
||||
|
||||
if(SDL_POWER)
|
||||
set(SDL_POWER_OPENHARMONY 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/power/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/power/openharmony/*.h"
|
||||
)
|
||||
sdl_link_dependency(openharmonypower LIBS ohbattery_info)
|
||||
set(HAVE_SDL_POWER TRUE)
|
||||
endif()
|
||||
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/locale/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/locale/openharmony/*.h"
|
||||
)
|
||||
set(HAVE_SDL_LOCALE TRUE)
|
||||
|
||||
set(SDL_TIME_UNIX 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/time/unix/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/time/unix/*.h"
|
||||
)
|
||||
set(HAVE_SDL_TIME TRUE)
|
||||
|
||||
set(SDL_TIMER_UNIX 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/timer/unix/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/timer/unix/*.h"
|
||||
)
|
||||
set(HAVE_SDL_TIMERS TRUE)
|
||||
|
||||
if(False)
|
||||
if(SDL_SENSOR)
|
||||
set(SDL_SENSOR_OPENHARMONY 1)
|
||||
set(HAVE_SDL_SENSORS TRUE)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/sensor/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/sensor/openharmony/*.h"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SDL_CAMERA)
|
||||
set(SDL_CAMERA_DRIVER_OPENHARMONY 1)
|
||||
set(HAVE_CAMERA TRUE)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/camera/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/camera/openharmony/*.h"
|
||||
)
|
||||
sdl_link_dependency(openharmonycamera LIBS ohcamera ohimage image_receiver native_image native_buffer)
|
||||
endif()
|
||||
|
||||
if(SDL_VIDEO)
|
||||
set(SDL_VIDEO_DRIVER_OPENHARMONY 1)
|
||||
sdl_glob_sources(
|
||||
"${SDL3_SOURCE_DIR}/src/video/openharmony/*.c"
|
||||
"${SDL3_SOURCE_DIR}/src/video/openharmony/*.h"
|
||||
)
|
||||
set(HAVE_SDL_VIDEO TRUE)
|
||||
sdl_link_dependency(openharmonyvideo LIBS native_display_manager pasteboard udmf)
|
||||
|
||||
# Core stuff
|
||||
# find_library(ANDROID_DL_LIBRARY dl)
|
||||
# FIXME failing dlopen https://github.com/android-ndk/ndk/issues/929
|
||||
# !!! FIXME
|
||||
# sdl_link_dependency(android_video LIBS dl log android)
|
||||
sdl_compile_definitions(PRIVATE "GL_GLEXT_PROTOTYPES")
|
||||
|
||||
#enable gles
|
||||
if(SDL_OPENGLES)
|
||||
set(SDL_VIDEO_OPENGL_EGL 1)
|
||||
set(HAVE_OPENGLES TRUE)
|
||||
set(SDL_VIDEO_OPENGL_ES2 1)
|
||||
set(SDL_VIDEO_RENDER_OGL_ES2 1)
|
||||
#sdl_link_dependency(opengles LIBS GLESv3)
|
||||
endif()
|
||||
|
||||
if(SDL_VULKAN)
|
||||
set(SDL_VIDEO_VULKAN 1)
|
||||
set(HAVE_VULKAN TRUE)
|
||||
if(SDL_RENDER_VULKAN)
|
||||
set(SDL_VIDEO_RENDER_VULKAN 1)
|
||||
set(HAVE_RENDER_VULKAN TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
CheckPTHREAD()
|
||||
|
||||
if(SDL_CLOCK_GETTIME)
|
||||
set(HAVE_CLOCK_GETTIME 1)
|
||||
endif()
|
||||
|
||||
elseif(EMSCRIPTEN)
|
||||
# Hide noisy warnings that intend to aid mostly during initial stages of porting a new
|
||||
# project. Uncomment at will for verbose cross-compiling -I/../ path info.
|
||||
|
||||
Executable
+209
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,188 @@
|
||||
if(OHOS)
|
||||
function(SDL_Preseed_CMakeCache)
|
||||
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
|
||||
set(COMPILER_SUPPORTS_GCC_ATOMICS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_GCC_ATOMICS")
|
||||
set(COMPILER_SUPPORTS_SYNC_LOCK_TEST_AND_SET "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SYNC_LOCK_TEST_AND_SET")
|
||||
set(HAVE_CLANG_COMMENT_BLOCK_COMMANDS "1" CACHE INTERNAL "Test HAVE_CLANG_COMMENT_BLOCK_COMMANDS")
|
||||
set(HAVE_ALLOCA_H "1" CACHE INTERNAL "Have include alloca.h")
|
||||
set(HAVE_LIBM "1" CACHE INTERNAL "Have library m")
|
||||
set(HAVE_POSIX_SPAWN "1" CACHE INTERNAL "Have symbol posix_spawn")
|
||||
set(HAVE_FSEEKO "1" CACHE INTERNAL "Have symbol fseeko")
|
||||
set(HAVE_OFF64_T "1" CACHE INTERNAL "Have symbol off64_t")
|
||||
set(LIBC_HAS_ABS "1" CACHE INTERNAL "Have symbol abs")
|
||||
set(LIBC_HAS_ACOS "1" CACHE INTERNAL "Have symbol acos")
|
||||
set(LIBC_HAS_ACOSF "1" CACHE INTERNAL "Have symbol acosf")
|
||||
set(LIBC_HAS_ASIN "1" CACHE INTERNAL "Have symbol asin")
|
||||
set(LIBC_HAS_ASINF "1" CACHE INTERNAL "Have symbol asinf")
|
||||
set(LIBC_HAS_ATAN "1" CACHE INTERNAL "Have symbol atan")
|
||||
set(LIBC_HAS_ATAN2 "1" CACHE INTERNAL "Have symbol atan2")
|
||||
set(LIBC_HAS_ATAN2F "1" CACHE INTERNAL "Have symbol atan2f")
|
||||
set(LIBC_HAS_ATANF "1" CACHE INTERNAL "Have symbol atanf")
|
||||
set(LIBC_HAS_ATOF "1" CACHE INTERNAL "Have symbol atof")
|
||||
set(LIBC_HAS_ATOI "1" CACHE INTERNAL "Have symbol atoi")
|
||||
set(LIBC_HAS_BCOPY "1" CACHE INTERNAL "Have symbol bcopy")
|
||||
set(LIBC_HAS_CALLOC "1" CACHE INTERNAL "Have symbol calloc")
|
||||
set(LIBC_HAS_CEIL "1" CACHE INTERNAL "Have symbol ceil")
|
||||
set(LIBC_HAS_CEILF "1" CACHE INTERNAL "Have symbol ceilf")
|
||||
set(LIBC_HAS_COPYSIGN "1" CACHE INTERNAL "Have symbol copysign")
|
||||
set(LIBC_HAS_COPYSIGNF "1" CACHE INTERNAL "Have symbol copysignf")
|
||||
set(LIBC_HAS_COS "1" CACHE INTERNAL "Have symbol cos")
|
||||
set(LIBC_HAS_COSF "1" CACHE INTERNAL "Have symbol cosf")
|
||||
set(LIBC_HAS_EXP "1" CACHE INTERNAL "Have symbol exp")
|
||||
set(LIBC_HAS_EXPF "1" CACHE INTERNAL "Have symbol expf")
|
||||
set(LIBC_HAS_FABS "1" CACHE INTERNAL "Have symbol fabs")
|
||||
set(LIBC_HAS_FABSF "1" CACHE INTERNAL "Have symbol fabsf")
|
||||
set(LIBC_HAS_FLOAT_H "1" CACHE INTERNAL "Have include float.h")
|
||||
set(LIBC_HAS_FLOOR "1" CACHE INTERNAL "Have symbol floor")
|
||||
set(LIBC_HAS_FLOORF "1" CACHE INTERNAL "Have symbol floorf")
|
||||
set(LIBC_HAS_FMOD "1" CACHE INTERNAL "Have symbol fmod")
|
||||
set(LIBC_HAS_FMODF "1" CACHE INTERNAL "Have symbol fmodf")
|
||||
set(LIBC_HAS_FOPEN64 "1" CACHE INTERNAL "Have symbol fopen64")
|
||||
set(LIBC_HAS_FREE "1" CACHE INTERNAL "Have symbol free")
|
||||
set(LIBC_HAS_FSEEKO "1" CACHE INTERNAL "Have symbol fseeko")
|
||||
set(LIBC_HAS_FSEEKO64 "1" CACHE INTERNAL "Have symbol fseeko64 (broken in DJGPP)")
|
||||
set(LIBC_HAS_GETENV "1" CACHE INTERNAL "Have symbol getenv")
|
||||
set(LIBC_HAS_ICONV_H "1" CACHE INTERNAL "Have include iconv.h")
|
||||
set(LIBC_HAS_INDEX "1" CACHE INTERNAL "Have symbol index")
|
||||
set(LIBC_HAS_INTTYPES_H "1" CACHE INTERNAL "Have include inttypes.h")
|
||||
set(LIBC_HAS_ISINF "" CACHE INTERNAL "Have include isinf(double)")
|
||||
set(LIBC_ISINF_HANDLES_FLOAT "" CACHE INTERNAL "Have include isinf(float)")
|
||||
set(LIBC_HAS_ISINFF "" CACHE INTERNAL "Have include isinff(float)")
|
||||
set(LIBC_HAS_ISNAN "" CACHE INTERNAL "Have include isnan(double)")
|
||||
set(LIBC_ISNAN_HANDLES_FLOAT "" CACHE INTERNAL "Have include isnan(float)")
|
||||
set(LIBC_HAS_ISNANF "" CACHE INTERNAL "Have include isnanf(float)")
|
||||
set(LIBC_HAS_ITOA "" CACHE INTERNAL "Have symbol itoa")
|
||||
set(LIBC_HAS_LIMITS_H "1" CACHE INTERNAL "Have include limits.h")
|
||||
set(LIBC_HAS_LOG "1" CACHE INTERNAL "Have symbol log")
|
||||
set(LIBC_HAS_LOG10 "1" CACHE INTERNAL "Have symbol log10")
|
||||
set(LIBC_HAS_LOG10F "1" CACHE INTERNAL "Have symbol log10f")
|
||||
set(LIBC_HAS_LOGF "1" CACHE INTERNAL "Have symbol logf")
|
||||
set(LIBC_HAS_LROUND "1" CACHE INTERNAL "Have symbol lround")
|
||||
set(LIBC_HAS_LROUNDF "1" CACHE INTERNAL "Have symbol lroundf")
|
||||
set(LIBC_HAS_MALLOC "1" CACHE INTERNAL "Have symbol malloc")
|
||||
set(LIBC_HAS_MALLOC_H "1" CACHE INTERNAL "Have include malloc.h")
|
||||
set(LIBC_HAS_MATH_H "1" CACHE INTERNAL "Have include math.h")
|
||||
set(LIBC_HAS_MEMCMP "1" CACHE INTERNAL "Have symbol memcmp")
|
||||
set(LIBC_HAS_MEMCPY "1" CACHE INTERNAL "Have symbol memcpy")
|
||||
set(LIBC_HAS_MEMMOVE "1" CACHE INTERNAL "Have symbol memmove")
|
||||
set(LIBC_HAS_MEMORY_H "1" CACHE INTERNAL "Have include memory.h")
|
||||
set(LIBC_HAS_MEMSET "1" CACHE INTERNAL "Have symbol memset")
|
||||
set(LIBC_HAS_MODF "1" CACHE INTERNAL "Have symbol modf")
|
||||
set(LIBC_HAS_MODFF "1" CACHE INTERNAL "Have symbol modff")
|
||||
set(LIBC_HAS_POW "1" CACHE INTERNAL "Have symbol pow")
|
||||
set(LIBC_HAS_POWF "1" CACHE INTERNAL "Have symbol powf")
|
||||
set(LIBC_HAS_PUTENV "1" CACHE INTERNAL "Have symbol putenv")
|
||||
set(LIBC_HAS_REALLOC "1" CACHE INTERNAL "Have symbol realloc")
|
||||
set(LIBC_HAS_RINDEX "" CACHE INTERNAL "Have symbol rindex")
|
||||
set(LIBC_HAS_ROUND "1" CACHE INTERNAL "Have symbol round")
|
||||
set(LIBC_HAS_ROUNDF "1" CACHE INTERNAL "Have symbol roundf")
|
||||
set(LIBC_HAS_SCALBN "1" CACHE INTERNAL "Have symbol scalbn")
|
||||
set(LIBC_HAS_SCALBNF "1" CACHE INTERNAL "Have symbol scalbnf")
|
||||
set(LIBC_HAS_SETENV "1" CACHE INTERNAL "Have symbol setenv")
|
||||
set(LIBC_HAS_SIGNAL_H "1" CACHE INTERNAL "Have include signal.h")
|
||||
set(LIBC_HAS_SIN "1" CACHE INTERNAL "Have symbol sin")
|
||||
set(LIBC_HAS_SINF "1" CACHE INTERNAL "Have symbol sinf")
|
||||
set(LIBC_HAS_SQR "" CACHE INTERNAL "Have symbol sqr")
|
||||
set(LIBC_HAS_SQRT "1" CACHE INTERNAL "Have symbol sqrt")
|
||||
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
|
||||
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
|
||||
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
|
||||
set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h")
|
||||
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
|
||||
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
|
||||
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
|
||||
set(LIBC_HAS_STDLIB_H "1" CACHE INTERNAL "Have include stdlib.h")
|
||||
set(LIBC_HAS_STRCASESTR "1" CACHE INTERNAL "Have symbol strcasestr")
|
||||
set(LIBC_HAS_STRCHR "1" CACHE INTERNAL "Have symbol strchr")
|
||||
set(LIBC_HAS_STRCMP "1" CACHE INTERNAL "Have symbol strcmp")
|
||||
set(LIBC_HAS_STRINGS_H "1" CACHE INTERNAL "Have include strings.h")
|
||||
set(LIBC_HAS_STRING_H "1" CACHE INTERNAL "Have include string.h")
|
||||
set(LIBC_HAS_STRLCAT "1" CACHE INTERNAL "Have symbol strlcat")
|
||||
set(LIBC_HAS_STRLCPY "1" CACHE INTERNAL "Have symbol strlcpy")
|
||||
set(LIBC_HAS_STRLEN "1" CACHE INTERNAL "Have symbol strlen")
|
||||
set(LIBC_HAS_STRNCMP "1" CACHE INTERNAL "Have symbol strncmp")
|
||||
set(LIBC_HAS_STRNLEN "1" CACHE INTERNAL "Have symbol strnlen")
|
||||
set(LIBC_HAS_STRNSTR "" CACHE INTERNAL "Have symbol strnstr")
|
||||
set(LIBC_HAS_STRPBRK "1" CACHE INTERNAL "Have symbol strpbrk")
|
||||
set(LIBC_HAS_STRRCHR "1" CACHE INTERNAL "Have symbol strrchr")
|
||||
set(LIBC_HAS_STRSTR "1" CACHE INTERNAL "Have symbol strstr")
|
||||
set(LIBC_HAS_STRTOD "1" CACHE INTERNAL "Have symbol strtod")
|
||||
set(LIBC_HAS_STRTOK_R "1" CACHE INTERNAL "Have symbol strtok_r")
|
||||
set(LIBC_HAS_STRTOL "1" CACHE INTERNAL "Have symbol strtol")
|
||||
set(LIBC_HAS_STRTOLL "1" CACHE INTERNAL "Have symbol strtoll")
|
||||
set(LIBC_HAS_STRTOUL "1" CACHE INTERNAL "Have symbol strtoul")
|
||||
set(LIBC_HAS_STRTOULL "1" CACHE INTERNAL "Have symbol strtoull")
|
||||
set(LIBC_HAS_SYS_TYPES_H "1" CACHE INTERNAL "Have include sys/types.h")
|
||||
set(LIBC_HAS_TAN "1" CACHE INTERNAL "Have symbol tan")
|
||||
set(LIBC_HAS_TANF "1" CACHE INTERNAL "Have symbol tanf")
|
||||
set(LIBC_HAS_TIME_H "1" CACHE INTERNAL "Have include time.h")
|
||||
set(LIBC_HAS_TRUNC "1" CACHE INTERNAL "Have symbol trunc")
|
||||
set(LIBC_HAS_TRUNCF "1" CACHE INTERNAL "Have symbol truncf")
|
||||
set(LIBC_HAS_UNSETENV "1" CACHE INTERNAL "Have symbol unsetenv")
|
||||
set(LIBC_HAS_VFORK "1" CACHE INTERNAL "Have symbol vfork")
|
||||
set(LIBC_HAS_VSNPRINTF "1" CACHE INTERNAL "Have symbol vsnprintf")
|
||||
set(LIBC_HAS_VSSCANF "1" CACHE INTERNAL "Have symbol vsscanf")
|
||||
set(LIBC_HAS_WCHAR_H "1" CACHE INTERNAL "Have include wchar.h")
|
||||
set(LIBC_HAS_WCSCMP "1" CACHE INTERNAL "Have symbol wcscmp")
|
||||
set(LIBC_HAS_WCSDUP "1" CACHE INTERNAL "Have symbol wcsdup")
|
||||
set(LIBC_HAS_WCSLCAT "" CACHE INTERNAL "Have symbol wcslcat")
|
||||
set(LIBC_HAS_WCSLCPY "" CACHE INTERNAL "Have symbol wcslcpy")
|
||||
set(LIBC_HAS_WCSLEN "1" CACHE INTERNAL "Have symbol wcslen")
|
||||
set(LIBC_HAS_WCSNCMP "1" CACHE INTERNAL "Have symbol wcsncmp")
|
||||
set(LIBC_HAS_WCSNLEN "1" CACHE INTERNAL "Have symbol wcsnlen")
|
||||
set(LIBC_HAS_WCSSTR "1" CACHE INTERNAL "Have symbol wcsstr")
|
||||
set(LIBC_HAS_WCSTOL "1" CACHE INTERNAL "Have symbol wcstol")
|
||||
set(LIBC_HAS_WCSTOLL "1" CACHE INTERNAL "Have symbol wcstoll")
|
||||
set(LIBC_HAS_WCSTOUL "1" CACHE INTERNAL "Have symbol wcstoul")
|
||||
set(LIBC_HAS_WCSTOULL "1" CACHE INTERNAL "Have symbol wcstoull")
|
||||
set(LIBC_HAS__EXIT "1" CACHE INTERNAL "Have symbol _Exit")
|
||||
set(LIBC_HAS__I64TOA "" CACHE INTERNAL "Have symbol _i64toa")
|
||||
set(LIBC_HAS__LTOA "" CACHE INTERNAL "Have symbol _ltoa")
|
||||
set(LIBC_HAS__STRREV "" CACHE INTERNAL "Have symbol _strrev")
|
||||
set(LIBC_HAS__ULTOA "" CACHE INTERNAL "Have symbol _ultoa")
|
||||
set(LIBC_HAS__WCSDUP "1" CACHE INTERNAL "Have symbol _wcsdup")
|
||||
set(LIBC_IS_GLIBC "" CACHE INTERNAL "Have symbol __GLIBC__")
|
||||
set(HAVE_GCC_WALL "1" CACHE INTERNAL "Test HAVE_GCC_WALL")
|
||||
set(HAVE_GCC_WUNDEF "1" CACHE INTERNAL "Test HAVE_GCC_WUNDEF")
|
||||
set(HAVE_GCC_WFLOAT_CONVERSION "1" CACHE INTERNAL "Test HAVE_GCC_WFLOAT_CONVERSION")
|
||||
set(HAVE_GCC_NO_STRICT_ALIASING "1" CACHE INTERNAL "Test HAVE_GCC_NO_STRICT_ALIASING")
|
||||
set(HAVE_GCC_WDOCUMENTATION "1" CACHE INTERNAL "Test HAVE_GCC_WDOCUMENTATION")
|
||||
set(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND "1" CACHE INTERNAL "Test HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND")
|
||||
set(HAVE_GCC_COMMENT_BLOCK_COMMANDS "1" CACHE INTERNAL "Test HAVE_GCC_COMMENT_BLOCK_COMMANDS")
|
||||
set(HAVE_GCC_WSHADOW "1" CACHE INTERNAL "Test HAVE_GCC_WSHADOW")
|
||||
set(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS "1" CACHE INTERNAL "Test HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS")
|
||||
set(HAVE_GCC_WIMPLICIT_FALLTHROUGH "1" CACHE INTERNAL "Test HAVE_GCC_WIMPLICIT_FALLTHROUGH")
|
||||
set(HAVE_GCC_FVISIBILITY "" CACHE INTERNAL "Test HAVE_GCC_FVISIBILITY")
|
||||
set(HAVE_ST_MTIM "1" CACHE INTERNAL "Test HAVE_ST_MTIM")
|
||||
set(HAVE_LD_VERSION_SCRIPT "1" CACHE INTERNAL "Test HAVE_LD_VERSION_SCRIPT")
|
||||
set(HAVE_WL_VERSION_SCRIPT "1" CACHE INTERNAL "Test HAVE_WL_VERSION_SCRIPT")
|
||||
set(LINKER_SUPPORTS_VERSION_SCRIPT "1" CACHE INTERNAL "Test LINKER_SUPPORTS_VERSION_SCRIPT")
|
||||
set(LINKER_SUPPORTS_WL_NO_UNDEFINED "1" CACHE INTERNAL "Test LINKER_SUPPORTS_WL_NO_UNDEFINED")
|
||||
set(ICONV_IN_LIBC "1" CACHE INTERNAL "Test ICONV_IN_LIBC")
|
||||
set(ICONV_IN_LIBICONV "" CACHE INTERNAL "Test ICONV_IN_LIBICONV")
|
||||
set(HAVE_GETPAGESIZE "1" CACHE INTERNAL "Have symbol getpagesize")
|
||||
set(HAVE_SIGACTION "1" CACHE INTERNAL "Have symbol sigaction")
|
||||
set(HAVE_SA_SIGACTION "1" CACHE INTERNAL "Have symbol sa_sigaction")
|
||||
set(HAVE_SETJMP "1" CACHE INTERNAL "Have symbol setjmp")
|
||||
set(HAVE_NANOSLEEP "1" CACHE INTERNAL "Have symbol nanosleep")
|
||||
set(HAVE_GMTIME_R "1" CACHE INTERNAL "Have symbol gmtime_r")
|
||||
set(HAVE_LOCALTIME_R "1" CACHE INTERNAL "Have symbol localtime_r")
|
||||
set(HAVE_NL_LANGINFO "1" CACHE INTERNAL "Have symbol nl_langinfo")
|
||||
set(HAVE_SYSCONF "1" CACHE INTERNAL "Have symbol sysconf")
|
||||
set(HAVE_SYSCTLBYNAME "" CACHE INTERNAL "Have symbol sysctlbyname")
|
||||
set(HAVE_GETAUXVAL "1" CACHE INTERNAL "Have symbol getauxval")
|
||||
set(HAVE_ELF_AUX_INFO "" CACHE INTERNAL "Have symbol elf_aux_info")
|
||||
set(HAVE_POLL "" CACHE INTERNAL "Have symbol poll")
|
||||
set(HAVE_MEMFD_CREATE "1" CACHE INTERNAL "Have symbol memfd_create")
|
||||
set(HAVE_POSIX_FALLOCATE "1" CACHE INTERNAL "Have symbol posix_fallocate")
|
||||
set(HAVE_DLOPEN_IN_LIBC "1" CACHE INTERNAL "Have symbol dlopen")
|
||||
set(HAVE_GETHOSTNAME "1" CACHE INTERNAL "Have symbol gethostname")
|
||||
set(HAVE_SIGTIMEDWAIT "1" CACHE INTERNAL "Have symbol sigtimedwait")
|
||||
set(HAVE_PPOLL "1" CACHE INTERNAL "Have symbol ppoll")
|
||||
set(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR "" CACHE INTERNAL "Have symbol addchdir")
|
||||
set(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP "" CACHE INTERNAL "Have symbol addchdir_np")
|
||||
set(HAVE_FDATASYNC "1" CACHE INTERNAL "Have symbol fdatasync")
|
||||
set(HAVE_GETRESUID "1" CACHE INTERNAL "Have symbol getresuid")
|
||||
set(HAVE_GETRESGID "1" CACHE INTERNAL "Have symbol getresgid")
|
||||
endfunction()
|
||||
endif()
|
||||
+1
-1
@@ -425,7 +425,7 @@ function(SDL_PrintSummary)
|
||||
message(STATUS "")
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT (ANDROID OR APPLE OR EMSCRIPTEN OR HAIKU OR RISCOS OR DJGPP OR CYGWIN))
|
||||
if(UNIX AND NOT (ANDROID OR APPLE OR EMSCRIPTEN OR HAIKU OR RISCOS OR DJGPP OR CYGWIN OR OHOS))
|
||||
if(NOT (HAVE_X11 OR HAVE_WAYLAND))
|
||||
if(NOT SDL_UNIX_CONSOLE_BUILD)
|
||||
message(FATAL_ERROR
|
||||
|
||||
@@ -184,6 +184,11 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
||||
if(USE_TCC)
|
||||
sdl_target_compile_option_all_languages(${TARGET} "-DSTBI_NO_SIMD")
|
||||
endif()
|
||||
|
||||
if(OHOS) # OpenHarmony/HarmonyOS
|
||||
# Stop the `clang: warning: argument unused during compilation: '--gcc-toolchain=$X/sdk/default/openharmony/native/llvm' [-Wunused-command-line-argument]` on every file compiled. I think this is a toolchain file issue...?
|
||||
sdl_target_compile_option_all_languages(${TARGET} "-Wno-unused-command-line-argument")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(check_x86_source_compiles BODY VAR)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ SDL3 has been known to work on the following platforms at some point:
|
||||
- [Emscripten](README-emscripten.md) (Web browsers)
|
||||
- [FreeBSD](README-bsd.md)
|
||||
- [Haiku OS](README-haiku.md)
|
||||
- [HarmonyOS/OpenHarmony](README-harmonyos.md)
|
||||
- [iOS](README-ios.md)
|
||||
- [Linux](README-linux.md)
|
||||
- [macOS](README-macos.md) (10.14 and later)
|
||||
|
||||
@@ -257,6 +257,10 @@ typedef struct SDL_IOStream SDL_IOStream;
|
||||
* to an Android NDK `AAsset *`, that this SDL_IOStream is using to access
|
||||
* the filesystem. If SDL used some other method to access the filesystem,
|
||||
* this property will not be set.
|
||||
* - `SDL_PROP_IOSTREAM_OPENHARMONY_RAWFILE64_POINTER`: a pointer, that can be
|
||||
* cast to an OpenHarmony/HarmonyOS `RawFile64 *`, that this SDL_IOStream is
|
||||
* using to access the filesystem. If SDL used some other method to access
|
||||
* the filesystem, this property will not be set.
|
||||
*
|
||||
* \param file a UTF-8 string representing the filename to open.
|
||||
* \param mode an ASCII string representing the mode to be used for opening
|
||||
@@ -277,10 +281,11 @@ typedef struct SDL_IOStream SDL_IOStream;
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, const char *mode);
|
||||
|
||||
#define SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER "SDL.iostream.windows.handle"
|
||||
#define SDL_PROP_IOSTREAM_STDIO_FILE_POINTER "SDL.iostream.stdio.file"
|
||||
#define SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER "SDL.iostream.file_descriptor"
|
||||
#define SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER "SDL.iostream.android.aasset"
|
||||
#define SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER "SDL.iostream.windows.handle"
|
||||
#define SDL_PROP_IOSTREAM_STDIO_FILE_POINTER "SDL.iostream.stdio.file"
|
||||
#define SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER "SDL.iostream.file_descriptor"
|
||||
#define SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER "SDL.iostream.android.aasset"
|
||||
#define SDL_PROP_IOSTREAM_OPENHARMONY_RAWFILE64_POINTER "SDL.iostream.openharmony.rawfile64"
|
||||
|
||||
/**
|
||||
* Use this function to prepare a read-write memory buffer for use with
|
||||
|
||||
@@ -464,6 +464,12 @@ typedef enum SDL_Capitalization
|
||||
* use, overriding other properties. This is documented at
|
||||
* https://developer.android.com/reference/android/text/InputType
|
||||
*
|
||||
* On HarmonyOS/OpenHarmony you can directly specify the input type:
|
||||
*
|
||||
* - `SDL_PROP_TEXTINPUT_OPENHARMONY_INPUTTYPE_NUMBER` - the text input type to
|
||||
* use, overriding other properties. This is documented at
|
||||
* https://developer.android.com/reference/android/text/InputType
|
||||
*
|
||||
* \param window the window to enable text input.
|
||||
* \param props the properties to use.
|
||||
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||
@@ -489,6 +495,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInputWithProperties(SDL_Window *wi
|
||||
#define SDL_PROP_TEXTINPUT_DEFAULT_TEXT_STRING "SDL.textinput.default_text"
|
||||
#define SDL_PROP_TEXTINPUT_MAX_LENGTH_NUMBER "SDL.textinput.max_length"
|
||||
#define SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER "SDL.textinput.android.inputtype"
|
||||
#define SDL_PROP_TEXTINPUT_OPENHARMONY_INPUTTYPE_NUMBER "SDL.textinput.openharmony.inputtype"
|
||||
|
||||
/**
|
||||
* Check whether or not Unicode text input events are enabled for a window.
|
||||
|
||||
@@ -193,6 +193,19 @@
|
||||
*/
|
||||
#define SDL_MAIN_EXPORTED
|
||||
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
/* On HarmonyOS/OpenHarmony SDL does a lot of work to gain control of the app. */
|
||||
#define SDL_MAIN_NEEDED
|
||||
|
||||
/* As this is launched from ArkTS, the real entry point (main() function)
|
||||
is outside of the the binary built from this code.
|
||||
This define makes sure that, unlike on other platforms, SDL_main.h
|
||||
and SDL_main_impl.h export an `SDL_main()` function (to be called
|
||||
from ArkTS, sort of), but don't implement a native
|
||||
`int main(int argc, char* argv[])` or similar.
|
||||
*/
|
||||
#define SDL_MAIN_EXPORTED
|
||||
|
||||
#elif defined(SDL_PLATFORM_EMSCRIPTEN)
|
||||
/* On Emscripten, SDL provides a main function that converts URL
|
||||
parameters that start with "SDL_" to environment variables, so
|
||||
|
||||
@@ -49,6 +49,13 @@
|
||||
/* currently there are no platforms that _need_ a magic entry point here
|
||||
for callbacks, but if one shows up, implement it here. */
|
||||
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
/* HarmonyOS/OpenHarmony: we look up SDL_AppInit/SDL_AppIterate/etc in libmain.so and call them directly.
|
||||
Since we don't need a `main` entry point, we don't generate an SDL_main implementation here _at all_. */
|
||||
#ifndef SDL_MAIN_USE_CALLBACKS /* !!! FIXME, remove this later? */
|
||||
#error SDL3 on OpenHarmony currently requires the SDL Main Callbacks to operate.
|
||||
#endif
|
||||
|
||||
#else /* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */
|
||||
|
||||
/* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */
|
||||
|
||||
@@ -112,6 +112,17 @@
|
||||
#undef SDL_PLATFORM_LINUX
|
||||
#endif
|
||||
|
||||
#if defined(__OHOS__)
|
||||
|
||||
/**
|
||||
* A preprocessor macro that is only defined if compiling for OpenHarmony/HarmonyOS.
|
||||
*
|
||||
* \since This macro is available since SDL 3.6.0.
|
||||
*/
|
||||
#define SDL_PLATFORM_OPENHARMONY 1
|
||||
#undef SDL_PLATFORM_LINUX
|
||||
#endif
|
||||
|
||||
#if defined(__unix__) || defined(__unix) || defined(unix)
|
||||
|
||||
/**
|
||||
|
||||
@@ -522,7 +522,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void)
|
||||
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void);
|
||||
|
||||
/**
|
||||
* Callback that presents a response from a SDL_RequestAndroidPermission call.
|
||||
* Callback that presents SDL_RequestAndroidPermission() results.
|
||||
*
|
||||
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||
* \param permission the Android-specific permission name that was requested.
|
||||
@@ -616,6 +616,99 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int para
|
||||
|
||||
#endif /* SDL_PLATFORM_ANDROID */
|
||||
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
/**
|
||||
* Query OpenHarmony API level of the current device.
|
||||
*
|
||||
* - API level 20: OpenHarmony 6.0.0
|
||||
* - API level 18: OpenHarmony 5.1.0
|
||||
* - API level 16: OpenHarmony 5.0.4
|
||||
* - API level 15: OpenHarmony 5.0.3
|
||||
* - API level 14: OpenHarmony 5.0.2
|
||||
* - API level 13: OpenHarmony 5.0.1
|
||||
* - API level 12: OpenHarmony 5.0.0
|
||||
* - API level 11: OpenHarmony 4.1.0
|
||||
* - API level 10: OpenHarmony 4.0.0
|
||||
* - API level 9: OpenHarmony 3.2.0
|
||||
*
|
||||
* \returns the OpenHarmony API level.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.6.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetOpenHarmonySDKVersion(void);
|
||||
|
||||
/**
|
||||
* Get the path used for internal storage for this OpenHarmony application.
|
||||
*
|
||||
* This path is unique to your application and cannot be written to by other
|
||||
* applications.
|
||||
*
|
||||
* Your internal storage path is typically:
|
||||
* `/data/storage/el2/base/files`.
|
||||
*
|
||||
* \returns the path used for internal storage or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.6.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC const char * SDLCALL SDL_GetOpenHarmonyInternalStoragePath(void);
|
||||
|
||||
/**
|
||||
* Callback that presents SDL_RequestOpenHarmonyPermission() results.
|
||||
*
|
||||
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||
* \param permission the OpenHarmony-specific permission name that was requested.
|
||||
* \param granted true if permission is granted, false if denied.
|
||||
*
|
||||
* \since This datatype is available since SDL 3.6.0.
|
||||
*
|
||||
* \sa SDL_RequestOpenHarmonyPermission
|
||||
*/
|
||||
typedef void (SDLCALL *SDL_RequestOpenHarmonyPermissionCallback)(void *userdata, const char *permission, bool granted);
|
||||
|
||||
/**
|
||||
* Request permissions at runtime, asynchronously.
|
||||
*
|
||||
* You do not need to call this for built-in functionality of SDL; recording
|
||||
* from a microphone or reading images from a camera, using standard SDL APIs,
|
||||
* will manage permission requests for you.
|
||||
*
|
||||
* This function never blocks. Instead, the app-supplied callback will be
|
||||
* called when a decision has been made. This callback may happen on a
|
||||
* different thread, and possibly much later, as it might wait on a user to
|
||||
* respond to a system dialog. If permission has already been granted for a
|
||||
* specific entitlement, the callback will still fire, probably on the current
|
||||
* thread and before this function returns.
|
||||
*
|
||||
* If the request submission fails, this function returns false and the
|
||||
* callback will NOT be called, but this should only happen in catastrophic
|
||||
* conditions, like memory running out. Normally there will be a yes or no to
|
||||
* the request through the callback.
|
||||
*
|
||||
* For the `permission` parameter, choose a value from here:
|
||||
*
|
||||
* https://developer.huawei.com/consumer/en/doc/harmonyos-guides/app-permissions
|
||||
*
|
||||
* Strings should be in the form of "ohos.permission.PERMISSION_NAME".
|
||||
*
|
||||
* \param permission the permission to request.
|
||||
* \param cb the callback to trigger when the request has a response.
|
||||
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||
* \returns true if the request was submitted, false if there was an error
|
||||
* submitting. The result of the request is only ever reported
|
||||
* through the callback, not this return value.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.6.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_RequestOpenHarmonyPermission(const char *permission, SDL_RequestOpenHarmonyPermissionCallback cb, void *userdata);
|
||||
|
||||
#endif /* SDL_PLATFORM_OPENHARMONY */
|
||||
|
||||
|
||||
/**
|
||||
* Query if the current device is a phone.
|
||||
*
|
||||
|
||||
@@ -1579,6 +1579,15 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window)
|
||||
* - `SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER`: the EGLSurface associated with
|
||||
* the window
|
||||
*
|
||||
* On OpenHarmony/HarmonyOS:
|
||||
*
|
||||
* - `SDL_PROP_WINDOW_OPENHARMONY_XCOMPONENT_POINTER`: the OH_NativeXComponent
|
||||
* associated with the window
|
||||
* - `SDL_PROP_WINDOW_OPENHARMONY_WINDOW_POINTER`: the OHNativeWindow associated
|
||||
* with the window
|
||||
* - `SDL_PROP_WINDOW_OPENHARMONY_SURFACE_POINTER`: the EGLSurface associated with
|
||||
* the window
|
||||
*
|
||||
* On iOS:
|
||||
*
|
||||
* - `SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER`: the `(__unsafe_unretained)`
|
||||
@@ -1706,6 +1715,9 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window
|
||||
#define SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT "SDL.window.HDR_headroom"
|
||||
#define SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER "SDL.window.android.window"
|
||||
#define SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER "SDL.window.android.surface"
|
||||
#define SDL_PROP_WINDOW_OPENHARMONY_XCOMPONENT_POINTER "SDL.window.openharmony.xcomponent"
|
||||
#define SDL_PROP_WINDOW_OPENHARMONY_WINDOW_POINTER "SDL.window.openharmony.window"
|
||||
#define SDL_PROP_WINDOW_OPENHARMONY_SURFACE_POINTER "SDL.window.openharmony.surface"
|
||||
#define SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER "SDL.window.uikit.window"
|
||||
#define SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER "SDL.window.uikit.metal_view_tag"
|
||||
#define SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.framebuffer"
|
||||
|
||||
@@ -297,6 +297,7 @@
|
||||
#cmakedefine SDL_AUDIO_DRIVER_NGAGE 1
|
||||
#cmakedefine SDL_AUDIO_DRIVER_QNX 1
|
||||
#cmakedefine SDL_AUDIO_DRIVER_DOS_SOUNDBLASTER 1
|
||||
#cmakedefine SDL_AUDIO_DRIVER_OHAUDIO 1
|
||||
#cmakedefine SDL_AUDIO_DRIVER_PRIVATE 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
@@ -404,6 +405,7 @@
|
||||
|
||||
/* Enable various video drivers */
|
||||
#cmakedefine SDL_VIDEO_DRIVER_ANDROID 1
|
||||
#cmakedefine SDL_VIDEO_DRIVER_OPENHARMONY 1
|
||||
#cmakedefine SDL_VIDEO_DRIVER_COCOA 1
|
||||
#cmakedefine SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN 1
|
||||
@@ -513,6 +515,7 @@
|
||||
#cmakedefine SDL_POWER_VITA 1
|
||||
#cmakedefine SDL_POWER_PSP 1
|
||||
#cmakedefine SDL_POWER_N3DS 1
|
||||
#cmakedefine SDL_POWER_OPENHARMONY 1
|
||||
|
||||
#cmakedefine SDL_POWER_PRIVATE 1
|
||||
|
||||
@@ -530,6 +533,7 @@
|
||||
#cmakedefine SDL_FILESYSTEM_PS2 1
|
||||
#cmakedefine SDL_FILESYSTEM_N3DS 1
|
||||
#cmakedefine SDL_FILESYSTEM_DOS 1
|
||||
#cmakedefine SDL_FILESYSTEM_OPENHARMONY 1
|
||||
|
||||
#cmakedefine SDL_FILESYSTEM_PRIVATE 1
|
||||
|
||||
@@ -551,6 +555,7 @@
|
||||
#cmakedefine SDL_CAMERA_DRIVER_V4L2 1
|
||||
#cmakedefine SDL_CAMERA_DRIVER_COREMEDIA 1
|
||||
#cmakedefine SDL_CAMERA_DRIVER_ANDROID 1
|
||||
#cmakedefine SDL_CAMERA_DRIVER_OPENHARMONY 1
|
||||
#cmakedefine SDL_CAMERA_DRIVER_EMSCRIPTEN 1
|
||||
#cmakedefine SDL_CAMERA_DRIVER_MEDIAFOUNDATION 1
|
||||
#cmakedefine SDL_CAMERA_DRIVER_PIPEWIRE 1
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/node_modules
|
||||
/oh_modules
|
||||
/local.properties
|
||||
/.idea
|
||||
**/build
|
||||
/.hvigor
|
||||
.cxx
|
||||
/.clangd
|
||||
/.clang-format
|
||||
/.clang-tidy
|
||||
**/.test
|
||||
/.appanalyzer
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.example.app",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"buildVersion": "1",
|
||||
"icon": "$media:layered_image",
|
||||
"label": "$string:app_name"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "app"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"layered-image":
|
||||
{
|
||||
"background" : "$media:background",
|
||||
"foreground" : "$media:foreground"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"app": {
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"targetSdkVersion": "5.0.4(16)",
|
||||
"compatibleSdkVersion": "5.0.4(16)",
|
||||
"runtimeOS": "HarmonyOS",
|
||||
"buildOption": {
|
||||
"nativeCompiler": "BiSheng",
|
||||
"strictMode": {
|
||||
"caseSensitiveCheck": true,
|
||||
"useNormalizedOHMUrl": true
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildModeSet": [
|
||||
{
|
||||
"name": "debug",
|
||||
},
|
||||
{
|
||||
"name": "release"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"files": [
|
||||
"**/*.ets"
|
||||
],
|
||||
"ignore": [
|
||||
"**/src/ohosTest/**/*",
|
||||
"**/src/test/**/*",
|
||||
"**/src/mock/**/*",
|
||||
"**/node_modules/**/*",
|
||||
"**/oh_modules/**/*",
|
||||
"**/build/**/*",
|
||||
"**/.preview/**/*"
|
||||
],
|
||||
"ruleSet": [
|
||||
"plugin:@performance/recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"@security/no-unsafe-aes": "error",
|
||||
"@security/no-unsafe-hash": "error",
|
||||
"@security/no-unsafe-mac": "warn",
|
||||
"@security/no-unsafe-dh": "error",
|
||||
"@security/no-unsafe-dsa": "error",
|
||||
"@security/no-unsafe-ecdsa": "error",
|
||||
"@security/no-unsafe-rsa-encrypt": "error",
|
||||
"@security/no-unsafe-rsa-sign": "error",
|
||||
"@security/no-unsafe-rsa-key": "error",
|
||||
"@security/no-unsafe-dsa-key": "error",
|
||||
"@security/no-unsafe-dh-key": "error",
|
||||
"@security/no-unsafe-3des": "error"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/node_modules
|
||||
/oh_modules
|
||||
/.preview
|
||||
/build
|
||||
/.cxx
|
||||
/.test
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
"resOptions": {
|
||||
"copyCodeResource": {
|
||||
"enable": false
|
||||
}
|
||||
},
|
||||
"externalNativeOptions": {
|
||||
"path": "./src/main/cpp/CMakeLists.txt",
|
||||
"arguments": "-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=1", // Otherwise, we load SDL3's data segment twice. :(
|
||||
"cppFlags": "",
|
||||
"abiFilters": [
|
||||
"arm64-v8a",
|
||||
"x86_64"
|
||||
]
|
||||
}
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": false,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"nativeLib": {
|
||||
"debugSymbol": {
|
||||
"strip": true,
|
||||
"exclude": []
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/en/doc/harmonyos-guides/source-obfuscation
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
||||
|
||||
-enable-property-obfuscation
|
||||
-enable-toplevel-obfuscation
|
||||
-enable-filename-obfuscation
|
||||
-enable-export-obfuscation
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"meta": {
|
||||
"stableOrder": true,
|
||||
"enableUnifiedLockfile": false
|
||||
},
|
||||
"lockfileVersion": 3,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
"specifiers": {
|
||||
"libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry"
|
||||
},
|
||||
"packages": {
|
||||
"libentry.so@src/main/cpp/types/libentry": {
|
||||
"name": "libentry.so",
|
||||
"version": "1.0.0",
|
||||
"resolved": "src/main/cpp/types/libentry",
|
||||
"registryType": "local"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"author": "",
|
||||
"license": "",
|
||||
"dependencies": {
|
||||
//"libSDL3.so": "file:./src/main/cpp/types/libSDL3",
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# the minimum version of CMake.
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(loopwave)
|
||||
|
||||
set(NATIVEAPP_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(DEFINED PACKAGE_FIND_FILE)
|
||||
include(${PACKAGE_FIND_FILE})
|
||||
endif()
|
||||
|
||||
add_subdirectory("SDL")
|
||||
|
||||
include_directories(${NATIVEAPP_ROOT_PATH}
|
||||
${NATIVEAPP_ROOT_PATH}/include
|
||||
${NATIVEAPP_ROOT_PATH}/SDL/include)
|
||||
|
||||
add_library(main SHARED myapp.c)
|
||||
target_link_libraries(main PUBLIC SDL3::SDL3)
|
||||
@@ -0,0 +1 @@
|
||||
export const provideArkTSObjects: (ability: UIAbility, atManager: abilityAccessCtrl.AtManager, locale: intl.Locale) => void;
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "libSDL3.so",
|
||||
"types": "./Index.d.ts",
|
||||
"version": "1.0.0",
|
||||
"description": "SDL3 interfaces callable from ArkTS."
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { abilityAccessCtrl, AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { i18n } from '@kit.LocalizationKit';
|
||||
import { inputMethod } from '@kit.IMEKit';
|
||||
import pointer from "@ohos.multimodalInput.pointer"
|
||||
import sdl from 'libSDL3.so';
|
||||
|
||||
const DOMAIN = 0x0000;
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
hilog.info(DOMAIN, 'SDL/STARTUP', '%{public}s', 'Handing control from ArkTS to native SDL.');
|
||||
try {
|
||||
// This hands stuff to SDL's C code that it needs to deal with ArkTS interfaces. We are trying not to write scripting code, if we can
|
||||
// handle it awkwardly in C through NAPI calls, so we have a _tiny_ surface area of risk where the script and the native code can go
|
||||
// out of sync. This function call will add methods to `this`, such as onWindowStageCreate(), so we can drive everything from C and
|
||||
// have almost no ArkTS code at all.
|
||||
// Which is to say: if this function call fails, your app won't actually start.
|
||||
//
|
||||
// ONLY EVER ADD PARAMETERS TO THIS FUNCTION CALL. THE C CODE WILL ABORT IF IT DOESN'T GET THE EXACT NUMBER IT EXPECTS.
|
||||
sdl.provideArkTSObjects(this, abilityAccessCtrl.createAtManager(), i18n.System, pointer.setPointerVisibleSync, inputMethod.getController());
|
||||
} catch (e) {
|
||||
hilog.info(DOMAIN, 'SDL/STARTUP', '%{public}s', 'Exception thrown! App will not start.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
||||
|
||||
const DOMAIN = 0x0000;
|
||||
|
||||
export default class EntryBackupAbility extends BackupExtensionAbility {
|
||||
async onBackup() {
|
||||
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
|
||||
await Promise.resolve();
|
||||
}
|
||||
|
||||
async onRestore(bundleVersion: BundleVersion) {
|
||||
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
||||
await Promise.resolve();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
const DOMAIN = 0x0000;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
XComponent({ id: 'SDL_XComponent', type: XComponentType.SURFACE, libraryname: 'SDL3' }).id('SDL_XComponent')
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
"type": "entry",
|
||||
"description": "$string:module_desc",
|
||||
"mainElement": "EntryAbility",
|
||||
// !!! FIXME: we can maybe put "car" and "wearable" in here, too, if SDL will run on them and we could test it at some point.
|
||||
"deviceTypes": [
|
||||
"phone",
|
||||
"tablet",
|
||||
"2in1",
|
||||
"tv"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
|
||||
// PERMISSIONS: Uncomment if your app needs any of these things. Please edit the "reason" text to more-clearly explain why you need access to the feature.
|
||||
// Documentation on this section: https://developer.huawei.com/consumer/en/doc/harmonyos-guides/declare-permissions
|
||||
// Lists of specific permissions: https://developer.huawei.com/consumer/en/doc/harmonyos-guides/app-permissions
|
||||
// Note that READ_PASTEBOARD is a restricted permission, you need to take serious extra steps to use it. https://developer.huawei.com/consumer/en/doc/harmonyos-guides/restricted-permissions#ohospermissionread_pasteboard
|
||||
"requestPermissions": [
|
||||
//{ "name": "ohos.permission.MICROPHONE", "reason": "$string:perm_reason_MICROPHONE", "usedScene": { "abilities": [ "EntryAbility" ], "when": "inuse" } },
|
||||
//{ "name": "ohos.permission.CAMERA", "reason": "$string:perm_reason_CAMERA", "usedScene": { "abilities": [ "EntryAbility" ], "when": "inuse" } },
|
||||
//{ "name": "ohos.permission.INTERNET", "reason": "$string:perm_reason_INTERNET", "usedScene": { "abilities": [ "EntryAbility" ], "when": "inuse" } },
|
||||
//{ "name": "ohos.permission.READ_PASTEBOARD", "reason": "$string:perm_reason_READ_PASTEBOARD", "usedScene": { "abilities": [ "EntryAbility" ], "when": "inuse" } },
|
||||
],
|
||||
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"orientation": "auto_rotation_restricted",
|
||||
"srcEntry": "./ets/entryability/EntryAbility.ets",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:layered_image",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"startWindowIcon": "$media:startIcon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"exported": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"ohos.want.action.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"extensionAbilities": [
|
||||
{
|
||||
"name": "EntryBackupAbility",
|
||||
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
|
||||
"type": "backup",
|
||||
"exported": false,
|
||||
"metadata": [
|
||||
{
|
||||
"name": "ohos.extension.backup",
|
||||
"resource": "$profile:backup_config"
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"float": [
|
||||
{
|
||||
"name": "page_text_font_size",
|
||||
"value": "50fp"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "SDL Application"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "SDL Application"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "SDL App"
|
||||
},
|
||||
{
|
||||
"name": "perm_reason_MICROPHONE",
|
||||
"value": "Used to record audio"
|
||||
},
|
||||
{
|
||||
"name": "perm_reason_CAMERA",
|
||||
"value": "Used to record video"
|
||||
},
|
||||
{
|
||||
"name": "perm_reason_INTERNET",
|
||||
"value": "Used to download additional content"
|
||||
},
|
||||
{
|
||||
"name": "perm_reason_READ_PASTEBOARD",
|
||||
"value": "Used to read from the pasteboard"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"layered-image":
|
||||
{
|
||||
"background" : "$media:background",
|
||||
"foreground" : "$media:foreground"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"allowToBackupRestore": true
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"modelVersion": "6.1.1",
|
||||
"dependencies": {
|
||||
},
|
||||
"execution": {
|
||||
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */
|
||||
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
|
||||
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
|
||||
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
|
||||
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
|
||||
// "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */
|
||||
},
|
||||
"logging": {
|
||||
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
|
||||
},
|
||||
"debugging": {
|
||||
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
|
||||
},
|
||||
"nodeOptions": {
|
||||
// "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
|
||||
// "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"meta": {
|
||||
"stableOrder": true,
|
||||
"enableUnifiedLockfile": false
|
||||
},
|
||||
"lockfileVersion": 3,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
"specifiers": {
|
||||
"@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0",
|
||||
"@ohos/hypium@1.0.25": "@ohos/hypium@1.0.25"
|
||||
},
|
||||
"packages": {
|
||||
"@ohos/hamock@1.0.0": {
|
||||
"name": "@ohos/hamock",
|
||||
"version": "1.0.0",
|
||||
"integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==",
|
||||
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har",
|
||||
"registryType": "ohpm"
|
||||
},
|
||||
"@ohos/hypium@1.0.25": {
|
||||
"name": "@ohos/hypium",
|
||||
"version": "1.0.25",
|
||||
"integrity": "sha512-l6uO2pjl8HyEKdekLqQt7tUpWbDqX/42zoAzkagtUVZAW9jT6lMvbe54MVjoLxq/RwQGygRvi6j4GpypSMFSHw==",
|
||||
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.25.har",
|
||||
"registryType": "ohpm"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"modelVersion": "6.1.1",
|
||||
"description": "Please describe the basic information.",
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ohos/hypium": "1.0.25",
|
||||
"@ohos/hamock": "1.0.0"
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,9 @@
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#include "core/android/SDL_android.h"
|
||||
#endif
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
#include "core/openharmony/SDL_openharmony.h"
|
||||
#endif
|
||||
|
||||
#define SDL_ALL_SUBSYSTEM_FLAGS ~0U
|
||||
|
||||
@@ -803,6 +806,8 @@ const char *SDL_GetPlatform(void)
|
||||
return "Nokia N-Gage";
|
||||
#elif defined(SDL_PLATFORM_OPENBSD)
|
||||
return "OpenBSD";
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
return "OpenHarmony";
|
||||
#elif defined(SDL_PLATFORM_OS2)
|
||||
return "OS/2";
|
||||
#elif defined(SDL_PLATFORM_OSF)
|
||||
@@ -867,6 +872,8 @@ SDL_FormFactor SDL_GetDeviceFormFactor(void)
|
||||
return SDL_FORMFACTOR_PRIVATE;
|
||||
#elif defined(SDL_PLATFORM_ANDROID)
|
||||
return SDL_GetAndroidDeviceFormFactor();
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
return SDL_GetOpenHarmonyDeviceFormFactor();
|
||||
#elif defined(SDL_PLATFORM_IOS)
|
||||
extern SDL_FormFactor SDL_GetUIKitDeviceFormFactor(void);
|
||||
return SDL_GetUIKitDeviceFormFactor();
|
||||
|
||||
+24
-5
@@ -40,6 +40,10 @@
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
#include <hilog/log.h>
|
||||
#endif
|
||||
|
||||
#include "stdlib/SDL_vacopy.h"
|
||||
|
||||
// The size of the stack buffer to use for rendering log messages.
|
||||
@@ -122,7 +126,19 @@ static int SDL_android_priority[] = {
|
||||
ANDROID_LOG_FATAL
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(android_priority, SDL_arraysize(SDL_android_priority) == SDL_LOG_PRIORITY_COUNT);
|
||||
#endif // SDL_PLATFORM_ANDROID
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
static int SDL_openharmony_priority[] = {
|
||||
LOG_DEBUG,
|
||||
LOG_DEBUG,
|
||||
LOG_DEBUG,
|
||||
LOG_DEBUG,
|
||||
LOG_INFO,
|
||||
LOG_WARN,
|
||||
LOG_ERROR,
|
||||
LOG_FATAL
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(openharmony_priority, SDL_arraysize(SDL_openharmony_priority) == SDL_LOG_PRIORITY_COUNT);
|
||||
#endif
|
||||
|
||||
static void SDLCALL SDL_LoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
@@ -583,7 +599,7 @@ void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_ST
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
static const char *GetCategoryPrefix(int category)
|
||||
{
|
||||
if (category < SDL_LOG_CATEGORY_RESERVED2) {
|
||||
@@ -594,7 +610,7 @@ static const char *GetCategoryPrefix(int category)
|
||||
}
|
||||
return "CUSTOM";
|
||||
}
|
||||
#endif // SDL_PLATFORM_ANDROID
|
||||
#endif // SDL_PLATFORM_ANDROID || SDL_PLATFORM_OPENHARMONY
|
||||
|
||||
void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
|
||||
{
|
||||
@@ -758,12 +774,15 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
SDL_free(tstr);
|
||||
SDL_small_free(output, isstack);
|
||||
}
|
||||
#elif defined(SDL_PLATFORM_ANDROID)
|
||||
#elif defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
{
|
||||
char tag[32];
|
||||
|
||||
SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
|
||||
#if defined(SDL_PLATFORM_ANDROID)
|
||||
__android_log_write(SDL_android_priority[priority], tag, message);
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
OH_LOG_Print(LOG_APP, SDL_openharmony_priority[priority], LOG_DOMAIN, tag, "%{public}s", message);
|
||||
#endif
|
||||
}
|
||||
#elif defined(SDL_PLATFORM_APPLE) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))
|
||||
/* Technically we don't need Cocoa/UIKit, but that's where this function is defined for now.
|
||||
|
||||
@@ -95,6 +95,9 @@ static const AudioBootStrap *const bootstrap[] = {
|
||||
#ifdef SDL_AUDIO_DRIVER_DOS_SOUNDBLASTER
|
||||
&DOSSOUNDBLASTER_bootstrap,
|
||||
#endif
|
||||
#ifdef SDL_AUDIO_DRIVER_OHAUDIO
|
||||
&OHAUDIO_bootstrap,
|
||||
#endif
|
||||
#ifdef SDL_AUDIO_DRIVER_DISK
|
||||
&DISKAUDIO_bootstrap,
|
||||
#endif
|
||||
|
||||
@@ -395,5 +395,6 @@ extern AudioBootStrap NGAGEAUDIO_bootstrap;
|
||||
extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap;
|
||||
extern AudioBootStrap QSAAUDIO_bootstrap;
|
||||
extern AudioBootStrap DOSSOUNDBLASTER_bootstrap;
|
||||
extern AudioBootStrap OHAUDIO_bootstrap;
|
||||
|
||||
#endif // SDL_sysaudio_h_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_ohaudio_h_
|
||||
#define SDL_ohaudio_h_
|
||||
|
||||
#ifdef SDL_AUDIO_DRIVER_OHAUDIO
|
||||
|
||||
extern void OHAUDIO_ResumeDevices(void);
|
||||
extern void OHAUDIO_PauseDevices(void);
|
||||
|
||||
#else
|
||||
|
||||
#define OHAUDIO_ResumeDevices()
|
||||
#define OHAUDIO_PauseDevices()
|
||||
|
||||
#endif
|
||||
|
||||
#endif // SDL_ohaudio_h_
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright , (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_PROC_OPTIONAL
|
||||
#define SDL_PROC_OPTIONAL(ret, func, params) SDL_PROC(ret, func, params)
|
||||
#endif
|
||||
|
||||
#define SDL_PROC_UNUSED(ret, func, params)
|
||||
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_Create, (OH_AudioStreamBuilder** builder, OH_AudioStream_Type type))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_Destroy, (OH_AudioStreamBuilder* builder))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetSamplingRate, (OH_AudioStreamBuilder* builder, int32_t rate))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetChannelCount, (OH_AudioStreamBuilder* builder, int32_t channelCount))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetSampleFormat, (OH_AudioStreamBuilder* builder, OH_AudioStream_SampleFormat format))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetLatencyMode, (OH_AudioStreamBuilder* builder, OH_AudioStream_LatencyMode latencyMode))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetChannelLayout, (OH_AudioStreamBuilder* builder, OH_AudioChannelLayout channelLayout))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetRendererInfo, (OH_AudioStreamBuilder* builder, OH_AudioStream_Usage usage))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetCapturerInfo, (OH_AudioStreamBuilder* builder, OH_AudioStream_SourceType sourceType))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_GenerateRenderer, (OH_AudioStreamBuilder* builder, OH_AudioRenderer** audioRenderer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_GenerateCapturer, (OH_AudioStreamBuilder* builder, OH_AudioCapturer** audioCapturer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetRendererWriteDataCallback, (OH_AudioStreamBuilder* builder, OH_AudioRenderer_OnWriteDataCallback callback, void* userData))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetRendererErrorCallback, (OH_AudioStreamBuilder* builder, OH_AudioRenderer_OnErrorCallback callback, void* userData))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetCapturerReadDataCallback, (OH_AudioStreamBuilder* builder, OH_AudioCapturer_OnReadDataCallback callback, void* userData))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetCapturerErrorCallback, (OH_AudioStreamBuilder* builder, OH_AudioCapturer_OnErrorCallback callback, void* userData))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Release, (OH_AudioRenderer* renderer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Start, (OH_AudioRenderer* renderer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Pause, (OH_AudioRenderer* renderer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Stop, (OH_AudioRenderer* renderer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_GetSamplingRate, (OH_AudioRenderer* renderer, int32_t* rate))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_GetChannelCount, (OH_AudioRenderer* renderer, int32_t* channelCount))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_GetSampleFormat, (OH_AudioRenderer* renderer, OH_AudioStream_SampleFormat* sampleFormat))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_GetFrameSizeInCallback, (OH_AudioRenderer* renderer, int32_t* frameSize))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_Release, (OH_AudioCapturer* capturer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_Start, (OH_AudioCapturer* capturer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_Pause, (OH_AudioCapturer* capturer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_Stop, (OH_AudioCapturer* capturer))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_GetSamplingRate, (OH_AudioCapturer* capturer, int32_t* rate))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_GetChannelCount, (OH_AudioCapturer* capturer, int32_t* channelCount))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_GetSampleFormat, (OH_AudioCapturer* capturer, OH_AudioStream_SampleFormat* sampleFormat))
|
||||
SDL_PROC(OH_AudioStream_Result, OH_AudioCapturer_GetFrameSizeInCallback, (OH_AudioCapturer* capturer, int32_t* frameSize))
|
||||
|
||||
#undef SDL_PROC
|
||||
#undef SDL_PROC_UNUSED
|
||||
#undef SDL_PROC_OPTIONAL
|
||||
@@ -44,6 +44,9 @@ static const CameraBootStrap *const bootstrap[] = {
|
||||
#ifdef SDL_CAMERA_DRIVER_ANDROID
|
||||
&ANDROIDCAMERA_bootstrap,
|
||||
#endif
|
||||
#ifdef SDL_CAMERA_DRIVER_OPENHARMONY
|
||||
&OPENHARMONYCAMERA_bootstrap,
|
||||
#endif
|
||||
#ifdef SDL_CAMERA_DRIVER_EMSCRIPTEN
|
||||
&EMSCRIPTENCAMERA_bootstrap,
|
||||
#endif
|
||||
|
||||
@@ -222,6 +222,7 @@ extern CameraBootStrap PIPEWIRECAMERA_bootstrap;
|
||||
extern CameraBootStrap V4L2_bootstrap;
|
||||
extern CameraBootStrap COREMEDIA_bootstrap;
|
||||
extern CameraBootStrap ANDROIDCAMERA_bootstrap;
|
||||
extern CameraBootStrap OPENHARMONYCAMERA_bootstrap;
|
||||
extern CameraBootStrap EMSCRIPTENCAMERA_bootstrap;
|
||||
extern CameraBootStrap MEDIAFOUNDATION_bootstrap;
|
||||
extern CameraBootStrap VITACAMERA_bootstrap;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -204,3 +204,25 @@ bool SDL_IsUbuntuTouch(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SDL_PLATFORM_OPENHARMONY
|
||||
const char *SDL_GetOpenHarmonyInternalStoragePath(void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SDL_GetOpenHarmonySDKVersion(void)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
bool SDL_RequestOpenHarmonyPermission(const char *permission, SDL_RequestOpenHarmonyPermissionCallback cb, void *userdata)
|
||||
{
|
||||
(void)permission;
|
||||
(void)cb;
|
||||
(void)userdata;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -69,3 +69,11 @@ extern SDL_DECLSPEC Sint32 SDLCALL JNI_OnLoad(JavaVM *vm, void *reserved);
|
||||
#if !defined(SDL_PLATFORM_LINUX)
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_IsUbuntuTouch(void);
|
||||
#endif /* !SDL_PLATFORM_LINUX */
|
||||
|
||||
#if !defined(SDL_PLATFORM_OPENHARMONY)
|
||||
typedef void *SDL_RequestOpenHarmonyPermissionCallback;
|
||||
extern SDL_DECLSPEC const char * SDLCALL SDL_GetOpenHarmonyInternalStoragePath(void);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetOpenHarmonySDKVersion(void);
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_RequestOpenHarmonyPermission(const char *permission, SDL_RequestOpenHarmonyPermissionCallback cb, void *userdata);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -113,6 +113,10 @@ bool Android_JNI_FileClose(void *userdata);
|
||||
bool Android_JNI_EnumerateAssetDirectory(const char *path, SDL_EnumerateDirectoryCallback cb, void *userdata);
|
||||
bool Android_JNI_GetAssetPathInfo(const char *path, SDL_PathInfo *info);
|
||||
|
||||
#define SDL_PlatformEnumerateAssetDirectory Android_JNI_EnumerateAssetDirectory
|
||||
#define SDL_GetPlatformInternalStoragePath SDL_GetAndroidInternalStoragePath
|
||||
#define SDL_PlatformGetAssetPathInfo Android_JNI_GetAssetPathInfo
|
||||
|
||||
// Environment support
|
||||
void Android_JNI_GetManifestEnvironmentVariables(void);
|
||||
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_openharmony_h
|
||||
#define SDL_openharmony_h
|
||||
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
void SDL_DebugLogOpenHarmonyInfo(void);
|
||||
const char *SDL_GetOpenHarmonySystemLocale(void);
|
||||
SDL_SystemTheme SDL_GetOpenHarmonySystemTheme(void);
|
||||
SDL_DisplayOrientation SDL_GetOpenHarmonyDeviceCurrentOrientation(void);
|
||||
SDL_FormFactor SDL_GetOpenHarmonyDeviceFormFactor(void);
|
||||
|
||||
bool SDL_OpenHarmonyOpenURL(const char *url);
|
||||
bool SDL_OpenHarmonyToggleSystemBars(bool status_bar, bool navigation_bar);
|
||||
bool SDL_OpenHarmonyChangeScreenSaver(bool enable);
|
||||
bool SDL_OpenHarmonyShowScreenKeyboard(int input_type, int cap_type, const SDL_Rect *text_input_rect);
|
||||
bool SDL_OpenHarmonyHideScreenKeyboard(void);
|
||||
bool SDL_OpenHarmonyShowMousePointer(void);
|
||||
bool SDL_OpenHarmonyHideMousePointer(void);
|
||||
|
||||
bool SDL_OpenHarmonyRawFileOpen(void **puserdata, const char *fileName, const char *mode);
|
||||
Sint64 SDL_OpenHarmonyRawFileSize(void *userdata);
|
||||
Sint64 SDL_OpenHarmonyRawFileSeek(void *userdata, Sint64 offset, SDL_IOWhence whence);
|
||||
size_t SDL_OpenHarmonyRawFileRead(void *userdata, void *buffer, size_t size, SDL_IOStatus *status);
|
||||
bool SDL_OpenHarmonyRawFileClose(void *userdata);
|
||||
bool SDL_OpenHarmonyEnumerateAssetDirectory(const char *path, SDL_EnumerateDirectoryCallback cb, void *userdata);
|
||||
bool SDL_OpenHarmonyGetAssetPathInfo(const char *path, SDL_PathInfo *info);
|
||||
|
||||
#define SDL_PlatformEnumerateAssetDirectory SDL_OpenHarmonyEnumerateAssetDirectory
|
||||
#define SDL_GetPlatformInternalStoragePath SDL_GetOpenHarmonyInternalStoragePath
|
||||
#define SDL_PlatformGetAssetPathInfo SDL_OpenHarmonyGetAssetPathInfo
|
||||
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#endif // SDL_openharmony_h
|
||||
@@ -493,7 +493,7 @@ static int CPU_haveNEON(void)
|
||||
return 0;
|
||||
}
|
||||
return (hasneon & HWCAP_NEON) == HWCAP_NEON;
|
||||
#elif (defined(SDL_PLATFORM_LINUX) && defined(HAVE_GETAUXVAL)) || defined(SDL_PLATFORM_ANDROID)
|
||||
#elif (defined(SDL_PLATFORM_LINUX) && defined(HAVE_GETAUXVAL)) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
return (getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON;
|
||||
#elif defined(SDL_PLATFORM_LINUX)
|
||||
return readProcAuxvForNeon();
|
||||
|
||||
@@ -1311,3 +1311,6 @@ _SDL_SetRenderViewportFloat
|
||||
_SDL_GetRenderViewportFloat
|
||||
_SDL_SetRenderClipRectFloat
|
||||
_SDL_GetRenderClipRectFloat
|
||||
_SDL_GetOpenHarmonySDKVersion
|
||||
_SDL_GetOpenHarmonyInternalStoragePath
|
||||
_SDL_RequestOpenHarmonyPermission
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_ANDROID) // probably not useful on Android.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY) // probably not useful on OpenHarmony.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_EMSCRIPTEN) // probably not useful on Emscripten.
|
||||
#define SDL_DYNAMIC_API 0
|
||||
#elif defined(SDL_PLATFORM_PS2) && SDL_PLATFORM_PS2
|
||||
|
||||
@@ -1312,6 +1312,9 @@ SDL3_0.0.0 {
|
||||
SDL_GetRenderViewportFloat;
|
||||
SDL_SetRenderClipRectFloat;
|
||||
SDL_GetRenderClipRectFloat;
|
||||
SDL_GetOpenHarmonySDKVersion;
|
||||
SDL_GetOpenHarmonyInternalStoragePath;
|
||||
SDL_RequestOpenHarmonyPermission;
|
||||
# extra symbols go here (don't modify this line)
|
||||
local: *;
|
||||
};
|
||||
|
||||
@@ -1338,3 +1338,6 @@
|
||||
#define SDL_GetRenderViewportFloat SDL_GetRenderViewportFloat_REAL
|
||||
#define SDL_SetRenderClipRectFloat SDL_SetRenderClipRectFloat_REAL
|
||||
#define SDL_GetRenderClipRectFloat SDL_GetRenderClipRectFloat_REAL
|
||||
#define SDL_GetOpenHarmonySDKVersion SDL_GetOpenHarmonySDKVersion_REAL
|
||||
#define SDL_GetOpenHarmonyInternalStoragePath SDL_GetOpenHarmonyInternalStoragePath_REAL
|
||||
#define SDL_RequestOpenHarmonyPermission SDL_RequestOpenHarmonyPermission_REAL
|
||||
|
||||
@@ -1346,3 +1346,6 @@ SDL_DYNAPI_PROC(bool,SDL_SetRenderViewportFloat,(SDL_Renderer *a,const SDL_FRect
|
||||
SDL_DYNAPI_PROC(bool,SDL_GetRenderViewportFloat,(SDL_Renderer *a,SDL_FRect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(bool,SDL_SetRenderClipRectFloat,(SDL_Renderer *a,const SDL_FRect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(bool,SDL_GetRenderClipRectFloat,(SDL_Renderer *a,SDL_FRect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetOpenHarmonySDKVersion,(void),(),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetOpenHarmonyInternalStoragePath,(void),(),return)
|
||||
SDL_DYNAPI_PROC(bool,SDL_RequestOpenHarmonyPermission,(const char *a,SDL_RequestOpenHarmonyPermissionCallback b,void *c),(a,b,c),return)
|
||||
|
||||
@@ -333,7 +333,7 @@ SDL_Window *SDL_GetKeyboardFocus(void)
|
||||
|
||||
bool SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
{
|
||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID)
|
||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_OPENHARMONY)
|
||||
SDL_VideoDevice *video = SDL_GetVideoDevice();
|
||||
#endif
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
@@ -354,7 +354,7 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
if (keyboard->focus && keyboard->focus != window) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0);
|
||||
|
||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID)
|
||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_OPENHARMONY)
|
||||
// Ensures IME compositions are committed
|
||||
if (SDL_TextInputActive(keyboard->focus)) {
|
||||
if (video && video->StopTextInput) {
|
||||
@@ -384,7 +384,7 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
if (keyboard->focus) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_GAINED, 0, 0);
|
||||
|
||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID)
|
||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (SDL_TextInputActive(keyboard->focus)) {
|
||||
if (video && video->StartTextInput) {
|
||||
video->StartTextInput(video, keyboard->focus, keyboard->focus->text_input_props);
|
||||
|
||||
@@ -375,7 +375,7 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
|
||||
size_t pathlen = SDL_strlen(path);
|
||||
|
||||
// if path ends with any slash, chop them off, so we don't confuse the pattern matcher later.
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (SDL_strcmp(path, "assets://") == 0) { // don't chop '//' off this if we're looking for the root of the asset tree.
|
||||
pathlen--; // we'll add a 1 again later.
|
||||
} else
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_FILESYSTEM_OPENHARMONY
|
||||
|
||||
|
||||
// !!! FIXME: HACK to prevent <AbilityKit/ability_runtime/start_options.h> from including. It has '&' instead of '*' for some args, which suggests it's only been tested with C++.
|
||||
#define ABILITY_RUNTIME_START_OPTIONS_H
|
||||
typedef enum AbilityRuntime_StartOptions AbilityRuntime_StartOptions;
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <AbilityKit/ability_runtime/application_context.h>
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
// System dependent filesystem routines
|
||||
|
||||
#include "../SDL_sysfilesystem.h"
|
||||
|
||||
char *SDL_SYS_GetBasePath(void)
|
||||
{
|
||||
return SDL_strdup("assets://");
|
||||
}
|
||||
|
||||
char *SDL_SYS_GetExeName(void)
|
||||
{
|
||||
char buffer[128];
|
||||
int32_t writelen = 0;
|
||||
const AbilityRuntime_ErrorCode rc = OH_AbilityRuntime_ApplicationContextGetBundleName(buffer, (int32_t) sizeof (buffer), &writelen);
|
||||
if (rc != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) {
|
||||
SDL_SetError("OH_AbilityRuntime_ApplicationContextGetBundleName failed: %d", (int) rc);
|
||||
return NULL;
|
||||
}
|
||||
return SDL_strdup(buffer);
|
||||
}
|
||||
|
||||
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
const char *prefdir = SDL_GetOpenHarmonyInternalStoragePath();
|
||||
char *retval = NULL;
|
||||
if (prefdir) {
|
||||
if (SDL_asprintf(&retval, "%s/%s/", prefdir, app) < 0) {
|
||||
retval = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mkdir(prefdir, 0755);
|
||||
mkdir(retval, 0755);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *SDL_SYS_GetUserFolder(SDL_Folder folder)
|
||||
{
|
||||
SDL_Unsupported(); // !!! FIXME: Can we support _any_ of this?
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // SDL_FILESYSTEM_OPENHARMONY
|
||||
@@ -39,24 +39,28 @@
|
||||
#include "../../core/android/SDL_android.h"
|
||||
#endif
|
||||
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
#include "../../core/openharmony/SDL_openharmony.h"
|
||||
#endif
|
||||
|
||||
|
||||
bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback cb, void *userdata)
|
||||
{
|
||||
char *apath = NULL; // absolute path (for Android, iOS, etc). Overrides `path`.
|
||||
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_IOS)
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (*path == '\0') {
|
||||
return SDL_SetError("No such file or directory");
|
||||
} else if (*path != '/') {
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (SDL_strncmp(path, "assets://", 9) == 0) {
|
||||
char *pathwithsep = NULL;
|
||||
SDL_asprintf(&pathwithsep, "%s%s", path, (path[SDL_strlen(path) - 1] != '/') ? "/" : "");
|
||||
const bool retval = pathwithsep ? Android_JNI_EnumerateAssetDirectory(pathwithsep, cb, userdata) : false;
|
||||
const bool retval = pathwithsep ? SDL_PlatformEnumerateAssetDirectory(pathwithsep, cb, userdata) : false;
|
||||
SDL_free(pathwithsep);
|
||||
return retval;
|
||||
}
|
||||
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
||||
SDL_asprintf(&apath, "%s/%s", SDL_GetPlatformInternalStoragePath(), path);
|
||||
#elif defined(SDL_PLATFORM_IOS)
|
||||
char *base = SDL_GetPrefPath("", "");
|
||||
if (!base) {
|
||||
@@ -71,7 +75,7 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#elif 0 // this is just for testing that `apath` works when you aren't on iOS or Android.
|
||||
#elif 0 // this is just for testing that `apath` works when you aren't on iOS or Android or HarmonyOS.
|
||||
if (*path != '/') {
|
||||
char *c = SDL_SYS_GetCurrentDirectory();
|
||||
SDL_asprintf(&apath, "%s%s", c, path);
|
||||
@@ -98,9 +102,9 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
|
||||
|
||||
DIR *dir = opendir(pathwithsep);
|
||||
if (!dir) {
|
||||
#ifdef SDL_PLATFORM_ANDROID // Maybe it's an asset... that didn't use an "assets://" URL?
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY) // Maybe it's an asset... that didn't use an "assets://" URL?
|
||||
if (*pathwithsep != '/') { // don't fall back to asset tree for absolute paths, in case opendir() failed for other reasons, like opendir("/") returning EACCES.
|
||||
const bool retval = Android_JNI_EnumerateAssetDirectory(pathwithsep + extralen, cb, userdata);
|
||||
const bool retval = SDL_PlatformEnumerateAssetDirectory(pathwithsep + extralen, cb, userdata);
|
||||
SDL_free(pathwithsep);
|
||||
return retval;
|
||||
}
|
||||
@@ -130,12 +134,12 @@ bool SDL_SYS_RemovePath(const char *path)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (*path == '/') {
|
||||
rc = remove(path);
|
||||
} else {
|
||||
char *apath = NULL;
|
||||
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
||||
SDL_asprintf(&apath, "%s/%s", SDL_GetPlatformInternalStoragePath(), path);
|
||||
if (!apath) {
|
||||
return false;
|
||||
}
|
||||
@@ -177,18 +181,18 @@ bool SDL_SYS_RenamePath(const char *oldpath, const char *newpath)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
char *aoldpath = NULL;
|
||||
char *anewpath = NULL;
|
||||
if (*oldpath != '/') {
|
||||
SDL_asprintf(&aoldpath, "%s/%s", SDL_GetAndroidInternalStoragePath(), oldpath);
|
||||
SDL_asprintf(&aoldpath, "%s/%s", SDL_GetPlatformInternalStoragePath(), oldpath);
|
||||
if (!aoldpath) {
|
||||
return false;
|
||||
}
|
||||
oldpath = aoldpath;
|
||||
}
|
||||
if (*newpath != '/') {
|
||||
SDL_asprintf(&anewpath, "%s/%s", SDL_GetAndroidInternalStoragePath(), newpath);
|
||||
SDL_asprintf(&anewpath, "%s/%s", SDL_GetPlatformInternalStoragePath(), newpath);
|
||||
if (!anewpath) {
|
||||
SDL_free(aoldpath);
|
||||
return false;
|
||||
@@ -349,16 +353,16 @@ bool SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
|
||||
struct stat statbuf;
|
||||
int rc;
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (*path == '\0') {
|
||||
return SDL_SetError("No such file or directory");
|
||||
} else if (*path == '/') {
|
||||
rc = stat(path, &statbuf);
|
||||
} else if (SDL_strncmp(path, "assets://", 9) == 0) {
|
||||
return Android_JNI_GetAssetPathInfo(path, info);
|
||||
return SDL_PlatformGetAssetPathInfo(path, info);
|
||||
} else {
|
||||
char *apath = NULL;
|
||||
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
||||
SDL_asprintf(&apath, "%s/%s", SDL_GetPlatformInternalStoragePath(), path);
|
||||
if (!apath) {
|
||||
return false;
|
||||
}
|
||||
@@ -366,7 +370,7 @@ bool SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
|
||||
SDL_free(apath);
|
||||
}
|
||||
if (rc < 0) { // Maybe it's an asset... that didn't use an "assets://" URL?
|
||||
return Android_JNI_GetAssetPathInfo(path, info);
|
||||
return SDL_PlatformGetAssetPathInfo(path, info);
|
||||
}
|
||||
#elif defined(SDL_PLATFORM_IOS)
|
||||
if (*path == '/') {
|
||||
|
||||
+36
-2
@@ -69,6 +69,11 @@ struct SDL_IOStream
|
||||
#include "../core/android/SDL_android.h"
|
||||
#endif
|
||||
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
#include <unistd.h>
|
||||
#include "../core/openharmony/SDL_openharmony.h"
|
||||
#endif
|
||||
|
||||
#if defined(SDL_PLATFORM_WINDOWS) && !defined(SDL_PLATFORM_CYGWIN)
|
||||
|
||||
typedef struct IOStreamWindowsData
|
||||
@@ -1024,7 +1029,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
#ifdef HAVE_STDIO_H
|
||||
// Try to open the file on the filesystem first
|
||||
if (*file == '/') {
|
||||
@@ -1037,6 +1042,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
||||
}
|
||||
return SDL_IOFromFP(fp, true);
|
||||
}
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
} else if (SDL_strncmp(file, "content://", 10) == 0) {
|
||||
// Try opening content:// URI
|
||||
int fd = Android_JNI_OpenFileDescriptor(file, mode);
|
||||
@@ -1053,10 +1059,11 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
||||
}
|
||||
|
||||
return SDL_IOFromFP(fp, true);
|
||||
#endif
|
||||
} else if (SDL_strncmp(file, "assets://", 9) != 0) {
|
||||
// Try opening it from internal storage if it's a relative path
|
||||
char *path = NULL;
|
||||
SDL_asprintf(&path, "%s/%s", SDL_GetAndroidInternalStoragePath(), file);
|
||||
SDL_asprintf(&path, "%s/%s", SDL_GetPlatformInternalStoragePath(), file);
|
||||
if (path) {
|
||||
FILE *fp = fopen(path, mode);
|
||||
SDL_free(path);
|
||||
@@ -1072,6 +1079,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
||||
}
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
// Try to open the file from the asset system?
|
||||
void *iodata = NULL;
|
||||
if (!Android_JNI_FileOpen(&iodata, file, mode)) {
|
||||
@@ -1093,6 +1101,32 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
||||
iostr->setioprops = android_setioprops;
|
||||
}
|
||||
|
||||
#elif defined(SDL_PLATFORM_OPENHARMONY)
|
||||
// Try to open the file from the asset system?
|
||||
void *iodata = NULL;
|
||||
if (!SDL_OpenHarmonyRawFileOpen(&iodata, file, mode)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_IOStreamInterface iface;
|
||||
SDL_INIT_INTERFACE(&iface);
|
||||
iface.size = SDL_OpenHarmonyRawFileSize;
|
||||
iface.seek = SDL_OpenHarmonyRawFileSeek;
|
||||
iface.read = SDL_OpenHarmonyRawFileRead;
|
||||
iface.write = NULL; // no write access via RawFile.
|
||||
iface.close = SDL_OpenHarmonyRawFileClose;
|
||||
|
||||
iostr = SDL_OpenIO(&iface, iodata);
|
||||
if (!iostr) {
|
||||
iface.close(iodata);
|
||||
} else {
|
||||
const SDL_PropertiesID props = SDL_GetIOProperties(iostr);
|
||||
if (props) {
|
||||
SDL_SetPointerProperty(props, SDL_PROP_IOSTREAM_OPENHARMONY_RAWFILE64_POINTER, iodata);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(SDL_PLATFORM_IOS)
|
||||
|
||||
// Try to open the file on the filesystem first
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL_internal.h"
|
||||
#include "../SDL_syslocale.h"
|
||||
|
||||
#include "../../core/openharmony/SDL_openharmony.h"
|
||||
|
||||
bool SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
|
||||
{
|
||||
const char *syslocale = SDL_GetOpenHarmonySystemLocale();
|
||||
if (!syslocale) {
|
||||
return SDL_SetError("Current locale couldn't be determined");
|
||||
}
|
||||
SDL_strlcpy(buf, syslocale, buflen);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,4 +75,3 @@ bool SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -88,10 +88,7 @@ static bool SDLCALL SDL_MainCallbackEventWatcher(void *userdata, SDL_Event *even
|
||||
|
||||
bool SDL_HasMainCallbacks(void)
|
||||
{
|
||||
if (SDL_main_iteration_callback) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (SDL_main_iteration_callback != NULL);
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_InitMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||
@@ -107,9 +104,7 @@ SDL_AppResult SDL_InitMainCallbacks(int argc, char *argv[], SDL_AppInit_func app
|
||||
if (!SDL_InitSubSystem(SDL_INIT_EVENTS)) {
|
||||
SDL_SetAtomicInt(&apprc, SDL_APP_FAILURE);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (!SDL_AddEventWatch(SDL_MainCallbackEventWatcher, NULL)) {
|
||||
} else if (!SDL_AddEventWatch(SDL_MainCallbackEventWatcher, NULL)) {
|
||||
SDL_SetAtomicInt(&apprc, SDL_APP_FAILURE);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../SDL_main_callbacks.h"
|
||||
#include "../../video/SDL_sysvideo.h"
|
||||
|
||||
// !!! FIXME: does this ifndef need to be here?
|
||||
#ifndef SDL_PLATFORM_IOS
|
||||
|
||||
static Uint64 callback_rate_increment = 0;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
|
||||
#include "../SDL_main_callbacks.h"
|
||||
|
||||
void SDL_OpenHarmonyOnFrameCallback(void) // src/core/openharmony calls this when our XComponent is ready for a new frame, and we call SDL_AppIterate here
|
||||
{
|
||||
if (SDL_HasMainCallbacks()) { // ignore this if we're using SDL_main().
|
||||
const SDL_AppResult rc = SDL_IterateMainCallbacks(true);
|
||||
if (rc != SDL_APP_CONTINUE) {
|
||||
SDL_Log("SDL_AppIterate said %s! Terminating!", (rc == SDL_APP_FAILURE) ? "SDL_APP_FAILURE" : "SDL_APP_SUCCESS");
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
exit((rc == SDL_APP_FAILURE) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We hook into this deep into the actual OpenHarmony app lifecycle, see notes elsewhere. Once we return from this, we'll get OnFrame callbacks from our
|
||||
// XComponent, which we'll use for SDL_AppIterate, etc.
|
||||
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||
{
|
||||
const SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||
if (rc == SDL_APP_CONTINUE) {
|
||||
SDL_Log("SDL_AppInit said continue! We are live!");
|
||||
return 0; // this will fall all the way out of SDL_main (or whatever), where OpenHarmony will keep running the process, passing events through ArkTS, etc...
|
||||
}
|
||||
|
||||
SDL_Log("SDL_AppInit said %s! Terminating!", (rc == SDL_APP_FAILURE) ? "SDL_APP_FAILURE" : "SDL_APP_SUCCESS");
|
||||
|
||||
// appinit requested quit, just bounce out now.
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
exit((rc == SDL_APP_FAILURE) ? 1 : 0);
|
||||
|
||||
return 1; // just in case.
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_PLATFORM_OPENHARMONY
|
||||
|
||||
#include <hilog/log.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "../SDL_main_callbacks.h"
|
||||
|
||||
static int SDL_main_argc = 0;
|
||||
static char **SDL_main_argv = NULL;
|
||||
static void *ThreadEntry__SDL_main(void *userdata)
|
||||
{
|
||||
SDL_main_func pMain = (SDL_main_func) userdata;
|
||||
pthread_setname_np(pthread_self(), "SDL_main");
|
||||
OH_LOG_Print(LOG_APP, LOG_FATAL, LOG_DOMAIN, "SDL/STARTUP", "Calling SDL_main!");
|
||||
const int rc = pMain(SDL_main_argc, SDL_main_argv);
|
||||
OH_LOG_Print(LOG_APP, LOG_FATAL, LOG_DOMAIN, "SDL/STARTUP", "SDL_main returned %{public}d! Now terminating the process...", rc);
|
||||
exit(rc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// This is passed to SDL_RunApp. It decides whether libmain.so has the main callbacks or SDL_main,
|
||||
// and either calls SDL_EnterAppMainCallbacks or spins a thread and attempts to work with SDL_main().
|
||||
// This will log something and attempt to terminate the process if things go wrong.
|
||||
static int RunAppOpenHarmonyMain(int argc, char **argv)
|
||||
{
|
||||
// don't call SDL_Log() in here, we aren't necessarily set up yet! Use hilog directly!!
|
||||
|
||||
const char *sofile = "libmain.so";
|
||||
void *lib = dlopen(sofile, RTLD_NOW | RTLD_LOCAL);
|
||||
if (!lib) {
|
||||
OH_LOG_Print(LOG_APP, LOG_FATAL, LOG_DOMAIN, "SDL/STARTUP", "Failed loading %{public}s, can't start app! (%{public}s)", sofile, dlerror());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
SDL_main_func pMain = (SDL_main_func) dlsym(lib, "SDL_main");
|
||||
if (pMain) {
|
||||
SDL_main_argc = argc;
|
||||
SDL_main_argv = argv;
|
||||
pthread_t thread;
|
||||
const int rc = pthread_create(&thread, NULL, ThreadEntry__SDL_main, pMain);
|
||||
if (rc != 0) {
|
||||
OH_LOG_Print(LOG_APP, LOG_FATAL, LOG_DOMAIN, "SDL/STARTUP", "Failed to create thread to run SDL_main from %{public}s, can't start app! (%{public}s)", sofile, strerror(rc));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pthread_detach(thread); // we won't be waiting on this.
|
||||
return 0; // SDL_main is running in another thread, and this thread returns to the app's core loop thing.
|
||||
}
|
||||
|
||||
#define FINDCBFN(nam) \
|
||||
SDL_App##nam##_func pApp##nam = (SDL_App##nam##_func) dlsym(lib, "SDL_App" #nam); \
|
||||
if (!pApp##nam) { \
|
||||
OH_LOG_Print(LOG_APP, LOG_FATAL, LOG_DOMAIN, "SDL/STARTUP", "Couldn't find %{public}s in %{public}s, can't start app! (%{public}s)", "SDL_App" #nam, sofile, dlerror()); \
|
||||
exit(1); \
|
||||
}
|
||||
FINDCBFN(Init);
|
||||
FINDCBFN(Iterate);
|
||||
FINDCBFN(Event);
|
||||
FINDCBFN(Quit);
|
||||
#undef FINDCBFN
|
||||
|
||||
// this returns after SDL_AppInit, and we'll deal with SDL_AppEvent/SDL_AppIterate in SDL_sysmain_callbacks.c, when we get OnFrame events from SDL's XComponent.
|
||||
return SDL_EnterAppMainCallbacks(argc, argv, pAppInit, pAppIterate, pAppEvent, pAppQuit);
|
||||
}
|
||||
|
||||
void SDL_OpenHarmonyMainSurfaceCreated(void) // src/core/openharmony calls this when our XComponent is ready to go, and we use this to get the actual native app code booted.
|
||||
{
|
||||
static bool booted = false;
|
||||
if (!booted) { // just in case we make more XComponents later...?
|
||||
booted = true;
|
||||
SDL_RunApp(0, NULL, RunAppOpenHarmonyMain, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#if defined(SDL_PLATFORM_ANDROID)
|
||||
|
||||
#include "../SDL_sysurl.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
@@ -27,3 +29,6 @@ bool SDL_SYS_OpenURL(const char *url)
|
||||
{
|
||||
return Android_JNI_OpenURL(url);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#if defined(SDL_PLATFORM_OPENHARMONY)
|
||||
|
||||
#include "../SDL_sysurl.h"
|
||||
#include "../../core/openharmony/SDL_openharmony.h"
|
||||
|
||||
bool SDL_SYS_OpenURL(const char *url)
|
||||
{
|
||||
return SDL_OpenHarmonyOpenURL(url);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -62,6 +62,9 @@ static SDL_GetPowerInfo_Impl implementations[] = {
|
||||
#ifdef SDL_POWER_ANDROID // handles Android.
|
||||
SDL_GetPowerInfo_Android,
|
||||
#endif
|
||||
#ifdef SDL_POWER_OPENHARMONY // handles HarmonyOS/OpenHarmony
|
||||
SDL_GetPowerInfo_OpenHarmony,
|
||||
#endif
|
||||
#ifdef SDL_POWER_PSP // handles PSP.
|
||||
SDL_GetPowerInfo_PSP,
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,7 @@ bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_OpenHarmony(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_VITA(SDL_PowerState *, int *, int *);
|
||||
bool SDL_GetPowerInfo_N3DS(SDL_PowerState *, int *, int *);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_POWER_DISABLED
|
||||
#ifdef SDL_POWER_OPENHARMONY
|
||||
|
||||
#include <BasicServicesKit/ohbattery_info.h>
|
||||
|
||||
bool SDL_GetPowerInfo_OpenHarmony(SDL_PowerState *state, int *seconds, int *percent)
|
||||
{
|
||||
*seconds = -1;
|
||||
*percent = (int) OH_BatteryInfo_GetCapacity();
|
||||
|
||||
const BatteryInfo_BatteryPluggedType pluggedtype = OH_BatteryInfo_GetPluggedType();
|
||||
if (pluggedtype == PLUGGED_TYPE_NONE) {
|
||||
*state = SDL_POWERSTATE_ON_BATTERY;
|
||||
} else {
|
||||
*state = (*percent < 100) ? SDL_POWERSTATE_CHARGING : SDL_POWERSTATE_CHARGED;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_POWER_OPENHARMONY
|
||||
#endif // SDL_POWER_DISABLED
|
||||
|
||||
@@ -40,7 +40,7 @@ SDL_AddEventWatch to catch SDL_EVENT_WILL_ENTER_BACKGROUND events and stopped
|
||||
drawing themselves. Other platforms still draw, as the compositor can use it,
|
||||
and more importantly: drawing to render targets isn't lost. But I still think
|
||||
this should probably be removed at some point in the future. --ryan. */
|
||||
#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) || defined(SDL_PLATFORM_ANDROID)
|
||||
#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
#define DONT_DRAW_WHILE_HIDDEN 1
|
||||
#else
|
||||
#define DONT_DRAW_WHILE_HIDDEN 0
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "../../core/linux/SDL_dbus.h"
|
||||
#endif // SDL_PLATFORM_LINUX
|
||||
|
||||
#if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN)
|
||||
#if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
#ifndef RTLD_DEFAULT
|
||||
#define RTLD_DEFAULT NULL
|
||||
@@ -77,7 +77,7 @@ static void *RunThread(void *data)
|
||||
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN)
|
||||
static bool checked_setname = false;
|
||||
static int (*ppthread_setname_np)(const char *) = NULL;
|
||||
#elif (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_DLOPEN)
|
||||
#elif (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)) && defined(HAVE_DLOPEN)
|
||||
static bool checked_setname = false;
|
||||
static int (*ppthread_setname_np)(pthread_t, const char *) = NULL;
|
||||
#endif
|
||||
@@ -88,12 +88,12 @@ bool SDL_SYS_CreateThread(SDL_Thread *thread,
|
||||
pthread_attr_t type;
|
||||
|
||||
// do this here before any threads exist, so there's no race condition.
|
||||
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_DLOPEN)
|
||||
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)) && defined(HAVE_DLOPEN)
|
||||
if (!checked_setname) {
|
||||
void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np");
|
||||
#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)
|
||||
ppthread_setname_np = (int (*)(const char *))fn;
|
||||
#elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)
|
||||
#elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
ppthread_setname_np = (int (*)(pthread_t, const char *))fn;
|
||||
#endif
|
||||
checked_setname = true;
|
||||
@@ -129,12 +129,12 @@ void SDL_SYS_SetupThread(const char *name)
|
||||
#endif
|
||||
|
||||
if (name) {
|
||||
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_DLOPEN)
|
||||
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)) && defined(HAVE_DLOPEN)
|
||||
SDL_assert(checked_setname);
|
||||
if (ppthread_setname_np) {
|
||||
#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)
|
||||
ppthread_setname_np(name);
|
||||
#elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)
|
||||
#elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_OPENHARMONY)
|
||||
if (ppthread_setname_np(pthread_self(), name) == ERANGE) {
|
||||
char namebuf[16]; // Limited to 16 char
|
||||
SDL_strlcpy(namebuf, name, sizeof(namebuf));
|
||||
@@ -171,6 +171,9 @@ void SDL_SYS_SetupThread(const char *name)
|
||||
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
||||
#endif
|
||||
|
||||
// HarmonyOS defines this, but doesn't offer pthread_setcanceltype.
|
||||
// !!! FIXME: but it looks like we shouldn't be using this on any platform! https://clang.llvm.org/extra/clang-tidy/checks/concurrency/thread-canceltype-asynchronous.html
|
||||
#ifndef SDL_PLATFORM_OPENHARMONY
|
||||
#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
|
||||
// Allow ourselves to be asynchronously cancelled
|
||||
{
|
||||
@@ -178,6 +181,7 @@ void SDL_SYS_SetupThread(const char *name)
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_ThreadID SDL_GetCurrentThreadID(void)
|
||||
|
||||
@@ -86,6 +86,10 @@
|
||||
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.so"
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_OPENHARMONY)
|
||||
#define DEFAULT_EGL "libEGL.so"
|
||||
#define DEFAULT_OGL_ES2 "libGLESv3.so"
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_WINDOWS)
|
||||
// EGL AND OpenGL ES support via ANGLE
|
||||
#define DEFAULT_EGL "libEGL.dll"
|
||||
|
||||
@@ -529,6 +529,7 @@ extern VideoBootStrap WINDOWS_bootstrap;
|
||||
extern VideoBootStrap HAIKU_bootstrap;
|
||||
extern VideoBootStrap UIKIT_bootstrap;
|
||||
extern VideoBootStrap Android_bootstrap;
|
||||
extern VideoBootStrap OPENHARMONY_bootstrap;
|
||||
extern VideoBootStrap PS2_bootstrap;
|
||||
extern VideoBootStrap PSP_bootstrap;
|
||||
extern VideoBootStrap VITA_bootstrap;
|
||||
|
||||
@@ -110,6 +110,9 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#ifdef SDL_VIDEO_DRIVER_ANDROID
|
||||
&Android_bootstrap,
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_OPENHARMONY
|
||||
&OPENHARMONY_bootstrap,
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_PS2
|
||||
&PS2_bootstrap,
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#ifdef SDL_VIDEO_DRIVER_ANDROID
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_OPENHARMONY
|
||||
#define VK_USE_PLATFORM_OHOS
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_COCOA
|
||||
#define VK_USE_PLATFORM_METAL_EXT
|
||||
#define VK_USE_PLATFORM_MACOS_MVK
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_openharmonyclipboard_h_
|
||||
#define SDL_openharmonyclipboard_h_
|
||||
|
||||
extern void OPENHARMONY_InitClipboard(SDL_VideoDevice *_this);
|
||||
extern void OPENHARMONY_QuitClipboard(SDL_VideoDevice *_this);
|
||||
|
||||
extern const char *const *OPENHARMONY_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types);
|
||||
extern bool OPENHARMONY_SetClipboardText(SDL_VideoDevice *_this, const char *text);
|
||||
extern char *OPENHARMONY_GetClipboardText(SDL_VideoDevice *_this);
|
||||
extern bool OPENHARMONY_HasClipboardText(SDL_VideoDevice *_this);
|
||||
|
||||
#endif // SDL_openharmonyclipboard_h_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
// src/core/openharmony/SDL_openharmony.c calls these when it gets events from the system.
|
||||
extern void SDL_OpenHarmonyDispatchTouchEvent(void *component, void *window);
|
||||
extern void SDL_OpenHarmonyDispatchMouseEvent(void *component, void *window);
|
||||
extern void SDL_OpenHarmonyDispatchKeyEvent(void *component, void *window);
|
||||
extern void SDL_OpenHarmonyDispatchUIInputEvent(void *component, void *event, int32_t type);
|
||||
|
||||
extern void OPENHARMONY_InitEvents(void);
|
||||
extern void OPENHARMONY_PumpEvents(SDL_VideoDevice *_this);
|
||||
extern void OPENHARMONY_QuitEvents(void);
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_OPENHARMONY
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_openharmonykeyboard.h"
|
||||
|
||||
#include "../../core/openharmony/SDL_openharmony.h"
|
||||
|
||||
bool OPENHARMONY_HasScreenKeyboardSupport(SDL_VideoDevice *_this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void OPENHARMONY_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props)
|
||||
{
|
||||
int input_type = 0;
|
||||
int cap_type = 0;
|
||||
if (SDL_HasProperty(props, SDL_PROP_TEXTINPUT_OPENHARMONY_INPUTTYPE_NUMBER)) {
|
||||
input_type = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTINPUT_OPENHARMONY_INPUTTYPE_NUMBER, 0);
|
||||
} else {
|
||||
switch (SDL_GetTextInputType(props)) {
|
||||
#define INPUTTYPE(sdl,oh) case SDL_TEXTINPUT_TYPE_##sdl: input_type = oh; break
|
||||
INPUTTYPE(TEXT, 0);
|
||||
INPUTTYPE(TEXT_NAME, 0);
|
||||
INPUTTYPE(TEXT_EMAIL, 5);
|
||||
INPUTTYPE(TEXT_USERNAME, 10);
|
||||
INPUTTYPE(TEXT_PASSWORD_HIDDEN, 7); // !!! FIXME: this is _also_ PASSWORD_VISIBLE, but I think this doesn't dictate rendering...?
|
||||
INPUTTYPE(TEXT_PASSWORD_VISIBLE, 7);
|
||||
INPUTTYPE(NUMBER_PASSWORD_HIDDEN, 8); // !!! FIXME: this is _also_ NUMBER_PASSWORD_VISIBLE, but I think this doesn't dictate rendering...?
|
||||
INPUTTYPE(NUMBER_PASSWORD_VISIBLE, 8);
|
||||
#undef INPUTTYPE
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch (SDL_GetTextInputCapitalization(props)) {
|
||||
#define CAPTYPE(sdl,oh) case SDL_CAPITALIZE_##sdl: cap_type = oh; break
|
||||
CAPTYPE(NONE, 0);
|
||||
CAPTYPE(LETTERS, 3);
|
||||
CAPTYPE(WORDS, 2);
|
||||
CAPTYPE(SENTENCES, 1);
|
||||
#undef CAPTYPE
|
||||
default: break;
|
||||
}
|
||||
|
||||
#if 0 // !!! FIXME
|
||||
if (SDL_GetTextInputAutocorrect(props)) {
|
||||
input_type |= (TYPE_TEXT_FLAG_AUTO_CORRECT | TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SDL_GetTextInputMultiline(props)) {
|
||||
input_type = 1; // sorry, this only works with basic TEXT type.
|
||||
}
|
||||
}
|
||||
SDL_OpenHarmonyShowScreenKeyboard(input_type, cap_type, &window->text_input_rect);
|
||||
}
|
||||
|
||||
void OPENHARMONY_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_OpenHarmonyHideScreenKeyboard();
|
||||
}
|
||||
|
||||
void OPENHARMONY_RestoreScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
if (_this->screen_keyboard_shown) {
|
||||
OPENHARMONY_ShowScreenKeyboard(_this, window, window->text_input_props);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_DRIVER_OPENHARMONY
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#include "SDL_openharmonyvideo.h"
|
||||
|
||||
extern bool OPENHARMONY_HasScreenKeyboardSupport(SDL_VideoDevice *_this);
|
||||
extern void OPENHARMONY_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||
extern void OPENHARMONY_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void OPENHARMONY_RestoreScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user