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

Added "ctr.hid.cstick()", untested with the circle pad pro, works on New 3DS.

I'm working on the issue with :bind(), looks like it's not just my code ...
This commit is contained in:
Firew0lf 2016-06-06 19:17:47 +02:00
parent 5494f3d2e5
commit 20f8cd3cb9

View file

@ -1,11 +1,12 @@
/*** /***
The `hid` module. The `hid` module.
The circle pad pro is supported, it's keys replace de "3ds only" keys The circle pad pro is supported, it's keys replace the "3ds only" keys
@module ctr.hid @module ctr.hid
@usage local hid = require("ctr.hid") @usage local hid = require("ctr.hid")
*/ */
#include <3ds/types.h> #include <3ds/types.h>
#include <3ds/services/hid.h> #include <3ds/services/hid.h>
#include <3ds/services/irrst.h>
#include <lua.h> #include <lua.h>
#include <lauxlib.h> #include <lauxlib.h>
@ -175,6 +176,25 @@ static int hid_circle(lua_State *L) {
return 2; return 2;
} }
/***
Return the C-stick position.
`0,0` is the center position, and the stick should return to it if not touched (95% of the time).
Range is from `-146` to `146` on both X and Y, but these are hard to reach.
@newonly
@function cstick
@treturn number X position
@treturn number Y position
*/
static int hid_cstick(lua_State *L) {
circlePosition pos;
irrstCstickRead(&pos);
lua_pushinteger(L, pos.dx);
lua_pushinteger(L, pos.dy);
return 2;
}
/*** /***
Return the accelerometer vector Return the accelerometer vector
@function accel @function accel
@ -243,6 +263,7 @@ static const struct luaL_Reg hid_lib[] = {
{ "keys", hid_keys }, { "keys", hid_keys },
{ "touch", hid_touch }, { "touch", hid_touch },
{ "circle", hid_circle }, { "circle", hid_circle },
{ "cstick", hid_cstick },
{ "accel", hid_accel }, { "accel", hid_accel },
{ "gyro", hid_gyro }, { "gyro", hid_gyro },
{ "volume", hid_volume }, { "volume", hid_volume },