mirror of
https://github.com/love2d/love-android.git
synced 2026-08-19 20:20:25 +02:00
updated to latest mobile-common (0cf55b7da58e), removed libtiff, libpng, libmng, devil, jasper, jpeg-8d, added libturbo-jpeg
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <spawn.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#elif defined(LOVE_WINDOWS)
|
||||
#include "common/utf8.h"
|
||||
@@ -43,6 +44,20 @@ namespace love
|
||||
namespace system
|
||||
{
|
||||
|
||||
System::System()
|
||||
{
|
||||
#if defined(LOVE_LINUX)
|
||||
// Enable automatic cleanup of zombie processes
|
||||
struct sigaction act = {0};
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_handler = SIG_DFL;
|
||||
act.sa_flags = SA_NOCLDWAIT;
|
||||
|
||||
// Requires linux 2.6 or higher, so anything remotely modern
|
||||
sigaction(SIGCHLD, &act, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string System::getOS() const
|
||||
{
|
||||
#if defined(LOVE_MACOSX)
|
||||
@@ -94,12 +109,14 @@ bool System::openURL(const std::string &url) const
|
||||
if (posix_spawnp(&pid, "xdg-open", nullptr, nullptr, const_cast<char **>(argv), environ) != 0)
|
||||
return false;
|
||||
|
||||
// Wait for xdg-open to complete (or fail.)
|
||||
// Check if xdg-open already completed (or failed.)
|
||||
int status = 0;
|
||||
if (waitpid(pid, &status, 0) == pid)
|
||||
if (waitpid(pid, &status, WNOHANG) > 0)
|
||||
return (status == 0);
|
||||
else
|
||||
return false;
|
||||
// We can't tell what actually happens without waiting for
|
||||
// the process to finish, which could take forever (literally).
|
||||
return true;
|
||||
|
||||
#elif defined(LOVE_WINDOWS)
|
||||
|
||||
|
||||
@@ -48,8 +48,12 @@ public:
|
||||
POWER_MAX_ENUM
|
||||
};
|
||||
|
||||
System();
|
||||
virtual ~System() {}
|
||||
|
||||
// Implements Module.
|
||||
virtual ModuleType getModuleType() const { return M_SYSTEM; }
|
||||
|
||||
/**
|
||||
* Gets the current operating system.
|
||||
**/
|
||||
|
||||
@@ -27,30 +27,30 @@ namespace love
|
||||
namespace system
|
||||
{
|
||||
|
||||
static System *instance = nullptr;
|
||||
#define instance() (Module::getInstance<System>(Module::M_SYSTEM))
|
||||
|
||||
int w_getOS(lua_State *L)
|
||||
{
|
||||
luax_pushstring(L, instance->getOS());
|
||||
luax_pushstring(L, instance()->getOS());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_getProcessorCount(lua_State *L)
|
||||
{
|
||||
lua_pushinteger(L, instance->getProcessorCount());
|
||||
lua_pushinteger(L, instance()->getProcessorCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_setClipboardText(lua_State *L)
|
||||
{
|
||||
const char *text = luaL_checkstring(L, 1);
|
||||
instance->setClipboardText(text);
|
||||
instance()->setClipboardText(text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_getClipboardText(lua_State *L)
|
||||
{
|
||||
luax_pushstring(L, instance->getClipboardText());
|
||||
luax_pushstring(L, instance()->getClipboardText());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ int w_getPowerInfo(lua_State *L)
|
||||
int seconds = -1, percent = -1;
|
||||
const char *str;
|
||||
|
||||
System::PowerState state = instance->getPowerInfo(seconds, percent);
|
||||
System::PowerState state = instance()->getPowerInfo(seconds, percent);
|
||||
|
||||
if (!System::getConstant(state, str))
|
||||
str = "unknown";
|
||||
@@ -82,14 +82,14 @@ int w_getPowerInfo(lua_State *L)
|
||||
int w_openURL(lua_State *L)
|
||||
{
|
||||
std::string url = luax_checkstring(L, 1);
|
||||
luax_pushboolean(L, instance->openURL(url));
|
||||
luax_pushboolean(L, instance()->openURL(url));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_vibrate(lua_State *L)
|
||||
{
|
||||
double seconds = static_cast<double>(luaL_checknumber(L, 1));
|
||||
instance->vibrate(seconds);
|
||||
instance()->vibrate(seconds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_love_system(lua_State *L)
|
||||
{
|
||||
System *instance = instance();
|
||||
if (instance == nullptr)
|
||||
{
|
||||
instance = new love::system::sdl::System();
|
||||
|
||||
Reference in New Issue
Block a user