mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Added all the other hid functions
This commit is contained in:
parent
d21906c684
commit
12a315b738
2 changed files with 73 additions and 2 deletions
64
source/hid.c
64
source/hid.c
|
|
@ -74,8 +74,72 @@ static int hid_read(lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int hid_touch(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
touchPosition pos;
|
||||
hidTouchRead(&pos);
|
||||
|
||||
lua_pushinteger(L, (lua_Integer)pos.px);
|
||||
lua_pushinteger(L, (lua_Integer)pos.py);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int hid_circle(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
circlePosition pos;
|
||||
hidCircleRead(&pos);
|
||||
|
||||
lua_pushinteger(L, (lua_Integer)pos.dx);
|
||||
lua_pushinteger(L, (lua_Integer)pos.dy);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int hid_accel(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
accelVector pos;
|
||||
hidAccelRead(&pos);
|
||||
|
||||
lua_pushinteger(L, (lua_Integer)pos.x);
|
||||
lua_pushinteger(L, (lua_Integer)pos.y);
|
||||
lua_pushinteger(L, (lua_Integer)pos.z);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int hid_gyro(lua_State *L) {
|
||||
hidScanInput();
|
||||
|
||||
angularRate pos;
|
||||
hidGyroRead(&pos);
|
||||
|
||||
lua_pushinteger(L, (lua_Integer)pos.x);
|
||||
lua_pushinteger(L, (lua_Integer)pos.y);
|
||||
lua_pushinteger(L, (lua_Integer)pos.z);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int hid_volume(lua_State *L) {
|
||||
u8 volume = 0;
|
||||
HIDUSER_GetSoundVolume(&volume);
|
||||
|
||||
lua_pushinteger(L, (lua_Integer)volume);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg hid_lib[] = {
|
||||
{ "read", hid_read },
|
||||
{ "touch", hid_touch },
|
||||
{ "circle", hid_circle },
|
||||
{ "accel", hid_accel },
|
||||
{ "gyro", hid_gyro },
|
||||
{ "volume", hid_volume },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ int main() {
|
|||
sftd_init();
|
||||
//sf2d_set_3d(true);
|
||||
|
||||
// Init accel/gyro
|
||||
HIDUSER_EnableAccelerometer();
|
||||
HIDUSER_EnableGyroscope();
|
||||
|
||||
// Init Lua
|
||||
lua_State *L = luaL_newstate();
|
||||
if (L == NULL) error("memory allocation error while creating a new Lua state");
|
||||
|
|
@ -46,5 +50,8 @@ int main() {
|
|||
// Un-init (?)
|
||||
sftd_fini();
|
||||
sf2d_fini();
|
||||
// Disable needed things
|
||||
HIDUSER_DisableAccelerometer();
|
||||
HIDUSER_DisableGyroscope();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue