Module ctr.hid
The hid module.
The circle pad pro is supported, it's keys replace the "3ds only" keys
Usage:
local hid = require("ctr.hid")
Functions
read () | Refresh the HID state. |
keys () | Return the keys states as state.key in a table. |
touch () | Return the touch position on the touch screen. |
circle () | Return the circle pad position. |
cstick () | Return the C-stick position. |
accel () | Return the accelerometer vector |
gyro () | Return the gyroscope rate. |
volume () | Return the sound volume. |
pos3d () | Return the 3D cursor position. |
Tables
keys | Keys list |
states | Keys states |
Functions
- read ()
- Refresh the HID state.
- keys ()
-
Return the keys states as
state.key
in a table.Returns:
-
table
keys states
Usage:
-- Just an example hid.read() local keys = hid.keys() if keys.held.a then -- do stuff end
- touch ()
-
Return the touch position on the touch screen.
0,0
is the top-left corner.Returns:
- number X position
- number Y position
- circle ()
-
Return the circle pad position.
0,0
is the center position. Warning: the circle pad doesn't always go back to0,0
.Returns:
- number X position
- number Y position
- cstick ()
-
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
to146
on both X and Y, but these are hard to reach.Returns:
- number X position
- number Y position
- accel ()
-
Return the accelerometer vector
Returns:
- number X acceleration
- number Y acceleration
- number Z acceleration
- gyro ()
-
Return the gyroscope rate.
Returns:
- number roll
- number pitch
- number yaw
- volume ()
-
Return the sound volume.
Returns:
-
number
volume (
0
to63
) - pos3d ()
-
Return the 3D cursor position.
Returns:
-
number
3d cursor position (
0
to1
)
Tables
- keys
-
Keys list
Fields:
- a A
- b B
- select Select
- start Start
- dRight D-Pad right
- dLeft D-Pad Left
- dUp D-Pad Up
- dDown D-Pad Down
- r R trigger
- l L trigger
- x X
- y Y
- zl ZL trigger (new3ds only)
- zr ZR trigger (new3ds only)
- touch
- cstickRight C-Stick right (new3ds only)
- cstickLeft C-Stick left (new3ds only)
- cstickUp C-Stick up (new3ds only)
- cstickDown C-Stick down (new3ds only)
- cpadRight Circle pad right
- cpadLeft Circle pad left
- cpadUp Circle pad up
- cpadDown Circle pad down
- up Generic up
- down Generic down
- left Generic left
- right Generic right
- states
-
Keys states
Fields:
- down keys which have been just pressed
- held keys which are held down
- up keys whick are been just released