1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Updated ctr.apt to the latest ctrulib, added ctr.apt.isNew3DS()

This commit is contained in:
Reuh 2016-06-27 13:42:38 +02:00
parent 20f8cd3cb9
commit 4a2c1a7c68
2 changed files with 63 additions and 51 deletions

View file

@ -13,27 +13,10 @@ Used to manage the applets and application status.
#include <lua.h> #include <lua.h>
#include <lauxlib.h> #include <lauxlib.h>
/***
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. Set the app status.
@function setStatus @function setStatus
@tparam integer status the new app status
*/ */
static int apt_setStatus(lua_State *L) { static int apt_setStatus(lua_State *L) {
APT_AppStatus status = luaL_checkinteger(L, 1); APT_AppStatus status = luaL_checkinteger(L, 1);
@ -46,11 +29,13 @@ static int apt_setStatus(lua_State *L) {
/*** /***
Get the app status. Get the app status.
@function getStatus @function getStatus
@treturn integer the app status
*/ */
static int apt_getStatus(lua_State *L) { static int apt_getStatus(lua_State *L) {
APT_AppStatus status = aptGetStatus(); APT_AppStatus status = aptGetStatus();
lua_pushinteger(L, status); lua_pushinteger(L, status);
return 1; return 1;
} }
@ -60,6 +45,7 @@ Return to the Home menu.
*/ */
static int apt_returnToMenu(lua_State *L) { static int apt_returnToMenu(lua_State *L) {
aptReturnToMenu(); aptReturnToMenu();
return 0; return 0;
} }
@ -72,6 +58,7 @@ static int apt_getStatusPower(lua_State *L) {
u32 status = aptGetStatusPower(); u32 status = aptGetStatusPower();
lua_pushboolean(L, status); lua_pushboolean(L, status);
return 1; return 1;
} }
@ -94,6 +81,7 @@ Signal that the application is ready for sleeping.
*/ */
static int apt_signalReadyForSleep(lua_State *L) { static int apt_signalReadyForSleep(lua_State *L) {
aptSignalReadyForSleep(); aptSignalReadyForSleep();
return 0; return 0;
} }
@ -104,6 +92,7 @@ Return the Home menu AppID.
*/ */
static int apt_getMenuAppID(lua_State *L) { static int apt_getMenuAppID(lua_State *L) {
lua_pushinteger(L, aptGetMenuAppID()); lua_pushinteger(L, aptGetMenuAppID());
return 1; return 1;
} }
@ -131,18 +120,32 @@ static int apt_isSleepAllowed(lua_State *L) {
return 1; 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[] = { static const struct luaL_Reg apt_lib[] = {
{"openSession", apt_openSession }, { "setStatus", apt_setStatus },
{"closeSession", apt_closeSession }, { "getStatus", apt_getStatus },
{"setStatus", apt_setStatus }, { "returnToMenu", apt_returnToMenu },
{"getStatus", apt_getStatus }, { "getStatusPower", apt_getStatusPower },
{"returnToMenu", apt_returnToMenu }, { "setStatusPower", apt_setStatusPower },
{"getStatusPower", apt_getStatusPower }, { "signalReadyForSleep", apt_signalReadyForSleep },
{"setStatusPower", apt_setStatusPower }, { "getMenuAppID", apt_getMenuAppID },
{"signalReadyForSleep", apt_signalReadyForSleep}, { "setSleepAllowed", apt_setSleepAllowed },
{"getMenuAppID", apt_getMenuAppID }, { "isSleepAllowed", apt_isSleepAllowed },
{"setSleepAllowed", apt_setSleepAllowed }, { "isNew3DS", apt_isNew3DS },
{"isSleepAllowed", apt_isSleepAllowed },
{NULL, NULL} {NULL, NULL}
}; };
@ -268,37 +271,45 @@ struct { char *name; int value; } apt_constants[] = {
*/ */
{"APTSIGNAL_HOMEBUTTON", APTSIGNAL_HOMEBUTTON }, {"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 @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 @field APTSIGNAL_POWERBUTTON
*/ */
{"APTSIGNAL_POWERBUTTON", 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 @field APTHOOK_ONSUSPEND
*/ */

View file

@ -18,7 +18,8 @@ The `gfx.font` module
u32 textSize = 9; 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 @function load
@tparam string path path to the file @tparam string path path to the file
@treturn[1] font the loaded font. @treturn[1] font the loaded font.