mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Renamed os.run to ctr.run ; added ctr.hid.read
All other HID functions no longer update inputs when they are called.
This commit is contained in:
parent
036c0a03ce
commit
155a2e9805
4 changed files with 16 additions and 35 deletions
|
|
@ -30,7 +30,8 @@ local function drawStuffIn3D(depth)
|
|||
gfx.circle(125 - depth*4, 125, 16)
|
||||
end
|
||||
|
||||
while os.run() do
|
||||
while ctr.run() do
|
||||
hid.read()
|
||||
local keys = hid.keys()
|
||||
|
||||
if keys.down.start then return end
|
||||
|
|
|
|||
10
source/ctr.c
10
source/ctr.c
|
|
@ -1,15 +1,21 @@
|
|||
#include <3ds/types.h>
|
||||
#include <3ds/services/apt.h>
|
||||
#include <3ds/os.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
int load_os_lib(lua_State *L);
|
||||
int load_gfx_lib(lua_State *L);
|
||||
int load_news_lib(lua_State *L);
|
||||
int load_ptm_lib(lua_State *L);
|
||||
int load_hid_lib(lua_State *L);
|
||||
|
||||
static int ctr_run(lua_State *L) {
|
||||
lua_pushboolean(L, aptMainLoop());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ctr_time(lua_State *L) {
|
||||
lua_pushinteger(L, osGetTime());
|
||||
|
||||
|
|
@ -18,6 +24,7 @@ static int ctr_time(lua_State *L) {
|
|||
|
||||
// Functions
|
||||
static const struct luaL_Reg ctr_lib[] = {
|
||||
{ "run", ctr_run },
|
||||
{ "time", ctr_time},
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
@ -43,6 +50,5 @@ int luaopen_ctr_lib(lua_State *L) {
|
|||
}
|
||||
|
||||
void load_ctr_lib(lua_State *L) {
|
||||
load_os_lib(L);
|
||||
luaL_requiref(L, "ctr", luaopen_ctr_lib, 0);
|
||||
}
|
||||
|
|
|
|||
15
source/hid.c
15
source/hid.c
|
|
@ -38,9 +38,13 @@ struct { PAD_KEY key; char *name; } hid_keys_name[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static int hid_keys(lua_State *L) {
|
||||
static int hid_read(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hid_keys(lua_State *L) {
|
||||
u32 kDown = hidKeysDown();
|
||||
u32 kHeld = hidKeysHeld();
|
||||
u32 kUp = hidKeysUp();
|
||||
|
|
@ -76,8 +80,6 @@ static int hid_keys(lua_State *L) {
|
|||
}
|
||||
|
||||
static int hid_touch(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
touchPosition pos;
|
||||
hidTouchRead(&pos);
|
||||
|
||||
|
|
@ -88,8 +90,6 @@ static int hid_touch(lua_State *L) {
|
|||
}
|
||||
|
||||
static int hid_circle(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
circlePosition pos;
|
||||
hidCircleRead(&pos);
|
||||
|
||||
|
|
@ -100,8 +100,6 @@ static int hid_circle(lua_State *L) {
|
|||
}
|
||||
|
||||
static int hid_accel(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
accelVector pos;
|
||||
hidAccelRead(&pos);
|
||||
|
||||
|
|
@ -113,8 +111,6 @@ static int hid_accel(lua_State *L) {
|
|||
}
|
||||
|
||||
static int hid_gyro(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
angularRate pos;
|
||||
hidGyroRead(&pos);
|
||||
|
||||
|
|
@ -135,6 +131,7 @@ static int hid_volume(lua_State *L) {
|
|||
}
|
||||
|
||||
static const struct luaL_Reg hid_lib[] = {
|
||||
{ "read", hid_read },
|
||||
{ "keys", hid_keys },
|
||||
{ "touch", hid_touch },
|
||||
{ "circle", hid_circle },
|
||||
|
|
|
|||
23
source/os.c
23
source/os.c
|
|
@ -1,23 +0,0 @@
|
|||
#include <3ds/types.h>
|
||||
#include <3ds/services/apt.h>
|
||||
|
||||
#include <lua.h>
|
||||
|
||||
static int os_run(lua_State *L) {
|
||||
bool run = aptMainLoop();
|
||||
|
||||
lua_pushboolean(L, run);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void load_os_lib(lua_State *L) {
|
||||
lua_getglobal(L, "os");
|
||||
|
||||
lua_pushcfunction(L, os_run);
|
||||
lua_setfield(L, -2, "run");
|
||||
|
||||
lua_pop(L, 1);
|
||||
|
||||
return;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue