mirror of https://github.com/bjornbytes/lovr.git
lovr.system.openConsole;
This commit is contained in:
parent
761a454291
commit
375866d3d4
|
@ -126,6 +126,11 @@ static int l_lovrSystemGetCoreCount(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrSystemOpenConsole(lua_State* L) {
|
||||
lovrSystemOpenConsole();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrSystemRequestPermission(lua_State* L) {
|
||||
Permission permission = luax_checkenum(L, 1, Permission, NULL);
|
||||
lovrSystemRequestPermission(permission);
|
||||
|
@ -307,6 +312,7 @@ static int l_lovrSystemWasMouseReleased(lua_State* L) {
|
|||
static const luaL_Reg lovrSystem[] = {
|
||||
{ "getOS", l_lovrSystemGetOS },
|
||||
{ "getCoreCount", l_lovrSystemGetCoreCount },
|
||||
{ "openConsole", l_lovrSystemOpenConsole },
|
||||
{ "requestPermission", l_lovrSystemRequestPermission },
|
||||
{ "openWindow", l_lovrSystemOpenWindow },
|
||||
{ "isWindowOpen", l_lovrSystemIsWindowOpen },
|
||||
|
|
|
@ -200,6 +200,7 @@ uint32_t os_get_core_count(void) {
|
|||
// To make regular printing work, a thread makes a pipe and redirects stdout and stderr to the write
|
||||
// end of the pipe. The read end of the pipe is forwarded to __android_log_write.
|
||||
static struct {
|
||||
bool attached;
|
||||
int handles[2];
|
||||
pthread_t thread;
|
||||
} log;
|
||||
|
@ -221,8 +222,11 @@ static void* log_main(void* data) {
|
|||
}
|
||||
|
||||
void os_open_console(void) {
|
||||
pthread_create(&log.thread, NULL, log_main, log.handles);
|
||||
pthread_detach(log.thread);
|
||||
if (!log.attached) {
|
||||
pthread_create(&log.thread, NULL, log_main, log.handles);
|
||||
pthread_detach(log.thread);
|
||||
log.attached = true;
|
||||
}
|
||||
}
|
||||
|
||||
#define NS_PER_SEC 1000000000ULL
|
||||
|
|
|
@ -108,6 +108,10 @@ const char* lovrSystemGetOS(void) {
|
|||
return os_get_name();
|
||||
}
|
||||
|
||||
void lovrSystemOpenConsole(void) {
|
||||
os_open_console();
|
||||
}
|
||||
|
||||
uint32_t lovrSystemGetCoreCount(void) {
|
||||
return os_get_core_count();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ bool lovrSystemInit(void);
|
|||
void lovrSystemDestroy(void);
|
||||
const char* lovrSystemGetOS(void);
|
||||
uint32_t lovrSystemGetCoreCount(void);
|
||||
void lovrSystemOpenConsole(void);
|
||||
void lovrSystemRequestPermission(Permission permission);
|
||||
void lovrSystemOpenWindow(struct os_window_config* config);
|
||||
bool lovrSystemIsWindowOpen(void);
|
||||
|
|
Loading…
Reference in New Issue