From 4a2c1a7c68d99e1d4c16d486b21208b6922f47e9 Mon Sep 17 00:00:00 2001 From: Reuh Date: Mon, 27 Jun 2016 13:42:38 +0200 Subject: [PATCH] Updated ctr.apt to the latest ctrulib, added ctr.apt.isNew3DS() --- source/apt.c | 111 +++++++++++++++++++++++++++----------------------- source/font.c | 3 +- 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/source/apt.c b/source/apt.c index bcbc26b..6f2f28c 100644 --- a/source/apt.c +++ b/source/apt.c @@ -13,44 +13,29 @@ Used to manage the applets and application status. #include #include -/*** -Open an APT session. Should only work if you don't use the homebrew menu. -@function openSession -*/ -static int apt_openSession(lua_State *L) { - aptOpenSession(); - return 0; -} - -/*** -Close the current APT session. -@function closeSession -*/ -static int apt_closeSession(lua_State *L) { - aptCloseSession(); - return 0; -} - /*** Set the app status. @function setStatus +@tparam integer status the new app status */ static int apt_setStatus(lua_State *L) { APT_AppStatus status = luaL_checkinteger(L, 1); - + aptSetStatus(status); - + return 0; } /*** Get the app status. @function getStatus +@treturn integer the app status */ static int apt_getStatus(lua_State *L) { APT_AppStatus status = aptGetStatus(); lua_pushinteger(L, status); + return 1; } @@ -60,6 +45,7 @@ Return to the Home menu. */ static int apt_returnToMenu(lua_State *L) { aptReturnToMenu(); + return 0; } @@ -70,8 +56,9 @@ Get the power status. */ static int apt_getStatusPower(lua_State *L) { u32 status = aptGetStatusPower(); - + lua_pushboolean(L, status); + return 1; } @@ -82,9 +69,9 @@ Set the power status. */ static int apt_setStatusPower(lua_State *L) { u32 status = lua_toboolean(L, 1); - + aptSetStatusPower(status); - + return 0; } @@ -94,6 +81,7 @@ Signal that the application is ready for sleeping. */ static int apt_signalReadyForSleep(lua_State *L) { aptSignalReadyForSleep(); + return 0; } @@ -104,6 +92,7 @@ Return the Home menu AppID. */ static int apt_getMenuAppID(lua_State *L) { lua_pushinteger(L, aptGetMenuAppID()); + return 1; } @@ -114,9 +103,9 @@ Allow or not the system to enter sleep mode. */ static int apt_setSleepAllowed(lua_State *L) { bool allowed = lua_toboolean(L, 1); - + aptSetSleepAllowed(allowed); - + return 0; } @@ -127,22 +116,36 @@ Check if sleep mode is allowed. */ static int apt_isSleepAllowed(lua_State *L) { lua_pushboolean(L, aptIsSleepAllowed()); - + + return 1; +} + +/*** +Checks whether the system is a New 3DS. +@function isNew3DS +@treturn boolean `true` if it's a New3DS, false otherwise +*/ +static int apt_isNew3DS(lua_State *L) { + bool isNew3ds; + + APT_CheckNew3DS(&isNew3ds); + + lua_pushboolean(L, isNew3ds); + return 1; } static const struct luaL_Reg apt_lib[] = { - {"openSession", apt_openSession }, - {"closeSession", apt_closeSession }, - {"setStatus", apt_setStatus }, - {"getStatus", apt_getStatus }, - {"returnToMenu", apt_returnToMenu }, - {"getStatusPower", apt_getStatusPower }, - {"setStatusPower", apt_setStatusPower }, - {"signalReadyForSleep", apt_signalReadyForSleep}, - {"getMenuAppID", apt_getMenuAppID }, - {"setSleepAllowed", apt_setSleepAllowed }, - {"isSleepAllowed", apt_isSleepAllowed }, + { "setStatus", apt_setStatus }, + { "getStatus", apt_getStatus }, + { "returnToMenu", apt_returnToMenu }, + { "getStatusPower", apt_getStatusPower }, + { "setStatusPower", apt_setStatusPower }, + { "signalReadyForSleep", apt_signalReadyForSleep }, + { "getMenuAppID", apt_getMenuAppID }, + { "setSleepAllowed", apt_setSleepAllowed }, + { "isSleepAllowed", apt_isSleepAllowed }, + { "isNew3DS", apt_isNew3DS }, {NULL, NULL} }; @@ -268,37 +271,45 @@ struct { char *name; int value; } apt_constants[] = { */ {"APTSIGNAL_HOMEBUTTON", APTSIGNAL_HOMEBUTTON }, /*** - @field APTSIGNAL_PREPARESLEEP + @field APTSIGNAL_HOMEBUTTON2 */ - {"APTSIGNAL_PREPARESLEEP", APTSIGNAL_PREPARESLEEP}, + {"APTSIGNAL_HOMEBUTTON2", APTSIGNAL_HOMEBUTTON2 }, /*** - @field APTSIGNAL_ENTERSLEEP + @field APTSIGNAL_SLEEP_QUERY */ - {"APTSIGNAL_ENTERSLEEP", APTSIGNAL_ENTERSLEEP }, + {"APTSIGNAL_SLEEP_QUERY", APTSIGNAL_SLEEP_QUERY }, + /*** + @field APTSIGNAL_SLEEP_CANCEL + */ + {"APTSIGNAL_SLEEP_CANCEL", APTSIGNAL_SLEEP_CANCEL}, + /*** + @field APTSIGNAL_SLEEP_ENTER + */ + {"APTSIGNAL_SLEEP_ENTER", APTSIGNAL_SLEEP_ENTER }, /*** @field APTSIGNAL_WAKEUP */ - {"APTSIGNAL_WAKEUP", APTSIGNAL_WAKEUP }, + {"APTSIGNAL_SLEEP_WAKEUP", APTSIGNAL_SLEEP_WAKEUP}, /*** - @field APTSIGNAL_ENABLE + @field APTSIGNAL_SHUTDOWN */ - {"APTSIGNAL_ENABLE", APTSIGNAL_ENABLE }, + {"APTSIGNAL_SHUTDOWN", APTSIGNAL_SHUTDOWN }, /*** @field APTSIGNAL_POWERBUTTON */ {"APTSIGNAL_POWERBUTTON", APTSIGNAL_POWERBUTTON }, /*** - @field APTSIGNAL_UTILITY + @field APTSIGNAL_POWERBUTTON2 */ - {"APTSIGNAL_UTILITY", APTSIGNAL_UTILITY }, + {"APTSIGNAL_POWERBUTTON2", APTSIGNAL_POWERBUTTON2}, /*** - @field APTSIGNAL_SLEEPSYSTEM + @field APTSIGNAL_TRY_SLEEP */ - {"APTSIGNAL_SLEEPSYSTEM", APTSIGNAL_SLEEPSYSTEM }, + {"APTSIGNAL_TRY_SLEEP", APTSIGNAL_TRY_SLEEP }, /*** - @field APTSIGNAL_ERROR + @field APTSIGNAL_ORDERTOCLOSE */ - {"APTSIGNAL_ERROR", APTSIGNAL_ERROR }, + {"APTSIGNAL_ORDERTOCLOSE", APTSIGNAL_ORDERTOCLOSE}, /*** @field APTHOOK_ONSUSPEND */ diff --git a/source/font.c b/source/font.c index 1110432..615b299 100644 --- a/source/font.c +++ b/source/font.c @@ -18,7 +18,8 @@ The `gfx.font` module u32 textSize = 9; /*** -Load a TTF font. +Load a font. Supported formats: TTF, OTF, TTC, OTC, WOFF, PFA, PFB, PCF, FNT, BDF, PFR, and others. +ctrµLua support all formats supported by FreeType. See here for a more complete list: http://freetype.org/freetype2/docs/index.html @function load @tparam string path path to the file @treturn[1] font the loaded font.