Skip to content

Commit

Permalink
Added "ctr.hid.cstick()", untested with the circle pad pro, works on …
Browse files Browse the repository at this point in the history
…New 3DS.

I'm working on the issue with :bind(), looks like it's not just my code ...
  • Loading branch information
firew0lf committed Jun 6, 2016
1 parent 5494f3d commit 20f8cd3
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion source/hid.c
Original file line number Original file line Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 20f8cd3

Please sign in to comment.