8000 tvOS support by XITRIX · Pull Request #84 · xfangfang/borealis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

tvOS support #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,18 @@ elseif (PLATFORM_SWITCH)
)
elseif (PLATFORM_IOS)
ios_bundle(
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/tvos/Splash.storyboard"
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/iphoneos/Splash.storyboard"
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/Images.xcassets"
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/iOSBundleInfo.plist.in"
"borealis"
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_ALTER}")
elseif (PLATFORM_TVOS)
ios_bundle(
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/tvos/Splash.storyboard"
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/Images.xcassets"
"${CMAKE_CURRENT_SOURCE_DIR}/demo/ios/iOSBundleInfo.plist.in"
"borealis"
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_ALTER}")
endif ()

target_include_directories(${PROJECT_NAME} PRIVATE demo ${APP_PLATFORM_INCLUDE})
Expand Down
9 changes: 7 additions & 2 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,21 @@ elseif(PLATFORM_ANDROID)
${BOREALIS_PATH}/lib/platforms/android)
list(APPEND BRLS_PLATFORM_LIBS SDL2 SDL2main)
list(APPEND BRLS_PLATFORM_OPTION -D__SDL2__ -DANDROID)
elseif(PLATFORM_IOS)
elseif(PLATFORM_IOS OR PLATFORM_TVOS)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${BOREALIS_PATH}/lib/extern/SDL)
find_library(SDL2 NAMES SDL2-static SDL2main)
list(APPEND BOREALIS_SOURCE
${BOREALIS_PATH}/lib/platforms/sdl
${BOREALIS_PATH}/lib/platforms/desktop)
list(APPEND BRLS_PLATFORM_LIBS SDL2-static SDL2main)
list(APPEND BRLS_PLATFORM_OPTION -D__SDL2__ -DIOS)
list(APPEND BOREALIS_SRC ${BOREALIS_PATH}/lib/platforms/desktop/ios_darwin.mm)

if(PLATFORM_IOS)
list(APPEND BRLS_PLATFORM_OPTION -D__SDL2__ -DIOS)
elseif(PLATFORM_TVOS)
list(APPEND BRLS_PLATFORM_OPTION -D__SDL2__ -DTVOS)
endif()
elseif(PLATFORM_SWITCH)
list(APPEND BOREALIS_SOURCE
${BOREALIS_PATH}/lib/extern/switch-libpulsar/src/archive
Expand Down
1 change: 1 addition & 0 deletions library/cmake/commonOption.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include(CMakeDependentOption)
# Platform
option(PLATFORM_DESKTOP "build for desktop (Linux, macOS, Windows)" OFF)
option(PLATFORM_IOS "build for iOS" OFF)
option(PLATFORM_TVOS "build for tvOS" OFF)
option(PLATFORM_ANDROID "build for Android" OFF)
option(PLATFORM_PSV "build for psv" OFF)
option(PLATFORM_PS4 "build for ps4" OFF)
Expand Down
22 changes: 13 additions & 9 deletions library/cmake/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ if (PLATFORM_DESKTOP)
message(STATUS "building for Desktop")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
elseif (PLATFORM_IOS)
message(STATUS "building for iOS")
elseif (PLATFORM_IOS OR PLATFORM_TVOS)
if(PLATFORM_IOS)
message(STATUS "building for iOS")
elseif (PLATFORM_TVOS)
message(STATUS "building for tvOS")
endif ()
set(ENABLE_STRICT_TRY_COMPILE ON)
if (NOT DEFINED BOREALIS_LIBRARY)
message(FATAL_ERROR BOREALIS_LIBRARY is not defined)
Expand All @@ -27,7 +31,11 @@ elseif (PLATFORM_IOS)
set(USE_GLES3 ON)
endif()
set(USE_LIBROMFS ON)
set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") # iphone, ipad
if(PLATFORM_IOS)
set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") # iphone, ipad
elseif(PLATFORM_TVOS)
set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "3") # tvos
endif()
check_libromfs_generator()
elseif(PLATFORM_ANDROID)
message(STATUS "building for Android")
Expand Down Expand Up @@ -134,7 +142,7 @@ function(program_target target source)
endif ()
endfunction()

function(ios_bundle tvosStoryBoard iosStoryBoard assets plist name version)
function(ios_bundle iosStoryBoard assets plist name version)
set(IOS_CODE_SIGN_IDENTITY "" CACHE STRING "The code sign identity to use when building the IPA.")
set(IOS_GUI_IDENTIFIER "" CACHE STRING "The package name")
if(IOS_CODE_SIGN_IDENTITY STREQUAL "")
Expand All @@ -146,11 +154,7 @@ function(ios_bundle tvosStoryBoard iosStoryBoard assets plist name version)
set(IOS_GUI_IDENTIFIER "${PACKAGE_NAME}")
message(WARNING "Using default package name: ${PACKAGE_NAME}")
endif ()
if (TVOS)
set(IOS_SPLASH_STORYBOARD "${tvosStoryBoard}")
else ()
set(IOS_SPLASH_STORYBOARD "${iosStoryBoard}")
endif ()
set(IOS_SPLASH_STORYBOARD "${iosStoryBoard}")
set(IOS_ASSETS ${assets})
set_target_properties(${PROJECT_NAME} PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${IOS_CODE_SIGN_IDENTITY}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#elif defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
#elif defined(__APPLE__)
#include <IOKit/pwr_mgt/IOPMLib.h>
#endif
Expand Down Expand Up @@ -81,7 +81,7 @@ class DesktopPlatform : public Platform
uint32_t inhibitCookie = 0;
#elif defined(_WIN32)
HANDLE hLCD;
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
#elif defined(__APPLE__)
IOPMAssertionID assertionID = 0;
#endif
Expand Down
33 changes: 18 additions & 15 deletions library/lib/platforms/desktop/desktop_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <shellapi.h>
#include <winioctl.h>
#include <ntddvdeo.h>
#elif IOS
#elif IOS || TVOS
#elif __APPLE__
#include <IOKit/ps/IOPSKeys.h>
#include <IOKit/ps/IOPowerSources.h>
Expand Down Expand Up @@ -131,7 +131,7 @@ int win32_wlan_quality()
}
return quality;
}
#elif IOS
#elif IOS || TVOS
extern ThemeVariant ios_theme();
extern uint8_t ios_battery_status();
extern float ios_battery();
Ex AE8F pand Down Expand Up @@ -393,7 +393,7 @@ DesktopPlatform::DesktopPlatform()
char* themeEnv = getenv("BOREALIS_THEME");
if (themeEnv == nullptr)
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
this->themeVariant = ios_theme();
#elif __APPLE__
CFPropertyListRef propertyList = CFPreferencesCopyValue(
Expand Down Expand Up @@ -461,7 +461,7 @@ DesktopPlatform::DesktopPlatform()

bool DesktopPlatform::canShowBatteryLevel()
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
return ios_battery_status() != 0;
#elif defined(__APPLE__)
return darwin_get_powerstate() >= 0;
Expand All @@ -477,7 +477,8 @@ bool DesktopPlatform::canShowBatteryLevel()

bool DesktopPlatform::canShowWirelessLevel()
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
return false;
#elif defined(__APPLE__)
return true;
#elif defined(_WIN32)
Expand All @@ -489,7 +490,7 @@ bool DesktopPlatform::canShowWirelessLevel()

int DesktopPlatform::getBatteryLevel()
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
return ios_battery() * 100;
#elif defined(__APPLE__)
return darwin_get_powerstate() & 0x7F;
Expand All @@ -505,7 +506,7 @@ int DesktopPlatform::getBatteryLevel()

bool DesktopPlatform::isBatteryCharging()
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
return ios_battery_status() == 2;
#elif defined(__APPLE__)
return darwin_get_powerstate() & 0x80;
Expand All @@ -521,7 +522,8 @@ bool DesktopPlatform::isBatteryCharging()

bool DesktopPlatform::hasWirelessConnection()
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
return false;
#elif defined(__APPLE__)
return darwin_wlan_quality() > 0;
#elif defined(__WINRT__)
Expand All @@ -535,7 +537,8 @@ bool DesktopPlatform::hasWirelessConnection()

int DesktopPlatform::getWirelessLevel()
{
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
return 0;
#elif defined(__APPLE__)
return darwin_wlan_quality();
#elif defined(__WINRT__)
Expand All @@ -552,7 +555,7 @@ int DesktopPlatform::getWirelessLevel()
bool DesktopPlatform::hasEthernetConnection()
{
bool has_eth = false;
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
#elif defined(__APPLE__)
SCDynamicStoreRef storeRef = SCDynamicStoreCreate(nullptr, CFSTR("FindCurrentInterface"), nullptr, nullptr);
CFDictionaryRef globalRef = (CFDictionaryRef)SCDynamicStoreCopyValue(storeRef, CFSTR("State:/Network/Global/IPv4"));
Expand Down Expand Up @@ -632,7 +635,7 @@ void DesktopPlatform::disableScreenDimming(bool disable, const std::string& reas
if (disable)
{
#ifdef ANDROID
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
#elif defined(__linux__)
inhibitCookie = dbusInhibit(dbus_conn.get(), app, reason);
#elif __APPLE__
Expand All @@ -649,7 +652,7 @@ void DesktopPlatform::disableScreenDimming(bool disable, const std::string& reas
else
{
#ifdef ANDROID
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
#elif defined(__linux__)
if (inhibitCookie != 0)
dbusUnInhibit(dbus_conn.get(), inhibitCookie);
Expand Down Expand Up @@ -738,7 +741,7 @@ std::string DesktopPlatform::getIpAddress()
{
std::string ipaddr = "-";
#if defined(ANDROID)
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
#elif defined(__APPLE__) || defined(__linux__)
struct ifaddrs* interfaces = nullptr;
if (getifaddrs(&interfaces) == 0)
Expand Down Expand Up @@ -799,7 +802,7 @@ std::string DesktopPlatform::getIpAddress()
std::string DesktopPlatform::getDnsServer()
{
std::string dnssvr = "-";
#if defined(IOS)
#if defined(IOS) || defined(TVOS)
#elif defined(__APPLE__)
SCPreferencesRef prefsDNS = SCPreferencesCreate(nullptr, CFSTR("DNSSETTING"), nullptr);
CFArrayRef services = SCNetworkServiceCopyAll(prefsDNS);
Expand Down Expand Up @@ -871,7 +874,7 @@ std::string DesktopPlatform::exec(const char* cmd)
{
std::stringstream ss;
#if defined(ANDROID)
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
#elif defined(__APPLE__) || defined(__linux__)
FILE* pipe = popen(cmd, "r");
if (!pipe)
Expand Down
8 changes: 8 additions & 0 deletions library/lib/platforms/desktop/ios_darwin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ bool darwin_runloop(const std::function<bool()>& runLoopImpl) {
}

uint8_t ios_battery_status() {
#if defined(IOS)
UIDevice.currentDevice.batteryMonitoringEnabled = true;
return UIDevice.currentDevice.batteryState;
#else
return 0;
#endif
}

float ios_battery() {
#if defined(IOS)
return UIDevice.currentDevice.batteryLevel;
#else
return 0;
#endif
}
};
4 changes: 2 additions & 2 deletions library/lib/platforms/sdl/sdl_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <borealis/platforms/sdl/sdl_platform.hpp>
#include <unordered_map>

#ifdef IOS
#if defined(IOS) || defined(TVOS)
#include <sys/utsname.h>

static bool isIPad()
Expand All @@ -43,7 +43,7 @@ SDLPlatform::SDLPlatform()
VideoContext::FULLSCREEN = true;
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
#elif defined(IOS)
#elif defined(IOS) || defined(TVOS)
// Enable Fullscreen on iOS
VideoContext::FULLSCREEN = true;
if (!isIPad())
Expand Down
0