Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace PLATFORM_* with SE_PLATFORM_*
Browse files Browse the repository at this point in the history
OFFTKP committed Dec 15, 2023
1 parent 800ee06 commit d324938
Showing 6 changed files with 56 additions and 56 deletions.
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
set(LINK_LIBS "")
if (EMSCRIPTEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DPLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DPLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ")
endif ()
if (MSVC)
# Perform extremely aggressive optimization on Release builds:
@@ -64,7 +64,7 @@ if(IOS)
endif()
if(WIN32)
message("Building for Windows")
add_definitions(-DPLATFORM_WINDOWS=1)
add_definitions(-DSE_PLATFORM_WINDOWS=1)
endif()
if(ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@@ -81,17 +81,17 @@ if ((CMAKE_SYSTEM_NAME STREQUAL Linux) AND NOT EMSCRIPTEN AND NOT ANDROID)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(ALSA REQUIRED)
set(PLATFORM_LINUX TRUE)
add_definitions(-DPLATFORM_LINUX=1)
set(SE_PLATFORM_LINUX TRUE)
add_definitions(-DSE_PLATFORM_LINUX=1)
endif()
if (UNIX AND NOT APPLE AND NOT PLATFORM_LINUX AND NOT EMSCRIPTEN AND NOT ANDROID)
set(PLATFORM_FREEBSD TRUE)
add_definitions(-DPLATFORM_FREEBSD=1)
if (UNIX AND NOT APPLE AND NOT SE_PLATFORM_LINUX AND NOT EMSCRIPTEN AND NOT ANDROID)
set(SE_PLATFORM_FREEBSD TRUE)
add_definitions(-DSE_PLATFORM_FREEBSD=1)
find_package(ALSA REQUIRED)
link_directories(/usr/local/lib)
endif()

if (PLATFORM_LINUX OR PLATFORM_FREEBSD)
if (SE_PLATFORM_LINUX OR SE_PLATFORM_FREEBSD)
find_package(X11 REQUIRED)
endif()

@@ -108,7 +108,7 @@ if(NOT EMSCRIPTEN AND NOT ANDROID AND NOT IOS)
endif()

# TinyFileDialogs
if ((NOT IOS) AND (NOT EMSCRIPTEN) AND (NOT ANDROID) AND (NOT PLATFORM_LINUX) AND (NOT PLATFORM_FREEBSD))
if ((NOT IOS) AND (NOT EMSCRIPTEN) AND (NOT ANDROID) AND (NOT SE_PLATFORM_LINUX) AND (NOT SE_PLATFORM_FREEBSD))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_TINY_FILE_DIALOGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_TINY_FILE_DIALOGS")
add_library(tinyfd STATIC
@@ -181,7 +181,7 @@ set(SOKOL_HEADERS
src/sokol/sokol_audio.h
src/sokol/sokol_glue.h)
if(ANDROID)
add_definitions(-DPLATFORM_ANDROID)
add_definitions(-DSE_PLATFORM_ANDROID)
set(LINK_LIBS ${LINK_LIBS} GLESv3 EGL OpenSLES log android curl z)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/android/${ANDROID_ABI})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/android/include)
@@ -190,7 +190,7 @@ endif()
if(MACOS OR IOS)
add_library(sokol STATIC src/sokol/sokol.m ${SOKOL_HEADERS})
if(MACOS AND (NOT IOS))
add_definitions(-DPLATFORM_MACOS)
add_definitions(-DSE_PLATFORM_MACOS)
target_link_libraries(sokol PUBLIC
"-framework QuartzCore"
"-framework Cocoa"
@@ -210,7 +210,7 @@ if(MACOS OR IOS)
else()
add_library(sokol STATIC src/sokol/sokol.c ${SOKOL_HEADERS})
set_property(TARGET sokol PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
if (PLATFORM_LINUX OR PLATFORM_FREEBSD)
if (SE_PLATFORM_LINUX OR SE_PLATFORM_FREEBSD)
target_include_directories(sokol PRIVATE "${X11_INCLUDE_DIR}")
target_link_libraries(sokol INTERFACE ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_Xcursor_LIB} OpenGL::OpenGL dl)
endif()
@@ -291,7 +291,7 @@ endif()

if(IOS)
set(SKYEMU_SRC ${SKYEMU_SRC} src/ios_support.m)
add_definitions(-DPLATFORM_IOS)
add_definitions(-DSE_PLATFORM_IOS)
set(LINK_LIBS ${LINK_LIBS} curl z)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/iOS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/iOS/include)
2 changes: 1 addition & 1 deletion src/cloud.cpp
Original file line number Diff line number Diff line change
@@ -616,7 +616,7 @@ void cloud_drive_authenticate(cloud_drive_t* drive)
{
#ifdef EMSCRIPTEN
return em_oath_sign_in(drive, GOOGLE_CLIENT_ID_WEB);
#elif !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE)
#elif !defined(SE_PLATFORM_ANDROID) && !defined(SE_PLATFORM_IOS)
srand(time(NULL));
const char* charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
std::string code_verifier;
10 changes: 5 additions & 5 deletions src/localization.c
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
#include <locale.h>
#include <ctype.h>

#if defined(PLATFORM_IOS) || defined(PLATFORM_MACOS)
#if defined(SE_PLATFORM_IOS) || defined(SE_PLATFORM_MACOS)
#include <CoreFoundation/CoreFoundation.h>
#endif

@@ -1777,13 +1777,13 @@ const char* se_language_string(int language_enum){
}
return "";
}
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
extern void se_android_get_language(char* language_buffer, size_t buffer_size);
#endif
int se_get_default_language(){
static int default_lang = SE_LANG_DEFAULT;
if(default_lang==SE_LANG_DEFAULT){
#if defined(PLATFORM_IOS) || defined(PLATFORM_MACOS)
#if defined(SE_PLATFORM_IOS) || defined(SE_PLATFORM_MACOS)
// Try to get from CF Locale
if(default_lang == SE_LANG_DEFAULT){
char lang_buffer[128];
@@ -1794,7 +1794,7 @@ int se_get_default_language(){
if(default_lang != SE_LANG_DEFAULT) printf("Detected CF locale language: %s (enum: %s)\n", lang_buffer ,se_language_string(default_lang));
}
#endif
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
// Try to get from JNI
if(default_lang == SE_LANG_DEFAULT){
char lang_buffer[128];
@@ -1822,7 +1822,7 @@ int se_get_default_language(){
printf("Couldn't detect language, defaulting to English\n");
default_lang = SE_LANG_ENGLISH;
}
#ifdef PLATFORM_WINDOWS
#ifdef SE_PLATFORM_WINDOWS
//Needed to let windows open files from UTF-8 paths
setlocale(LC_ALL, ".65001");
#endif
68 changes: 34 additions & 34 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -52,16 +52,16 @@
#define USE_BUILT_IN_FILEBROWSER
#include "tinydir.h"

#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
#include <android/log.h>
#endif
#ifdef PLATFORM_IOS
#ifdef SE_PLATFORM_IOS
#include "ios_support.h"
#endif
#ifdef USE_SDL
#include "SDL.h"
#endif
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
#include <android/native_activity.h>
#endif
#ifdef UNICODE_GUI
@@ -538,13 +538,13 @@ const char* se_get_pref_path(){
static const char* cached_pref_path=NULL;
if(cached_pref_path==NULL)cached_pref_path=SDL_GetPrefPath("Sky","SkyEmu");
return cached_pref_path;
#elif defined(PLATFORM_ANDROID)
#elif defined(SE_PLATFORM_ANDROID)
ANativeActivity* activity =(ANativeActivity*)sapp_android_get_native_activity();
if(activity->internalDataPath)return activity->internalDataPath;
#endif
return "";
}
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
float se_android_get_display_dpi_scale();
#endif
static float se_dpi_scale(){
@@ -554,7 +554,7 @@ static float se_dpi_scale(){
dpi_scale = sapp_dpi_scale();
if(dpi_scale<=0)dpi_scale=1.;
dpi_scale*=1.10;
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
dpi_scale = se_android_get_display_dpi_scale();
#endif
return dpi_scale;
@@ -1112,17 +1112,17 @@ const char *se_get_host_arch() {
#endif
}
const char *se_get_host_platform() {
#if defined(PLATFORM_WINDOWS)
#if defined(SE_PLATFORM_WINDOWS)
return "Windows";
#elif defined(PLATFORM_LINUX)
#elif defined(SE_PLATFORM_LINUX)
return "Linux";
#elif defined(PLATFORM_FREEBSD)
#elif defined(SE_PLATFORM_FREEBSD)
return "FreeBSD";
#elif defined(PLATFORM_MACOS)
#elif defined(SE_PLATFORM_MACOS)
return "macOS";
#elif defined(PLATFORM_IOS)
#elif defined(SE_PLATFORM_IOS)
return "iOS";
#elif defined(PLATFORM_ANDROID)
#elif defined(SE_PLATFORM_ANDROID)
return "Android";
#elif defined(__EMSCRIPTEN__)
return "Web";
@@ -3020,7 +3020,7 @@ static float se_draw_debug_panels(float screen_x, float sidebar_w, float y, floa
}else desc->function();

float bottom_padding =0;
#ifdef PLATFORM_IOS
#ifdef SE_PLATFORM_IOS
se_ios_get_safe_ui_padding(NULL,&bottom_padding,NULL,NULL);
#endif
igDummy((ImVec2){0,bottom_padding});
@@ -3301,7 +3301,7 @@ void se_initialize_keybind(se_keybind_state_t * state){
state->last_bind_activitiy=-1;

}
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
const char* se_android_key_to_name(int key){
switch(key){
case AKEYCODE_UNKNOWN: return "UNKNOWN";
@@ -3625,7 +3625,7 @@ bool se_handle_keybind_settings(int keybind_type, se_keybind_state_t * state){
if(state->bound_id[k]!=-1){
switch(keybind_type){
case SE_BIND_KEYBOARD: button_label=se_keycode_to_string(state->bound_id[k]);break;
#if defined(USE_SDL) || defined(PLATFORM_ANDROID)
#if defined(USE_SDL) || defined(SE_PLATFORM_ANDROID)
case SE_BIND_KEY:
{
int key = state->bound_id[k];
@@ -3650,7 +3650,7 @@ bool se_handle_keybind_settings(int keybind_type, se_keybind_state_t * state){
const char* dir = (key&SE_JOY_NEG_MASK)? "<-0.3": ">0.3";
snprintf(buff, sizeof(buff),se_localize("Analog %d %s"),joy_id,dir);
}else {
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
const char* android_name = se_android_key_to_name(state->bound_id[k]);
if(android_name) {
android_name = se_localize_and_cache(android_name);
@@ -4184,7 +4184,7 @@ bool se_selectable_with_box(const char * first_label, const char* second_label,
#endif
return clicked;
}
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
#include <android/log.h>

#define TAG "SkyEmu"
@@ -4622,11 +4622,11 @@ void se_open_file_browser(bool clicked, float x, float y, float w, float h, void
se_file_browser_accept(outPath);
}
#endif
#ifdef PLATFORM_IOS
#ifdef SE_PLATFORM_IOS
gui_state.file_browser.state=SE_FILE_BROWSER_CLOSED;
se_ios_open_file_picker(num_file_types,file_types);
#endif
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
gui_state.file_browser.state=SE_FILE_BROWSER_CLOSED;
se_android_open_file_picker();
#endif
@@ -5350,7 +5350,7 @@ void se_imgui_theme()
});
});
#endif
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
void se_set_default_controller_binds(se_controller_state_t* cont){
if(!cont)return;
for(int i=0;i<SE_NUM_KEYBINDS;++i)cont->key.bound_id[i]=-1;
@@ -5398,7 +5398,7 @@ bool se_load_controller_settings(se_controller_state_t * cont){
#ifdef USE_SDL
if(!cont->sdl_joystick)return false;
#endif
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
strncpy(cont->name,SE_ANDROID_CONTROLLER_NAME, sizeof(cont->name) );
#endif
int32_t bind_map[SE_NUM_BINDS_ALLOC*2];
@@ -5918,7 +5918,7 @@ void se_draw_menu_panel(){
se_emscripten_flush_fs();
}
}
#if defined( USE_SDL) ||defined(PLATFORM_ANDROID)
#if defined( USE_SDL) ||defined(SE_PLATFORM_ANDROID)
se_draw_controller_config(&gui_state);
#endif

@@ -6051,7 +6051,7 @@ void se_draw_menu_panel(){
#endif

float bottom_padding =0;
#ifdef PLATFORM_IOS
#ifdef SE_PLATFORM_IOS
se_ios_get_safe_ui_padding(NULL,&bottom_padding,NULL,NULL);
#endif
igDummy((ImVec2){0,bottom_padding});
@@ -6490,13 +6490,13 @@ static void frame(void) {
se_poll_sdl();
#endif
se_set_language(gui_state.settings.language);
#if !defined(EMSCRIPTEN) && !defined(PLATFORM_ANDROID) &&!defined(PLATFORM_IOS)
#if !defined(EMSCRIPTEN) && !defined(SE_PLATFORM_ANDROID) &&!defined(SE_PLATFORM_IOS)
static bool last_toggle_fullscreen=false;
if(emu_state.joy.inputs[SE_KEY_TOGGLE_FULLSCREEN]&&last_toggle_fullscreen==false)sapp_toggle_fullscreen();
last_toggle_fullscreen = emu_state.joy.inputs[SE_KEY_TOGGLE_FULLSCREEN];
#endif

#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
//Handle Android Back Button Navigation
static bool last_back_press = false;
if(!last_back_press&&gui_state.button_state[SAPP_KEYCODE_BACK]){
@@ -6524,13 +6524,13 @@ static void frame(void) {
float top_padding =0;
float left_padding = 0, right_padding=0;
style->DisplaySafeAreaPadding.x = style->DisplaySafeAreaPadding.y =0;
#ifdef PLATFORM_IOS
#ifdef SE_PLATFORM_IOS
se_ios_get_safe_ui_padding(&top_padding,NULL,&left_padding,&right_padding);
style->DisplaySafeAreaPadding.x = left_padding;
style->DisplaySafeAreaPadding.y = top_padding;
#endif

#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
se_android_poll_events(igGetIO()->WantTextInput);
#endif
sb_poll_controller_input(&emu_state.joy);
@@ -6927,7 +6927,7 @@ void se_load_settings(){
se_set_default_keybind(&gui_state);
}
}
#if defined(USE_SDL) || defined(PLATFORM_ANDROID)
#if defined(USE_SDL) || defined(SE_PLATFORM_ANDROID)
if(!se_load_controller_settings(&gui_state.controller)){
se_set_default_controller_binds(&gui_state.controller);
}
@@ -7470,11 +7470,11 @@ static void init(void) {
}
#endif
gui_state.ui_type=SE_UI_DESKTOP;
#if defined(PLATFORM_ANDROID)
#if defined(SE_PLATFORM_ANDROID)
gui_state.ui_type = SE_UI_ANDROID;
#elif defined(PLATFORM_IOS)
#elif defined(SE_PLATFORM_IOS)
gui_state.ui_type = SE_UI_IOS;
#elif defined(PLATFORM_WEB)
#elif defined(SE_PLATFORM_WEB)
gui_state.ui_type = SE_UI_WEB;
#endif

@@ -7532,7 +7532,7 @@ static void init(void) {
};
gui_state.quad_vb = sg_make_buffer(&vb_desc);
sg_pop_debug_group();
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
se_android_request_permissions();
#endif
}
@@ -7634,7 +7634,7 @@ static void headless_mode(){
#endif
}

#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
void Java_com_sky_SkyEmu_EnhancedNativeActivity_se_1android_1load_1rom(JNIEnv *env, jobject thiz, jstring filePath) {
const char *nativeFilePath = (*env)->GetStringUTFChars(env, filePath, 0);
gui_state.ran_from_launcher=true;
@@ -7672,7 +7672,7 @@ sapp_desc sokol_main(int argc, char* argv[]) {
#endif
if(emu_state.cmd_line_arg_count >3&&strcmp("http_server",emu_state.cmd_line_args[1])==0)headless_mode();

#ifdef PLATFORM_IOS
#ifdef SE_PLATFORM_IOS
se_ios_set_documents_working_directory();
#endif

2 changes: 1 addition & 1 deletion src/sb_types.h
Original file line number Diff line number Diff line change
@@ -287,7 +287,7 @@ static const char* sb_parent_path(const char* path){
}
static const char *sb_get_home_path(){
static char homedir[SB_FILE_PATH_SIZE];
#ifdef PLATFORM_ANDROID
#ifdef SE_PLATFORM_ANDROID
return "/sdcard/";
#elif defined(_WIN32)
snprintf(homedir, SB_FILE_PATH_SIZE, "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
2 changes: 1 addition & 1 deletion src/sokol/sokol.c
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
#define SOKOL_D3D11
#elif defined(__EMSCRIPTEN__)
#define SOKOL_GLES2
#elif defined(PLATFORM_ANDROID)
#elif defined(SE_PLATFORM_ANDROID)
#define SOKOL_GLES3
#elif defined(__APPLE__)
#error "Must use sokol.m on macOS"

0 comments on commit d324938

Please sign in to comment.