Skip to content

Commit

Permalink
Add Switch submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
halotroop2288 committed Feb 15, 2024
1 parent 3da74f0 commit e378bcb
Show file tree
Hide file tree
Showing 20 changed files with 693 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "platform/switch"]
path = platform/switch
url = https://github.com/Homebrodot/platform-switch
8 changes: 8 additions & 0 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
#endif

#ifdef HORIZON_ENABLED
if (!found) {
if (_load_resource_pack("romfs:/game.pck")) {
found = true;
}
}
#endif // HORIZON_ENABLED

if (!found) {
// Try to load data pack at the location of the executable.
// As mentioned above, we have two potential names to attempt.
Expand Down
8 changes: 4 additions & 4 deletions drivers/gles2/rasterizer_storage_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ GLuint RasterizerStorageGLES2::system_fbo = 0;
#define glClearDepth glClearDepthf

// enable extensions manually for android and ios
#ifndef UWP_ENABLED
#if defined IPHONE_ENABLED || defined ANDROID_ENABLED
#include <dlfcn.h> // needed to load extensions
#endif
#endif // IPHONE_ENABLED || ANDROID_ENABLED

#ifdef IPHONE_ENABLED

#include <OpenGLES/ES2/glext.h>
//void *glRenderbufferStorageMultisampleAPPLE;
//void *glResolveMultisampleFramebufferAPPLE;
#define glRenderbufferStorageMultisample glRenderbufferStorageMultisampleAPPLE
#elif defined(ANDROID_ENABLED)
#elif defined(ANDROID_ENABLED) || defined(HORIZON_ENABLED)

#include <GLES2/gl2ext.h>
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
Expand Down Expand Up @@ -5986,7 +5986,7 @@ void RasterizerStorageGLES2::initialize() {
// If the desktop build is using S3TC, and you export / run from the IDE for android, if the device supports
// S3TC it will crash trying to load these textures, as they are not exported in the APK. This is a simple way
// to prevent Android devices trying to load S3TC, by faking lack of hardware support.
#if defined(ANDROID_ENABLED) || defined(IPHONE_ENABLED)
#if defined(ANDROID_ENABLED) || defined(IPHONE_ENABLED) || defined(HORIZON_ENABLED)
config.s3tc_supported = false;
#endif

Expand Down
9 changes: 8 additions & 1 deletion drivers/unix/dir_access_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ String DirAccessUnix::read_link(String p_file) {

p_file = fix_path(p_file);

#ifdef HORIZON_ENABLED
return p_file;
#else // HORIZON_ENABLED
char buf[256];
memset(buf, 0, 256);
ssize_t len = readlink(p_file.utf8().get_data(), buf, sizeof(buf));
Expand All @@ -422,9 +425,11 @@ String DirAccessUnix::read_link(String p_file) {
link.parse_utf8(buf, len);
}
return link;
#endif // !HORIZON_ENABLED
}

Error DirAccessUnix::create_link(String p_source, String p_target) {
#ifndef HORIZON_ENABLED
if (p_target.is_rel_path())
p_target = get_current_dir().plus_file(p_target);

Expand All @@ -433,7 +438,9 @@ Error DirAccessUnix::create_link(String p_source, String p_target) {

if (symlink(p_source.utf8().get_data(), p_target.utf8().get_data()) == 0) {
return OK;
} else {
} else
#endif // !HORIZON_ENABLED
{
return FAILED;
}
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/unix/file_access_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#include <errno.h>

#if defined(UNIX_ENABLED)
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
#include <unistd.h>
#endif

Expand Down Expand Up @@ -131,6 +131,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
return last_error;
}

#ifndef HORIZON_ENABLED
// Set close on exec to avoid leaking it to subprocesses.
int fd = fileno(f);

Expand All @@ -143,6 +144,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
fcntl(fd, F_SETFD, opts | FD_CLOEXEC);
#endif
}
#endif // !HORIZON_ENABLED

last_error = OK;
flags = p_mode_flags;
Expand Down Expand Up @@ -280,7 +282,7 @@ bool FileAccessUnix::file_exists(const String &p_path) {
return false;
}

#ifdef UNIX_ENABLED
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
// See if we have access to the file
if (access(filename.utf8().get_data(), F_OK)) {
return false;
Expand Down
8 changes: 7 additions & 1 deletion drivers/unix/ip_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "ip_unix.h"

#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED)
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED) || defined(HORIZON_ENABLED)

#include <string.h>

Expand All @@ -54,7 +54,9 @@
#ifdef __FreeBSD__
#include <sys/types.h>
#endif
#ifndef HORIZON_ENABLED
#include <ifaddrs.h>
#endif // !HORIZON_ENABLED
#endif
#include <arpa/inet.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -213,6 +215,9 @@ void IP_Unix::get_local_interfaces(RBMap<String, Interface_Info> *r_interfaces)
void IP_Unix::get_local_interfaces(RBMap<String, Interface_Info> *r_interfaces) const {
struct ifaddrs *ifAddrStruct = nullptr;
struct ifaddrs *ifa = nullptr;
#ifdef HORIZON_ENABLED
// todo: nifm
#else // HORIZON_ENABLED
int family;

getifaddrs(&ifAddrStruct);
Expand Down Expand Up @@ -245,6 +250,7 @@ void IP_Unix::get_local_interfaces(RBMap<String, Interface_Info> *r_interfaces)
if (ifAddrStruct != nullptr) {
freeifaddrs(ifAddrStruct);
}
#endif // !HORIZON_ENABLED
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions drivers/unix/ip_unix.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#ifndef IP_UNIX_H
#define IP_UNIX_H

/*************************************************************************/
/* ip_unix.h */
/*************************************************************************/
Expand Down Expand Up @@ -32,9 +29,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef IP_UNIX_H
#define IP_UNIX_H

#include "core/io/ip.h"

#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED)
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED) || defined(HORIZON_ENABLED)

class IP_Unix : public IP {
GDCLASS(IP_Unix, IP);
Expand Down
6 changes: 4 additions & 2 deletions drivers/unix/net_socket_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "net_socket_posix.h"

#ifndef UNIX_SOCKET_UNAVAILABLE
#if defined(UNIX_ENABLED)
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)

#include <errno.h>
#include <netdb.h>
Expand All @@ -51,7 +51,7 @@
#include <netinet/in.h>

#include <sys/socket.h>
#ifdef JAVASCRIPT_ENABLED
#if defined(JAVASCRIPT_ENABLED) || defined(HORIZON_ENABLED)
#include <arpa/inet.h>
#endif

Expand Down Expand Up @@ -277,11 +277,13 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
memcpy(&greq.imr_interface, if_ip.get_ipv4(), 4);
ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq));
} else {
#ifndef HORIZON_ENABLED
struct ipv6_mreq greq;
int sock_opt = p_add ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP;
memcpy(&greq.ipv6mr_multiaddr, p_ip.get_ipv6(), 16);
greq.ipv6mr_interface = if_v6id;
ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq));
#endif // !HORIZON_ENABLED
}
ERR_FAIL_COND_V(ret != 0, FAILED);

Expand Down
3 changes: 3 additions & 0 deletions modules/database_sqlite/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ sources = [
"sqlite3_table_builder.cpp",
]

if module_env["platform"] == "switch":
sources += ["sqlite/nx-vfs.c"]

if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
# Shared lib compilation
module_env.Append(CCFLAGS=['-fPIC'])
Expand Down
Loading

0 comments on commit e378bcb

Please sign in to comment.