Permalink
Browse files

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 ...
  • Loading branch information...
Firew0lf committed Jun 6, 2016
1 parent 5494f3d commit 20f8cd3cb9fab9f15fc5931baf3e4f4047e81c41
Showing with 22 additions and 1 deletion.
  1. +22 −1 source/hid.c
@@ -1,11 +1,12 @@
/***
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
@usage local hid = require("ctr.hid")
*/
#include <3ds/types.h>
#include <3ds/services/hid.h>
#include <3ds/services/irrst.h>

#include <lua.h>
#include <lauxlib.h>
@@ -175,6 +176,25 @@ static int hid_circle(lua_State *L) {
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
@function accel
@@ -243,6 +263,7 @@ static const struct luaL_Reg hid_lib[] = {
{ "keys", hid_keys },
{ "touch", hid_touch },
{ "circle", hid_circle },
{ "cstick", hid_cstick },
{ "accel", hid_accel },
{ "gyro", hid_gyro },
{ "volume", hid_volume },

0 comments on commit 20f8cd3

Please sign in to comment.