Fix switch

This commit is contained in:
2025-08-19 11:12:04 -05:00
parent 038e07de84
commit bd71ca5239
6 changed files with 45 additions and 30 deletions

View File

@@ -61,6 +61,7 @@ option(TESSESFRAMEWORK_ENABLE_NETWORKING "Enable Networking" ON)
option(TESSESFRAMEWORK_ENABLE_THREADING "Enable Threading" ON) option(TESSESFRAMEWORK_ENABLE_THREADING "Enable Threading" ON)
option(TESSESFRAMEWORK_ENABLE_SQLITE "Enable sqlite (embedded in source)" ON) option(TESSESFRAMEWORK_ENABLE_SQLITE "Enable sqlite (embedded in source)" ON)
option(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS "Enable sago platformfolders (embedded in source)" ON) option(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS "Enable sago platformfolders (embedded in source)" ON)
option(TESSESFRAMEWORK_ENABLE_PROCESS "Enable process api" ON)
if(TESSESFRAMEWORK_DEFINE_SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS) if(TESSESFRAMEWORK_DEFINE_SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS)
add_definitions(-DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1) add_definitions(-DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1)
@@ -144,6 +145,10 @@ target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENAB
endif() endif()
if(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) if(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS)
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS)
endif()
if(TESSESFRAMEWORK_ENABLE_PROCESS)
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_PROCESS)
endif() endif()
target_include_directories(${TessesFramework_TARGET} target_include_directories(${TessesFramework_TARGET}
PUBLIC PUBLIC

View File

@@ -18,6 +18,8 @@ sudo make install
## What libraries have I embeded from other people ## What libraries have I embeded from other people
- [HodwardHinnart's date](https://github.com/HowardHinnant/date) (in folder src/HodwardHinnart_date, modified tz.cpp to point to correct header) - [HodwardHinnart's date](https://github.com/HowardHinnant/date) (in folder src/HodwardHinnart_date, modified tz.cpp to point to correct header)
- [PlatformFolders](https://github.com/sago007/PlatformFolders) (in folder src/Platform/sago, modified to conditionally disable for GEKKO, NX etc)
- [Sqlite 3](https://www.sqlite.org/) (in folder src/Serialization/sqlite, modified for GEKKO, NX etc, uses the amalgamation)
## Dependencies ## Dependencies
- [mbedtls](https://github.com/Mbed-TLS/mbedtls) - [mbedtls](https://github.com/Mbed-TLS/mbedtls)
@@ -27,4 +29,3 @@ sudo make install
## Resources used from others ## Resources used from others
- [ca-certificate.crt (from ubuntu)](ca-certificate.crt) - [ca-certificate.crt (from ubuntu)](ca-certificate.crt)
- [TanoheSans-Regular.ttf (license OFL)](font/License-OFL.txt)

View File

@@ -22,6 +22,9 @@
#if defined(TESSES_FRAMEWORK_FLAG_@TESSESFRAMEWORK_LOGTOFILE@) && !defined(TESSESFRAMEWORK_LOGTOFILE) #if defined(TESSES_FRAMEWORK_FLAG_@TESSESFRAMEWORK_LOGTOFILE@) && !defined(TESSESFRAMEWORK_LOGTOFILE)
#define TESSESFRAMEWORK_LOGTOFILE #define TESSESFRAMEWORK_LOGTOFILE
#endif #endif
#if defined(TESSES_FRAMEWORK_FLAG_@TESSESFRAMEWORK_ENABLE_PROCESS@) && !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#define TESSESFRAMEWORK_ENABLE_PROCESS
#endif
#undef TESSES_FRAMEWORK_FLAG_OFF #undef TESSES_FRAMEWORK_FLAG_OFF
#undef TESSES_FRAMEWORK_FLAG_ON #undef TESSES_FRAMEWORK_FLAG_ON

View File

@@ -73,7 +73,7 @@ namespace Tesses::Framework::Platform {
} }
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
int stdin_strm; int stdin_strm;
int stdout_strm; int stdout_strm;
@@ -91,7 +91,7 @@ namespace Tesses::Framework::Platform {
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
this->stdin_strm=-1; this->stdin_strm=-1;
@@ -105,7 +105,7 @@ namespace Tesses::Framework::Platform {
HANDLE strm; HANDLE strm;
bool writing; bool writing;
bool eos; bool eos;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
int strm; int strm;
@@ -120,7 +120,7 @@ namespace Tesses::Framework::Platform {
this->writing = writing; this->writing = writing;
this->eos = false; this->eos = false;
} }
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
ProcessStream(int strm, bool writing) ProcessStream(int strm, bool writing)
{ {
@@ -134,7 +134,7 @@ namespace Tesses::Framework::Platform {
//TODO: Implement for WIN32 //TODO: Implement for WIN32
#if defined(_WIN32) #if defined(_WIN32)
return this->strm == NULL || eos; return this->strm == NULL || eos;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return true; return true;
#else #else
return this->strm < 0 || eos; return this->strm < 0 || eos;
@@ -145,7 +145,7 @@ namespace Tesses::Framework::Platform {
//TODO: Implement for WIN32 //TODO: Implement for WIN32
#if defined(_WIN32) #if defined(_WIN32)
return !writing && this->strm != NULL; return !writing && this->strm != NULL;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return false; return false;
#else #else
return !writing && this->strm > -1; return !writing && this->strm > -1;
@@ -157,7 +157,7 @@ namespace Tesses::Framework::Platform {
#if defined(_WIN32) #if defined(_WIN32)
return writing && this->strm != NULL; return writing && this->strm != NULL;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return false; return false;
#else #else
return writing && this->strm > -1; return writing && this->strm > -1;
@@ -177,7 +177,7 @@ namespace Tesses::Framework::Platform {
this->eos = true; this->eos = true;
} }
return (size_t)dataR; return (size_t)dataR;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return 0; return 0;
#else #else
if(this->strm < 0 || this->eos && writing) return 0; if(this->strm < 0 || this->eos && writing) return 0;
@@ -199,7 +199,7 @@ namespace Tesses::Framework::Platform {
return 0; return 0;
return (size_t)dataW; return (size_t)dataW;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return 0; return 0;
#else #else
if(this->strm < 0 || !writing) return 0; if(this->strm < 0 || !writing) return 0;
@@ -242,7 +242,9 @@ namespace Tesses::Framework::Platform {
this->exited = true; this->exited = true;
return true; return true;
} }
#else #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return true;
#else
int r; int r;
if (waitpid(this->hidden.GetField<ProcessData*>()->pid, &r, WNOHANG) != -1) if (waitpid(this->hidden.GetField<ProcessData*>()->pid, &r, WNOHANG) != -1)
{ {
@@ -282,8 +284,8 @@ namespace Tesses::Framework::Platform {
CloseHandle(p->stdin_strm); CloseHandle(p->stdin_strm);
p->stdin_strm = NULL; p->stdin_strm = NULL;
} }
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
if (p->stdin_strm > -1) if (p->stdin_strm > -1)
{ {
@@ -313,8 +315,8 @@ namespace Tesses::Framework::Platform {
CloseHandle(p->pi.hProcess); CloseHandle(p->pi.hProcess);
CloseHandle(p->pi.hThread); CloseHandle(p->pi.hThread);
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
if (!this->exited) if (!this->exited)
{ {
@@ -496,7 +498,8 @@ CreateProcessW(
); );
*/ */
return true; return true;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return false; return false;
#else #else
@@ -646,7 +649,8 @@ CreateProcessW(
else else
TerminateProcess(this->hidden.GetField<ProcessData*>()->pi.hProcess,-1); TerminateProcess(this->hidden.GetField<ProcessData*>()->pi.hProcess,-1);
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#else #else
kill(this->hidden.GetField<ProcessData*>()->pid,signal); kill(this->hidden.GetField<ProcessData*>()->pid,signal);
#endif #endif
@@ -664,7 +668,8 @@ CreateProcessW(
this->exited = true; this->exited = true;
return (int)ret; return (int)ret;
#elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return -1; return -1;
#else #else
int r; int r;
@@ -681,7 +686,8 @@ CreateProcessW(
Tesses::Framework::Streams::Stream* Process::GetStdinStream() Tesses::Framework::Streams::Stream* Process::GetStdinStream()
{ {
if (this->exited) return nullptr; if (this->exited) return nullptr;
#if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return nullptr; return nullptr;
#else #else
return new ProcessStream(this->hidden.GetField<ProcessData*>()->stdin_strm,true); return new ProcessStream(this->hidden.GetField<ProcessData*>()->stdin_strm,true);
@@ -691,8 +697,8 @@ CreateProcessW(
{ {
if (this->exited) return nullptr; if (this->exited) return nullptr;
#if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return nullptr; return nullptr;
#else #else
return new ProcessStream(this->hidden.GetField<ProcessData*>()->stdout_strm,false); return new ProcessStream(this->hidden.GetField<ProcessData*>()->stdout_strm,false);
#endif #endif
@@ -701,7 +707,7 @@ CreateProcessW(
{ {
if (this->exited) return nullptr; if (this->exited) return nullptr;
#if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS)
return nullptr; return nullptr;
#else #else
return new ProcessStream(this->hidden.GetField<ProcessData*>()->stderr_strm,false); return new ProcessStream(this->hidden.GetField<ProcessData*>()->stderr_strm,false);

View File

@@ -30,9 +30,9 @@ SOFTWARE.
Modified by Mike Nolan for this project Modified by Mike Nolan for this project
I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc
*/ */
#if !defined(SAGO_DISABLE)
#include "platform_folders.h" #include "platform_folders.h"
#if !defined(SAGO_DISABLE)
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <cstdio> #include <cstdio>

View File

@@ -1,5 +1,5 @@
#include "TessesFramework/Streams/PtyStream.hpp" #include "TessesFramework/Streams/PtyStream.hpp"
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
#include <pty.h> #include <pty.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@@ -10,7 +10,7 @@
namespace Tesses::Framework::Streams { namespace Tesses::Framework::Streams {
PtyStream::PtyStream(WindowSize windowSize,std::string filename, std::vector<std::string> args, std::vector<std::string> env) PtyStream::PtyStream(WindowSize windowSize,std::string filename, std::vector<std::string> args, std::vector<std::string> env)
{ {
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
this->wS = windowSize; this->wS = windowSize;
this->eos=false; this->eos=false;
winsize sz; winsize sz;
@@ -80,7 +80,7 @@ namespace Tesses::Framework::Streams {
size_t PtyStream::Read(uint8_t* buff, size_t sz) size_t PtyStream::Read(uint8_t* buff, size_t sz)
{ {
if(this->eos) return 0; if(this->eos) return 0;
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
auto res = read(this->socket, buff,sz); auto res = read(this->socket, buff,sz);
if(res == -1) if(res == -1)
@@ -96,7 +96,7 @@ namespace Tesses::Framework::Streams {
} }
size_t PtyStream::Write(const uint8_t* buff, size_t sz) size_t PtyStream::Write(const uint8_t* buff, size_t sz)
{ {
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
auto res = write(this->socket, buff,sz); auto res = write(this->socket, buff,sz);
return res; return res;
#else #else
@@ -109,7 +109,7 @@ namespace Tesses::Framework::Streams {
} }
void PtyStream::Resize(WindowSize windowSize) void PtyStream::Resize(WindowSize windowSize)
{ {
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
this->wS = windowSize; this->wS = windowSize;
winsize sz; winsize sz;
sz.ws_col =(unsigned short)windowSize.Columns; sz.ws_col =(unsigned short)windowSize.Columns;
@@ -123,7 +123,7 @@ namespace Tesses::Framework::Streams {
PtyStream::~PtyStream() PtyStream::~PtyStream()
{ {
this->eos=true; this->eos=true;
#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS)
close(this->socket); close(this->socket);
kill((pid_t)this->pid,SIGHUP); kill((pid_t)this->pid,SIGHUP);